From b789ef5dd0bb47536d3d67b674429f508b87616c Mon Sep 17 00:00:00 2001 From: Nike Okoronkwo Date: Tue, 18 Nov 2025 12:44:38 -0600 Subject: [PATCH 01/14] [native_toolchain_c] Fix clang compiler search + tools for Swiftly Swiftly proxies commands to some of the tools that ship with Swift distributions, including: `clang`, `ld.lld`, and other tools. Therefore, such tools are symlinks to `swiftly`, and running `swiftly` directly would therefore not work when bundling assets. This PR adds support for using `package:native_toolchain_c` on macOS with Swiftly installed, defaulting to the user's default installation of `ar` and `ld` where applicable. --- .../lib/src/native_toolchain/apple_clang.dart | 15 +++++++++++++++ .../lib/src/tool/tool_resolver.dart | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 9c7eb4c99e..67dcf49619 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -2,6 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:code_assets/code_assets.dart'; + import '../tool/tool.dart'; import '../tool/tool_resolver.dart'; @@ -31,6 +33,10 @@ final Tool appleAr = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ar'), ), + PathToolResolver( + toolName: 'Apple archiver', + executableName: OS.current.executableFileName('ar'), + ), ]), ); @@ -43,6 +49,15 @@ final Tool appleLd = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ld'), ), + PathToolResolver( + toolName: 'Apple linker', + executableName: OS.current.executableFileName('ld'), + ), + RelativeToolResolver( + toolName: 'Apple linker', + wrappedResolver: appleClang.defaultResolver!, + relativePath: Uri.file(OS.current.executableFileName('ld.lld')), + ), ]), ); diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 0603703181..ec12fb57d5 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -2,6 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -65,8 +66,10 @@ class PathToolResolver extends ToolResolver { if (process.exitCode == 0) { final file = File(LineSplitter.split(process.stdout).first); final uri = File(await file.resolveSymbolicLinks()).uri; - if (uri.pathSegments.last == 'llvm') { + if (uri.pathSegments.last == 'llvm' || + uri.pathSegments.last == 'swiftly') { // https://github.com/dart-lang/native/issues/136 + // https://github.com/dart-lang/native/issues/2792 return file.uri; } return uri; From a367d17582bc1064bd9e9ad8151900a1a2c212b3 Mon Sep 17 00:00:00 2001 From: Nike Okoronkwo Date: Wed, 19 Nov 2025 08:55:13 -0600 Subject: [PATCH 02/14] Resolved tool_resolver.dart unnecessary import --- pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index ec12fb57d5..84fcdf679e 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:async'; import 'dart:convert'; import 'dart:io'; From 0ff54c46b2c41aa0d8078153a4bb52e2dcbfe2d4 Mon Sep 17 00:00:00 2001 From: Nike Okoronkwo Date: Wed, 19 Nov 2025 09:11:22 -0600 Subject: [PATCH 03/14] Added CHANGELOG.md update and version bump --- pkgs/native_toolchain_c/CHANGELOG.md | 5 +++++ pkgs/native_toolchain_c/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/native_toolchain_c/CHANGELOG.md b/pkgs/native_toolchain_c/CHANGELOG.md index 16151e6f64..916abb3089 100644 --- a/pkgs/native_toolchain_c/CHANGELOG.md +++ b/pkgs/native_toolchain_c/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.17.4 + +- Fixed resolution of C compiler and tools on macOS when `swiftly` is installed. +- Broaden compiler tool discovery on macOS. + ## 0.17.3 - Bump `package:hooks` and `package:code_assets`to 1.0.0. diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index d0f58df9a8..1a3e16f778 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -1,7 +1,7 @@ name: native_toolchain_c description: >- A library to invoke the native C compiler installed on the host machine. -version: 0.17.3 +version: 0.17.4 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c topics: From ec4e5d7c4cbcb28b9c71f7a56668d888d7637480 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Mon, 15 Dec 2025 12:30:23 -0500 Subject: [PATCH 04/14] updated lookup for apple linker --- .../lib/src/native_toolchain/apple_clang.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 67dcf49619..82005c06fa 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -49,14 +49,13 @@ final Tool appleLd = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ld'), ), - PathToolResolver( - toolName: 'Apple linker', - executableName: OS.current.executableFileName('ld'), - ), - RelativeToolResolver( - toolName: 'Apple linker', - wrappedResolver: appleClang.defaultResolver!, - relativePath: Uri.file(OS.current.executableFileName('ld.lld')), + CliFilter( + wrappedResolver: PathToolResolver( + toolName: 'Apple linker', + executableName: OS.current.executableFileName('ld'), + ), + cliArguments: ['-v'], + keepIf: ({required String stdout}) => stdout.contains('Apple TAPI'), ), ]), ); From 9cf4dacfdc2e95019c652e2b106f39b9dfb2a008 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Mon, 15 Dec 2025 12:50:56 -0500 Subject: [PATCH 05/14] updated pubspec version for native_toolchain_c --- pkgs/native_toolchain_c/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index 1a3e16f778..b8a7f673fa 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -1,7 +1,7 @@ name: native_toolchain_c description: >- A library to invoke the native C compiler installed on the host machine. -version: 0.17.4 +version: 0.17.5 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_toolchain_c topics: From 9980d95d344b931e015f33f24d0b1c6bf3b24faa Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Sat, 10 Jan 2026 15:31:31 -0600 Subject: [PATCH 06/14] Updated CI for swiftly --- .github/workflows/native_toolchain_c.yaml | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/native_toolchain_c.yaml b/.github/workflows/native_toolchain_c.yaml index bae4096539..6bf7e4af4f 100644 --- a/.github/workflows/native_toolchain_c.yaml +++ b/.github/workflows/native_toolchain_c.yaml @@ -18,6 +18,41 @@ on: - cron: "0 0 * * 0" # weekly jobs: + dart-swiftly-clang: + strategy: + matrix: + os: [ubuntu] + sdk: [dev, stable] + package: [native_toolchain_c] + + runs-on: ${{ matrix.os }}-latest + + defaults: + run: + working-directory: pkgs/${{ matrix.package }} + + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 + + - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c + with: + sdk: ${{ matrix.sdk }} + + - run: | + curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \ + tar zxf swiftly-$(uname -m).tar.gz && \ + ./swiftly init --quiet-shell-followup -y && \ + . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \ + hash -r + + - name: Install the latest Swift toolchain + run: swiftly install latest + + - run: echo "$SWIFTLY_BIN_DIR" >> $GITHUB_PATH + + - run: clang --version + + - run: dart test dart-sdk-clang: strategy: matrix: From 294624be794d2bfef65073e2f216ccddca30670c Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Sun, 15 Mar 2026 16:09:04 -0400 Subject: [PATCH 07/14] merge main branch --- .../refactor-dart-dot-shorthands/SKILL.md | 170 + .github/ISSUE_TEMPLATE/code_assets.md | 3 +- .github/ISSUE_TEMPLATE/data_assets.md | 3 +- .github/ISSUE_TEMPLATE/ffi.md | 2 +- .github/ISSUE_TEMPLATE/ffigen.md | 2 +- .github/ISSUE_TEMPLATE/hooks.md | 3 +- .github/ISSUE_TEMPLATE/hooks_runner.md | 3 +- .github/ISSUE_TEMPLATE/jnigen.md | 2 +- .github/ISSUE_TEMPLATE/native_toolchain_c.md | 2 +- .github/ISSUE_TEMPLATE/objective_c.md | 3 +- .github/ISSUE_TEMPLATE/record_use.md | 3 +- .github/ISSUE_TEMPLATE/swift2objc.md | 3 +- .github/ISSUE_TEMPLATE/swiftgen.md | 3 +- .github/PULL_REQUEST_TEMPLATE.md | 20 + .github/workflows/ffi.yaml | 73 - .github/workflows/ffigen.yml | 2 +- .github/workflows/health.yaml | 3 +- .github/workflows/jnigen.yaml | 2 + .github/workflows/native.yaml | 20 +- .github/workflows/objective_c.yaml | 4 +- .gitignore | 5 +- CONTRIBUTING.md | 39 + README.md | 1 + analysis_options.yaml | 4 + pkgs/code_assets/.gitignore | 1 + pkgs/code_assets/analysis_options.yaml | 6 - .../example/host_name/pubspec.yaml | 2 +- .../example/mini_audio/pubspec.yaml | 2 +- pkgs/code_assets/example/sqlite/pubspec.yaml | 2 +- .../example/sqlite_prebuilt/pubspec.yaml | 2 +- .../example/stb_image/pubspec.yaml | 2 +- pkgs/code_assets/pubspec.yaml | 5 +- pkgs/data_assets/.gitignore | 1 + pkgs/data_assets/analysis_options.yaml | 6 - .../lib/src/data_assets/data_asset.dart | 4 +- pkgs/data_assets/pubspec.yaml | 5 +- pkgs/ffi/CHANGELOG.md | 4 + pkgs/ffi/lib/ffi.dart | 3 +- pkgs/ffi/lib/src/utf8.dart | 2 +- pkgs/ffi/pubspec.yaml | 6 +- pkgs/ffi/test/utf8_test.dart | 225 +- pkgs/ffigen/CHANGELOG.md | 14 +- pkgs/ffigen/doc/objc_runtime_types.md | 23 +- .../c_json/cjson_generated_bindings.dart | 1552 +- .../ffinative/lib/generated_bindings.dart | 38 +- .../libclang-example/generated_bindings.dart | 17901 ++++++------ .../objective_c/avf_audio_bindings.dart | 12 +- pkgs/ffigen/example/objective_c/pubspec.yaml | 2 +- .../lib/generated/a_shared_b_gen.dart | 29 +- .../example/simple/generated_bindings.dart | 66 +- pkgs/ffigen/example/swift/pubspec.yaml | 2 +- .../example/swift/swift_api_bindings.dart | 141 +- .../example/swift/third_party/swift_api.h | 5 +- .../lib/src/code_generator/compound.dart | 85 + .../lib/src/code_generator/func_type.dart | 7 +- .../lib/src/code_generator/objc_block.dart | 43 +- .../objc_built_in_functions.dart | 10 +- .../src/code_generator/objc_interface.dart | 4 +- .../lib/src/code_generator/objc_methods.dart | 14 +- pkgs/ffigen/lib/src/code_generator/scope.dart | 12 +- .../ffigen/lib/src/code_generator/writer.dart | 5 +- .../lib/src/config_provider/config.dart | 4 - .../lib/src/config_provider/config_spec.dart | 25 +- .../lib/src/config_provider/path_finder.dart | 17 +- .../lib/src/config_provider/yaml_config.dart | 1 - pkgs/ffigen/lib/src/context.dart | 19 +- pkgs/ffigen/lib/src/header_parser/parser.dart | 28 +- .../sub_parsers/macro_parser.dart | 3 +- pkgs/ffigen/lib/src/strings.dart | 13 - .../src/visitor/fill_method_dependencies.dart | 76 +- .../ffigen/lib/src/visitor/list_bindings.dart | 15 + pkgs/ffigen/lib/src/visitor/visitor.dart | 5 + pkgs/ffigen/pubspec.yaml | 4 +- .../code_generator_test.dart | 44 +- .../_expected_boolean_dartbool_bindings.dart | 5 + ...ed_enumclass_func_and_struct_bindings.dart | 30 +- .../_expected_function_bindings.dart | 38 +- ..._expected_function_ffiNative_bindings.dart | 12 +- .../_expected_function_n_struct_bindings.dart | 10 + .../_expected_global_bindings.dart | 16 +- .../_expected_global_native_bindings.dart | 8 +- ...internal_conflict_resolution_bindings.dart | 42 +- .../_expected_packed_structs_bindings.dart | 40 +- ...ed_struct_allocate_collision_bindings.dart | 25 + .../_expected_struct_bindings.dart | 48 +- .../_expected_typealias_bindings.dart | 17 +- .../_expected_unions_bindings.dart | 25 +- .../decl_decl_collision_test.dart | 1 + .../decl_symbol_address_collision_test.dart | 2 + .../decl_type_name_collision_test.dart | 2 + ...expected_decl_decl_collision_bindings.dart | 50 +- ...ecl_symbol_address_collision_bindings.dart | 30 +- ...ted_decl_type_name_collision_bindings.dart | 11 + ...d_reserved_keyword_collision_bindings.dart | 8 + .../reserved_keyword_collision_test.dart | 3 +- .../example_tests/cjson_example_test.dart | 5 +- .../example_tests/ffinative_example_test.dart | 5 +- .../example_tests/libclang_example_test.dart | 2 +- .../shared_bindings_example_test.dart | 17 +- .../example_tests/simple_example_test.dart | 5 +- .../comment_markup_test.dart | 2 + .../header_parser_tests/dart_handle_test.dart | 2 + .../enum_int_mimic_test.dart | 2 + .../_expected_dart_handle_bindings.dart | 13 +- .../_expected_enum_int_mimic_bindings.dart | 76 +- .../_expected_forward_decl_bindings.dart | 8 + .../_expected_functions_bindings.dart | 42 +- ...expected_native_func_typedef_bindings.dart | 42 +- ...expected_opaque_dependencies_bindings.dart | 20 +- .../_expected_packed_structs_bindings.dart | 74 +- ..._expected_struct_fptr_fields_bindings.dart | 4 +- .../_expected_typedef_bindings.dart | 78 +- .../_expected_unions_bindings.dart | 16 +- .../_expected_varargs_bindings.dart | 10 + .../forward_decl_test.dart | 2 + .../header_parser_tests/functions_test.dart | 2 + .../imported_types_test.dart | 2 + .../native_func_typedef_test.dart | 2 + .../opaque_dependencies_test.dart | 2 + .../packed_structs_test.dart | 2 + .../header_parser_tests/regress_384_test.dart | 2 + .../test/header_parser_tests/sort_test.dart | 20 +- .../struct_fptr_fields_test.dart | 2 + .../header_parser_tests/typedef_test.dart | 2 + .../test/header_parser_tests/unions_test.dart | 2 + .../header_parser_tests/varargs_test.dart | 2 + .../_expected_cjson_bindings.dart | 1552 +- .../_expected_libclang_bindings.dart | 12098 +++++---- .../_expected_sqlite_bindings.dart | 22637 ++++++++-------- .../large_integration_tests/large_test.dart | 23 +- .../test/native_objc_test/category_test.dart | 2 +- .../native_objc_test/is_instance_test.dart | 6 + .../native_objc_test/transitive_test.dart | 23 + .../test/native_objc_test/transitive_test.h | 20 + .../_expected_native_test_bindings.dart | 224 +- pkgs/ffigen/test/test_utils.dart | 14 +- .../flutter_plugin_ffi_test.dart | 4 +- pkgs/hooks/.gitignore | 1 + pkgs/hooks/CHANGELOG.md | 8 + pkgs/hooks/analysis_options.yaml | 6 - pkgs/hooks/example/api/build_snippet_2.dart | 2 +- .../example/build/download_asset/ffigen.yaml | 4 +- .../lib/src/hook_helpers/targets.dart | 11 +- .../example/build/download_asset/pubspec.yaml | 2 +- .../example/build/local_asset/hook/build.dart | 2 +- .../example/build/local_asset/pubspec.yaml | 2 +- .../example/build/native_add_app/pubspec.yaml | 2 +- .../build/native_add_library/ffigen.yaml | 4 +- .../build/native_add_library/pubspec.yaml | 2 +- .../build/native_dynamic_linking/ffigen.yaml | 4 +- .../build/native_dynamic_linking/pubspec.yaml | 2 +- .../build/system_library/hook/build.dart | 10 +- .../example/build/system_library/pubspec.yaml | 2 +- .../example/build/use_dart_api/ffigen.yaml | 4 +- .../example/build/use_dart_api/pubspec.yaml | 2 +- .../app_with_asset_treeshaking/pubspec.yaml | 2 +- .../link/package_with_assets/hook/link.dart | 27 +- .../lib/package_with_assets.dart | 14 +- .../link/package_with_assets/pubspec.yaml | 2 +- pkgs/hooks/lib/hooks.dart | 38 + pkgs/hooks/lib/src/api/build_and_link.dart | 85 +- pkgs/hooks/lib/src/config.dart | 26 +- pkgs/hooks/pubspec.yaml | 7 +- pkgs/hooks/tool/update_snippets.dart | 61 +- pkgs/hooks_runner/CHANGELOG.md | 12 +- pkgs/hooks_runner/analysis_options.yaml | 7 +- .../lib/src/build_runner/build_planner.dart | 4 +- .../lib/src/build_runner/build_runner.dart | 77 +- .../hooks_runner/lib/src/locking/locking.dart | 4 +- pkgs/hooks_runner/lib/src/model/target.dart | 2 +- .../lib/src/utils/run_process.dart | 5 +- pkgs/hooks_runner/pubspec.yaml | 8 +- .../test/build_runner/absolute_path_test.dart | 4 +- .../build_runner/build_dependencies_test.dart | 2 +- .../test/build_runner/build_planner_test.dart | 2 +- .../build_runner/build_process_helper.dart | 8 +- .../build_runner_asset_id_test.dart | 7 +- ...build_runner_build_output_format_test.dart | 3 +- .../build_runner_caching_test.dart | 16 +- .../build_runner/build_runner_cycle_test.dart | 5 +- .../build_runner_failure_test.dart | 6 +- .../build_runner_non_root_package_test.dart | 4 +- .../test/build_runner/build_runner_test.dart | 4 +- .../test/build_runner/concurrency_test.dart | 10 +- .../build_runner/concurrency_test_helper.dart | 4 +- .../build_runner/conflicting_dylib_test.dart | 9 +- .../build_runner/environment_filter_test.dart | 37 + .../test/build_runner/link_caching_test.dart | 2 +- .../test/build_runner/link_test.dart | 12 +- .../build_runner/no_build_output_test.dart | 3 +- .../packaging_preference_test.dart | 16 +- .../test/build_runner/pub_workspace_test.dart | 8 +- .../test/build_runner/resources_test.dart | 190 +- .../build_runner/system_library_test.dart | 2 +- .../test/build_runner/version_skew_test.dart | 2 +- .../test/build_runner/wrong_linker_test.dart | 5 +- pkgs/hooks_runner/test/helpers.dart | 5 +- .../test/locking/locking_test.dart | 2 +- .../test/model/kernel_assets_test.dart | 15 +- .../reusable_dynamic_library_test.dart | 2 +- .../test/test_data/user_defines_test.dart | 2 +- .../test_data/add_asset_link/pubspec.yaml | 2 +- .../test_data/complex_link/pubspec.yaml | 3 +- .../complex_link_helper/pubspec.yaml | 3 +- .../cyclic_link_package_1/pubspec.yaml | 2 +- .../cyclic_link_package_2/pubspec.yaml | 2 +- .../test_data/cyclic_package_1/pubspec.yaml | 2 +- .../test_data/cyclic_package_2/pubspec.yaml | 2 +- .../test_data/dart_app/pubspec.yaml | 2 +- .../depend_on_fail_build/pubspec.yaml | 2 +- .../depend_on_fail_build_app/pubspec.yaml | 2 +- .../dev_dependency_with_hook/pubspec.yaml | 2 +- .../test_data/download_assets/hook/build.dart | 4 + .../test_data/download_assets/pubspec.yaml | 2 +- .../test_data/drop_dylib_link/pubspec.yaml | 2 +- .../test_data/fail_build/pubspec.yaml | 2 +- .../fail_on_os_sdk_version/pubspec.yaml | 2 +- .../fail_on_os_sdk_version_link/pubspec.yaml | 2 +- .../pubspec.yaml | 2 +- .../test_data/flag_app/pubspec.yaml | 2 +- .../test_data/flag_enthusiast_1/pubspec.yaml | 2 +- .../test_data/flag_enthusiast_2/pubspec.yaml | 2 +- .../test_data/fun_with_flags/pubspec.yaml | 2 +- .../test_data/infra_failure/pubspec.yaml | 2 +- .../test_data/link_inverse_app/pubspec.yaml | 2 +- .../link_inverse_package/pubspec.yaml | 2 +- pkgs/hooks_runner/test_data/manifest.yaml | 14 + .../test_data/manifest_generator.dart | 24 +- .../test_data/native_add/ffigen.yaml | 4 +- .../test_data/native_add/pubspec.yaml | 2 +- .../native_add_add_source/pubspec.yaml | 2 +- .../native_add_duplicate/pubspec.yaml | 2 +- .../native_add_version_skew/ffigen.yaml | 4 +- .../native_dynamic_linking/ffigen.yaml | 4 +- .../native_dynamic_linking/pubspec.yaml | 2 +- .../test_data/native_subtract/ffigen.yaml | 4 +- .../test_data/native_subtract/pubspec.yaml | 2 +- .../test_data/no_asset_for_link/pubspec.yaml | 2 +- .../test_data/no_build_output/pubspec.yaml | 2 +- .../test_data/no_hook/pubspec.yaml | 2 +- .../package_reading_metadata/pubspec.yaml | 2 +- .../package_with_metadata/pubspec.yaml | 2 +- .../bin/pirate_adventure.dart | 12 + .../test_data/pirate_adventure/pubspec.yaml | 15 + .../pirate_speak/data/translations.json | 7 + .../test_data/pirate_speak/hook/build.dart | 36 + .../test_data/pirate_speak/hook/link.dart | 109 + .../pirate_speak/lib/pirate_speak.dart | 5 + .../pirate_speak/lib/src/definitions.dart | 18 + .../test_data/pirate_speak/pubspec.yaml | 19 + .../pirate_technology/data/tech.json | 6 + .../pirate_technology/hook/build.dart | 27 + .../pirate_technology/hook/link.dart | 95 + .../lib/pirate_technology.dart | 5 + .../lib/src/definitions.dart | 41 + .../test_data/pirate_technology/pubspec.yaml | 19 + .../recursive_invocation/pubspec.yaml | 2 +- .../test_data/relative_path/pubspec.yaml | 2 +- .../reusable_dynamic_library/ffigen.yaml | 4 +- .../reusable_dynamic_library/pubspec.yaml | 2 +- .../reuse_dynamic_library/ffigen.yaml | 4 +- .../reuse_dynamic_library/pubspec.yaml | 2 +- .../test_data/simple_data_asset/pubspec.yaml | 2 +- .../test_data/simple_link/pubspec.yaml | 3 +- .../test_data/some_dev_dep/pubspec.yaml | 2 +- .../test_data/system_library/pubspec.yaml | 2 +- .../test_data/transformer/pubspec.yaml | 2 +- .../treeshaking_native_libs/ffigen.yaml | 4 +- .../treeshaking_native_libs/pubspec.yaml | 2 +- .../test_data/use_all_api/pubspec.yaml | 3 +- .../test_data/user_defines/pubspec.yaml | 2 +- .../test_data/wrong_build_output/pubspec.yaml | 2 +- .../wrong_build_output_2/pubspec.yaml | 2 +- .../wrong_build_output_3/pubspec.yaml | 2 +- .../test_data/wrong_linker/pubspec.yaml | 2 +- .../wrong_namespace_asset/pubspec.yaml | 2 +- pkgs/jni/CHANGELOG.md | 20 +- .../integration_test/on_device_jni_test.dart | 2 - pkgs/jni/ffigen.yaml | 2 +- pkgs/jni/lib/_internal.dart | 59 +- pkgs/jni/lib/jni.dart | 37 +- pkgs/jni/lib/src/accessors.dart | 6 +- pkgs/jni/lib/src/core_bindings.dart | 14950 ++++++++++ pkgs/jni/lib/src/errors.dart | 23 +- pkgs/jni/lib/src/jarray.dart | 1243 +- pkgs/jni/lib/src/jclass.dart | 68 +- pkgs/jni/lib/src/jimplementer.dart | 27 +- pkgs/jni/lib/src/jni.dart | 12 +- pkgs/jni/lib/src/jobject.dart | 98 +- pkgs/jni/lib/src/jprimitives.dart | 188 + pkgs/jni/lib/src/kotlin.dart | 10 +- pkgs/jni/lib/src/lang/jboolean.dart | 80 +- pkgs/jni/lib/src/lang/jbyte.dart | 79 +- pkgs/jni/lib/src/lang/jcharacter.dart | 78 +- pkgs/jni/lib/src/lang/jdouble.dart | 80 +- pkgs/jni/lib/src/lang/jfloat.dart | 80 +- pkgs/jni/lib/src/lang/jinteger.dart | 78 +- pkgs/jni/lib/src/lang/jlong.dart | 77 +- pkgs/jni/lib/src/lang/jnumber.dart | 77 +- pkgs/jni/lib/src/lang/jshort.dart | 78 +- pkgs/jni/lib/src/lang/jstring.dart | 76 +- pkgs/jni/lib/src/lang/lang.dart | 20 +- pkgs/jni/lib/src/method_invocation.dart | 10 +- pkgs/jni/lib/src/nio/jbuffer.dart | 66 +- pkgs/jni/lib/src/nio/jbyte_buffer.dart | 67 +- pkgs/jni/lib/src/nio/nio.dart | 4 +- pkgs/jni/lib/src/plugin/generated_plugin.dart | 131 +- pkgs/jni/lib/src/primitive_jarrays.dart | 750 + .../third_party/jni_bindings_generated.dart | 6926 +++-- pkgs/jni/lib/src/types.dart | 127 +- pkgs/jni/lib/src/util/jiterator.dart | 127 +- pkgs/jni/lib/src/util/jlist.dart | 296 +- pkgs/jni/lib/src/util/jmap.dart | 231 +- pkgs/jni/lib/src/util/jset.dart | 249 +- pkgs/jni/lib/src/util/util.dart | 8 +- pkgs/jni/pubspec.yaml | 4 +- pkgs/jni/test/boxed_test.dart | 64 - pkgs/jni/test/exception_test.dart | 6 +- pkgs/jni/test/global_env_test.dart | 2 +- pkgs/jni/test/jarray_test.dart | 70 +- pkgs/jni/test/jbyte_buffer_test.dart | 22 +- pkgs/jni/test/jlist_test.dart | 114 +- pkgs/jni/test/jmap_test.dart | 46 +- pkgs/jni/test/jobject_test.dart | 22 +- pkgs/jni/test/jset_test.dart | 82 +- pkgs/jni/test/load_test.dart | 2 +- pkgs/jni/test/type_test.dart | 610 - pkgs/jni/tool/generate_jni_bindings.dart | 60 +- pkgs/jni/tool/generate_primitive_arrays.dart | 200 + pkgs/jnigen/CHANGELOG.md | 17 +- .../in_app_java/lib/android_utils.g.dart | 3753 +-- pkgs/jnigen/example/in_app_java/lib/main.dart | 2 +- .../example/in_app_java/tool/jnigen.dart | 5 +- pkgs/jnigen/example/kotlin_plugin/README.md | 2 +- .../kotlin_plugin/lib/kotlin_bindings.dart | 97 +- .../example/notification_plugin/README.md | 2 +- .../lib/notifications.dart | 97 +- .../dart_example/bin/pdf_info.dart | 2 +- .../pdfbox_plugin/example/lib/main.dart | 4 +- .../org/apache/pdfbox/pdmodel/PDDocument.dart | 2338 +- .../pdfbox/pdmodel/PDDocumentInformation.dart | 251 +- .../org/apache/pdfbox/pdmodel/_package.dart | 2 +- .../apache/pdfbox/text/PDFTextStripper.dart | 345 +- .../org/apache/pdfbox/text/_package.dart | 2 +- .../lib/src/bindings/dart_generator.dart | 780 +- pkgs/jnigen/lib/src/bindings/linker.dart | 2 - pkgs/jnigen/lib/src/config/config_types.dart | 8 +- pkgs/jnigen/lib/src/elements/elements.dart | 11 +- pkgs/jnigen/lib/src/summary/summary.dart | 26 +- pkgs/jnigen/lib/src/tools/gradle_tools.dart | 37 +- pkgs/jnigen/pubspec.yaml | 2 +- .../runtime_test_registrant.dart | 4 +- .../fasterxml/jackson/core/JsonFactory.dart | 815 +- .../fasterxml/jackson/core/JsonParser.dart | 1058 +- .../com/fasterxml/jackson/core/JsonToken.dart | 173 +- .../com/fasterxml/jackson/core/_package.dart | 2 +- .../test/kotlin_test/bindings/kotlin.dart | 2505 +- .../com/github/dart_lang/jnigen/SuspendFun.kt | 8 + .../kotlin_test/runtime_test_registrant.dart | 139 +- .../bindings/simple_package.dart | 11425 +++----- .../test/simple_package_test/generate.dart | 7 + .../dart_lang/jnigen/inheritance/Animal.java | 12 + .../jnigen/inheritance/BaseClass.java | 6 +- .../jnigen/inheritance/BaseInterface.java | 2 + .../dart_lang/jnigen/inheritance/Child.java | 16 + .../dart_lang/jnigen/inheritance/Dog.java | 12 + .../jnigen/inheritance/FourLegged.java | 9 + .../dart_lang/jnigen/inheritance/Furry.java | 12 + .../dart_lang/jnigen/inheritance/Mammal.java | 12 + .../jnigen/inheritance/ShibaInu.java | 39 + .../inheritance/SpecificDerivedClass.java | 7 +- .../dart_lang/jnigen/regressions/R2250.java | 2 +- .../jnigen/simple_package/Exceptions.java | 13 + .../runtime_test_registrant.dart | 1758 +- .../test/summary_error_message_test.dart | 32 + pkgs/jnigen/test/summary_generation_test.dart | 46 + .../analysis_options.yaml | 6 - .../lib/src/generator/property_generator.dart | 2 +- .../lib/src/model/dart_type.dart | 10 + .../lib/src/parser/schema_analyzer.dart | 35 +- pkgs/json_syntax_generator/pubspec.yaml | 5 +- .../native_test_helpers/analysis_options.yaml | 6 - pkgs/native_test_helpers/pubspec.yaml | 2 +- pkgs/native_toolchain_c/CHANGELOG.md | 6 +- pkgs/native_toolchain_c/analysis_options.yaml | 6 - .../lib/src/cbuilder/cbuilder.dart | 16 +- .../lib/src/cbuilder/clinker.dart | 6 +- .../lib/src/cbuilder/compiler_resolver.dart | 54 +- .../lib/src/cbuilder/ctool.dart | 4 +- .../lib/src/cbuilder/linker_options.dart | 7 +- .../lib/src/cbuilder/linkmode.dart | 8 +- .../lib/src/cbuilder/logger.dart | 4 +- .../lib/src/cbuilder/run_cbuilder.dart | 50 +- .../lib/src/native_toolchain/clang.dart | 9 + .../lib/src/native_toolchain/msvc.dart | 40 +- .../lib/src/tool/tool_resolver.dart | 3 +- .../lib/src/utils/run_process.dart | 2 +- pkgs/native_toolchain_c/pubspec.yaml | 5 +- .../cbuilder/cbuilder_build_failure_test.dart | 13 +- .../cbuilder/cbuilder_cross_android_test.dart | 115 +- .../cbuilder/cbuilder_cross_ios_test.dart | 329 +- .../cbuilder_cross_linux_host_test.dart | 141 +- .../cbuilder_cross_macos_host_test.dart | 288 +- .../test/cbuilder/cbuilder_test.dart | 20 +- .../test/cbuilder/compiler_resolver_test.dart | 12 +- .../test/cbuilder/objective_c_test.dart | 4 +- .../clinker/objects_cross_android_test.dart | 49 +- .../test/clinker/objects_cross_ios_test.dart | 37 +- .../test/clinker/objects_helper.dart | 3 +- .../clinker/treeshake_cross_android_test.dart | 49 +- .../clinker/treeshake_cross_ios_test.dart | 53 +- pkgs/native_toolchain_c/test/helpers.dart | 26 +- pkgs/objective_c/CHANGELOG.md | 22 + .../example/command_line/pubspec.yaml | 2 +- pkgs/objective_c/hook/build.dart | 28 +- pkgs/objective_c/lib/src/autorelease.dart | 4 +- .../lib/src/c_bindings_generated.dart | 72 + pkgs/objective_c/lib/src/ns_array.dart | 6 - .../src/objective_c_bindings_generated.dart | 1676 +- .../lib/src/runtime_bindings_generated.dart | 8 + pkgs/objective_c/pubspec.yaml | 10 +- .../src/objective_c_bindings_generated.m | 106 +- pkgs/objective_c/test/autorelease_test.dart | 20 + .../test/hook_build_path_test.dart | 109 + pkgs/pub_formats/analysis_options.yaml | 1 + pkgs/pub_formats/pubspec.yaml | 3 +- pkgs/pub_formats/test/helpers.dart | 2 +- pkgs/pub_formats/test/package_graph_test.dart | 2 +- pkgs/pub_formats/test/pubspec_lock_test.dart | 8 +- pkgs/pub_formats/test/pubspec_test.dart | 3 +- pkgs/pub_formats/tool/generate.dart | 4 +- pkgs/record_use/CHANGELOG.md | 15 +- pkgs/record_use/README.md | 151 +- .../doc/schema/record_use.schema.json | 515 +- pkgs/record_use/doc/use_cases/README.md | 19 + pkgs/record_use/doc/use_cases/icon_data.md | 75 + pkgs/record_use/doc/use_cases/icu4x.md | 42 + pkgs/record_use/doc/use_cases/jaspr.md | 81 + pkgs/record_use/doc/use_cases/jnigen.md | 106 + pkgs/record_use/doc/use_cases/messages.md | 58 + pkgs/record_use/example/api/usage.dart | 32 + pkgs/record_use/example/api/usage_link.dart | 87 + pkgs/record_use/lib/record_use.dart | 128 +- pkgs/record_use/lib/record_use_internal.dart | 25 - .../lib/src/canonicalization_context.dart | 51 + pkgs/record_use/lib/src/constant.dart | 1343 +- pkgs/record_use/lib/src/definition.dart | 317 +- pkgs/record_use/lib/src/helper.dart | 16 + pkgs/record_use/lib/src/identifier.dart | 96 - pkgs/record_use/lib/src/loading_unit.dart | 43 + pkgs/record_use/lib/src/location.dart | 72 - pkgs/record_use/lib/src/metadata.dart | 35 +- pkgs/record_use/lib/src/record_use.dart | 134 - .../lib/src/recorded_usage_from_file.dart | 17 - pkgs/record_use/lib/src/recordings.dart | 637 +- pkgs/record_use/lib/src/reference.dart | 927 +- .../lib/src/serialization_context.dart | 109 + pkgs/record_use/lib/src/syntax.g.dart | 2121 +- pkgs/record_use/lib/src/version.dart | 2 +- pkgs/record_use/pubspec.yaml | 4 +- .../test/canonicalization_test.dart | 158 + pkgs/record_use/test/complex_keys_test.dart | 173 + .../record_use/test/double_constant_test.dart | 150 + .../test/extension_receiver_test.dart | 112 + pkgs/record_use/test/filter_test.dart | 139 + .../test/instance_references_test.dart | 133 + pkgs/record_use/test/int_constant_test.dart | 64 + .../test/json_schema/schema_test.dart | 247 +- .../test/json_schema/uri_pattern_test.dart | 45 + pkgs/record_use/test/maybe_constant_test.dart | 193 + .../test/non_constant_in_collection_test.dart | 83 + .../test/semantic_equality_golden_test.dart | 88 - .../test/semantic_equality_test.dart | 221 +- pkgs/record_use/test/storage_2_test.dart | 2 +- pkgs/record_use/test/storage_test.dart | 8 +- .../test/syntax/uri_pattern_test.dart | 63 + .../test/syntax/validation_test.dart | 31 + pkgs/record_use/test/test_data.dart | 328 +- pkgs/record_use/test/to_string_test.dart | 67 + pkgs/record_use/test/usage_test.dart | 122 - .../bin/drop_data_asset_instances.dart | 2 +- .../test_data/drop_data_asset/hook/link.dart | 81 +- .../lib/src/drop_data_asset.dart | 17 +- .../test_data/drop_data_asset/pubspec.yaml | 2 +- .../bin/drop_dylib_recording_instances.dart | 2 +- .../drop_dylib_recording/hook/link.dart | 90 +- .../lib/src/drop_dylib_recording.dart | 17 +- .../drop_dylib_recording/pubspec.yaml | 2 +- pkgs/record_use/test_data/json/basic.json | 52 + pkgs/record_use/test_data/json/complex.json | 69 +- .../json/const_argument_instance.json | 52 + .../json/constructor_invocation.json | 75 + .../test_data/json/constructor_tearoff.json | 50 + .../test_data/json/enum_const_arg.json | 57 + pkgs/record_use/test_data/json/extension.json | 52 +- .../test_data/json/instance_class.json | 50 +- .../test_data/json/instance_complex.json | 112 +- .../test_data/json/instance_duplicates.json | 73 +- .../test_data/json/instance_method.json | 37 +- .../json/instance_not_annotation.json | 50 +- .../json/loading_units_multiple.json | 75 +- .../test_data/json/loading_units_simple.json | 104 +- .../test_data/json/map_complex_keys.json | 77 + .../test_data/json/named_and_positional.json | 143 +- .../record_use/test_data/json/named_both.json | 127 +- .../test_data/json/named_optional.json | 71 +- .../test_data/json/named_required.json | 71 +- .../json/named_with_function_arg.json | 61 +- pkgs/record_use/test_data/json/nested.json | 109 +- .../json/nested_instance_constant.json | 50 + .../test_data/json/partfile_main.json | 58 +- .../test_data/json/positional_both.json | 85 +- .../positional_both_with_type_argument.json | 73 + .../test_data/json/positional_optional.json | 73 +- .../test_data/json/record_enum.json | 59 +- .../json/record_instance_constant.json | 43 +- .../json/record_instance_constant_empty.json | 53 +- .../test_data/json/recorded_uses.json | 189 +- .../test_data/json/recorded_uses_v2.json | 205 + .../test_data/json/recorded_uses_v2_2.json | 64 + pkgs/record_use/test_data/json/simple.json | 58 +- pkgs/record_use/test_data/json/tearoff.json | 52 +- .../test_data/json/top_level_method.json | 50 +- .../test_data/json/types_of_arguments.json | 194 +- .../json/unsupported_collections.json | 71 + .../test_data/json/unsupported_instance.json | 73 + .../test_data/json_dart2js/complex.json | 55 - .../test_data/json_dart2js/different.json | 15 - .../test_data/json_dart2js/extension.json | 47 - .../json_dart2js/instance_class.json | 15 - .../json_dart2js/instance_complex.json | 15 - .../json_dart2js/instance_duplicates.json | 15 - .../json_dart2js/instance_method.json | 15 - .../json_dart2js/instance_not_annotation.json | 15 - .../json_dart2js/loading_units_multiple.json | 85 - .../json_dart2js/loading_units_simple.json | 96 - .../json_dart2js/named_and_positional.json | 98 - .../test_data/json_dart2js/named_both.json | 98 - .../json_dart2js/named_optional.json | 59 - .../json_dart2js/named_required.json | 59 - .../test_data/json_dart2js/nested.json | 15 - .../test_data/json_dart2js/partfile_main.json | 47 - .../json_dart2js/positional_both.json | 69 - .../json_dart2js/positional_optional.json | 59 - .../test_data/json_dart2js/record_enum.json | 15 - .../record_instance_constant_empty.json | 15 - .../test_data/json_dart2js/simple.json | 47 - .../test_data/json_dart2js/tearoff.json | 47 - .../json_dart2js/top_level_method.json | 46 - .../json_dart2js/types_of_arguments.json | 98 - .../test_data/library_uris/bin/my_bin.dart | 21 + .../test_data/library_uris/hook/build.dart | 14 + .../test_data/library_uris/hook/link.dart | 73 + .../library_uris/lib/library_uris.dart | 6 + .../test_data/library_uris/lib/src/call.dart | 13 + .../library_uris/lib/src/definition.dart | 13 + .../test_data/library_uris/pubspec.yaml | 25 + .../lib/library_uris_helper.dart | 6 + .../lib/src/helper_call.dart | 9 + .../lib/src/helper_definition.dart | 13 + .../library_uris_helper/pubspec.yaml | 14 + pkgs/record_use/test_data/manifest.yaml | 53 +- pkgs/record_use/tool/generate_syntax.dart | 5 +- pkgs/repo_lint_rules/CHANGELOG.md | 3 - pkgs/repo_lint_rules/analysis_options.yaml | 19 - pkgs/repo_lint_rules/lib/repo_lint_rules.dart | 15 - .../src/avoid_import_outside_src_rule.dart | 59 - pkgs/repo_lint_rules/pubspec.yaml | 19 - pkgs/swift2objc/CHANGELOG.md | 5 + .../src/ast/_core/interfaces/declaration.dart | 11 +- .../_core/interfaces/enum_declaration.dart | 26 - .../src/ast/_core/shared/referred_type.dart | 91 + .../built_in/built_in_declaration.dart | 15 +- .../compounds/class_declaration.dart | 8 +- .../enum_declaration.dart} | 68 +- .../members/initializer_declaration.dart | 4 + .../compounds/members/method_declaration.dart | 6 + .../members/property_declaration.dart | 7 + .../compounds/protocol_declaration.dart | 8 +- .../compounds/struct_declaration.dart | 8 +- .../enums/normal_enum_declaration.dart | 91 - .../enums/raw_value_enum_declaration.dart | 102 - .../src/ast/declarations/globals/globals.dart | 8 + .../declarations/typealias_declaration.dart | 4 + pkgs/swift2objc/lib/src/ast/visitor.dart | 17 +- .../lib/src/generator/_core/utils.dart | 6 +- .../generator/generators/class_generator.dart | 1 + .../lib/src/parser/_core/utils.dart | 27 + .../parse_compound_declaration.dart | 65 +- .../parse_enum_declaration.dart | 64 + .../parse_function_declaration.dart | 103 +- .../parse_initializer_declaration.dart | 1 + .../parse_typealias_declaration.dart | 2 +- .../parse_variable_declaration.dart | 10 +- .../parser/parsers/parse_declarations.dart | 34 +- .../lib/src/parser/parsers/parse_type.dart | 85 +- .../src/transformer/_core/unique_namer.dart | 82 +- .../lib/src/transformer/_core/utils.dart | 68 +- .../lib/src/transformer/transform.dart | 79 +- .../src/transformer/transformers/const.dart | 3 +- .../transformers/transform_compound.dart | 92 +- .../transformers/transform_enum.dart | 82 + .../transformers/transform_function.dart | 56 +- .../transformers/transform_globals.dart | 18 +- .../transformers/transform_referred_type.dart | 171 +- pkgs/swift2objc/pubspec.yaml | 4 +- .../test/integration/available_output.swift | 9 +- .../test/integration/enum_input.swift | 74 + .../test/integration/enum_output.swift | 287 + ...lobal_variables_and_functions_output.swift | 6 - .../implicit_initializers_input.swift | 31 + .../implicit_initializers_output.swift | 165 + .../test/integration/inout_input.swift | 21 + .../test/integration/inout_output.swift | 50 + .../test/integration/integration_test.dart | 2 +- .../test/integration/nested_types_input.swift | 8 + .../integration/nested_types_output.swift | 18 +- .../test/integration/operators_input.swift | 24 + .../test/integration/operators_output.swift | 48 + .../test/integration/optional_output.swift | 3 - .../optional_primitives_input.swift | 12 + .../optional_primitives_output.swift | 98 + .../structs_and_properties_output.swift | 4 + .../test/integration/tuples_input.swift | 90 + .../test/integration/tuples_output.swift | 439 + .../test/unit/implicit_initializer_test.dart | 170 + .../test/unit/parse_function_info_test.dart | 188 +- .../swift2objc/test/unit/parse_type_test.dart | 152 + .../test/unit/unique_namer_test.dart | 49 + pkgs/swiftgen/example/avf_audio_bindings.dart | 12 +- pkgs/swiftgen/example/pubspec.yaml | 4 +- pkgs/swiftgen/pubspec.yaml | 4 +- .../swiftgen/test/integration/callbacks.swift | 18 + .../test/integration/callbacks_bindings.dart | 743 + .../test/integration/callbacks_test.dart | 56 + .../test/integration/classes_bindings.dart | 327 +- .../swiftgen/test/integration/protocols.swift | 29 + .../test/integration/protocols_bindings.dart | 1826 ++ .../test/integration/protocols_test.dart | 73 + pkgs/swiftgen/test/integration/util.dart | 29 +- pubspec.yaml | 68 +- tool/check_licenses.dart | 119 + tool/ci.dart | 330 +- 643 files changed, 80534 insertions(+), 58069 deletions(-) create mode 100644 .agents/skills/refactor-dart-dot-shorthands/SKILL.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/ffi.yaml create mode 100644 analysis_options.yaml create mode 100644 pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_allocate_collision_bindings.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_adventure/bin/pirate_adventure.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_adventure/pubspec.yaml create mode 100644 pkgs/hooks_runner/test_data/pirate_speak/data/translations.json create mode 100644 pkgs/hooks_runner/test_data/pirate_speak/hook/build.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_speak/hook/link.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_speak/lib/pirate_speak.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_speak/lib/src/definitions.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_speak/pubspec.yaml create mode 100644 pkgs/hooks_runner/test_data/pirate_technology/data/tech.json create mode 100644 pkgs/hooks_runner/test_data/pirate_technology/hook/build.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_technology/hook/link.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_technology/lib/pirate_technology.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_technology/lib/src/definitions.dart create mode 100644 pkgs/hooks_runner/test_data/pirate_technology/pubspec.yaml create mode 100644 pkgs/jni/lib/src/core_bindings.dart create mode 100644 pkgs/jni/lib/src/primitive_jarrays.dart delete mode 100644 pkgs/jni/test/type_test.dart create mode 100644 pkgs/jni/tool/generate_primitive_arrays.dart create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Animal.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Child.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Dog.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/FourLegged.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Furry.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Mammal.java create mode 100644 pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/ShibaInu.java create mode 100644 pkgs/jnigen/test/summary_error_message_test.dart create mode 100644 pkgs/objective_c/test/hook_build_path_test.dart create mode 100644 pkgs/pub_formats/analysis_options.yaml create mode 100644 pkgs/record_use/doc/use_cases/README.md create mode 100644 pkgs/record_use/doc/use_cases/icon_data.md create mode 100644 pkgs/record_use/doc/use_cases/icu4x.md create mode 100644 pkgs/record_use/doc/use_cases/jaspr.md create mode 100644 pkgs/record_use/doc/use_cases/jnigen.md create mode 100644 pkgs/record_use/doc/use_cases/messages.md create mode 100644 pkgs/record_use/example/api/usage.dart create mode 100644 pkgs/record_use/example/api/usage_link.dart delete mode 100644 pkgs/record_use/lib/record_use_internal.dart create mode 100644 pkgs/record_use/lib/src/canonicalization_context.dart delete mode 100644 pkgs/record_use/lib/src/identifier.dart create mode 100644 pkgs/record_use/lib/src/loading_unit.dart delete mode 100644 pkgs/record_use/lib/src/location.dart delete mode 100644 pkgs/record_use/lib/src/record_use.dart delete mode 100644 pkgs/record_use/lib/src/recorded_usage_from_file.dart create mode 100644 pkgs/record_use/lib/src/serialization_context.dart create mode 100644 pkgs/record_use/test/canonicalization_test.dart create mode 100644 pkgs/record_use/test/complex_keys_test.dart create mode 100644 pkgs/record_use/test/double_constant_test.dart create mode 100644 pkgs/record_use/test/extension_receiver_test.dart create mode 100644 pkgs/record_use/test/filter_test.dart create mode 100644 pkgs/record_use/test/instance_references_test.dart create mode 100644 pkgs/record_use/test/int_constant_test.dart create mode 100644 pkgs/record_use/test/json_schema/uri_pattern_test.dart create mode 100644 pkgs/record_use/test/maybe_constant_test.dart create mode 100644 pkgs/record_use/test/non_constant_in_collection_test.dart delete mode 100644 pkgs/record_use/test/semantic_equality_golden_test.dart create mode 100644 pkgs/record_use/test/syntax/uri_pattern_test.dart create mode 100644 pkgs/record_use/test/syntax/validation_test.dart create mode 100644 pkgs/record_use/test/to_string_test.dart delete mode 100644 pkgs/record_use/test/usage_test.dart create mode 100644 pkgs/record_use/test_data/json/basic.json create mode 100644 pkgs/record_use/test_data/json/const_argument_instance.json create mode 100644 pkgs/record_use/test_data/json/constructor_invocation.json create mode 100644 pkgs/record_use/test_data/json/constructor_tearoff.json create mode 100644 pkgs/record_use/test_data/json/enum_const_arg.json create mode 100644 pkgs/record_use/test_data/json/map_complex_keys.json create mode 100644 pkgs/record_use/test_data/json/nested_instance_constant.json create mode 100644 pkgs/record_use/test_data/json/positional_both_with_type_argument.json create mode 100644 pkgs/record_use/test_data/json/recorded_uses_v2.json create mode 100644 pkgs/record_use/test_data/json/recorded_uses_v2_2.json create mode 100644 pkgs/record_use/test_data/json/unsupported_collections.json create mode 100644 pkgs/record_use/test_data/json/unsupported_instance.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/complex.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/different.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/extension.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/instance_class.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/instance_complex.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/instance_duplicates.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/instance_method.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/instance_not_annotation.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/loading_units_multiple.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/loading_units_simple.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/named_and_positional.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/named_both.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/named_optional.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/named_required.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/nested.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/partfile_main.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/positional_both.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/positional_optional.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/record_enum.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/record_instance_constant_empty.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/simple.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/tearoff.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/top_level_method.json delete mode 100644 pkgs/record_use/test_data/json_dart2js/types_of_arguments.json create mode 100644 pkgs/record_use/test_data/library_uris/bin/my_bin.dart create mode 100644 pkgs/record_use/test_data/library_uris/hook/build.dart create mode 100644 pkgs/record_use/test_data/library_uris/hook/link.dart create mode 100644 pkgs/record_use/test_data/library_uris/lib/library_uris.dart create mode 100644 pkgs/record_use/test_data/library_uris/lib/src/call.dart create mode 100644 pkgs/record_use/test_data/library_uris/lib/src/definition.dart create mode 100644 pkgs/record_use/test_data/library_uris/pubspec.yaml create mode 100644 pkgs/record_use/test_data/library_uris_helper/lib/library_uris_helper.dart create mode 100644 pkgs/record_use/test_data/library_uris_helper/lib/src/helper_call.dart create mode 100644 pkgs/record_use/test_data/library_uris_helper/lib/src/helper_definition.dart create mode 100644 pkgs/record_use/test_data/library_uris_helper/pubspec.yaml delete mode 100644 pkgs/repo_lint_rules/CHANGELOG.md delete mode 100644 pkgs/repo_lint_rules/analysis_options.yaml delete mode 100644 pkgs/repo_lint_rules/lib/repo_lint_rules.dart delete mode 100644 pkgs/repo_lint_rules/lib/src/avoid_import_outside_src_rule.dart delete mode 100644 pkgs/repo_lint_rules/pubspec.yaml delete mode 100644 pkgs/swift2objc/lib/src/ast/_core/interfaces/enum_declaration.dart rename pkgs/swift2objc/lib/src/ast/declarations/{enums/associated_value_enum_declaration.dart => compounds/enum_declaration.dart} (56%) delete mode 100644 pkgs/swift2objc/lib/src/ast/declarations/enums/normal_enum_declaration.dart delete mode 100644 pkgs/swift2objc/lib/src/ast/declarations/enums/raw_value_enum_declaration.dart create mode 100644 pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_enum_declaration.dart create mode 100644 pkgs/swift2objc/lib/src/transformer/transformers/transform_enum.dart create mode 100644 pkgs/swift2objc/test/integration/enum_input.swift create mode 100644 pkgs/swift2objc/test/integration/enum_output.swift create mode 100644 pkgs/swift2objc/test/integration/implicit_initializers_input.swift create mode 100644 pkgs/swift2objc/test/integration/implicit_initializers_output.swift create mode 100644 pkgs/swift2objc/test/integration/inout_input.swift create mode 100644 pkgs/swift2objc/test/integration/inout_output.swift create mode 100644 pkgs/swift2objc/test/integration/operators_input.swift create mode 100644 pkgs/swift2objc/test/integration/operators_output.swift create mode 100644 pkgs/swift2objc/test/integration/optional_primitives_input.swift create mode 100644 pkgs/swift2objc/test/integration/optional_primitives_output.swift create mode 100644 pkgs/swift2objc/test/integration/tuples_input.swift create mode 100644 pkgs/swift2objc/test/integration/tuples_output.swift create mode 100644 pkgs/swift2objc/test/unit/implicit_initializer_test.dart create mode 100644 pkgs/swift2objc/test/unit/unique_namer_test.dart create mode 100644 pkgs/swiftgen/test/integration/callbacks.swift create mode 100644 pkgs/swiftgen/test/integration/callbacks_bindings.dart create mode 100644 pkgs/swiftgen/test/integration/callbacks_test.dart create mode 100644 pkgs/swiftgen/test/integration/protocols.swift create mode 100644 pkgs/swiftgen/test/integration/protocols_bindings.dart create mode 100644 pkgs/swiftgen/test/integration/protocols_test.dart create mode 100644 tool/check_licenses.dart diff --git a/.agents/skills/refactor-dart-dot-shorthands/SKILL.md b/.agents/skills/refactor-dart-dot-shorthands/SKILL.md new file mode 100644 index 0000000000..855581f3b7 --- /dev/null +++ b/.agents/skills/refactor-dart-dot-shorthands/SKILL.md @@ -0,0 +1,170 @@ +--- +name: refactor-dart-dot-shorthands +description: Refactor Dart code to use modern language features, specifically dot shorthands (member access shorthands) introduced in Dart 3.7. Use this when you want to make code more concise by removing redundant type names in enum or static member access when the context type is known. +--- + +# Refactor Dart Dot Shorthands + +Apply Dart 3.7+ dot shorthands (member access shorthands) to simplify code where the context type is already known. + +## Constraints + +* **Single Package Focus**: Only apply changes to a single package in `pkgs/` at a time. Do not spread changes across multiple packages in a single operation. +* **CI Usage**: Only run `dart tool/ci.dart --all --fast` if changes are made to packages that are part of the top-level pub workspace (as defined in the root `pubspec.yaml`). If the package is not in the workspace, use local validation (`dart analyze`, `dart test`) within that package's directory. +* **No `.new` Shorthand**: Do not use `.new` as a shorthand for constructors (e.g., keep `MyClass()` or `MyClass.new()` if explicit, but do not refactor to just `.new()`). +* **Immediate Clarity**: Only use dot shorthands if the type is immediately clear from the line itself (e.g., in a typed variable declaration, a switch on a variable with a clear type, or a collection with an explicit type argument). Do not use them if identifying the type requires scrolling or searching elsewhere in the file. +* **No Explicit Typing for Shorthands**: DO NOT add explicit type arguments to collections (e.g., changing `const x = [...]` to `const x = [...]`) or explicit types to variables just to enable the use of dot shorthands. Shorthands should only be used where the context type is already explicitly defined in the existing code. +* **Variable/Parameter Naming**: Only use shorthands if the variable or parameter name contains the type name (or a very clear abbreviation). Avoid renaming variables or parameters solely to enable shorthands, especially if they are part of a public API or used in many locations. +* **Avoid Complex Contexts**: Avoid using shorthands in complex contexts where inference might be brittle, such as inside nested tuples in switch statements, unless the analysis tool confirms it's valid. +* **Maintain Formatting**: When refactoring lists or collections, preserve the original formatting (e.g., multiline lists with trailing commas). Do not squash them into a single line. +* **No Redundant Shorthands**: Do not use dot shorthands if the member is already accessible without any qualifier (e.g., inside the class where the static member is defined). Prefer `member` over `.member` if both work. +* **Iterative Progress Tracking**: You MUST update `SHORTHAND_PROGRESS.md` after processing each file (or a small batch of no more than 3 files). This ensures progress is visible and prevents losing work if the session is interrupted. Do not wait until the end of the package to update the progress file. + +## Workflow + +1. **Select Target Package**: Choose a single package in `pkgs/` to refactor. +2. **Initialize Progress**: + * Recursively list all `.dart` files in the package. + * Create a temporary markdown file (e.g., `SHORTHAND_PROGRESS.md`) containing a checklist of all files. +3. **Iterative Refactoring**: Work through the files in small batches (1-3 files): + * **Identify**: Search for shorthand opportunities within the files that meet the **Constraints**. + * **Apply**: Replace `TypeName.memberName` with `.memberName`. + * **Validate**: Run `dart analyze` on the affected files/package. + * **Record**: Immediately update the checklist in `SHORTHAND_PROGRESS.md` to mark the processed files as completed. **Do not skip this step.** +4. **Final Verification**: + * Once all files are processed, perform the final validation step as described in the **Verification** section. +5. **Cleanup**: Delete the temporary progress file. + +## Examples + +### Arguments and named parameter default values + +```dart +// Before +super.language = Language.c, +``` + +```dart +// After +super.language = .c, +``` + +Only do the refactoring if the receiver or parameter name contains the type modulo spacing. + +```dart +// Before +super(type: OutputType.library); +``` + +```dart +// After, bad. (Type not clear from 'type' parameter) +super(type: .library); +``` + +If not part of the public API, consider renaming the named parameter to match the type name. + +```dart +// After +super(outputType: .library); +``` + +However, only do this if the code quality doesn't suffer. + +### Collections and Lists + +Maintain multiline formatting for better readability. + +```dart +// Before +const targets = [ + Architecture.arm, + Architecture.arm64, + Architecture.ia32, + Architecture.x64, +]; +``` + +```dart +// After +const targets = [ + .arm, + .arm64, + .ia32, + .x64, +]; +``` + +### Variable assignments and function calls + +```dart +// Before +logger.level = Level.INFO; +``` + +```dart +// After +logger.level = .INFO; +``` + +If the type is contained in the name it is fine: + +```dart +// Before +hostOS = hostOS ?? OS.current, +``` + +```dart +// After +hostOS = hostOS ?? .current, +``` + +Avoid shorthands if the context is lost: + +```dart +// Before +await expectMachineArchitecture(libUri, target, OS.android); +``` + +```dart +// After, bad. (What is .android? Architecture? OS?) +await expectMachineArchitecture(libUri, target, .android); +``` + +### Equality checks + +```dart +// Before +'/INCLUDE:${targetArch == Architecture.ia32 ? '_' : ''}$symbol' +``` + +```dart +// After, not great +'/INCLUDE:${targetArch == .ia32 ? '_' : ''}$symbol' +``` + +If variable names are not part of the public API, refactor variable name to match the type name. + +```dart +// After +'/INCLUDE:${targetArchitecture == .ia32 ? '_' : ''}$symbol' +``` + +However only do this if it keeps the code understandable. + +**Note**: Shorthands are most effective for enums and static constants used as values. + +## Verification + +After applying changes, run the following in the package directory: +```bash +dart analyze +``` + +If the package is part of the top-level workspace, run from the project root: +```bash +dart tool/ci.dart --all --fast +``` +Otherwise, run tests locally in the package directory: +```bash +dart test +``` diff --git a/.github/ISSUE_TEMPLATE/code_assets.md b/.github/ISSUE_TEMPLATE/code_assets.md index 8dc0375daf..3225f77199 100644 --- a/.github/ISSUE_TEMPLATE/code_assets.md +++ b/.github/ISSUE_TEMPLATE/code_assets.md @@ -1,5 +1,6 @@ --- name: "package:code_assets" about: "Create a bug or file a feature request against package:code_assets." -labels: "package:code_assets" +labels: ["needs-triage", "package:code_assets"] +projects: ["dart-lang/99"] --- diff --git a/.github/ISSUE_TEMPLATE/data_assets.md b/.github/ISSUE_TEMPLATE/data_assets.md index 318beda071..9b2ab3518f 100644 --- a/.github/ISSUE_TEMPLATE/data_assets.md +++ b/.github/ISSUE_TEMPLATE/data_assets.md @@ -1,5 +1,6 @@ --- name: "package:data_assets" about: "Create a bug or file a feature request against package:data_assets." -labels: "package:data_assets" +labels: ["needs-triage", "package:data_assets"] +projects: ["dart-lang/99"] --- diff --git a/.github/ISSUE_TEMPLATE/ffi.md b/.github/ISSUE_TEMPLATE/ffi.md index 9c42a774e8..186baa22a0 100644 --- a/.github/ISSUE_TEMPLATE/ffi.md +++ b/.github/ISSUE_TEMPLATE/ffi.md @@ -1,5 +1,5 @@ --- name: "package:ffi" about: "Create a bug or file a feature request against package:ffi." -labels: "package:ffi" +labels: ["needs-triage", "package:ffi"] --- diff --git a/.github/ISSUE_TEMPLATE/ffigen.md b/.github/ISSUE_TEMPLATE/ffigen.md index d3e7a651f5..124850e68b 100644 --- a/.github/ISSUE_TEMPLATE/ffigen.md +++ b/.github/ISSUE_TEMPLATE/ffigen.md @@ -1,5 +1,5 @@ --- name: "package:ffigen" about: "Create a bug or file a feature request against package:ffigen." -labels: "package:ffigen" +labels: ["needs-triage", "package:ffigen"] --- diff --git a/.github/ISSUE_TEMPLATE/hooks.md b/.github/ISSUE_TEMPLATE/hooks.md index 14f088866c..1f8c4a181f 100644 --- a/.github/ISSUE_TEMPLATE/hooks.md +++ b/.github/ISSUE_TEMPLATE/hooks.md @@ -1,5 +1,6 @@ --- name: "package:hooks" about: "Create a bug or file a feature request against package:hooks." -labels: "package:hooks" +labels: ["needs-triage", "package:hooks"] +projects: ["dart-lang/99"] --- diff --git a/.github/ISSUE_TEMPLATE/hooks_runner.md b/.github/ISSUE_TEMPLATE/hooks_runner.md index ba5843ab53..9ae9229325 100644 --- a/.github/ISSUE_TEMPLATE/hooks_runner.md +++ b/.github/ISSUE_TEMPLATE/hooks_runner.md @@ -1,5 +1,6 @@ --- name: "package:hooks_runner" about: "Create a bug or file a feature request against package:hooks_runner." -labels: "package:hooks_runner" +labels: ["needs-triage", "package:hooks_runner"] +projects: ["dart-lang/99"] --- diff --git a/.github/ISSUE_TEMPLATE/jnigen.md b/.github/ISSUE_TEMPLATE/jnigen.md index de9128814c..f405594f1e 100644 --- a/.github/ISSUE_TEMPLATE/jnigen.md +++ b/.github/ISSUE_TEMPLATE/jnigen.md @@ -1,6 +1,6 @@ --- name: "package:jnigen" about: "Create a bug or file a feature request against package:jnigen or its support library package:jni." -labels: ["package:jnigen", "package:jni"] +labels: ["needs-triage", "package:jnigen", "package:jni", "lang-java"] projects: ["dart-lang/69"] --- diff --git a/.github/ISSUE_TEMPLATE/native_toolchain_c.md b/.github/ISSUE_TEMPLATE/native_toolchain_c.md index 8a193465e6..650c8cc722 100644 --- a/.github/ISSUE_TEMPLATE/native_toolchain_c.md +++ b/.github/ISSUE_TEMPLATE/native_toolchain_c.md @@ -1,5 +1,5 @@ --- name: "package:native_toolchain_c" about: "Create a bug or file a feature request against package:native_toolchain_c." -labels: "package:native_toolchain_c" +labels: ["needs-triage", "package:native_toolchain_c"] --- diff --git a/.github/ISSUE_TEMPLATE/objective_c.md b/.github/ISSUE_TEMPLATE/objective_c.md index 97f1aaacfd..0301a43a9c 100644 --- a/.github/ISSUE_TEMPLATE/objective_c.md +++ b/.github/ISSUE_TEMPLATE/objective_c.md @@ -1,5 +1,6 @@ --- name: "package:objective_c" about: "Create a bug or file a feature request against package:objective_c." -labels: "package:objective_c" +labels: ["needs-triage", "package:objective_c", "lang-objective_c"] +projects: ["dart-lang/87"] --- diff --git a/.github/ISSUE_TEMPLATE/record_use.md b/.github/ISSUE_TEMPLATE/record_use.md index 5eddea3e19..f80c410443 100644 --- a/.github/ISSUE_TEMPLATE/record_use.md +++ b/.github/ISSUE_TEMPLATE/record_use.md @@ -1,5 +1,6 @@ --- name: "package:record_use" about: "Create a bug or file a feature request against package:record_use." -labels: "package:record_use" +labels: ["needs-triage", "package:record_use"] +projects: ["dart-lang/99"] --- diff --git a/.github/ISSUE_TEMPLATE/swift2objc.md b/.github/ISSUE_TEMPLATE/swift2objc.md index 9d62e0ac85..3787941ece 100644 --- a/.github/ISSUE_TEMPLATE/swift2objc.md +++ b/.github/ISSUE_TEMPLATE/swift2objc.md @@ -1,5 +1,6 @@ --- name: "package:swift2objc" about: "Create a bug or file a feature request against package:swift2objc." -labels: "package:swift2objc" +labels: ["needs-triage", "package:swift2objc", "lang-swift"] +projects: ["dart-lang/87"] --- diff --git a/.github/ISSUE_TEMPLATE/swiftgen.md b/.github/ISSUE_TEMPLATE/swiftgen.md index 710821a20e..bd959759b1 100644 --- a/.github/ISSUE_TEMPLATE/swiftgen.md +++ b/.github/ISSUE_TEMPLATE/swiftgen.md @@ -1,5 +1,6 @@ --- name: "package:swiftgen" about: "Create a bug or file a feature request against package:swiftgen." -labels: "package:swiftgen" +labels: ["needs-triage", "package:swiftgen", "lang-swift"] +projects: ["dart-lang/87"] --- diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..39d268037f --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,20 @@ + + +## Description + +*Replace this paragraph with a description of what this PR is changing or adding, and **why**. The 'why' is the most important part of the description.* + +## Related Issues + +*List which issues are fixed by this PR. Use the syntax `Fixes #1234`.* + +## PR Checklist + +- [ ] I’ve reviewed the [contributor guide](https://github.com/dart-lang/native/blob/main/CONTRIBUTING.md) and applied the relevant portions to this PR. +- [ ] I've run `dart tool/ci.dart --all` locally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevel `pubspec.yaml` workspace. +- [ ] All existing and new tests are passing. I added new tests to check the change I am making. +- [ ] The PR is actually solving the issue. PRs that don't solve the issue will be closed. Please be respectful of the maintainers' time. If it's not clear what the issue is, feel free to ask questions on the GitHub issue before submitting a PR. +- [ ] I have updated `CHANGELOG.md` for the relevant packages. (Not needed for small changes such as doc typos). +- [ ] I have [updated the pubspec package version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change) if necessary. diff --git a/.github/workflows/ffi.yaml b/.github/workflows/ffi.yaml deleted file mode 100644 index f5a241ad24..0000000000 --- a/.github/workflows/ffi.yaml +++ /dev/null @@ -1,73 +0,0 @@ -name: ffi - -on: - # Run on PRs and pushes to the default branch. - push: - branches: [main] - paths: - - '.github/workflows/ffi.yaml' - - 'pkgs/ffi/**' - pull_request: - branches: [main] - paths: - - '.github/workflows/ffi.yaml' - - 'pkgs/ffi/**' - schedule: - - cron: "0 0 * * 0" - -env: - PUB_ENVIRONMENT: bot.github - -jobs: - # Check code formatting and static analysis on a single OS (linux) - # against Dart dev. - analyze: - runs-on: ubuntu-latest - defaults: - run: - working-directory: pkgs/ffi/ - strategy: - fail-fast: false - matrix: - sdk: [dev] - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 - - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c - with: - sdk: ${{ matrix.sdk }} - - id: install - name: Install dependencies - run: dart pub get - - name: Check formatting - run: dart format --output=none --set-exit-if-changed . - if: always() && steps.install.outcome == 'success' - - name: Analyze code - run: dart analyze --fatal-infos - if: always() && steps.install.outcome == 'success' - - # Run tests on a matrix consisting of two dimensions: - # 1. OS: ubuntu-latest, (macos-latest, windows-latest) - # 2. release channel: dev - test: - needs: analyze - runs-on: ${{ matrix.os }} - defaults: - run: - working-directory: pkgs/ffi/ - strategy: - fail-fast: false - matrix: - # Add macos-latest and/or windows-latest if relevant for this package. - os: [ubuntu-latest] - sdk: [beta, dev] - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 - - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c - with: - sdk: ${{ matrix.sdk }} - - id: install - name: Install dependencies - run: dart pub get - - name: Run VM tests - run: dart test --platform vm - if: always() && steps.install.outcome == 'success' diff --git a/.github/workflows/ffigen.yml b/.github/workflows/ffigen.yml index 55ae003b31..9ad0163876 100644 --- a/.github/workflows/ffigen.yml +++ b/.github/workflows/ffigen.yml @@ -197,4 +197,4 @@ jobs: - name: Build test dylib and bindings run: dart --enable-asserts test/setup.dart - name: Run VM tests - run: flutter pub run test test_flutter/ + run: dart test test_flutter/ diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml index d25bed3938..0c1373931e 100644 --- a/.github/workflows/health.yaml +++ b/.github/workflows/health.yaml @@ -12,7 +12,8 @@ jobs: with: coverage_web: false # TODO(https://github.com/dart-lang/native/issues/1242): Add coverage back. - checks: "changelog,license,do-not-submit,breaking,leaking" + # TODO(https://github.com/dart-lang/native/issues/3148): Add copyright back. + checks: "changelog,do-not-submit,breaking,leaking" flutter_packages: "pkgs/ffigen,pkgs/jni,pkgs/jnigen,pkgs/objective_c" ignore_license: "**.g.dart" ignore_coverage: "**.mock.dart,**.g.dart" diff --git a/.github/workflows/jnigen.yaml b/.github/workflows/jnigen.yaml index 8d4d5487d4..1916d6fd42 100644 --- a/.github/workflows/jnigen.yaml +++ b/.github/workflows/jnigen.yaml @@ -229,6 +229,8 @@ jobs: run: | dart run tool/generate_jni_bindings.dart git diff --exit-code -- lib/src/plugin + dart run tool/generate_primitive_arrays.dart + git diff --exit-code -- lib/src/primitive_jarrays.dart # TODO(https://github.com/dart-lang/ffigen/issues/555): FFIgen generated # on my machine has macOS specific stuff and CI does not. # We should just generate the struct as opaque, but we currently can't. diff --git a/.github/workflows/native.yaml b/.github/workflows/native.yaml index 5d2c5ccbfc..ebc6157fd2 100644 --- a/.github/workflows/native.yaml +++ b/.github/workflows/native.yaml @@ -12,13 +12,13 @@ on: - '.github/workflows/native.yaml' - 'pkgs/code_assets/**' - 'pkgs/data_assets/**' - - 'pkgs/hooks_runner/**' + - 'pkgs/ffi/**' - 'pkgs/hooks/**' + - 'pkgs/hooks_runner/**' - 'pkgs/json_syntax_generator/**' - 'pkgs/native_test_helpers/**' - 'pkgs/native_toolchain_c/**' - 'pkgs/record_use/**' - - 'pkgs/repo_lint_rules/**' - 'tool/**' push: branches: [main] @@ -26,13 +26,13 @@ on: - '.github/workflows/native.yaml' - 'pkgs/code_assets/**' - 'pkgs/data_assets/**' - - 'pkgs/hooks_runner/**' + - 'pkgs/ffi/**' - 'pkgs/hooks/**' + - 'pkgs/hooks_runner/**' - 'pkgs/json_syntax_generator/**' - 'pkgs/native_test_helpers/**' - 'pkgs/native_toolchain_c/**' - 'pkgs/record_use/**' - - 'pkgs/repo_lint_rules/**' - 'tool/**' schedule: - cron: '0 0 * * 0' # weekly @@ -67,16 +67,14 @@ jobs: run: sudo apt-get update && sudo apt-get install clang-15 gcc-i686-linux-gnu gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-riscv64-linux-gnu if: ${{ matrix.os == 'ubuntu' }} - - run: dart pub get + - name: Install native toolchains + run: brew install lld + if: ${{ matrix.os == 'macos' }} - - name: Run pub get, analysis, formatting, generators, and tests. - # Don't run examples on stable, the experiment is not available on stable. - run: dart tool/ci.dart --all --no-example - if: ${{ matrix.sdk == 'stable' }} + - run: dart pub get - name: Run pub get, analysis, formatting, generators, tests, and examples. - run: dart tool/ci.dart --all - if: ${{ matrix.sdk != 'stable' }} + run: dart tool/ci.dart --all --no-apitool ${{ matrix.sdk == 'stable' && '--no-format' || '' }} - name: Upload coverage uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e diff --git a/.github/workflows/objective_c.yaml b/.github/workflows/objective_c.yaml index ddcd70fcc0..c5ec2b93e4 100644 --- a/.github/workflows/objective_c.yaml +++ b/.github/workflows/objective_c.yaml @@ -100,7 +100,9 @@ jobs: - name: Select the XCode version run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer - name: Install iOS SDK - run: xcodebuild -downloadPlatform iOS -buildVersion ${{ matrix.ios_version }} + run: | + xcrun simctl list > /dev/null # Wakes up and initializes the CoreSimulator daemon + xcodebuild -downloadPlatform iOS -buildVersion ${{ matrix.ios_version }} - name: Install dependencies run: flutter pub get - name: Build the example app for macos diff --git a/.gitignore b/.gitignore index 09a3ceb87a..79d8aba87e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ .DS_Store .atom/ .idea +.flutter-plugins* +.last_build_id .packages .pub/ .pub-cache/ .svn/ .dart_tool/ +local.properties .vscode/ .clangd .gdb_history @@ -46,7 +49,7 @@ local.properties keystore.properties **/Flutter/Generated.xcconfig **/Flutter/App.framework/ -**/Flutter/ephemeral/ +**/ephemeral/ **/Flutter/Flutter.podspec **/Flutter/Flutter.framework/ **/Flutter/flutter_assets/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 633e55f395..5b10f7bda2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,14 @@ You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again. +## Solving Issues + +Each PR should aim to solve a specific issue. If the issue's requirements are +unclear, please ask for clarification on the GitHub issue before submitting a PR. + +PRs that do not actually solve the issue will be closed. Please be respectful of +the maintainers' time. + ## Code Reviews All submissions, including submissions by project members, require review. We @@ -31,6 +39,34 @@ The Dart source code in this repo follows the: You should familiarize yourself with those guidelines. +## Continuous Integration (CI) + +Before submitting a PR, ensure that you have run the CI script locally: + +```bash +dart tool/ci.dart --all +``` + +CI scripts in this repository do not run on pull requests from external +contributors until a maintainer approves the run. To reduce roundtrip times +and ensure your PR is ready for review, it is important to run the CI script +locally before pushing. + +This script will run: +- Static analysis (`dart analyze`) +- Code formatting check (`dart format`) +- Code generation scripts +- Tests (`dart test`) +- API surface checks (`dart_apitool`) + +## Changelog and Versioning + +Most changes should add an entry to the `CHANGELOG.md` of the affected packages. +Small changes such as documentation typos do not require a changelog entry. + +When making a functional change, you may also need to [update the pubspec package +version](https://github.com/dart-lang/sdk/blob/main/docs/External-Package-Maintenance.md#making-a-change). + ## File headers All files in the Dart project must start with the following header; if you add a @@ -52,6 +88,9 @@ We pledge to maintain an open and welcoming environment. For details, see our ## Tests +Every PR that adds a feature or fixes a bug should include corresponding tests. +All existing and new tests must pass. + Packages `hooks`, `code_assets`, `data_assets`, `hooks_runner`, and `native_toolchain_c` roll into the Dart SDK. The tests of these packages are run on the Dart SDK in [a different diff --git a/README.md b/README.md index a2a9d75199..312c5a8256 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ Packages not on this repo but also related to FFI and native assets. ❤️ | --- | --- | --- | | [native_toolchain_cmake](https://github.com/rainyl/native_toolchain_cmake) | A library to invoke CMake for Dart Native Assets. | [![pub package](https://img.shields.io/pub/v/native_toolchain_cmake.svg)](https://pub.dev/packages/native_toolchain_cmake) | | [native_toolchain_go](https://github.com/csnewman/flutter-go-bridge/tree/master/native_toolchain_go) | A library to invoke the native Go compiler installed on the host machine. | [![pub package](https://img.shields.io/pub/v/native_toolchain_go.svg)](https://pub.dev/packages/native_toolchain_go) | +| [native_toolchain_ninja](https://github.com/knopp/native_toolchain_ninja) | A library to invoke Ninja for Dart Native Assets. | [![pub package](https://img.shields.io/pub/v/native_toolchain_ninja.svg)](https://pub.dev/packages/native_toolchain_ninja) | | [native_toolchain_rust](https://github.com/irondash/native_toolchain_rust) | A library to invoke the native Rust compiler installed on the host machine. | [![pub package](https://img.shields.io/pub/v/native_toolchain_rust.svg)](https://pub.dev/packages/native_toolchain_rust) | | [native_toolchain_rs](https://github.com/GregoryConrad/native_toolchain_rs) | A library to build and bundle Rust code for Dart Native Assets. | [![pub package](https://img.shields.io/pub/v/native_toolchain_rs.svg)](https://pub.dev/packages/native_toolchain_rs) | diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000000..543ecc0012 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml + +formatter: + trailing_commas: preserve diff --git a/pkgs/code_assets/.gitignore b/pkgs/code_assets/.gitignore index 71860a75db..e080e9249e 100644 --- a/pkgs/code_assets/.gitignore +++ b/pkgs/code_assets/.gitignore @@ -1 +1,2 @@ !build +.dart_tool/ diff --git a/pkgs/code_assets/analysis_options.yaml b/pkgs/code_assets/analysis_options.yaml index a366861354..1af54d8810 100644 --- a/pkgs/code_assets/analysis_options.yaml +++ b/pkgs/code_assets/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -14,7 +12,3 @@ linter: - prefer_expression_function_bodies - prefer_final_in_for_each - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/code_assets/example/host_name/pubspec.yaml b/pkgs/code_assets/example/host_name/pubspec.yaml index 2049028aa1..3c97630549 100644 --- a/pkgs/code_assets/example/host_name/pubspec.yaml +++ b/pkgs/code_assets/example/host_name/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/code_assets/example/mini_audio/pubspec.yaml b/pkgs/code_assets/example/mini_audio/pubspec.yaml index 8c058b847c..a37f18bbf3 100644 --- a/pkgs/code_assets/example/mini_audio/pubspec.yaml +++ b/pkgs/code_assets/example/mini_audio/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/code_assets/example/sqlite/pubspec.yaml b/pkgs/code_assets/example/sqlite/pubspec.yaml index 3506825e27..33c36fac0e 100644 --- a/pkgs/code_assets/example/sqlite/pubspec.yaml +++ b/pkgs/code_assets/example/sqlite/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/code_assets/example/sqlite_prebuilt/pubspec.yaml b/pkgs/code_assets/example/sqlite_prebuilt/pubspec.yaml index d75505496e..7d260f41e0 100644 --- a/pkgs/code_assets/example/sqlite_prebuilt/pubspec.yaml +++ b/pkgs/code_assets/example/sqlite_prebuilt/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: archive: ^4.0.7 diff --git a/pkgs/code_assets/example/stb_image/pubspec.yaml b/pkgs/code_assets/example/stb_image/pubspec.yaml index 31ae8aff8a..295bc9e278 100644 --- a/pkgs/code_assets/example/stb_image/pubspec.yaml +++ b/pkgs/code_assets/example/stb_image/pubspec.yaml @@ -13,7 +13,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/code_assets/pubspec.yaml b/pkgs/code_assets/pubspec.yaml index 073baa6dea..e0556b98bf 100644 --- a/pkgs/code_assets/pubspec.yaml +++ b/pkgs/code_assets/pubspec.yaml @@ -17,18 +17,15 @@ topics: resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: collection: ^1.19.1 hooks: ^1.0.0 dev_dependencies: - custom_lint: ^0.7.5 dart_flutter_team_lints: ^3.5.2 json_schema: ^5.2.0 # May only be used in tool/ and test/json_schema/. native_test_helpers: path: ../native_test_helpers/ - repo_lint_rules: - path: ../repo_lint_rules/ test: ^1.25.15 diff --git a/pkgs/data_assets/.gitignore b/pkgs/data_assets/.gitignore index 71860a75db..e080e9249e 100644 --- a/pkgs/data_assets/.gitignore +++ b/pkgs/data_assets/.gitignore @@ -1 +1,2 @@ !build +.dart_tool/ diff --git a/pkgs/data_assets/analysis_options.yaml b/pkgs/data_assets/analysis_options.yaml index c0462a3a77..19ef10adf6 100644 --- a/pkgs/data_assets/analysis_options.yaml +++ b/pkgs/data_assets/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -13,7 +11,3 @@ linter: - prefer_expression_function_bodies - prefer_final_in_for_each - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/data_assets/lib/src/data_assets/data_asset.dart b/pkgs/data_assets/lib/src/data_assets/data_asset.dart index df811b82c8..81a2c01bd1 100644 --- a/pkgs/data_assets/lib/src/data_assets/data_asset.dart +++ b/pkgs/data_assets/lib/src/data_assets/data_asset.dart @@ -13,7 +13,7 @@ import 'syntax.g.dart'; /// asset at runtime, the [id] is used. This enables access to the asset /// irrespective of how and where the application is run. /// -/// An data asset must provide a [DataAsset.file]. The Dart and Flutter SDK will +/// A data asset must provide a [DataAsset.file]. The Dart and Flutter SDK will /// bundle this code in the final application. final class DataAsset { /// The file to be bundled with the Dart or Flutter application. @@ -32,7 +32,7 @@ final class DataAsset { /// The identifier for this data asset. /// - /// An [DataAsset] has a string identifier called "asset id". Dart code that + /// A [DataAsset] has a string identifier called "asset id". Dart code that /// uses an asset references the asset using this asset id. /// /// An asset identifier consists of two elements, the `package` and `name`, diff --git a/pkgs/data_assets/pubspec.yaml b/pkgs/data_assets/pubspec.yaml index 8738386860..589caddd15 100644 --- a/pkgs/data_assets/pubspec.yaml +++ b/pkgs/data_assets/pubspec.yaml @@ -14,17 +14,14 @@ topics: resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: hooks: ^1.0.0 dev_dependencies: - custom_lint: ^0.7.5 dart_flutter_team_lints: ^3.5.2 json_schema: ^5.2.0 # May only be used in tool/ and test/json_schema/. native_test_helpers: path: ../native_test_helpers - repo_lint_rules: - path: ../repo_lint_rules/ test: ^1.25.15 diff --git a/pkgs/ffi/CHANGELOG.md b/pkgs/ffi/CHANGELOG.md index 53b1cac50b..3e86fa40aa 100644 --- a/pkgs/ffi/CHANGELOG.md +++ b/pkgs/ffi/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.0 + +- Export leaked types. + ## 2.1.5 - Update to the latest lints. diff --git a/pkgs/ffi/lib/ffi.dart b/pkgs/ffi/lib/ffi.dart index 159d00e115..bbca354a6c 100644 --- a/pkgs/ffi/lib/ffi.dart +++ b/pkgs/ffi/lib/ffi.dart @@ -2,7 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'src/allocation.dart' show calloc, malloc; +export 'src/allocation.dart' + show CallocAllocator, MallocAllocator, calloc, malloc; export 'src/arena.dart'; export 'src/utf16.dart'; export 'src/utf8.dart'; diff --git a/pkgs/ffi/lib/src/utf8.dart b/pkgs/ffi/lib/src/utf8.dart index d5379d4830..726fbd4c79 100644 --- a/pkgs/ffi/lib/src/utf8.dart +++ b/pkgs/ffi/lib/src/utf8.dart @@ -14,7 +14,7 @@ import '../ffi.dart'; /// the equivalent of a char pointer (`const char*`) in C code. final class Utf8 extends Opaque {} -/// Extension method for converting a`Pointer` to a [String]. +/// Extension method for converting a `Pointer` to a [String]. extension Utf8Pointer on Pointer { /// The number of UTF-8 code units in this zero-terminated UTF-8 string. /// diff --git a/pkgs/ffi/pubspec.yaml b/pkgs/ffi/pubspec.yaml index 15b01ed0a3..8751858c52 100644 --- a/pkgs/ffi/pubspec.yaml +++ b/pkgs/ffi/pubspec.yaml @@ -1,5 +1,5 @@ name: ffi -version: 2.1.5 +version: 2.2.0 description: Utilities for working with Foreign Function Interface (FFI) code. repository: https://github.com/dart-lang/native/tree/main/pkgs/ffi issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Affi @@ -9,8 +9,10 @@ topics: - ffi - codegen +resolution: workspace + environment: - sdk: '>=3.7.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dev_dependencies: dart_flutter_team_lints: ^3.5.2 diff --git a/pkgs/ffi/test/utf8_test.dart b/pkgs/ffi/test/utf8_test.dart index e796df5617..a22cfe2fc0 100644 --- a/pkgs/ffi/test/utf8_test.dart +++ b/pkgs/ffi/test/utf8_test.dart @@ -41,23 +41,22 @@ void main() { }); test('fromUtf8 ASCII', () { - final utf8 = - _bytesFromList([ - 72, - 101, - 108, - 108, - 111, - 32, - 87, - 111, - 114, - 108, - 100, - 33, - 10, - 0, - ]).cast(); + final utf8 = _bytesFromList([ + 72, + 101, + 108, + 108, + 111, + 32, + 87, + 111, + 114, + 108, + 100, + 33, + 10, + 0, + ]).cast(); final end = utf8.toDartString(); expect(end, 'Hello World!\n'); }); @@ -87,22 +86,21 @@ void main() { }); test('formUtf8 emoji', () { - final utf8 = - _bytesFromList([ - 240, - 159, - 152, - 142, - 240, - 159, - 145, - 191, - 240, - 159, - 146, - 172, - 0, - ]).cast(); + final utf8 = _bytesFromList([ + 240, + 159, + 152, + 142, + 240, + 159, + 145, + 191, + 240, + 159, + 146, + 172, + 0, + ]).cast(); final end = utf8.toDartString(); expect(end, '😎👿💬'); }); @@ -113,108 +111,103 @@ void main() { }); test('fromUtf8 ASCII with length', () { - final utf8 = - _bytesFromList([ - 72, - 101, - 108, - 108, - 111, - 32, - 87, - 111, - 114, - 108, - 100, - 33, - 10, - 0, - ]).cast(); + final utf8 = _bytesFromList([ + 72, + 101, + 108, + 108, + 111, + 32, + 87, + 111, + 114, + 108, + 100, + 33, + 10, + 0, + ]).cast(); final end = utf8.toDartString(length: 5); expect(end, 'Hello'); }); test('fromUtf8 emoji with length', () { - final utf8 = - _bytesFromList([ - 240, - 159, - 152, - 142, - 240, - 159, - 145, - 191, - 240, - 159, - 146, - 172, - 0, - ]).cast(); + final utf8 = _bytesFromList([ + 240, + 159, + 152, + 142, + 240, + 159, + 145, + 191, + 240, + 159, + 146, + 172, + 0, + ]).cast(); final end = utf8.toDartString(length: 4); expect(end, '😎'); }); test('fromUtf8 with zero length', () { - final utf8 = - _bytesFromList([ - 72, - 101, - 108, - 108, - 111, - 32, - 87, - 111, - 114, - 108, - 100, - 33, - 10, - 0, - ]).cast(); + final utf8 = _bytesFromList([ + 72, + 101, + 108, + 108, + 111, + 32, + 87, + 111, + 114, + 108, + 100, + 33, + 10, + 0, + ]).cast(); final end = utf8.toDartString(length: 0); expect(end, ''); }); test('fromUtf8 with negative length', () { - final utf8 = - _bytesFromList([ - 72, - 101, - 108, - 108, - 111, - 32, - 87, - 111, - 114, - 108, - 100, - 33, - 10, - 0, - ]).cast(); + final utf8 = _bytesFromList([ + 72, + 101, + 108, + 108, + 111, + 32, + 87, + 111, + 114, + 108, + 100, + 33, + 10, + 0, + ]).cast(); expect(() => utf8.toDartString(length: -1), throwsRangeError); }); test('fromUtf8 with length and containing a zero byte', () { - final utf8 = - _bytesFromList([ - 72, - 101, - 108, - 108, - 111, - 0, - 87, - 111, - 114, - 108, - 100, - 33, - 10, - ]).cast(); + final utf8 = _bytesFromList([ + 72, + 101, + 108, + 108, + 111, + 0, + 87, + 111, + 114, + 108, + 100, + 33, + 10, + ]).cast(); final end = utf8.toDartString(length: 13); expect(end, 'Hello\x00World!\n'); }); diff --git a/pkgs/ffigen/CHANGELOG.md b/pkgs/ffigen/CHANGELOG.md index 1dd7776cb0..c9b6f4e3cf 100644 --- a/pkgs/ffigen/CHANGELOG.md +++ b/pkgs/ffigen/CHANGELOG.md @@ -15,7 +15,19 @@ supports integers, doubles, and string literals. Including the variable name in the globals -> symbol-address configuration will still generate symbol lookups. - +- Fix [a bug](https://github.com/dart-lang/native/issues/2952) where block + helpers were occasionally given unexpected names. Technically a breaking + change because if you were affected by the bug, the block helper's name will + change to something more sensible. +- __Breaking change__: Deleted the config option `Output.sort`. Sorting is now + always enabled. +- Fix(https://github.com/dart-lang/native/issues/2877) + such that ObjCObject `isA` now accepts a nullable `ObjCObject?` and returns + `false` when called with `null`, aligning its behavior with Dart’s `is`operator. +- Use `xcrun` for resolving macOS SDK paths, enabling support for non-standard + Xcode installations. [#3134](https://github.com/dart-lang/native/issues/3134) +- Add allocate constructor for native C structs: + `$allocate(Allocator $allocator, {required ...})` ## 20.1.1 diff --git a/pkgs/ffigen/doc/objc_runtime_types.md b/pkgs/ffigen/doc/objc_runtime_types.md index e760e0629b..1640735cc0 100644 --- a/pkgs/ffigen/doc/objc_runtime_types.md +++ b/pkgs/ffigen/doc/objc_runtime_types.md @@ -26,15 +26,22 @@ Just like in the pure Dart case, the Dart static type determines what methods are allowed to be invoked, but now the method implementation that is actually invoked at run time is determined by the *Objective-C* runtime type. In fact, the Dart runtime type is -completely irrelevant when doing Objective-C interop. +completely irrelevant when doing Objective-C interop. Moreover, the +Dart wrapper around the Objective-C object is an [extension type]( +https://dart.dev/language/extension-types#type-considerations), +which means the Dart runtime type will always be [`ObjCObject`]( +https://pub.dev/documentation/objective_c/latest/objective_c/ObjCObject-class.html). Dart's `is` keyword checks the Dart runtime type. You shouldn't use -this on Objective-C objects, because the Dart runtime type is irrelevant, and -often won't match the Objective-C runtime type. Instead of `x is Foo`, -use `Foo.isA(x)`. +this on Objective-C objects, because the Dart runtime type is always +`ObjCObject`. If `Foo` and `Bar` are unrelated `ObjCObject`s, and `x` +a `Foo`, then `x is Bar` will be true, making these checks useless and +misleading. Instead of `x is Foo`, use `Foo.isA(x)`, which calls into +Objective-C to check the runtime type of the underlying object. Dart's `as` keyword changes the static type of an object (and also -checks its runtime type). You shouldn't use this on Objective-C objects, -because the runtime type check may fail since the Dart runtime -type often won't match the Objective-C runtime type. Instead of `x as Foo`, -use `Foo.as(x)`. +checks its runtime type). Since the Objective-C wrapper objects are +extension types, this works, but is unsafe. The implicit `is` check +that `as` performs is useless, for the reasons mentioned above. +Instead of `x as Foo`, use `Foo.as(x)`, which internally checks +`Foo.isA(x)`. diff --git a/pkgs/ffigen/example/c_json/cjson_generated_bindings.dart b/pkgs/ffigen/example/c_json/cjson_generated_bindings.dart index d5f80e1da4..95819bda82 100644 --- a/pkgs/ffigen/example/c_json/cjson_generated_bindings.dart +++ b/pkgs/ffigen/example/c_json/cjson_generated_bindings.dart @@ -38,362 +38,427 @@ class CJson { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - ffi.Pointer cJSON_Version() { - return _cJSON_Version(); - } - - late final _cJSON_VersionPtr = - _lookup Function()>>( - 'cJSON_Version', - ); - late final _cJSON_Version = _cJSON_VersionPtr - .asFunction Function()>(); - - void cJSON_InitHooks(ffi.Pointer hooks) { - return _cJSON_InitHooks(hooks); - } - - late final _cJSON_InitHooksPtr = - _lookup)>>( - 'cJSON_InitHooks', - ); - late final _cJSON_InitHooks = _cJSON_InitHooksPtr - .asFunction)>(); - - ffi.Pointer cJSON_Parse(ffi.Pointer value) { - return _cJSON_Parse(value); + ffi.Pointer cJSON_AddArrayToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddArrayToObject(object, name); } - late final _cJSON_ParsePtr = + late final _cJSON_AddArrayToObjectPtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_Parse'); - late final _cJSON_Parse = _cJSON_ParsePtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddArrayToObject'); + late final _cJSON_AddArrayToObject = _cJSON_AddArrayToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - ffi.Pointer cJSON_ParseWithOpts( - ffi.Pointer value, - ffi.Pointer> return_parse_end, - int require_null_terminated, + ffi.Pointer cJSON_AddBoolToObject( + ffi.Pointer object, + ffi.Pointer name, + int boolean, ) { - return _cJSON_ParseWithOpts( - value, - return_parse_end, - require_null_terminated, - ); + return _cJSON_AddBoolToObject(object, name, boolean); } - late final _cJSON_ParseWithOptsPtr = + late final _cJSON_AddBoolToObjectPtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer>, cJSON_bool, ) > - >('cJSON_ParseWithOpts'); - late final _cJSON_ParseWithOpts = _cJSON_ParseWithOptsPtr + >('cJSON_AddBoolToObject'); + late final _cJSON_AddBoolToObject = _cJSON_AddBoolToObjectPtr .asFunction< ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer>, int, ) >(); - ffi.Pointer cJSON_Print(ffi.Pointer item) { - return _cJSON_Print(item); - } - - late final _cJSON_PrintPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_Print'); - late final _cJSON_Print = _cJSON_PrintPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_PrintUnformatted(ffi.Pointer item) { - return _cJSON_PrintUnformatted(item); + ffi.Pointer cJSON_AddFalseToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddFalseToObject(object, name); } - late final _cJSON_PrintUnformattedPtr = + late final _cJSON_AddFalseToObjectPtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_PrintUnformatted'); - late final _cJSON_PrintUnformatted = _cJSON_PrintUnformattedPtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddFalseToObject'); + late final _cJSON_AddFalseToObject = _cJSON_AddFalseToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - ffi.Pointer cJSON_PrintBuffered( + void cJSON_AddItemReferenceToArray( + ffi.Pointer array, ffi.Pointer item, - int prebuffer, - int fmt, ) { - return _cJSON_PrintBuffered(item, prebuffer, fmt); + return _cJSON_AddItemReferenceToArray(array, item); } - late final _cJSON_PrintBufferedPtr = + late final _cJSON_AddItemReferenceToArrayPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, - cJSON_bool, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_PrintBuffered'); - late final _cJSON_PrintBuffered = _cJSON_PrintBufferedPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); + >('cJSON_AddItemReferenceToArray'); + late final _cJSON_AddItemReferenceToArray = _cJSON_AddItemReferenceToArrayPtr + .asFunction, ffi.Pointer)>(); - int cJSON_PrintPreallocated( + void cJSON_AddItemReferenceToObject( + ffi.Pointer object, + ffi.Pointer string, ffi.Pointer item, - ffi.Pointer buffer, - int length, - int format, ) { - return _cJSON_PrintPreallocated(item, buffer, length, format); + return _cJSON_AddItemReferenceToObject(object, string, item); } - late final _cJSON_PrintPreallocatedPtr = + late final _cJSON_AddItemReferenceToObjectPtr = _lookup< ffi.NativeFunction< - cJSON_bool Function( + ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Int, - cJSON_bool, + ffi.Pointer, ) > - >('cJSON_PrintPreallocated'); - late final _cJSON_PrintPreallocated = _cJSON_PrintPreallocatedPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, int) - >(); - - void cJSON_Delete(ffi.Pointer item) { - return _cJSON_Delete(item); - } - - late final _cJSON_DeletePtr = - _lookup)>>( - 'cJSON_Delete', - ); - late final _cJSON_Delete = _cJSON_DeletePtr - .asFunction)>(); - - int cJSON_GetArraySize(ffi.Pointer array) { - return _cJSON_GetArraySize(array); - } - - late final _cJSON_GetArraySizePtr = - _lookup)>>( - 'cJSON_GetArraySize', - ); - late final _cJSON_GetArraySize = _cJSON_GetArraySizePtr - .asFunction)>(); + >('cJSON_AddItemReferenceToObject'); + late final _cJSON_AddItemReferenceToObject = + _cJSON_AddItemReferenceToObjectPtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - ffi.Pointer cJSON_GetArrayItem(ffi.Pointer array, int index) { - return _cJSON_GetArrayItem(array, index); + void cJSON_AddItemToArray(ffi.Pointer array, ffi.Pointer item) { + return _cJSON_AddItemToArray(array, item); } - late final _cJSON_GetArrayItemPtr = + late final _cJSON_AddItemToArrayPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_GetArrayItem'); - late final _cJSON_GetArrayItem = _cJSON_GetArrayItemPtr - .asFunction Function(ffi.Pointer, int)>(); + >('cJSON_AddItemToArray'); + late final _cJSON_AddItemToArray = _cJSON_AddItemToArrayPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer cJSON_GetObjectItem( + void cJSON_AddItemToObject( ffi.Pointer object, ffi.Pointer string, + ffi.Pointer item, ) { - return _cJSON_GetObjectItem(object, string); + return _cJSON_AddItemToObject(object, string, item); } - late final _cJSON_GetObjectItemPtr = + late final _cJSON_AddItemToObjectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_GetObjectItem'); - late final _cJSON_GetObjectItem = _cJSON_GetObjectItemPtr + >('cJSON_AddItemToObject'); + late final _cJSON_AddItemToObject = _cJSON_AddItemToObjectPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >(); - ffi.Pointer cJSON_GetObjectItemCaseSensitive( + void cJSON_AddItemToObjectCS( ffi.Pointer object, ffi.Pointer string, + ffi.Pointer item, ) { - return _cJSON_GetObjectItemCaseSensitive(object, string); + return _cJSON_AddItemToObjectCS(object, string, item); } - late final _cJSON_GetObjectItemCaseSensitivePtr = + late final _cJSON_AddItemToObjectCSPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_GetObjectItemCaseSensitive'); - late final _cJSON_GetObjectItemCaseSensitive = - _cJSON_GetObjectItemCaseSensitivePtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('cJSON_AddItemToObjectCS'); + late final _cJSON_AddItemToObjectCS = _cJSON_AddItemToObjectCSPtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int cJSON_HasObjectItem( + ffi.Pointer cJSON_AddNullToObject( ffi.Pointer object, - ffi.Pointer string, + ffi.Pointer name, ) { - return _cJSON_HasObjectItem(object, string); + return _cJSON_AddNullToObject(object, name); } - late final _cJSON_HasObjectItemPtr = + late final _cJSON_AddNullToObjectPtr = _lookup< ffi.NativeFunction< - cJSON_bool Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_HasObjectItem'); - late final _cJSON_HasObjectItem = _cJSON_HasObjectItemPtr - .asFunction, ffi.Pointer)>(); + >('cJSON_AddNullToObject'); + late final _cJSON_AddNullToObject = _cJSON_AddNullToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - ffi.Pointer cJSON_GetErrorPtr() { - return _cJSON_GetErrorPtr(); + ffi.Pointer cJSON_AddNumberToObject( + ffi.Pointer object, + ffi.Pointer name, + double number, + ) { + return _cJSON_AddNumberToObject(object, name, number); } - late final _cJSON_GetErrorPtrPtr = - _lookup Function()>>( - 'cJSON_GetErrorPtr', - ); - late final _cJSON_GetErrorPtr = _cJSON_GetErrorPtrPtr - .asFunction Function()>(); + late final _cJSON_AddNumberToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Double, + ) + > + >('cJSON_AddNumberToObject'); + late final _cJSON_AddNumberToObject = _cJSON_AddNumberToObjectPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + double, + ) + >(); - ffi.Pointer cJSON_GetStringValue(ffi.Pointer item) { - return _cJSON_GetStringValue(item); + ffi.Pointer cJSON_AddObjectToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddObjectToObject(object, name); } - late final _cJSON_GetStringValuePtr = + late final _cJSON_AddObjectToObjectPtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_GetStringValue'); - late final _cJSON_GetStringValue = _cJSON_GetStringValuePtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddObjectToObject'); + late final _cJSON_AddObjectToObject = _cJSON_AddObjectToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - int cJSON_IsInvalid(ffi.Pointer item) { - return _cJSON_IsInvalid(item); + ffi.Pointer cJSON_AddRawToObject( + ffi.Pointer object, + ffi.Pointer name, + ffi.Pointer raw, + ) { + return _cJSON_AddRawToObject(object, name, raw); } - late final _cJSON_IsInvalidPtr = - _lookup)>>( - 'cJSON_IsInvalid', - ); - late final _cJSON_IsInvalid = _cJSON_IsInvalidPtr - .asFunction)>(); + late final _cJSON_AddRawToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('cJSON_AddRawToObject'); + late final _cJSON_AddRawToObject = _cJSON_AddRawToObjectPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int cJSON_IsFalse(ffi.Pointer item) { - return _cJSON_IsFalse(item); + ffi.Pointer cJSON_AddStringToObject( + ffi.Pointer object, + ffi.Pointer name, + ffi.Pointer string, + ) { + return _cJSON_AddStringToObject(object, name, string); } - late final _cJSON_IsFalsePtr = - _lookup)>>( - 'cJSON_IsFalse', - ); - late final _cJSON_IsFalse = _cJSON_IsFalsePtr - .asFunction)>(); + late final _cJSON_AddStringToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('cJSON_AddStringToObject'); + late final _cJSON_AddStringToObject = _cJSON_AddStringToObjectPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int cJSON_IsTrue(ffi.Pointer item) { - return _cJSON_IsTrue(item); + ffi.Pointer cJSON_AddTrueToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddTrueToObject(object, name); } - late final _cJSON_IsTruePtr = - _lookup)>>( - 'cJSON_IsTrue', - ); - late final _cJSON_IsTrue = _cJSON_IsTruePtr - .asFunction)>(); + late final _cJSON_AddTrueToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddTrueToObject'); + late final _cJSON_AddTrueToObject = _cJSON_AddTrueToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - int cJSON_IsBool(ffi.Pointer item) { - return _cJSON_IsBool(item); + int cJSON_Compare( + ffi.Pointer a, + ffi.Pointer b, + int case_sensitive, + ) { + return _cJSON_Compare(a, b, case_sensitive); } - late final _cJSON_IsBoolPtr = - _lookup)>>( - 'cJSON_IsBool', - ); - late final _cJSON_IsBool = _cJSON_IsBoolPtr - .asFunction)>(); + late final _cJSON_ComparePtr = + _lookup< + ffi.NativeFunction< + cJSON_bool Function( + ffi.Pointer, + ffi.Pointer, + cJSON_bool, + ) + > + >('cJSON_Compare'); + late final _cJSON_Compare = _cJSON_ComparePtr + .asFunction, ffi.Pointer, int)>(); - int cJSON_IsNull(ffi.Pointer item) { - return _cJSON_IsNull(item); + ffi.Pointer cJSON_CreateArray() { + return _cJSON_CreateArray(); } - late final _cJSON_IsNullPtr = - _lookup)>>( - 'cJSON_IsNull', + late final _cJSON_CreateArrayPtr = + _lookup Function()>>( + 'cJSON_CreateArray', ); - late final _cJSON_IsNull = _cJSON_IsNullPtr - .asFunction)>(); + late final _cJSON_CreateArray = _cJSON_CreateArrayPtr + .asFunction Function()>(); - int cJSON_IsNumber(ffi.Pointer item) { - return _cJSON_IsNumber(item); + ffi.Pointer cJSON_CreateArrayReference(ffi.Pointer child) { + return _cJSON_CreateArrayReference(child); } - late final _cJSON_IsNumberPtr = - _lookup)>>( - 'cJSON_IsNumber', - ); - late final _cJSON_IsNumber = _cJSON_IsNumberPtr - .asFunction)>(); + late final _cJSON_CreateArrayReferencePtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateArrayReference'); + late final _cJSON_CreateArrayReference = _cJSON_CreateArrayReferencePtr + .asFunction Function(ffi.Pointer)>(); - int cJSON_IsString(ffi.Pointer item) { - return _cJSON_IsString(item); + ffi.Pointer cJSON_CreateBool(int boolean) { + return _cJSON_CreateBool(boolean); } - late final _cJSON_IsStringPtr = - _lookup)>>( - 'cJSON_IsString', + late final _cJSON_CreateBoolPtr = + _lookup Function(cJSON_bool)>>( + 'cJSON_CreateBool', ); - late final _cJSON_IsString = _cJSON_IsStringPtr - .asFunction)>(); + late final _cJSON_CreateBool = _cJSON_CreateBoolPtr + .asFunction Function(int)>(); - int cJSON_IsArray(ffi.Pointer item) { - return _cJSON_IsArray(item); + ffi.Pointer cJSON_CreateDoubleArray( + ffi.Pointer numbers, + int count, + ) { + return _cJSON_CreateDoubleArray(numbers, count); } - late final _cJSON_IsArrayPtr = - _lookup)>>( - 'cJSON_IsArray', - ); - late final _cJSON_IsArray = _cJSON_IsArrayPtr - .asFunction)>(); + late final _cJSON_CreateDoubleArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('cJSON_CreateDoubleArray'); + late final _cJSON_CreateDoubleArray = _cJSON_CreateDoubleArrayPtr + .asFunction Function(ffi.Pointer, int)>(); - int cJSON_IsObject(ffi.Pointer item) { - return _cJSON_IsObject(item); + ffi.Pointer cJSON_CreateFalse() { + return _cJSON_CreateFalse(); } - late final _cJSON_IsObjectPtr = - _lookup)>>( - 'cJSON_IsObject', + late final _cJSON_CreateFalsePtr = + _lookup Function()>>( + 'cJSON_CreateFalse', ); - late final _cJSON_IsObject = _cJSON_IsObjectPtr - .asFunction)>(); + late final _cJSON_CreateFalse = _cJSON_CreateFalsePtr + .asFunction Function()>(); - int cJSON_IsRaw(ffi.Pointer item) { - return _cJSON_IsRaw(item); + ffi.Pointer cJSON_CreateFloatArray( + ffi.Pointer numbers, + int count, + ) { + return _cJSON_CreateFloatArray(numbers, count); } - late final _cJSON_IsRawPtr = - _lookup)>>( - 'cJSON_IsRaw', - ); - late final _cJSON_IsRaw = _cJSON_IsRawPtr - .asFunction)>(); + late final _cJSON_CreateFloatArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('cJSON_CreateFloatArray'); + late final _cJSON_CreateFloatArray = _cJSON_CreateFloatArrayPtr + .asFunction Function(ffi.Pointer, int)>(); + + ffi.Pointer cJSON_CreateIntArray( + ffi.Pointer numbers, + int count, + ) { + return _cJSON_CreateIntArray(numbers, count); + } + + late final _cJSON_CreateIntArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('cJSON_CreateIntArray'); + late final _cJSON_CreateIntArray = _cJSON_CreateIntArrayPtr + .asFunction Function(ffi.Pointer, int)>(); ffi.Pointer cJSON_CreateNull() { return _cJSON_CreateNull(); @@ -406,39 +471,6 @@ class CJson { late final _cJSON_CreateNull = _cJSON_CreateNullPtr .asFunction Function()>(); - ffi.Pointer cJSON_CreateTrue() { - return _cJSON_CreateTrue(); - } - - late final _cJSON_CreateTruePtr = - _lookup Function()>>( - 'cJSON_CreateTrue', - ); - late final _cJSON_CreateTrue = _cJSON_CreateTruePtr - .asFunction Function()>(); - - ffi.Pointer cJSON_CreateFalse() { - return _cJSON_CreateFalse(); - } - - late final _cJSON_CreateFalsePtr = - _lookup Function()>>( - 'cJSON_CreateFalse', - ); - late final _cJSON_CreateFalse = _cJSON_CreateFalsePtr - .asFunction Function()>(); - - ffi.Pointer cJSON_CreateBool(int boolean) { - return _cJSON_CreateBool(boolean); - } - - late final _cJSON_CreateBoolPtr = - _lookup Function(cJSON_bool)>>( - 'cJSON_CreateBool', - ); - late final _cJSON_CreateBool = _cJSON_CreateBoolPtr - .asFunction Function(int)>(); - ffi.Pointer cJSON_CreateNumber(double num) { return _cJSON_CreateNumber(num); } @@ -450,39 +482,6 @@ class CJson { late final _cJSON_CreateNumber = _cJSON_CreateNumberPtr .asFunction Function(double)>(); - ffi.Pointer cJSON_CreateString(ffi.Pointer string) { - return _cJSON_CreateString(string); - } - - late final _cJSON_CreateStringPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateString'); - late final _cJSON_CreateString = _cJSON_CreateStringPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_CreateRaw(ffi.Pointer raw) { - return _cJSON_CreateRaw(raw); - } - - late final _cJSON_CreateRawPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateRaw'); - late final _cJSON_CreateRaw = _cJSON_CreateRawPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_CreateArray() { - return _cJSON_CreateArray(); - } - - late final _cJSON_CreateArrayPtr = - _lookup Function()>>( - 'cJSON_CreateArray', - ); - late final _cJSON_CreateArray = _cJSON_CreateArrayPtr - .asFunction Function()>(); - ffi.Pointer cJSON_CreateObject() { return _cJSON_CreateObject(); } @@ -494,17 +493,6 @@ class CJson { late final _cJSON_CreateObject = _cJSON_CreateObjectPtr .asFunction Function()>(); - ffi.Pointer cJSON_CreateStringReference(ffi.Pointer string) { - return _cJSON_CreateStringReference(string); - } - - late final _cJSON_CreateStringReferencePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateStringReference'); - late final _cJSON_CreateStringReference = _cJSON_CreateStringReferencePtr - .asFunction Function(ffi.Pointer)>(); - ffi.Pointer cJSON_CreateObjectReference(ffi.Pointer child) { return _cJSON_CreateObjectReference(child); } @@ -516,64 +504,27 @@ class CJson { late final _cJSON_CreateObjectReference = _cJSON_CreateObjectReferencePtr .asFunction Function(ffi.Pointer)>(); - ffi.Pointer cJSON_CreateArrayReference(ffi.Pointer child) { - return _cJSON_CreateArrayReference(child); - } - - late final _cJSON_CreateArrayReferencePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateArrayReference'); - late final _cJSON_CreateArrayReference = _cJSON_CreateArrayReferencePtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_CreateIntArray( - ffi.Pointer numbers, - int count, - ) { - return _cJSON_CreateIntArray(numbers, count); - } - - late final _cJSON_CreateIntArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('cJSON_CreateIntArray'); - late final _cJSON_CreateIntArray = _cJSON_CreateIntArrayPtr - .asFunction Function(ffi.Pointer, int)>(); - - ffi.Pointer cJSON_CreateFloatArray( - ffi.Pointer numbers, - int count, - ) { - return _cJSON_CreateFloatArray(numbers, count); + ffi.Pointer cJSON_CreateRaw(ffi.Pointer raw) { + return _cJSON_CreateRaw(raw); } - late final _cJSON_CreateFloatArrayPtr = + late final _cJSON_CreateRawPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('cJSON_CreateFloatArray'); - late final _cJSON_CreateFloatArray = _cJSON_CreateFloatArrayPtr - .asFunction Function(ffi.Pointer, int)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateRaw'); + late final _cJSON_CreateRaw = _cJSON_CreateRawPtr + .asFunction Function(ffi.Pointer)>(); - ffi.Pointer cJSON_CreateDoubleArray( - ffi.Pointer numbers, - int count, - ) { - return _cJSON_CreateDoubleArray(numbers, count); + ffi.Pointer cJSON_CreateString(ffi.Pointer string) { + return _cJSON_CreateString(string); } - late final _cJSON_CreateDoubleArrayPtr = + late final _cJSON_CreateStringPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('cJSON_CreateDoubleArray'); - late final _cJSON_CreateDoubleArray = _cJSON_CreateDoubleArrayPtr - .asFunction Function(ffi.Pointer, int)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateString'); + late final _cJSON_CreateString = _cJSON_CreateStringPtr + .asFunction Function(ffi.Pointer)>(); ffi.Pointer cJSON_CreateStringArray( ffi.Pointer> strings, @@ -584,146 +535,96 @@ class CJson { late final _cJSON_CreateStringArrayPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer>, - ffi.Int, - ) - > - >('cJSON_CreateStringArray'); - late final _cJSON_CreateStringArray = _cJSON_CreateStringArrayPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer>, int) - >(); - - void cJSON_AddItemToArray(ffi.Pointer array, ffi.Pointer item) { - return _cJSON_AddItemToArray(array, item); - } - - late final _cJSON_AddItemToArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddItemToArray'); - late final _cJSON_AddItemToArray = _cJSON_AddItemToArrayPtr - .asFunction, ffi.Pointer)>(); - - void cJSON_AddItemToObject( - ffi.Pointer object, - ffi.Pointer string, - ffi.Pointer item, - ) { - return _cJSON_AddItemToObject(object, string, item); - } - - late final _cJSON_AddItemToObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('cJSON_AddItemToObject'); - late final _cJSON_AddItemToObject = _cJSON_AddItemToObjectPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void cJSON_AddItemToObjectCS( - ffi.Pointer object, - ffi.Pointer string, - ffi.Pointer item, - ) { - return _cJSON_AddItemToObjectCS(object, string, item); - } - - late final _cJSON_AddItemToObjectCSPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer>, + ffi.Int, ) > - >('cJSON_AddItemToObjectCS'); - late final _cJSON_AddItemToObjectCS = _cJSON_AddItemToObjectCSPtr + >('cJSON_CreateStringArray'); + late final _cJSON_CreateStringArray = _cJSON_CreateStringArrayPtr .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer>, int) >(); - void cJSON_AddItemReferenceToArray( - ffi.Pointer array, - ffi.Pointer item, - ) { - return _cJSON_AddItemReferenceToArray(array, item); + ffi.Pointer cJSON_CreateStringReference(ffi.Pointer string) { + return _cJSON_CreateStringReference(string); } - late final _cJSON_AddItemReferenceToArrayPtr = + late final _cJSON_CreateStringReferencePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddItemReferenceToArray'); - late final _cJSON_AddItemReferenceToArray = _cJSON_AddItemReferenceToArrayPtr - .asFunction, ffi.Pointer)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateStringReference'); + late final _cJSON_CreateStringReference = _cJSON_CreateStringReferencePtr + .asFunction Function(ffi.Pointer)>(); - void cJSON_AddItemReferenceToObject( + ffi.Pointer cJSON_CreateTrue() { + return _cJSON_CreateTrue(); + } + + late final _cJSON_CreateTruePtr = + _lookup Function()>>( + 'cJSON_CreateTrue', + ); + late final _cJSON_CreateTrue = _cJSON_CreateTruePtr + .asFunction Function()>(); + + void cJSON_Delete(ffi.Pointer item) { + return _cJSON_Delete(item); + } + + late final _cJSON_DeletePtr = + _lookup)>>( + 'cJSON_Delete', + ); + late final _cJSON_Delete = _cJSON_DeletePtr + .asFunction)>(); + + void cJSON_DeleteItemFromArray(ffi.Pointer array, int which) { + return _cJSON_DeleteItemFromArray(array, which); + } + + late final _cJSON_DeleteItemFromArrayPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('cJSON_DeleteItemFromArray'); + late final _cJSON_DeleteItemFromArray = _cJSON_DeleteItemFromArrayPtr + .asFunction, int)>(); + + void cJSON_DeleteItemFromObject( ffi.Pointer object, ffi.Pointer string, - ffi.Pointer item, ) { - return _cJSON_AddItemReferenceToObject(object, string, item); + return _cJSON_DeleteItemFromObject(object, string); } - late final _cJSON_AddItemReferenceToObjectPtr = + late final _cJSON_DeleteItemFromObjectPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_AddItemReferenceToObject'); - late final _cJSON_AddItemReferenceToObject = - _cJSON_AddItemReferenceToObjectPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('cJSON_DeleteItemFromObject'); + late final _cJSON_DeleteItemFromObject = _cJSON_DeleteItemFromObjectPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer cJSON_DetachItemViaPointer( - ffi.Pointer parent, - ffi.Pointer item, + void cJSON_DeleteItemFromObjectCaseSensitive( + ffi.Pointer object, + ffi.Pointer string, ) { - return _cJSON_DetachItemViaPointer(parent, item); + return _cJSON_DeleteItemFromObjectCaseSensitive(object, string); } - late final _cJSON_DetachItemViaPointerPtr = + late final _cJSON_DeleteItemFromObjectCaseSensitivePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_DetachItemViaPointer'); - late final _cJSON_DetachItemViaPointer = _cJSON_DetachItemViaPointerPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_DeleteItemFromObjectCaseSensitive'); + late final _cJSON_DeleteItemFromObjectCaseSensitive = + _cJSON_DeleteItemFromObjectCaseSensitivePtr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >(); ffi.Pointer cJSON_DetachItemFromArray( ffi.Pointer array, @@ -741,17 +642,6 @@ class CJson { late final _cJSON_DetachItemFromArray = _cJSON_DetachItemFromArrayPtr .asFunction Function(ffi.Pointer, int)>(); - void cJSON_DeleteItemFromArray(ffi.Pointer array, int which) { - return _cJSON_DeleteItemFromArray(array, which); - } - - late final _cJSON_DeleteItemFromArrayPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('cJSON_DeleteItemFromArray'); - late final _cJSON_DeleteItemFromArray = _cJSON_DeleteItemFromArrayPtr - .asFunction, int)>(); - ffi.Pointer cJSON_DetachItemFromObject( ffi.Pointer object, ffi.Pointer string, @@ -792,394 +682,493 @@ class CJson { ) >(); - void cJSON_DeleteItemFromObject( - ffi.Pointer object, - ffi.Pointer string, + ffi.Pointer cJSON_DetachItemViaPointer( + ffi.Pointer parent, + ffi.Pointer item, ) { - return _cJSON_DeleteItemFromObject(object, string); + return _cJSON_DetachItemViaPointer(parent, item); } - late final _cJSON_DeleteItemFromObjectPtr = + late final _cJSON_DetachItemViaPointerPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_DeleteItemFromObject'); - late final _cJSON_DeleteItemFromObject = _cJSON_DeleteItemFromObjectPtr - .asFunction, ffi.Pointer)>(); + >('cJSON_DetachItemViaPointer'); + late final _cJSON_DetachItemViaPointer = _cJSON_DetachItemViaPointerPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - void cJSON_DeleteItemFromObjectCaseSensitive( - ffi.Pointer object, - ffi.Pointer string, - ) { - return _cJSON_DeleteItemFromObjectCaseSensitive(object, string); + ffi.Pointer cJSON_Duplicate(ffi.Pointer item, int recurse) { + return _cJSON_Duplicate(item, recurse); } - late final _cJSON_DeleteItemFromObjectCaseSensitivePtr = + late final _cJSON_DuplicatePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, cJSON_bool) > - >('cJSON_DeleteItemFromObjectCaseSensitive'); - late final _cJSON_DeleteItemFromObjectCaseSensitive = - _cJSON_DeleteItemFromObjectCaseSensitivePtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_Duplicate'); + late final _cJSON_Duplicate = _cJSON_DuplicatePtr + .asFunction Function(ffi.Pointer, int)>(); - void cJSON_InsertItemInArray( - ffi.Pointer array, - int which, - ffi.Pointer newitem, - ) { - return _cJSON_InsertItemInArray(array, which, newitem); + ffi.Pointer cJSON_GetArrayItem(ffi.Pointer array, int index) { + return _cJSON_GetArrayItem(array, index); } - late final _cJSON_InsertItemInArrayPtr = + late final _cJSON_GetArrayItemPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('cJSON_InsertItemInArray'); - late final _cJSON_InsertItemInArray = _cJSON_InsertItemInArrayPtr - .asFunction, int, ffi.Pointer)>(); + >('cJSON_GetArrayItem'); + late final _cJSON_GetArrayItem = _cJSON_GetArrayItemPtr + .asFunction Function(ffi.Pointer, int)>(); - int cJSON_ReplaceItemViaPointer( - ffi.Pointer parent, - ffi.Pointer item, - ffi.Pointer replacement, - ) { - return _cJSON_ReplaceItemViaPointer(parent, item, replacement); + int cJSON_GetArraySize(ffi.Pointer array) { + return _cJSON_GetArraySize(array); } - late final _cJSON_ReplaceItemViaPointerPtr = - _lookup< - ffi.NativeFunction< - cJSON_bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('cJSON_ReplaceItemViaPointer'); - late final _cJSON_ReplaceItemViaPointer = _cJSON_ReplaceItemViaPointerPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer) - >(); + late final _cJSON_GetArraySizePtr = + _lookup)>>( + 'cJSON_GetArraySize', + ); + late final _cJSON_GetArraySize = _cJSON_GetArraySizePtr + .asFunction)>(); - void cJSON_ReplaceItemInArray( - ffi.Pointer array, - int which, - ffi.Pointer newitem, - ) { - return _cJSON_ReplaceItemInArray(array, which, newitem); + ffi.Pointer cJSON_GetErrorPtr() { + return _cJSON_GetErrorPtr(); } - late final _cJSON_ReplaceItemInArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) - > - >('cJSON_ReplaceItemInArray'); - late final _cJSON_ReplaceItemInArray = _cJSON_ReplaceItemInArrayPtr - .asFunction, int, ffi.Pointer)>(); + late final _cJSON_GetErrorPtrPtr = + _lookup Function()>>( + 'cJSON_GetErrorPtr', + ); + late final _cJSON_GetErrorPtr = _cJSON_GetErrorPtrPtr + .asFunction Function()>(); - void cJSON_ReplaceItemInObject( + ffi.Pointer cJSON_GetObjectItem( ffi.Pointer object, ffi.Pointer string, - ffi.Pointer newitem, ) { - return _cJSON_ReplaceItemInObject(object, string, newitem); + return _cJSON_GetObjectItem(object, string); } - late final _cJSON_ReplaceItemInObjectPtr = + late final _cJSON_GetObjectItemPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_ReplaceItemInObject'); - late final _cJSON_ReplaceItemInObject = _cJSON_ReplaceItemInObjectPtr + >('cJSON_GetObjectItem'); + late final _cJSON_GetObjectItem = _cJSON_GetObjectItemPtr .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) >(); - void cJSON_ReplaceItemInObjectCaseSensitive( + ffi.Pointer cJSON_GetObjectItemCaseSensitive( ffi.Pointer object, ffi.Pointer string, - ffi.Pointer newitem, ) { - return _cJSON_ReplaceItemInObjectCaseSensitive(object, string, newitem); + return _cJSON_GetObjectItemCaseSensitive(object, string); } - late final _cJSON_ReplaceItemInObjectCaseSensitivePtr = + late final _cJSON_GetObjectItemCaseSensitivePtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_ReplaceItemInObjectCaseSensitive'); - late final _cJSON_ReplaceItemInObjectCaseSensitive = - _cJSON_ReplaceItemInObjectCaseSensitivePtr + >('cJSON_GetObjectItemCaseSensitive'); + late final _cJSON_GetObjectItemCaseSensitive = + _cJSON_GetObjectItemCaseSensitivePtr .asFunction< - void Function( + ffi.Pointer Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, ) >(); - ffi.Pointer cJSON_Duplicate(ffi.Pointer item, int recurse) { - return _cJSON_Duplicate(item, recurse); + ffi.Pointer cJSON_GetStringValue(ffi.Pointer item) { + return _cJSON_GetStringValue(item); } - late final _cJSON_DuplicatePtr = + late final _cJSON_GetStringValuePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, cJSON_bool) - > - >('cJSON_Duplicate'); - late final _cJSON_Duplicate = _cJSON_DuplicatePtr - .asFunction Function(ffi.Pointer, int)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_GetStringValue'); + late final _cJSON_GetStringValue = _cJSON_GetStringValuePtr + .asFunction Function(ffi.Pointer)>(); - int cJSON_Compare( - ffi.Pointer a, - ffi.Pointer b, - int case_sensitive, + int cJSON_HasObjectItem( + ffi.Pointer object, + ffi.Pointer string, ) { - return _cJSON_Compare(a, b, case_sensitive); + return _cJSON_HasObjectItem(object, string); } - late final _cJSON_ComparePtr = + late final _cJSON_HasObjectItemPtr = _lookup< ffi.NativeFunction< - cJSON_bool Function( - ffi.Pointer, - ffi.Pointer, - cJSON_bool, - ) + cJSON_bool Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_Compare'); - late final _cJSON_Compare = _cJSON_ComparePtr - .asFunction, ffi.Pointer, int)>(); + >('cJSON_HasObjectItem'); + late final _cJSON_HasObjectItem = _cJSON_HasObjectItemPtr + .asFunction, ffi.Pointer)>(); - void cJSON_Minify(ffi.Pointer json) { - return _cJSON_Minify(json); + void cJSON_InitHooks(ffi.Pointer hooks) { + return _cJSON_InitHooks(hooks); } - late final _cJSON_MinifyPtr = - _lookup)>>( - 'cJSON_Minify', + late final _cJSON_InitHooksPtr = + _lookup)>>( + 'cJSON_InitHooks', ); - late final _cJSON_Minify = _cJSON_MinifyPtr - .asFunction)>(); + late final _cJSON_InitHooks = _cJSON_InitHooksPtr + .asFunction)>(); - ffi.Pointer cJSON_AddNullToObject( - ffi.Pointer object, - ffi.Pointer name, + void cJSON_InsertItemInArray( + ffi.Pointer array, + int which, + ffi.Pointer newitem, ) { - return _cJSON_AddNullToObject(object, name); + return _cJSON_InsertItemInArray(array, which, newitem); } - late final _cJSON_AddNullToObjectPtr = + late final _cJSON_InsertItemInArrayPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) > - >('cJSON_AddNullToObject'); - late final _cJSON_AddNullToObject = _cJSON_AddNullToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_InsertItemInArray'); + late final _cJSON_InsertItemInArray = _cJSON_InsertItemInArrayPtr + .asFunction, int, ffi.Pointer)>(); - ffi.Pointer cJSON_AddTrueToObject( - ffi.Pointer object, - ffi.Pointer name, - ) { - return _cJSON_AddTrueToObject(object, name); + int cJSON_IsArray(ffi.Pointer item) { + return _cJSON_IsArray(item); } - late final _cJSON_AddTrueToObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddTrueToObject'); - late final _cJSON_AddTrueToObject = _cJSON_AddTrueToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + late final _cJSON_IsArrayPtr = + _lookup)>>( + 'cJSON_IsArray', + ); + late final _cJSON_IsArray = _cJSON_IsArrayPtr + .asFunction)>(); - ffi.Pointer cJSON_AddFalseToObject( - ffi.Pointer object, - ffi.Pointer name, - ) { - return _cJSON_AddFalseToObject(object, name); + int cJSON_IsBool(ffi.Pointer item) { + return _cJSON_IsBool(item); } - late final _cJSON_AddFalseToObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddFalseToObject'); - late final _cJSON_AddFalseToObject = _cJSON_AddFalseToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + late final _cJSON_IsBoolPtr = + _lookup)>>( + 'cJSON_IsBool', + ); + late final _cJSON_IsBool = _cJSON_IsBoolPtr + .asFunction)>(); - ffi.Pointer cJSON_AddBoolToObject( - ffi.Pointer object, - ffi.Pointer name, - int boolean, + int cJSON_IsFalse(ffi.Pointer item) { + return _cJSON_IsFalse(item); + } + + late final _cJSON_IsFalsePtr = + _lookup)>>( + 'cJSON_IsFalse', + ); + late final _cJSON_IsFalse = _cJSON_IsFalsePtr + .asFunction)>(); + + int cJSON_IsInvalid(ffi.Pointer item) { + return _cJSON_IsInvalid(item); + } + + late final _cJSON_IsInvalidPtr = + _lookup)>>( + 'cJSON_IsInvalid', + ); + late final _cJSON_IsInvalid = _cJSON_IsInvalidPtr + .asFunction)>(); + + int cJSON_IsNull(ffi.Pointer item) { + return _cJSON_IsNull(item); + } + + late final _cJSON_IsNullPtr = + _lookup)>>( + 'cJSON_IsNull', + ); + late final _cJSON_IsNull = _cJSON_IsNullPtr + .asFunction)>(); + + int cJSON_IsNumber(ffi.Pointer item) { + return _cJSON_IsNumber(item); + } + + late final _cJSON_IsNumberPtr = + _lookup)>>( + 'cJSON_IsNumber', + ); + late final _cJSON_IsNumber = _cJSON_IsNumberPtr + .asFunction)>(); + + int cJSON_IsObject(ffi.Pointer item) { + return _cJSON_IsObject(item); + } + + late final _cJSON_IsObjectPtr = + _lookup)>>( + 'cJSON_IsObject', + ); + late final _cJSON_IsObject = _cJSON_IsObjectPtr + .asFunction)>(); + + int cJSON_IsRaw(ffi.Pointer item) { + return _cJSON_IsRaw(item); + } + + late final _cJSON_IsRawPtr = + _lookup)>>( + 'cJSON_IsRaw', + ); + late final _cJSON_IsRaw = _cJSON_IsRawPtr + .asFunction)>(); + + int cJSON_IsString(ffi.Pointer item) { + return _cJSON_IsString(item); + } + + late final _cJSON_IsStringPtr = + _lookup)>>( + 'cJSON_IsString', + ); + late final _cJSON_IsString = _cJSON_IsStringPtr + .asFunction)>(); + + int cJSON_IsTrue(ffi.Pointer item) { + return _cJSON_IsTrue(item); + } + + late final _cJSON_IsTruePtr = + _lookup)>>( + 'cJSON_IsTrue', + ); + late final _cJSON_IsTrue = _cJSON_IsTruePtr + .asFunction)>(); + + void cJSON_Minify(ffi.Pointer json) { + return _cJSON_Minify(json); + } + + late final _cJSON_MinifyPtr = + _lookup)>>( + 'cJSON_Minify', + ); + late final _cJSON_Minify = _cJSON_MinifyPtr + .asFunction)>(); + + ffi.Pointer cJSON_Parse(ffi.Pointer value) { + return _cJSON_Parse(value); + } + + late final _cJSON_ParsePtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_Parse'); + late final _cJSON_Parse = _cJSON_ParsePtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer cJSON_ParseWithOpts( + ffi.Pointer value, + ffi.Pointer> return_parse_end, + int require_null_terminated, ) { - return _cJSON_AddBoolToObject(object, name, boolean); + return _cJSON_ParseWithOpts( + value, + return_parse_end, + require_null_terminated, + ); } - late final _cJSON_AddBoolToObjectPtr = + late final _cJSON_ParseWithOptsPtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer, ffi.Pointer, + ffi.Pointer>, cJSON_bool, ) > - >('cJSON_AddBoolToObject'); - late final _cJSON_AddBoolToObject = _cJSON_AddBoolToObjectPtr + >('cJSON_ParseWithOpts'); + late final _cJSON_ParseWithOpts = _cJSON_ParseWithOptsPtr .asFunction< ffi.Pointer Function( - ffi.Pointer, ffi.Pointer, + ffi.Pointer>, int, ) >(); - ffi.Pointer cJSON_AddNumberToObject( - ffi.Pointer object, - ffi.Pointer name, - double number, + ffi.Pointer cJSON_Print(ffi.Pointer item) { + return _cJSON_Print(item); + } + + late final _cJSON_PrintPtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_Print'); + late final _cJSON_Print = _cJSON_PrintPtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer cJSON_PrintBuffered( + ffi.Pointer item, + int prebuffer, + int fmt, ) { - return _cJSON_AddNumberToObject(object, name, number); + return _cJSON_PrintBuffered(item, prebuffer, fmt); } - late final _cJSON_AddNumberToObjectPtr = + late final _cJSON_PrintBufferedPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, - ffi.Pointer, - ffi.Double, + ffi.Int, + cJSON_bool, ) > - >('cJSON_AddNumberToObject'); - late final _cJSON_AddNumberToObject = _cJSON_AddNumberToObjectPtr + >('cJSON_PrintBuffered'); + late final _cJSON_PrintBuffered = _cJSON_PrintBufferedPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - double, - ) + ffi.Pointer Function(ffi.Pointer, int, int) >(); - ffi.Pointer cJSON_AddStringToObject( - ffi.Pointer object, - ffi.Pointer name, - ffi.Pointer string, + int cJSON_PrintPreallocated( + ffi.Pointer item, + ffi.Pointer buffer, + int length, + int format, ) { - return _cJSON_AddStringToObject(object, name, string); + return _cJSON_PrintPreallocated(item, buffer, length, format); } - late final _cJSON_AddStringToObjectPtr = + late final _cJSON_PrintPreallocatedPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + cJSON_bool Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Int, + cJSON_bool, ) > - >('cJSON_AddStringToObject'); - late final _cJSON_AddStringToObject = _cJSON_AddStringToObjectPtr + >('cJSON_PrintPreallocated'); + late final _cJSON_PrintPreallocated = _cJSON_PrintPreallocatedPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer, int, int) >(); - ffi.Pointer cJSON_AddRawToObject( + ffi.Pointer cJSON_PrintUnformatted(ffi.Pointer item) { + return _cJSON_PrintUnformatted(item); + } + + late final _cJSON_PrintUnformattedPtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_PrintUnformatted'); + late final _cJSON_PrintUnformatted = _cJSON_PrintUnformattedPtr + .asFunction Function(ffi.Pointer)>(); + + void cJSON_ReplaceItemInArray( + ffi.Pointer array, + int which, + ffi.Pointer newitem, + ) { + return _cJSON_ReplaceItemInArray(array, which, newitem); + } + + late final _cJSON_ReplaceItemInArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) + > + >('cJSON_ReplaceItemInArray'); + late final _cJSON_ReplaceItemInArray = _cJSON_ReplaceItemInArrayPtr + .asFunction, int, ffi.Pointer)>(); + + void cJSON_ReplaceItemInObject( ffi.Pointer object, - ffi.Pointer name, - ffi.Pointer raw, + ffi.Pointer string, + ffi.Pointer newitem, ) { - return _cJSON_AddRawToObject(object, name, raw); + return _cJSON_ReplaceItemInObject(object, string, newitem); } - late final _cJSON_AddRawToObjectPtr = + late final _cJSON_ReplaceItemInObjectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Pointer, ) > - >('cJSON_AddRawToObject'); - late final _cJSON_AddRawToObject = _cJSON_AddRawToObjectPtr + >('cJSON_ReplaceItemInObject'); + late final _cJSON_ReplaceItemInObject = _cJSON_ReplaceItemInObjectPtr .asFunction< - ffi.Pointer Function( + void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Pointer, ) >(); - ffi.Pointer cJSON_AddObjectToObject( + void cJSON_ReplaceItemInObjectCaseSensitive( ffi.Pointer object, - ffi.Pointer name, + ffi.Pointer string, + ffi.Pointer newitem, ) { - return _cJSON_AddObjectToObject(object, name); + return _cJSON_ReplaceItemInObjectCaseSensitive(object, string, newitem); } - late final _cJSON_AddObjectToObjectPtr = + late final _cJSON_ReplaceItemInObjectCaseSensitivePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_AddObjectToObject'); - late final _cJSON_AddObjectToObject = _cJSON_AddObjectToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_ReplaceItemInObjectCaseSensitive'); + late final _cJSON_ReplaceItemInObjectCaseSensitive = + _cJSON_ReplaceItemInObjectCaseSensitivePtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - ffi.Pointer cJSON_AddArrayToObject( - ffi.Pointer object, - ffi.Pointer name, + int cJSON_ReplaceItemViaPointer( + ffi.Pointer parent, + ffi.Pointer item, + ffi.Pointer replacement, ) { - return _cJSON_AddArrayToObject(object, name); + return _cJSON_ReplaceItemViaPointer(parent, item, replacement); } - late final _cJSON_AddArrayToObjectPtr = + late final _cJSON_ReplaceItemViaPointerPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + cJSON_bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_AddArrayToObject'); - late final _cJSON_AddArrayToObject = _cJSON_AddArrayToObjectPtr + >('cJSON_ReplaceItemViaPointer'); + late final _cJSON_ReplaceItemViaPointer = _cJSON_ReplaceItemViaPointerPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer) >(); double cJSON_SetNumberHelper(ffi.Pointer object, double number) { @@ -1193,16 +1182,16 @@ class CJson { late final _cJSON_SetNumberHelper = _cJSON_SetNumberHelperPtr .asFunction, double)>(); - ffi.Pointer cJSON_malloc(int size) { - return _cJSON_malloc(size); + ffi.Pointer cJSON_Version() { + return _cJSON_Version(); } - late final _cJSON_mallocPtr = - _lookup Function(ffi.Size)>>( - 'cJSON_malloc', + late final _cJSON_VersionPtr = + _lookup Function()>>( + 'cJSON_Version', ); - late final _cJSON_malloc = _cJSON_mallocPtr - .asFunction Function(int)>(); + late final _cJSON_Version = _cJSON_VersionPtr + .asFunction Function()>(); void cJSON_free(ffi.Pointer object) { return _cJSON_free(object); @@ -1214,8 +1203,29 @@ class CJson { ); late final _cJSON_free = _cJSON_freePtr .asFunction)>(); + + ffi.Pointer cJSON_malloc(int size) { + return _cJSON_malloc(size); + } + + late final _cJSON_mallocPtr = + _lookup Function(ffi.Size)>>( + 'cJSON_malloc', + ); + late final _cJSON_malloc = _cJSON_mallocPtr + .asFunction Function(int)>(); } +const double CJSON_DOUBLE_PRECISION = 1e-16; + +const int CJSON_NESTING_LIMIT = 1000; + +const int CJSON_VERSION_MAJOR = 1; + +const int CJSON_VERSION_MINOR = 7; + +const int CJSON_VERSION_PATCH = 12; + final class cJSON extends ffi.Struct { external ffi.Pointer next; @@ -1235,8 +1245,32 @@ final class cJSON extends ffi.Struct { external double valuedouble; external ffi.Pointer string; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer next, + required ffi.Pointer prev, + required ffi.Pointer child, + required int type, + required ffi.Pointer valuestring, + required int valueint, + required double valuedouble, + required ffi.Pointer string, + }) => $allocator() + ..ref.next = next + ..ref.prev = prev + ..ref.child = child + ..ref.type = type + ..ref.valuestring = valuestring + ..ref.valueint = valueint + ..ref.valuedouble = valuedouble + ..ref.string = string; } +const int cJSON_Array = 32; + +const int cJSON_False = 1; + final class cJSON_Hooks extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction Function(ffi.Size sz)> @@ -1247,39 +1281,39 @@ final class cJSON_Hooks extends ffi.Struct { ffi.NativeFunction ptr)> > free_fn; -} -typedef cJSON_bool = ffi.Int; -typedef DartcJSON_bool = int; - -const int CJSON_VERSION_MAJOR = 1; - -const int CJSON_VERSION_MINOR = 7; - -const int CJSON_VERSION_PATCH = 12; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction Function(ffi.Size sz)> + > + malloc_fn, + required ffi.Pointer< + ffi.NativeFunction ptr)> + > + free_fn, + }) => $allocator() + ..ref.malloc_fn = malloc_fn + ..ref.free_fn = free_fn; +} const int cJSON_Invalid = 0; -const int cJSON_False = 1; - -const int cJSON_True = 2; +const int cJSON_IsReference = 256; const int cJSON_NULL = 4; const int cJSON_Number = 8; -const int cJSON_String = 16; - -const int cJSON_Array = 32; - const int cJSON_Object = 64; const int cJSON_Raw = 128; -const int cJSON_IsReference = 256; +const int cJSON_String = 16; const int cJSON_StringIsConst = 512; -const int CJSON_NESTING_LIMIT = 1000; +const int cJSON_True = 2; -const double CJSON_DOUBLE_PRECISION = 1e-16; +typedef cJSON_bool = ffi.Int; +typedef DartcJSON_bool = int; diff --git a/pkgs/ffigen/example/ffinative/lib/generated_bindings.dart b/pkgs/ffigen/example/ffinative/lib/generated_bindings.dart index 63abe0e8a8..e24e6bd560 100644 --- a/pkgs/ffigen/example/ffinative/lib/generated_bindings.dart +++ b/pkgs/ffigen/example/ffinative/lib/generated_bindings.dart @@ -12,17 +12,9 @@ library; import 'dart:ffi' as ffi; import '' as self; -/// Adds 2 integers. -@ffi.Native() -external int sum(int a, int b); - -/// Subtracts 2 integers. -@ffi.Native() -external int subtract(int a, int b); - -/// Multiplies 2 integers, returns pointer to an integer,. -@ffi.Native Function(ffi.Int, ffi.Int)>() -external ffi.Pointer multiply(int a, int b); +@ffi.Array.multi([5]) +@ffi.Native>() +external ffi.Array array; /// Divides 2 integers, returns pointer to a float. @ffi.Native Function(ffi.Int, ffi.Int)>() @@ -32,23 +24,31 @@ external ffi.Pointer divide(int a, int b); @ffi.Native Function(ffi.Float, ffi.Float)>() external ffi.Pointer dividePrecision(double a, double b); +/// Version of the native C library +@ffi.Native>() +external final ffi.Pointer library_version; + @ffi.Native() external int log_level; -@ffi.Array.multi([5]) -@ffi.Native>() -external ffi.Array array; +/// Multiplies 2 integers, returns pointer to an integer,. +@ffi.Native Function(ffi.Int, ffi.Int)>() +external ffi.Pointer multiply(int a, int b); -/// Version of the native C library -@ffi.Native>() -external final ffi.Pointer library_version; +/// Subtracts 2 integers. +@ffi.Native() +external int subtract(int a, int b); + +/// Adds 2 integers. +@ffi.Native() +external int sum(int a, int b); const addresses = _SymbolAddresses(); class _SymbolAddresses { const _SymbolAddresses(); - ffi.Pointer> get sum => - ffi.Native.addressOf(self.sum); ffi.Pointer> get library_version => ffi.Native.addressOf(self.library_version); + ffi.Pointer> get sum => + ffi.Native.addressOf(self.sum); } diff --git a/pkgs/ffigen/example/libclang-example/generated_bindings.dart b/pkgs/ffigen/example/libclang-example/generated_bindings.dart index f0368fe878..23f400b8e6 100644 --- a/pkgs/ffigen/example/libclang-example/generated_bindings.dart +++ b/pkgs/ffigen/example/libclang-example/generated_bindings.dart @@ -24,104 +24,49 @@ class LibClang { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - /// Retrieve the character data associated with the given string. - ffi.Pointer clang_getCString(CXString string) { - return _clang_getCString(string); - } - - late final _clang_getCStringPtr = - _lookup>('clang_getCString'); - late final _clang_getCString = _clang_getCStringPtr - .asFunction(); - - /// Free the given string. - void clang_disposeString(CXString string) { - return _clang_disposeString(string); - } - - late final _clang_disposeStringPtr = - _lookup>( - 'clang_disposeString', - ); - late final _clang_disposeString = _clang_disposeStringPtr - .asFunction(); - - /// Free the given string set. - void clang_disposeStringSet(ffi.Pointer set) { - return _clang_disposeStringSet(set); + /// Queries a CXCursorSet to see if it contains a specific CXCursor. + /// + /// \returns non-zero if the set contains the specified cursor. + int clang_CXCursorSet_contains(CXCursorSet cset, CXCursor cursor) { + return _clang_CXCursorSet_contains(cset, cursor); } - late final _clang_disposeStringSetPtr = - _lookup>( - 'clang_disposeStringSet', + late final _clang_CXCursorSet_containsPtr = + _lookup>( + 'clang_CXCursorSet_contains', ); - late final _clang_disposeStringSet = _clang_disposeStringSetPtr - .asFunction(); + late final _clang_CXCursorSet_contains = _clang_CXCursorSet_containsPtr + .asFunction(); - /// Provides a shared context for creating translation units. - /// - /// It provides two options: - /// - /// - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" - /// declarations (when loading any new translation units). A "local" declaration - /// is one that belongs in the translation unit itself and not in a precompiled - /// header that was used by the translation unit. If zero, all declarations - /// will be enumerated. - /// - /// Here is an example: - /// - /// \code - /// // excludeDeclsFromPCH = 1, displayDiagnostics=1 - /// Idx = clang_createIndex(1, 1); - /// - /// // IndexTest.pch was produced with the following command: - /// // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" - /// TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); - /// - /// // This will load all the symbols from 'IndexTest.pch' - /// clang_visitChildren(clang_getTranslationUnitCursor(TU), - /// TranslationUnitVisitor, 0); - /// clang_disposeTranslationUnit(TU); - /// - /// // This will load all the symbols from 'IndexTest.c', excluding symbols - /// // from 'IndexTest.pch'. - /// char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; - /// TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, - /// 0, 0); - /// clang_visitChildren(clang_getTranslationUnitCursor(TU), - /// TranslationUnitVisitor, 0); - /// clang_disposeTranslationUnit(TU); - /// \endcode + /// Inserts a CXCursor into a CXCursorSet. /// - /// This process of creating the 'pch', loading it separately, and using it (via - /// -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks - /// (which gives the indexer the same performance benefit as the compiler). - CXIndex clang_createIndex( - int excludeDeclarationsFromPCH, - int displayDiagnostics, - ) { - return _clang_createIndex(excludeDeclarationsFromPCH, displayDiagnostics); + /// \returns zero if the CXCursor was already in the set, and non-zero otherwise. + int clang_CXCursorSet_insert(CXCursorSet cset, CXCursor cursor) { + return _clang_CXCursorSet_insert(cset, cursor); } - late final _clang_createIndexPtr = - _lookup>('clang_createIndex'); - late final _clang_createIndex = _clang_createIndexPtr - .asFunction(); + late final _clang_CXCursorSet_insertPtr = + _lookup>( + 'clang_CXCursorSet_insert', + ); + late final _clang_CXCursorSet_insert = _clang_CXCursorSet_insertPtr + .asFunction(); - /// Destroy the given index. + /// Gets the general options associated with a CXIndex. /// - /// The index must not be destroyed until all of the translation units created - /// within that index have been destroyed. - void clang_disposeIndex(CXIndex index) { - return _clang_disposeIndex(index); + /// \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that + /// are associated with the given CXIndex object. + int clang_CXIndex_getGlobalOptions(CXIndex arg0) { + return _clang_CXIndex_getGlobalOptions(arg0); } - late final _clang_disposeIndexPtr = - _lookup>( - 'clang_disposeIndex', + late final _clang_CXIndex_getGlobalOptionsPtr = + _lookup>( + 'clang_CXIndex_getGlobalOptions', ); - late final _clang_disposeIndex = _clang_disposeIndexPtr - .asFunction(); + late final _clang_CXIndex_getGlobalOptions = + _clang_CXIndex_getGlobalOptionsPtr + .asFunction(); /// Sets general options associated with a CXIndex. /// @@ -146,22 +91,6 @@ class LibClang { _clang_CXIndex_setGlobalOptionsPtr .asFunction(); - /// Gets the general options associated with a CXIndex. - /// - /// \returns A bitmask of options, a bitwise OR of CXGlobalOpt_XXX flags that - /// are associated with the given CXIndex object. - int clang_CXIndex_getGlobalOptions(CXIndex arg0) { - return _clang_CXIndex_getGlobalOptions(arg0); - } - - late final _clang_CXIndex_getGlobalOptionsPtr = - _lookup>( - 'clang_CXIndex_getGlobalOptions', - ); - late final _clang_CXIndex_getGlobalOptions = - _clang_CXIndex_getGlobalOptionsPtr - .asFunction(); - /// Sets the invocation emission path option in a CXIndex. /// /// The invocation emission path specifies a path which will contain log @@ -182,2809 +111,2490 @@ class LibClang { _clang_CXIndex_setInvocationEmissionPathOptionPtr .asFunction(); - /// Retrieve the complete file and path name of the given file. - CXString clang_getFileName(CXFile SFile) { - return _clang_getFileName(SFile); + /// Determine if a C++ constructor is a converting constructor. + int clang_CXXConstructor_isConvertingConstructor(CXCursor C) { + return _clang_CXXConstructor_isConvertingConstructor(C); } - late final _clang_getFileNamePtr = - _lookup>('clang_getFileName'); - late final _clang_getFileName = _clang_getFileNamePtr - .asFunction(); + late final _clang_CXXConstructor_isConvertingConstructorPtr = + _lookup< + ffi.NativeFunction + >('clang_CXXConstructor_isConvertingConstructor'); + late final _clang_CXXConstructor_isConvertingConstructor = + _clang_CXXConstructor_isConvertingConstructorPtr + .asFunction(); - /// Retrieve the last modification time of the given file. - int clang_getFileTime(CXFile SFile) { - return _clang_getFileTime(SFile); + /// Determine if a C++ constructor is a copy constructor. + int clang_CXXConstructor_isCopyConstructor(CXCursor C) { + return _clang_CXXConstructor_isCopyConstructor(C); } - late final _clang_getFileTimePtr = - _lookup>('clang_getFileTime'); - late final _clang_getFileTime = _clang_getFileTimePtr - .asFunction(); + late final _clang_CXXConstructor_isCopyConstructorPtr = + _lookup>( + 'clang_CXXConstructor_isCopyConstructor', + ); + late final _clang_CXXConstructor_isCopyConstructor = + _clang_CXXConstructor_isCopyConstructorPtr + .asFunction(); - /// Retrieve the unique ID for the given \c file. - /// - /// \param file the file to get the ID for. - /// \param outID stores the returned CXFileUniqueID. - /// \returns If there was a failure getting the unique ID, returns non-zero, - /// otherwise returns 0. - int clang_getFileUniqueID(CXFile file, ffi.Pointer outID) { - return _clang_getFileUniqueID(file, outID); + /// Determine if a C++ constructor is the default constructor. + int clang_CXXConstructor_isDefaultConstructor(CXCursor C) { + return _clang_CXXConstructor_isDefaultConstructor(C); } - late final _clang_getFileUniqueIDPtr = - _lookup>( - 'clang_getFileUniqueID', - ); - late final _clang_getFileUniqueID = _clang_getFileUniqueIDPtr - .asFunction(); + late final _clang_CXXConstructor_isDefaultConstructorPtr = + _lookup< + ffi.NativeFunction + >('clang_CXXConstructor_isDefaultConstructor'); + late final _clang_CXXConstructor_isDefaultConstructor = + _clang_CXXConstructor_isDefaultConstructorPtr + .asFunction(); - /// Determine whether the given header is guarded against - /// multiple inclusions, either with the conventional - /// \#ifndef/\#define/\#endif macro guards or with \#pragma once. - int clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file) { - return _clang_isFileMultipleIncludeGuarded(tu, file); + /// Determine if a C++ constructor is a move constructor. + int clang_CXXConstructor_isMoveConstructor(CXCursor C) { + return _clang_CXXConstructor_isMoveConstructor(C); } - late final _clang_isFileMultipleIncludeGuardedPtr = - _lookup>( - 'clang_isFileMultipleIncludeGuarded', + late final _clang_CXXConstructor_isMoveConstructorPtr = + _lookup>( + 'clang_CXXConstructor_isMoveConstructor', ); - late final _clang_isFileMultipleIncludeGuarded = - _clang_isFileMultipleIncludeGuardedPtr - .asFunction(); + late final _clang_CXXConstructor_isMoveConstructor = + _clang_CXXConstructor_isMoveConstructorPtr + .asFunction(); - /// Retrieve a file handle within the given translation unit. - /// - /// \param tu the translation unit - /// - /// \param file_name the name of the file. - /// - /// \returns the file handle for the named file in the translation unit \p tu, - /// or a NULL file handle if the file was not a part of this translation unit. - CXFile clang_getFile(CXTranslationUnit tu, ffi.Pointer file_name) { - return _clang_getFile(tu, file_name); + /// Determine if a C++ field is declared 'mutable'. + int clang_CXXField_isMutable(CXCursor C) { + return _clang_CXXField_isMutable(C); } - late final _clang_getFilePtr = - _lookup>('clang_getFile'); - late final _clang_getFile = _clang_getFilePtr.asFunction(); + late final _clang_CXXField_isMutablePtr = + _lookup>( + 'clang_CXXField_isMutable', + ); + late final _clang_CXXField_isMutable = _clang_CXXField_isMutablePtr + .asFunction(); - /// Retrieve the buffer associated with the given file. - /// - /// \param tu the translation unit - /// - /// \param file the file for which to retrieve the buffer. - /// - /// \param size [out] if non-NULL, will be set to the size of the buffer. - /// - /// \returns a pointer to the buffer in memory that holds the contents of - /// \p file, or a NULL pointer when the file is not loaded. - ffi.Pointer clang_getFileContents( - CXTranslationUnit tu, - CXFile file, - ffi.Pointer size, - ) { - return _clang_getFileContents(tu, file, size); + /// Determine if a C++ member function or member function template is + /// declared 'const'. + int clang_CXXMethod_isConst(CXCursor C) { + return _clang_CXXMethod_isConst(C); } - late final _clang_getFileContentsPtr = - _lookup>( - 'clang_getFileContents', + late final _clang_CXXMethod_isConstPtr = + _lookup>( + 'clang_CXXMethod_isConst', ); - late final _clang_getFileContents = _clang_getFileContentsPtr - .asFunction(); + late final _clang_CXXMethod_isConst = _clang_CXXMethod_isConstPtr + .asFunction(); - /// Returns non-zero if the \c file1 and \c file2 point to the same file, - /// or they are both NULL. - int clang_File_isEqual(CXFile file1, CXFile file2) { - return _clang_File_isEqual(file1, file2); + /// Determine if a C++ method is declared '= default'. + int clang_CXXMethod_isDefaulted(CXCursor C) { + return _clang_CXXMethod_isDefaulted(C); } - late final _clang_File_isEqualPtr = - _lookup>( - 'clang_File_isEqual', + late final _clang_CXXMethod_isDefaultedPtr = + _lookup>( + 'clang_CXXMethod_isDefaulted', ); - late final _clang_File_isEqual = _clang_File_isEqualPtr - .asFunction(); + late final _clang_CXXMethod_isDefaulted = _clang_CXXMethod_isDefaultedPtr + .asFunction(); - /// Returns the real path name of \c file. - /// - /// An empty string may be returned. Use \c clang_getFileName() in that case. - CXString clang_File_tryGetRealPathName(CXFile file) { - return _clang_File_tryGetRealPathName(file); + /// Determine if a C++ member function or member function template is + /// pure virtual. + int clang_CXXMethod_isPureVirtual(CXCursor C) { + return _clang_CXXMethod_isPureVirtual(C); } - late final _clang_File_tryGetRealPathNamePtr = - _lookup>( - 'clang_File_tryGetRealPathName', + late final _clang_CXXMethod_isPureVirtualPtr = + _lookup>( + 'clang_CXXMethod_isPureVirtual', ); - late final _clang_File_tryGetRealPathName = _clang_File_tryGetRealPathNamePtr - .asFunction(); + late final _clang_CXXMethod_isPureVirtual = _clang_CXXMethod_isPureVirtualPtr + .asFunction(); - /// Retrieve a NULL (invalid) source location. - CXSourceLocation clang_getNullLocation() { - return _clang_getNullLocation(); + /// Determine if a C++ member function or member function template is + /// declared 'static'. + int clang_CXXMethod_isStatic(CXCursor C) { + return _clang_CXXMethod_isStatic(C); } - late final _clang_getNullLocationPtr = - _lookup>( - 'clang_getNullLocation', + late final _clang_CXXMethod_isStaticPtr = + _lookup>( + 'clang_CXXMethod_isStatic', ); - late final _clang_getNullLocation = _clang_getNullLocationPtr - .asFunction(); + late final _clang_CXXMethod_isStatic = _clang_CXXMethod_isStaticPtr + .asFunction(); - /// Determine whether two source locations, which must refer into - /// the same translation unit, refer to exactly the same point in the source - /// code. - /// - /// \returns non-zero if the source locations refer to the same location, zero - /// if they refer to different locations. - int clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2) { - return _clang_equalLocations(loc1, loc2); + /// Determine if a C++ member function or member function template is + /// explicitly declared 'virtual' or if it overrides a virtual method from + /// one of the base classes. + int clang_CXXMethod_isVirtual(CXCursor C) { + return _clang_CXXMethod_isVirtual(C); } - late final _clang_equalLocationsPtr = - _lookup>( - 'clang_equalLocations', + late final _clang_CXXMethod_isVirtualPtr = + _lookup>( + 'clang_CXXMethod_isVirtual', ); - late final _clang_equalLocations = _clang_equalLocationsPtr - .asFunction(); + late final _clang_CXXMethod_isVirtual = _clang_CXXMethod_isVirtualPtr + .asFunction(); - /// Retrieves the source location associated with a given file/line/column - /// in a particular translation unit. - CXSourceLocation clang_getLocation( - CXTranslationUnit tu, - CXFile file, - int line, - int column, - ) { - return _clang_getLocation(tu, file, line, column); + /// Determine if a C++ record is abstract, i.e. whether a class or struct + /// has a pure virtual member function. + int clang_CXXRecord_isAbstract(CXCursor C) { + return _clang_CXXRecord_isAbstract(C); } - late final _clang_getLocationPtr = - _lookup>('clang_getLocation'); - late final _clang_getLocation = _clang_getLocationPtr - .asFunction(); + late final _clang_CXXRecord_isAbstractPtr = + _lookup>( + 'clang_CXXRecord_isAbstract', + ); + late final _clang_CXXRecord_isAbstract = _clang_CXXRecord_isAbstractPtr + .asFunction(); - /// Retrieves the source location associated with a given character offset - /// in a particular translation unit. - CXSourceLocation clang_getLocationForOffset( - CXTranslationUnit tu, - CXFile file, - int offset, - ) { - return _clang_getLocationForOffset(tu, file, offset); + /// If cursor is a statement declaration tries to evaluate the + /// statement and if its variable, tries to evaluate its initializer, + /// into its corresponding type. + CXEvalResult clang_Cursor_Evaluate(CXCursor C) { + return _clang_Cursor_Evaluate(C); } - late final _clang_getLocationForOffsetPtr = - _lookup>( - 'clang_getLocationForOffset', + late final _clang_Cursor_EvaluatePtr = + _lookup>( + 'clang_Cursor_Evaluate', ); - late final _clang_getLocationForOffset = _clang_getLocationForOffsetPtr - .asFunction(); + late final _clang_Cursor_Evaluate = _clang_Cursor_EvaluatePtr + .asFunction(); - /// Returns non-zero if the given source location is in a system header. - int clang_Location_isInSystemHeader(CXSourceLocation location) { - return _clang_Location_isInSystemHeader(location); + /// Retrieve the argument cursor of a function or method. + /// + /// The argument cursor can be determined for calls as well as for declarations + /// of functions or methods. For other cursors and for invalid indices, an + /// invalid cursor is returned. + CXCursor clang_Cursor_getArgument(CXCursor C, int i) { + return _clang_Cursor_getArgument(C, i); } - late final _clang_Location_isInSystemHeaderPtr = - _lookup>( - 'clang_Location_isInSystemHeader', + late final _clang_Cursor_getArgumentPtr = + _lookup>( + 'clang_Cursor_getArgument', ); - late final _clang_Location_isInSystemHeader = - _clang_Location_isInSystemHeaderPtr - .asFunction(); + late final _clang_Cursor_getArgument = _clang_Cursor_getArgumentPtr + .asFunction(); - /// Returns non-zero if the given source location is in the main file of - /// the corresponding translation unit. - int clang_Location_isFromMainFile(CXSourceLocation location) { - return _clang_Location_isFromMainFile(location); + /// Given a cursor that represents a documentable entity (e.g., + /// declaration), return the associated \paragraph; otherwise return the + /// first paragraph. + CXString clang_Cursor_getBriefCommentText(CXCursor C) { + return _clang_Cursor_getBriefCommentText(C); } - late final _clang_Location_isFromMainFilePtr = - _lookup>( - 'clang_Location_isFromMainFile', + late final _clang_Cursor_getBriefCommentTextPtr = + _lookup>( + 'clang_Cursor_getBriefCommentText', ); - late final _clang_Location_isFromMainFile = _clang_Location_isFromMainFilePtr - .asFunction(); + late final _clang_Cursor_getBriefCommentText = + _clang_Cursor_getBriefCommentTextPtr + .asFunction(); - /// Retrieve a NULL (invalid) source range. - CXSourceRange clang_getNullRange() { - return _clang_getNullRange(); + /// Retrieve the CXStrings representing the mangled symbols of the C++ + /// constructor or destructor at the cursor. + ffi.Pointer clang_Cursor_getCXXManglings(CXCursor arg0) { + return _clang_Cursor_getCXXManglings(arg0); } - late final _clang_getNullRangePtr = - _lookup>( - 'clang_getNullRange', + late final _clang_Cursor_getCXXManglingsPtr = + _lookup>( + 'clang_Cursor_getCXXManglings', ); - late final _clang_getNullRange = _clang_getNullRangePtr - .asFunction(); + late final _clang_Cursor_getCXXManglings = _clang_Cursor_getCXXManglingsPtr + .asFunction(); - /// Retrieve a source range given the beginning and ending source - /// locations. - CXSourceRange clang_getRange(CXSourceLocation begin, CXSourceLocation end) { - return _clang_getRange(begin, end); + /// Given a cursor that represents a declaration, return the associated + /// comment's source range. The range may include multiple consecutive comments + /// with whitespace in between. + CXSourceRange clang_Cursor_getCommentRange(CXCursor C) { + return _clang_Cursor_getCommentRange(C); } - late final _clang_getRangePtr = - _lookup>('clang_getRange'); - late final _clang_getRange = _clang_getRangePtr - .asFunction(); + late final _clang_Cursor_getCommentRangePtr = + _lookup>( + 'clang_Cursor_getCommentRange', + ); + late final _clang_Cursor_getCommentRange = _clang_Cursor_getCommentRangePtr + .asFunction(); - /// Determine whether two ranges are equivalent. - /// - /// \returns non-zero if the ranges are the same, zero if they differ. - int clang_equalRanges(CXSourceRange range1, CXSourceRange range2) { - return _clang_equalRanges(range1, range2); + /// Retrieve the CXString representing the mangled name of the cursor. + CXString clang_Cursor_getMangling(CXCursor arg0) { + return _clang_Cursor_getMangling(arg0); } - late final _clang_equalRangesPtr = - _lookup>('clang_equalRanges'); - late final _clang_equalRanges = _clang_equalRangesPtr - .asFunction(); + late final _clang_Cursor_getManglingPtr = + _lookup>( + 'clang_Cursor_getMangling', + ); + late final _clang_Cursor_getMangling = _clang_Cursor_getManglingPtr + .asFunction(); - /// Returns non-zero if \p range is null. - int clang_Range_isNull(CXSourceRange range) { - return _clang_Range_isNull(range); + /// Given a CXCursor_ModuleImportDecl cursor, return the associated module. + CXModule clang_Cursor_getModule(CXCursor C) { + return _clang_Cursor_getModule(C); } - late final _clang_Range_isNullPtr = - _lookup>( - 'clang_Range_isNull', + late final _clang_Cursor_getModulePtr = + _lookup>( + 'clang_Cursor_getModule', ); - late final _clang_Range_isNull = _clang_Range_isNullPtr - .asFunction(); + late final _clang_Cursor_getModule = _clang_Cursor_getModulePtr + .asFunction(); - /// Retrieve the file, line, column, and offset represented by - /// the given source location. - /// - /// If the location refers into a macro expansion, retrieves the - /// location of the macro expansion. - /// - /// \param location the location within a source file that will be decomposed - /// into its parts. - /// - /// \param file [out] if non-NULL, will be set to the file to which the given - /// source location points. - /// - /// \param line [out] if non-NULL, will be set to the line to which the given - /// source location points. + /// Retrieve the number of non-variadic arguments associated with a given + /// cursor. /// - /// \param column [out] if non-NULL, will be set to the column to which the given - /// source location points. - /// - /// \param offset [out] if non-NULL, will be set to the offset into the - /// buffer to which the given source location points. - void clang_getExpansionLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getExpansionLocation(location, file, line, column, offset); + /// The number of arguments can be determined for calls as well as for + /// declarations of functions or methods. For other cursors -1 is returned. + int clang_Cursor_getNumArguments(CXCursor C) { + return _clang_Cursor_getNumArguments(C); } - late final _clang_getExpansionLocationPtr = - _lookup>( - 'clang_getExpansionLocation', + late final _clang_Cursor_getNumArgumentsPtr = + _lookup>( + 'clang_Cursor_getNumArguments', ); - late final _clang_getExpansionLocation = _clang_getExpansionLocationPtr - .asFunction(); + late final _clang_Cursor_getNumArguments = _clang_Cursor_getNumArgumentsPtr + .asFunction(); - /// Retrieve the file, line and column represented by the given source - /// location, as specified in a # line directive. - /// - /// Example: given the following source code in a file somefile.c - /// - /// \code - /// #123 "dummy.c" 1 - /// - /// static int func(void) - /// { - /// return 0; - /// } - /// \endcode - /// - /// the location information returned by this function would be - /// - /// File: dummy.c Line: 124 Column: 12 - /// - /// whereas clang_getExpansionLocation would have returned - /// - /// File: somefile.c Line: 3 Column: 12 + /// Returns the number of template args of a function decl representing a + /// template specialization. /// - /// \param location the location within a source file that will be decomposed - /// into its parts. + /// If the argument cursor cannot be converted into a template function + /// declaration, -1 is returned. /// - /// \param filename [out] if non-NULL, will be set to the filename of the - /// source location. Note that filenames returned will be for "virtual" files, - /// which don't necessarily exist on the machine running clang - e.g. when - /// parsing preprocessed output obtained from a different environment. If - /// a non-NULL value is passed in, remember to dispose of the returned value - /// using \c clang_disposeString() once you've finished with it. For an invalid - /// source location, an empty string is returned. + /// For example, for the following declaration and specialization: + /// template + /// void foo() { ... } /// - /// \param line [out] if non-NULL, will be set to the line number of the - /// source location. For an invalid source location, zero is returned. + /// template <> + /// void foo(); /// - /// \param column [out] if non-NULL, will be set to the column number of the - /// source location. For an invalid source location, zero is returned. - void clang_getPresumedLocation( - CXSourceLocation location, - ffi.Pointer filename, - ffi.Pointer line, - ffi.Pointer column, - ) { - return _clang_getPresumedLocation(location, filename, line, column); + /// The value 3 would be returned from this call. + int clang_Cursor_getNumTemplateArguments(CXCursor C) { + return _clang_Cursor_getNumTemplateArguments(C); } - late final _clang_getPresumedLocationPtr = - _lookup>( - 'clang_getPresumedLocation', + late final _clang_Cursor_getNumTemplateArgumentsPtr = + _lookup>( + 'clang_Cursor_getNumTemplateArguments', ); - late final _clang_getPresumedLocation = _clang_getPresumedLocationPtr - .asFunction(); + late final _clang_Cursor_getNumTemplateArguments = + _clang_Cursor_getNumTemplateArgumentsPtr + .asFunction(); - /// Legacy API to retrieve the file, line, column, and offset represented - /// by the given source location. - /// - /// This interface has been replaced by the newer interface - /// #clang_getExpansionLocation(). See that interface's documentation for - /// details. - void clang_getInstantiationLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getInstantiationLocation( - location, - file, - line, - column, - offset, - ); + /// Given a cursor that represents an Objective-C method or parameter + /// declaration, return the associated Objective-C qualifiers for the return + /// type or the parameter respectively. The bits are formed from + /// CXObjCDeclQualifierKind. + int clang_Cursor_getObjCDeclQualifiers(CXCursor C) { + return _clang_Cursor_getObjCDeclQualifiers(C); } - late final _clang_getInstantiationLocationPtr = - _lookup>( - 'clang_getInstantiationLocation', + late final _clang_Cursor_getObjCDeclQualifiersPtr = + _lookup>( + 'clang_Cursor_getObjCDeclQualifiers', ); - late final _clang_getInstantiationLocation = - _clang_getInstantiationLocationPtr - .asFunction(); + late final _clang_Cursor_getObjCDeclQualifiers = + _clang_Cursor_getObjCDeclQualifiersPtr + .asFunction(); - /// Retrieve the file, line, column, and offset represented by - /// the given source location. - /// - /// If the location refers into a macro instantiation, return where the - /// location was originally spelled in the source file. - /// - /// \param location the location within a source file that will be decomposed - /// into its parts. - /// - /// \param file [out] if non-NULL, will be set to the file to which the given - /// source location points. - /// - /// \param line [out] if non-NULL, will be set to the line to which the given - /// source location points. - /// - /// \param column [out] if non-NULL, will be set to the column to which the given - /// source location points. - /// - /// \param offset [out] if non-NULL, will be set to the offset into the - /// buffer to which the given source location points. - void clang_getSpellingLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getSpellingLocation(location, file, line, column, offset); + /// Retrieve the CXStrings representing the mangled symbols of the ObjC + /// class interface or implementation at the cursor. + ffi.Pointer clang_Cursor_getObjCManglings(CXCursor arg0) { + return _clang_Cursor_getObjCManglings(arg0); } - late final _clang_getSpellingLocationPtr = - _lookup>( - 'clang_getSpellingLocation', + late final _clang_Cursor_getObjCManglingsPtr = + _lookup>( + 'clang_Cursor_getObjCManglings', ); - late final _clang_getSpellingLocation = _clang_getSpellingLocationPtr - .asFunction(); + late final _clang_Cursor_getObjCManglings = _clang_Cursor_getObjCManglingsPtr + .asFunction(); - /// Retrieve the file, line, column, and offset represented by - /// the given source location. - /// - /// If the location refers into a macro expansion, return where the macro was - /// expanded or where the macro argument was written, if the location points at - /// a macro argument. - /// - /// \param location the location within a source file that will be decomposed - /// into its parts. - /// - /// \param file [out] if non-NULL, will be set to the file to which the given - /// source location points. - /// - /// \param line [out] if non-NULL, will be set to the line to which the given - /// source location points. - /// - /// \param column [out] if non-NULL, will be set to the column to which the given - /// source location points. + /// Given a cursor that represents a property declaration, return the + /// associated property attributes. The bits are formed from + /// \c CXObjCPropertyAttrKind. /// - /// \param offset [out] if non-NULL, will be set to the offset into the - /// buffer to which the given source location points. - void clang_getFileLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getFileLocation(location, file, line, column, offset); + /// \param reserved Reserved for future use, pass 0. + int clang_Cursor_getObjCPropertyAttributes(CXCursor C, int reserved) { + return _clang_Cursor_getObjCPropertyAttributes(C, reserved); } - late final _clang_getFileLocationPtr = - _lookup>( - 'clang_getFileLocation', + late final _clang_Cursor_getObjCPropertyAttributesPtr = + _lookup>( + 'clang_Cursor_getObjCPropertyAttributes', ); - late final _clang_getFileLocation = _clang_getFileLocationPtr - .asFunction(); + late final _clang_Cursor_getObjCPropertyAttributes = + _clang_Cursor_getObjCPropertyAttributesPtr + .asFunction(); - /// Retrieve a source location representing the first character within a - /// source range. - CXSourceLocation clang_getRangeStart(CXSourceRange range) { - return _clang_getRangeStart(range); + /// Given a cursor that represents a property declaration, return the + /// name of the method that implements the getter. + CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C) { + return _clang_Cursor_getObjCPropertyGetterName(C); } - late final _clang_getRangeStartPtr = - _lookup>( - 'clang_getRangeStart', + late final _clang_Cursor_getObjCPropertyGetterNamePtr = + _lookup>( + 'clang_Cursor_getObjCPropertyGetterName', ); - late final _clang_getRangeStart = _clang_getRangeStartPtr - .asFunction(); + late final _clang_Cursor_getObjCPropertyGetterName = + _clang_Cursor_getObjCPropertyGetterNamePtr + .asFunction(); - /// Retrieve a source location representing the last character within a - /// source range. - CXSourceLocation clang_getRangeEnd(CXSourceRange range) { - return _clang_getRangeEnd(range); + /// Given a cursor that represents a property declaration, return the + /// name of the method that implements the setter, if any. + CXString clang_Cursor_getObjCPropertySetterName(CXCursor C) { + return _clang_Cursor_getObjCPropertySetterName(C); } - late final _clang_getRangeEndPtr = - _lookup>('clang_getRangeEnd'); - late final _clang_getRangeEnd = _clang_getRangeEndPtr - .asFunction(); + late final _clang_Cursor_getObjCPropertySetterNamePtr = + _lookup>( + 'clang_Cursor_getObjCPropertySetterName', + ); + late final _clang_Cursor_getObjCPropertySetterName = + _clang_Cursor_getObjCPropertySetterNamePtr + .asFunction(); - /// Retrieve all ranges that were skipped by the preprocessor. - /// - /// The preprocessor will skip lines when they are surrounded by an - /// if/ifdef/ifndef directive whose condition does not evaluate to true. - ffi.Pointer clang_getSkippedRanges( - CXTranslationUnit tu, - CXFile file, - ) { - return _clang_getSkippedRanges(tu, file); - } - - late final _clang_getSkippedRangesPtr = - _lookup>( - 'clang_getSkippedRanges', - ); - late final _clang_getSkippedRanges = _clang_getSkippedRangesPtr - .asFunction(); - - /// Retrieve all ranges from all files that were skipped by the - /// preprocessor. + /// If the cursor points to a selector identifier in an Objective-C + /// method or message expression, this returns the selector index. /// - /// The preprocessor will skip lines when they are surrounded by an - /// if/ifdef/ifndef directive whose condition does not evaluate to true. - ffi.Pointer clang_getAllSkippedRanges( - CXTranslationUnit tu, - ) { - return _clang_getAllSkippedRanges(tu); + /// After getting a cursor with #clang_getCursor, this can be called to + /// determine if the location points to a selector identifier. + /// + /// \returns The selector index if the cursor is an Objective-C method or message + /// expression and the cursor is pointing to a selector identifier, or -1 + /// otherwise. + int clang_Cursor_getObjCSelectorIndex(CXCursor arg0) { + return _clang_Cursor_getObjCSelectorIndex(arg0); } - late final _clang_getAllSkippedRangesPtr = - _lookup>( - 'clang_getAllSkippedRanges', + late final _clang_Cursor_getObjCSelectorIndexPtr = + _lookup>( + 'clang_Cursor_getObjCSelectorIndex', ); - late final _clang_getAllSkippedRanges = _clang_getAllSkippedRangesPtr - .asFunction(); + late final _clang_Cursor_getObjCSelectorIndex = + _clang_Cursor_getObjCSelectorIndexPtr + .asFunction(); - /// Destroy the given \c CXSourceRangeList. - void clang_disposeSourceRangeList(ffi.Pointer ranges) { - return _clang_disposeSourceRangeList(ranges); + /// Return the offset of the field represented by the Cursor. + /// + /// If the cursor is not a field declaration, -1 is returned. + /// If the cursor semantic parent is not a record field declaration, + /// CXTypeLayoutError_Invalid is returned. + /// If the field's type declaration is an incomplete type, + /// CXTypeLayoutError_Incomplete is returned. + /// If the field's type declaration is a dependent type, + /// CXTypeLayoutError_Dependent is returned. + /// If the field's name S is not found, + /// CXTypeLayoutError_InvalidFieldName is returned. + int clang_Cursor_getOffsetOfField(CXCursor C) { + return _clang_Cursor_getOffsetOfField(C); } - late final _clang_disposeSourceRangeListPtr = - _lookup>( - 'clang_disposeSourceRangeList', + late final _clang_Cursor_getOffsetOfFieldPtr = + _lookup>( + 'clang_Cursor_getOffsetOfField', ); - late final _clang_disposeSourceRangeList = _clang_disposeSourceRangeListPtr - .asFunction(); + late final _clang_Cursor_getOffsetOfField = _clang_Cursor_getOffsetOfFieldPtr + .asFunction(); - /// Determine the number of diagnostics in a CXDiagnosticSet. - int clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags) { - return _clang_getNumDiagnosticsInSet(Diags); + /// Given a cursor that represents a declaration, return the associated + /// comment text, including comment markers. + CXString clang_Cursor_getRawCommentText(CXCursor C) { + return _clang_Cursor_getRawCommentText(C); } - late final _clang_getNumDiagnosticsInSetPtr = - _lookup>( - 'clang_getNumDiagnosticsInSet', + late final _clang_Cursor_getRawCommentTextPtr = + _lookup>( + 'clang_Cursor_getRawCommentText', ); - late final _clang_getNumDiagnosticsInSet = _clang_getNumDiagnosticsInSetPtr - .asFunction(); + late final _clang_Cursor_getRawCommentText = + _clang_Cursor_getRawCommentTextPtr + .asFunction(); - /// Retrieve a diagnostic associated with the given CXDiagnosticSet. - /// - /// \param Diags the CXDiagnosticSet to query. - /// \param Index the zero-based diagnostic number to retrieve. - /// - /// \returns the requested diagnostic. This diagnostic must be freed - /// via a call to \c clang_disposeDiagnostic(). - CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, int Index) { - return _clang_getDiagnosticInSet(Diags, Index); + /// Given a cursor pointing to an Objective-C message or property + /// reference, or C++ method call, returns the CXType of the receiver. + CXType clang_Cursor_getReceiverType(CXCursor C) { + return _clang_Cursor_getReceiverType(C); } - late final _clang_getDiagnosticInSetPtr = - _lookup>( - 'clang_getDiagnosticInSet', + late final _clang_Cursor_getReceiverTypePtr = + _lookup>( + 'clang_Cursor_getReceiverType', ); - late final _clang_getDiagnosticInSet = _clang_getDiagnosticInSetPtr - .asFunction(); + late final _clang_Cursor_getReceiverType = _clang_Cursor_getReceiverTypePtr + .asFunction(); - /// Deserialize a set of diagnostics from a Clang diagnostics bitcode - /// file. + /// Retrieve a range for a piece that forms the cursors spelling name. + /// Most of the times there is only one range for the complete spelling but for + /// Objective-C methods and Objective-C message expressions, there are multiple + /// pieces for each selector identifier. /// - /// \param file The name of the file to deserialize. - /// \param error A pointer to a enum value recording if there was a problem - /// deserializing the diagnostics. - /// \param errorString A pointer to a CXString for recording the error string - /// if the file was not successfully loaded. + /// \param pieceIndex the index of the spelling name piece. If this is greater + /// than the actual number of pieces, it will return a NULL (invalid) range. /// - /// \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These - /// diagnostics should be released using clang_disposeDiagnosticSet(). - CXDiagnosticSet clang_loadDiagnostics( - ffi.Pointer file, - ffi.Pointer error, - ffi.Pointer errorString, + /// \param options Reserved. + CXSourceRange clang_Cursor_getSpellingNameRange( + CXCursor arg0, + int pieceIndex, + int options, ) { - return _clang_loadDiagnostics(file, error, errorString); - } - - late final _clang_loadDiagnosticsPtr = - _lookup>( - 'clang_loadDiagnostics', - ); - late final _clang_loadDiagnostics = _clang_loadDiagnosticsPtr - .asFunction(); - - /// Release a CXDiagnosticSet and all of its contained diagnostics. - void clang_disposeDiagnosticSet(CXDiagnosticSet Diags) { - return _clang_disposeDiagnosticSet(Diags); + return _clang_Cursor_getSpellingNameRange(arg0, pieceIndex, options); } - late final _clang_disposeDiagnosticSetPtr = - _lookup>( - 'clang_disposeDiagnosticSet', + late final _clang_Cursor_getSpellingNameRangePtr = + _lookup>( + 'clang_Cursor_getSpellingNameRange', ); - late final _clang_disposeDiagnosticSet = _clang_disposeDiagnosticSetPtr - .asFunction(); + late final _clang_Cursor_getSpellingNameRange = + _clang_Cursor_getSpellingNameRangePtr + .asFunction(); - /// Retrieve the child diagnostics of a CXDiagnostic. + /// Returns the storage class for a function or variable declaration. /// - /// This CXDiagnosticSet does not need to be released by - /// clang_disposeDiagnosticSet. - CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D) { - return _clang_getChildDiagnostics(D); + /// If the passed in Cursor is not a function or variable declaration, + /// CX_SC_Invalid is returned else the storage class. + CX_StorageClass clang_Cursor_getStorageClass(CXCursor arg0) { + return CX_StorageClass.fromValue(_clang_Cursor_getStorageClass(arg0)); } - late final _clang_getChildDiagnosticsPtr = - _lookup>( - 'clang_getChildDiagnostics', + late final _clang_Cursor_getStorageClassPtr = + _lookup>( + 'clang_Cursor_getStorageClass', ); - late final _clang_getChildDiagnostics = _clang_getChildDiagnosticsPtr - .asFunction(); + late final _clang_Cursor_getStorageClass = _clang_Cursor_getStorageClassPtr + .asFunction(); - /// Determine the number of diagnostics produced for the given - /// translation unit. - int clang_getNumDiagnostics(CXTranslationUnit Unit) { - return _clang_getNumDiagnostics(Unit); + /// Retrieve the kind of the I'th template argument of the CXCursor C. + /// + /// If the argument CXCursor does not represent a FunctionDecl, an invalid + /// template argument kind is returned. + /// + /// For example, for the following declaration and specialization: + /// template + /// void foo() { ... } + /// + /// template <> + /// void foo(); + /// + /// For I = 0, 1, and 2, Type, Integral, and Integral will be returned, + /// respectively. + CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( + CXCursor C, + int I, + ) { + return CXTemplateArgumentKind.fromValue( + _clang_Cursor_getTemplateArgumentKind(C, I), + ); } - late final _clang_getNumDiagnosticsPtr = - _lookup>( - 'clang_getNumDiagnostics', + late final _clang_Cursor_getTemplateArgumentKindPtr = + _lookup>( + 'clang_Cursor_getTemplateArgumentKind', ); - late final _clang_getNumDiagnostics = _clang_getNumDiagnosticsPtr - .asFunction(); + late final _clang_Cursor_getTemplateArgumentKind = + _clang_Cursor_getTemplateArgumentKindPtr + .asFunction(); - /// Retrieve a diagnostic associated with the given translation unit. + /// Retrieve a CXType representing the type of a TemplateArgument of a + /// function decl representing a template specialization. /// - /// \param Unit the translation unit to query. - /// \param Index the zero-based diagnostic number to retrieve. + /// If the argument CXCursor does not represent a FunctionDecl whose I'th + /// template argument has a kind of CXTemplateArgKind_Integral, an invalid type + /// is returned. /// - /// \returns the requested diagnostic. This diagnostic must be freed - /// via a call to \c clang_disposeDiagnostic(). - CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, int Index) { - return _clang_getDiagnostic(Unit, Index); + /// For example, for the following declaration and specialization: + /// template + /// void foo() { ... } + /// + /// template <> + /// void foo(); + /// + /// If called with I = 0, "float", will be returned. + /// Invalid types will be returned for I == 1 or 2. + CXType clang_Cursor_getTemplateArgumentType(CXCursor C, int I) { + return _clang_Cursor_getTemplateArgumentType(C, I); } - late final _clang_getDiagnosticPtr = - _lookup>( - 'clang_getDiagnostic', + late final _clang_Cursor_getTemplateArgumentTypePtr = + _lookup>( + 'clang_Cursor_getTemplateArgumentType', ); - late final _clang_getDiagnostic = _clang_getDiagnosticPtr - .asFunction(); + late final _clang_Cursor_getTemplateArgumentType = + _clang_Cursor_getTemplateArgumentTypePtr + .asFunction(); - /// Retrieve the complete set of diagnostics associated with a - /// translation unit. + /// Retrieve the value of an Integral TemplateArgument (of a function + /// decl representing a template specialization) as an unsigned long long. /// - /// \param Unit the translation unit to query. - CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) { - return _clang_getDiagnosticSetFromTU(Unit); - } - - late final _clang_getDiagnosticSetFromTUPtr = - _lookup>( - 'clang_getDiagnosticSetFromTU', - ); - late final _clang_getDiagnosticSetFromTU = _clang_getDiagnosticSetFromTUPtr - .asFunction(); - - /// Destroy a diagnostic. - void clang_disposeDiagnostic(CXDiagnostic Diagnostic) { - return _clang_disposeDiagnostic(Diagnostic); + /// It is undefined to call this function on a CXCursor that does not represent a + /// FunctionDecl or whose I'th template argument is not an integral value. + /// + /// For example, for the following declaration and specialization: + /// template + /// void foo() { ... } + /// + /// template <> + /// void foo(); + /// + /// If called with I = 1 or 2, 2147483649 or true will be returned, respectively. + /// For I == 0, this function's behavior is undefined. + int clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, int I) { + return _clang_Cursor_getTemplateArgumentUnsignedValue(C, I); } - late final _clang_disposeDiagnosticPtr = - _lookup>( - 'clang_disposeDiagnostic', - ); - late final _clang_disposeDiagnostic = _clang_disposeDiagnosticPtr - .asFunction(); + late final _clang_Cursor_getTemplateArgumentUnsignedValuePtr = + _lookup< + ffi.NativeFunction + >('clang_Cursor_getTemplateArgumentUnsignedValue'); + late final _clang_Cursor_getTemplateArgumentUnsignedValue = + _clang_Cursor_getTemplateArgumentUnsignedValuePtr + .asFunction(); - /// Format the given diagnostic in a manner that is suitable for display. + /// Retrieve the value of an Integral TemplateArgument (of a function + /// decl representing a template specialization) as a signed long long. /// - /// This routine will format the given diagnostic to a string, rendering - /// the diagnostic according to the various options given. The - /// \c clang_defaultDiagnosticDisplayOptions() function returns the set of - /// options that most closely mimics the behavior of the clang compiler. + /// It is undefined to call this function on a CXCursor that does not represent a + /// FunctionDecl or whose I'th template argument is not an integral value. /// - /// \param Diagnostic The diagnostic to print. + /// For example, for the following declaration and specialization: + /// template + /// void foo() { ... } /// - /// \param Options A set of options that control the diagnostic display, - /// created by combining \c CXDiagnosticDisplayOptions values. + /// template <> + /// void foo(); /// - /// \returns A new string containing for formatted diagnostic. - CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, int Options) { - return _clang_formatDiagnostic(Diagnostic, Options); + /// If called with I = 1 or 2, -7 or true will be returned, respectively. + /// For I == 0, this function's behavior is undefined. + int clang_Cursor_getTemplateArgumentValue(CXCursor C, int I) { + return _clang_Cursor_getTemplateArgumentValue(C, I); } - late final _clang_formatDiagnosticPtr = - _lookup>( - 'clang_formatDiagnostic', + late final _clang_Cursor_getTemplateArgumentValuePtr = + _lookup>( + 'clang_Cursor_getTemplateArgumentValue', ); - late final _clang_formatDiagnostic = _clang_formatDiagnosticPtr - .asFunction(); + late final _clang_Cursor_getTemplateArgumentValue = + _clang_Cursor_getTemplateArgumentValuePtr + .asFunction(); - /// Retrieve the set of display options most similar to the - /// default behavior of the clang compiler. - /// - /// \returns A set of display options suitable for use with \c - /// clang_formatDiagnostic(). - int clang_defaultDiagnosticDisplayOptions() { - return _clang_defaultDiagnosticDisplayOptions(); + /// Returns the translation unit that a cursor originated from. + CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor arg0) { + return _clang_Cursor_getTranslationUnit(arg0); } - late final _clang_defaultDiagnosticDisplayOptionsPtr = - _lookup>( - 'clang_defaultDiagnosticDisplayOptions', + late final _clang_Cursor_getTranslationUnitPtr = + _lookup>( + 'clang_Cursor_getTranslationUnit', ); - late final _clang_defaultDiagnosticDisplayOptions = - _clang_defaultDiagnosticDisplayOptionsPtr - .asFunction(); + late final _clang_Cursor_getTranslationUnit = + _clang_Cursor_getTranslationUnitPtr + .asFunction(); - /// Determine the severity of the given diagnostic. - CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic arg0) { - return CXDiagnosticSeverity.fromValue(_clang_getDiagnosticSeverity(arg0)); + /// Determine whether the given cursor has any attributes. + int clang_Cursor_hasAttrs(CXCursor C) { + return _clang_Cursor_hasAttrs(C); } - late final _clang_getDiagnosticSeverityPtr = - _lookup>( - 'clang_getDiagnosticSeverity', + late final _clang_Cursor_hasAttrsPtr = + _lookup>( + 'clang_Cursor_hasAttrs', ); - late final _clang_getDiagnosticSeverity = _clang_getDiagnosticSeverityPtr - .asFunction(); + late final _clang_Cursor_hasAttrs = _clang_Cursor_hasAttrsPtr + .asFunction(); - /// Retrieve the source location of the given diagnostic. - /// - /// This location is where Clang would print the caret ('^') when - /// displaying the diagnostic on the command line. - CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic arg0) { - return _clang_getDiagnosticLocation(arg0); + /// Determine whether the given cursor represents an anonymous + /// tag or namespace + int clang_Cursor_isAnonymous(CXCursor C) { + return _clang_Cursor_isAnonymous(C); } - late final _clang_getDiagnosticLocationPtr = - _lookup>( - 'clang_getDiagnosticLocation', + late final _clang_Cursor_isAnonymousPtr = + _lookup>( + 'clang_Cursor_isAnonymous', ); - late final _clang_getDiagnosticLocation = _clang_getDiagnosticLocationPtr - .asFunction(); + late final _clang_Cursor_isAnonymous = _clang_Cursor_isAnonymousPtr + .asFunction(); - /// Retrieve the text of the given diagnostic. - CXString clang_getDiagnosticSpelling(CXDiagnostic arg0) { - return _clang_getDiagnosticSpelling(arg0); + /// Determine whether the given cursor represents an anonymous record + /// declaration. + int clang_Cursor_isAnonymousRecordDecl(CXCursor C) { + return _clang_Cursor_isAnonymousRecordDecl(C); } - late final _clang_getDiagnosticSpellingPtr = - _lookup>( - 'clang_getDiagnosticSpelling', + late final _clang_Cursor_isAnonymousRecordDeclPtr = + _lookup>( + 'clang_Cursor_isAnonymousRecordDecl', ); - late final _clang_getDiagnosticSpelling = _clang_getDiagnosticSpellingPtr - .asFunction(); + late final _clang_Cursor_isAnonymousRecordDecl = + _clang_Cursor_isAnonymousRecordDeclPtr + .asFunction(); - /// Retrieve the name of the command-line option that enabled this - /// diagnostic. - /// - /// \param Diag The diagnostic to be queried. - /// - /// \param Disable If non-NULL, will be set to the option that disables this - /// diagnostic (if any). - /// - /// \returns A string that contains the command-line option used to enable this - /// warning, such as "-Wconversion" or "-pedantic". - CXString clang_getDiagnosticOption( - CXDiagnostic Diag, - ffi.Pointer Disable, - ) { - return _clang_getDiagnosticOption(Diag, Disable); + /// Returns non-zero if the cursor specifies a Record member that is a + /// bitfield. + int clang_Cursor_isBitField(CXCursor C) { + return _clang_Cursor_isBitField(C); } - late final _clang_getDiagnosticOptionPtr = - _lookup>( - 'clang_getDiagnosticOption', + late final _clang_Cursor_isBitFieldPtr = + _lookup>( + 'clang_Cursor_isBitField', ); - late final _clang_getDiagnosticOption = _clang_getDiagnosticOptionPtr - .asFunction(); + late final _clang_Cursor_isBitField = _clang_Cursor_isBitFieldPtr + .asFunction(); - /// Retrieve the category number for this diagnostic. + /// Given a cursor pointing to a C++ method call or an Objective-C + /// message, returns non-zero if the method/message is "dynamic", meaning: /// - /// Diagnostics can be categorized into groups along with other, related - /// diagnostics (e.g., diagnostics under the same warning flag). This routine - /// retrieves the category number for the given diagnostic. + /// For a C++ method: the call is virtual. + /// For an Objective-C message: the receiver is an object instance, not 'super' + /// or a specific class. /// - /// \returns The number of the category that contains this diagnostic, or zero - /// if this diagnostic is uncategorized. - int clang_getDiagnosticCategory(CXDiagnostic arg0) { - return _clang_getDiagnosticCategory(arg0); + /// If the method/message is "static" or the cursor does not point to a + /// method/message, it will return zero. + int clang_Cursor_isDynamicCall(CXCursor C) { + return _clang_Cursor_isDynamicCall(C); } - late final _clang_getDiagnosticCategoryPtr = - _lookup>( - 'clang_getDiagnosticCategory', + late final _clang_Cursor_isDynamicCallPtr = + _lookup>( + 'clang_Cursor_isDynamicCall', ); - late final _clang_getDiagnosticCategory = _clang_getDiagnosticCategoryPtr - .asFunction(); + late final _clang_Cursor_isDynamicCall = _clang_Cursor_isDynamicCallPtr + .asFunction(); - /// Retrieve the name of a particular diagnostic category. This - /// is now deprecated. Use clang_getDiagnosticCategoryText() - /// instead. + /// Returns non-zero if the given cursor points to a symbol marked with + /// external_source_symbol attribute. /// - /// \param Category A diagnostic category number, as returned by - /// \c clang_getDiagnosticCategory(). + /// \param language If non-NULL, and the attribute is present, will be set to + /// the 'language' string from the attribute. /// - /// \returns The name of the given diagnostic category. - CXString clang_getDiagnosticCategoryName(int Category) { - return _clang_getDiagnosticCategoryName(Category); + /// \param definedIn If non-NULL, and the attribute is present, will be set to + /// the 'definedIn' string from the attribute. + /// + /// \param isGenerated If non-NULL, and the attribute is present, will be set to + /// non-zero if the 'generated_declaration' is set in the attribute. + int clang_Cursor_isExternalSymbol( + CXCursor C, + ffi.Pointer language, + ffi.Pointer definedIn, + ffi.Pointer isGenerated, + ) { + return _clang_Cursor_isExternalSymbol(C, language, definedIn, isGenerated); } - late final _clang_getDiagnosticCategoryNamePtr = - _lookup>( - 'clang_getDiagnosticCategoryName', + late final _clang_Cursor_isExternalSymbolPtr = + _lookup>( + 'clang_Cursor_isExternalSymbol', ); - late final _clang_getDiagnosticCategoryName = - _clang_getDiagnosticCategoryNamePtr - .asFunction(); + late final _clang_Cursor_isExternalSymbol = _clang_Cursor_isExternalSymbolPtr + .asFunction(); - /// Retrieve the diagnostic category text for a given diagnostic. - /// - /// \returns The text of the given diagnostic category. - CXString clang_getDiagnosticCategoryText(CXDiagnostic arg0) { - return _clang_getDiagnosticCategoryText(arg0); + /// Determine whether a CXCursor that is a function declaration, is an + /// inline declaration. + int clang_Cursor_isFunctionInlined(CXCursor C) { + return _clang_Cursor_isFunctionInlined(C); } - late final _clang_getDiagnosticCategoryTextPtr = - _lookup>( - 'clang_getDiagnosticCategoryText', - ); - late final _clang_getDiagnosticCategoryText = - _clang_getDiagnosticCategoryTextPtr - .asFunction(); + late final _clang_Cursor_isFunctionInlinedPtr = + _lookup>( + 'clang_Cursor_isFunctionInlined', + ); + late final _clang_Cursor_isFunctionInlined = + _clang_Cursor_isFunctionInlinedPtr + .asFunction(); - /// Determine the number of source ranges associated with the given - /// diagnostic. - int clang_getDiagnosticNumRanges(CXDiagnostic arg0) { - return _clang_getDiagnosticNumRanges(arg0); + /// Determine whether the given cursor represents an inline namespace + /// declaration. + int clang_Cursor_isInlineNamespace(CXCursor C) { + return _clang_Cursor_isInlineNamespace(C); } - late final _clang_getDiagnosticNumRangesPtr = - _lookup>( - 'clang_getDiagnosticNumRanges', + late final _clang_Cursor_isInlineNamespacePtr = + _lookup>( + 'clang_Cursor_isInlineNamespace', ); - late final _clang_getDiagnosticNumRanges = _clang_getDiagnosticNumRangesPtr - .asFunction(); + late final _clang_Cursor_isInlineNamespace = + _clang_Cursor_isInlineNamespacePtr + .asFunction(); - /// Retrieve a source range associated with the diagnostic. - /// - /// A diagnostic's source ranges highlight important elements in the source - /// code. On the command line, Clang displays source ranges by - /// underlining them with '~' characters. - /// - /// \param Diagnostic the diagnostic whose range is being extracted. - /// - /// \param Range the zero-based index specifying which range to - /// - /// \returns the requested source range. - CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, int Range) { - return _clang_getDiagnosticRange(Diagnostic, Range); + /// Determine whether a CXCursor that is a macro, is a + /// builtin one. + int clang_Cursor_isMacroBuiltin(CXCursor C) { + return _clang_Cursor_isMacroBuiltin(C); } - late final _clang_getDiagnosticRangePtr = - _lookup>( - 'clang_getDiagnosticRange', + late final _clang_Cursor_isMacroBuiltinPtr = + _lookup>( + 'clang_Cursor_isMacroBuiltin', ); - late final _clang_getDiagnosticRange = _clang_getDiagnosticRangePtr - .asFunction(); + late final _clang_Cursor_isMacroBuiltin = _clang_Cursor_isMacroBuiltinPtr + .asFunction(); - /// Determine the number of fix-it hints associated with the - /// given diagnostic. - int clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic) { - return _clang_getDiagnosticNumFixIts(Diagnostic); + /// Determine whether a CXCursor that is a macro, is + /// function like. + int clang_Cursor_isMacroFunctionLike(CXCursor C) { + return _clang_Cursor_isMacroFunctionLike(C); } - late final _clang_getDiagnosticNumFixItsPtr = - _lookup>( - 'clang_getDiagnosticNumFixIts', + late final _clang_Cursor_isMacroFunctionLikePtr = + _lookup>( + 'clang_Cursor_isMacroFunctionLike', ); - late final _clang_getDiagnosticNumFixIts = _clang_getDiagnosticNumFixItsPtr - .asFunction(); + late final _clang_Cursor_isMacroFunctionLike = + _clang_Cursor_isMacroFunctionLikePtr + .asFunction(); - /// Retrieve the replacement information for a given fix-it. - /// - /// Fix-its are described in terms of a source range whose contents - /// should be replaced by a string. This approach generalizes over - /// three kinds of operations: removal of source code (the range covers - /// the code to be removed and the replacement string is empty), - /// replacement of source code (the range covers the code to be - /// replaced and the replacement string provides the new code), and - /// insertion (both the start and end of the range point at the - /// insertion location, and the replacement string provides the text to - /// insert). - /// - /// \param Diagnostic The diagnostic whose fix-its are being queried. - /// - /// \param FixIt The zero-based index of the fix-it. - /// - /// \param ReplacementRange The source range whose contents will be - /// replaced with the returned replacement string. Note that source - /// ranges are half-open ranges [a, b), so the source code should be - /// replaced from a and up to (but not including) b. - /// - /// \returns A string containing text that should be replace the source - /// code indicated by the \c ReplacementRange. - CXString clang_getDiagnosticFixIt( - CXDiagnostic Diagnostic, - int FixIt, - ffi.Pointer ReplacementRange, - ) { - return _clang_getDiagnosticFixIt(Diagnostic, FixIt, ReplacementRange); + /// Returns non-zero if \p cursor is null. + int clang_Cursor_isNull(CXCursor cursor) { + return _clang_Cursor_isNull(cursor); } - late final _clang_getDiagnosticFixItPtr = - _lookup>( - 'clang_getDiagnosticFixIt', + late final _clang_Cursor_isNullPtr = + _lookup>( + 'clang_Cursor_isNull', ); - late final _clang_getDiagnosticFixIt = _clang_getDiagnosticFixItPtr - .asFunction(); + late final _clang_Cursor_isNull = _clang_Cursor_isNullPtr + .asFunction(); - /// Get the original translation unit source file name. - CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) { - return _clang_getTranslationUnitSpelling(CTUnit); + /// Given a cursor that represents an Objective-C method or property + /// declaration, return non-zero if the declaration was affected by "\@optional". + /// Returns zero if the cursor is not such a declaration or it is "\@required". + int clang_Cursor_isObjCOptional(CXCursor C) { + return _clang_Cursor_isObjCOptional(C); } - late final _clang_getTranslationUnitSpellingPtr = - _lookup>( - 'clang_getTranslationUnitSpelling', + late final _clang_Cursor_isObjCOptionalPtr = + _lookup>( + 'clang_Cursor_isObjCOptional', ); - late final _clang_getTranslationUnitSpelling = - _clang_getTranslationUnitSpellingPtr - .asFunction(); + late final _clang_Cursor_isObjCOptional = _clang_Cursor_isObjCOptionalPtr + .asFunction(); - /// Return the CXTranslationUnit for a given source file and the provided - /// command line arguments one would pass to the compiler. - /// - /// Note: The 'source_filename' argument is optional. If the caller provides a - /// NULL pointer, the name of the source file is expected to reside in the - /// specified command line arguments. - /// - /// Note: When encountered in 'clang_command_line_args', the following options - /// are ignored: - /// - /// '-c' - /// '-emit-ast' - /// '-fsyntax-only' - /// '-o \' (both '-o' and '\' are ignored) - /// - /// \param CIdx The index object with which the translation unit will be - /// associated. - /// - /// \param source_filename The name of the source file to load, or NULL if the - /// source file is included in \p clang_command_line_args. - /// - /// \param num_clang_command_line_args The number of command-line arguments in - /// \p clang_command_line_args. - /// - /// \param clang_command_line_args The command-line arguments that would be - /// passed to the \c clang executable if it were being invoked out-of-process. - /// These command-line options will be parsed and will affect how the translation - /// unit is parsed. Note that the following options are ignored: '-c', - /// '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. - /// - /// \param num_unsaved_files the number of unsaved file entries in \p - /// unsaved_files. - /// - /// \param unsaved_files the files that have not yet been saved to disk - /// but may be required for code completion, including the contents of - /// those files. The contents and name of these files (as specified by - /// CXUnsavedFile) are copied when necessary, so the client only needs to - /// guarantee their validity until the call to this function returns. - CXTranslationUnit clang_createTranslationUnitFromSourceFile( - CXIndex CIdx, - ffi.Pointer source_filename, - int num_clang_command_line_args, - ffi.Pointer> clang_command_line_args, - int num_unsaved_files, - ffi.Pointer unsaved_files, - ) { - return _clang_createTranslationUnitFromSourceFile( - CIdx, - source_filename, - num_clang_command_line_args, - clang_command_line_args, - num_unsaved_files, - unsaved_files, - ); + /// Returns non-zero if the given cursor is a variadic function or method. + int clang_Cursor_isVariadic(CXCursor C) { + return _clang_Cursor_isVariadic(C); } - late final _clang_createTranslationUnitFromSourceFilePtr = - _lookup< - ffi.NativeFunction - >('clang_createTranslationUnitFromSourceFile'); - late final _clang_createTranslationUnitFromSourceFile = - _clang_createTranslationUnitFromSourceFilePtr - .asFunction(); + late final _clang_Cursor_isVariadicPtr = + _lookup>( + 'clang_Cursor_isVariadic', + ); + late final _clang_Cursor_isVariadic = _clang_Cursor_isVariadicPtr + .asFunction(); - /// Same as \c clang_createTranslationUnit2, but returns - /// the \c CXTranslationUnit instead of an error code. In case of an error this - /// routine returns a \c NULL \c CXTranslationUnit, without further detailed - /// error codes. - CXTranslationUnit clang_createTranslationUnit( - CXIndex CIdx, - ffi.Pointer ast_filename, - ) { - return _clang_createTranslationUnit(CIdx, ast_filename); + /// Determine if an enum declaration refers to a scoped enum. + int clang_EnumDecl_isScoped(CXCursor C) { + return _clang_EnumDecl_isScoped(C); } - late final _clang_createTranslationUnitPtr = - _lookup>( - 'clang_createTranslationUnit', + late final _clang_EnumDecl_isScopedPtr = + _lookup>( + 'clang_EnumDecl_isScoped', ); - late final _clang_createTranslationUnit = _clang_createTranslationUnitPtr - .asFunction(); + late final _clang_EnumDecl_isScoped = _clang_EnumDecl_isScopedPtr + .asFunction(); - /// Create a translation unit from an AST file (\c -emit-ast). - /// - /// \param[out] out_TU A non-NULL pointer to store the created - /// \c CXTranslationUnit. - /// - /// \returns Zero on success, otherwise returns an error code. - CXErrorCode clang_createTranslationUnit2( - CXIndex CIdx, - ffi.Pointer ast_filename, - ffi.Pointer out_TU, - ) { - return CXErrorCode.fromValue( - _clang_createTranslationUnit2(CIdx, ast_filename, out_TU), - ); + /// Disposes the created Eval memory. + void clang_EvalResult_dispose(CXEvalResult E) { + return _clang_EvalResult_dispose(E); } - late final _clang_createTranslationUnit2Ptr = - _lookup>( - 'clang_createTranslationUnit2', + late final _clang_EvalResult_disposePtr = + _lookup>( + 'clang_EvalResult_dispose', ); - late final _clang_createTranslationUnit2 = _clang_createTranslationUnit2Ptr - .asFunction(); + late final _clang_EvalResult_dispose = _clang_EvalResult_disposePtr + .asFunction(); - /// Returns the set of flags that is suitable for parsing a translation - /// unit that is being edited. - /// - /// The set of flags returned provide options for \c clang_parseTranslationUnit() - /// to indicate that the translation unit is likely to be reparsed many times, - /// either explicitly (via \c clang_reparseTranslationUnit()) or implicitly - /// (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag - /// set contains an unspecified set of optimizations (e.g., the precompiled - /// preamble) geared toward improving the performance of these routines. The - /// set of optimizations enabled may change from one version to the next. - int clang_defaultEditingTranslationUnitOptions() { - return _clang_defaultEditingTranslationUnitOptions(); + /// Returns the evaluation result as double if the + /// kind is double. + double clang_EvalResult_getAsDouble(CXEvalResult E) { + return _clang_EvalResult_getAsDouble(E); } - late final _clang_defaultEditingTranslationUnitOptionsPtr = - _lookup< - ffi.NativeFunction - >('clang_defaultEditingTranslationUnitOptions'); - late final _clang_defaultEditingTranslationUnitOptions = - _clang_defaultEditingTranslationUnitOptionsPtr - .asFunction(); + late final _clang_EvalResult_getAsDoublePtr = + _lookup>( + 'clang_EvalResult_getAsDouble', + ); + late final _clang_EvalResult_getAsDouble = _clang_EvalResult_getAsDoublePtr + .asFunction(); - /// Same as \c clang_parseTranslationUnit2, but returns - /// the \c CXTranslationUnit instead of an error code. In case of an error this - /// routine returns a \c NULL \c CXTranslationUnit, without further detailed - /// error codes. - CXTranslationUnit clang_parseTranslationUnit( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ) { - return _clang_parseTranslationUnit( - CIdx, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - options, - ); + /// Returns the evaluation result as integer if the + /// kind is Int. + int clang_EvalResult_getAsInt(CXEvalResult E) { + return _clang_EvalResult_getAsInt(E); } - late final _clang_parseTranslationUnitPtr = - _lookup>( - 'clang_parseTranslationUnit', + late final _clang_EvalResult_getAsIntPtr = + _lookup>( + 'clang_EvalResult_getAsInt', ); - late final _clang_parseTranslationUnit = _clang_parseTranslationUnitPtr - .asFunction(); + late final _clang_EvalResult_getAsInt = _clang_EvalResult_getAsIntPtr + .asFunction(); - /// Parse the given source file and the translation unit corresponding - /// to that file. - /// - /// This routine is the main entry point for the Clang C API, providing the - /// ability to parse a source file into a translation unit that can then be - /// queried by other functions in the API. This routine accepts a set of - /// command-line arguments so that the compilation can be configured in the same - /// way that the compiler is configured on the command line. - /// - /// \param CIdx The index object with which the translation unit will be - /// associated. - /// - /// \param source_filename The name of the source file to load, or NULL if the - /// source file is included in \c command_line_args. - /// - /// \param command_line_args The command-line arguments that would be - /// passed to the \c clang executable if it were being invoked out-of-process. - /// These command-line options will be parsed and will affect how the translation - /// unit is parsed. Note that the following options are ignored: '-c', - /// '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. - /// - /// \param num_command_line_args The number of command-line arguments in - /// \c command_line_args. - /// - /// \param unsaved_files the files that have not yet been saved to disk - /// but may be required for parsing, including the contents of - /// those files. The contents and name of these files (as specified by - /// CXUnsavedFile) are copied when necessary, so the client only needs to - /// guarantee their validity until the call to this function returns. - /// - /// \param num_unsaved_files the number of unsaved file entries in \p - /// unsaved_files. - /// - /// \param options A bitmask of options that affects how the translation unit - /// is managed but not its compilation. This should be a bitwise OR of the - /// CXTranslationUnit_XXX flags. - /// - /// \param[out] out_TU A non-NULL pointer to store the created - /// \c CXTranslationUnit, describing the parsed code and containing any - /// diagnostics produced by the compiler. - /// - /// \returns Zero on success, otherwise returns an error code. - CXErrorCode clang_parseTranslationUnit2( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ffi.Pointer out_TU, - ) { - return CXErrorCode.fromValue( - _clang_parseTranslationUnit2( - CIdx, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - options, - out_TU, - ), - ); + /// Returns the evaluation result as a long long integer if the + /// kind is Int. This prevents overflows that may happen if the result is + /// returned with clang_EvalResult_getAsInt. + int clang_EvalResult_getAsLongLong(CXEvalResult E) { + return _clang_EvalResult_getAsLongLong(E); } - late final _clang_parseTranslationUnit2Ptr = - _lookup>( - 'clang_parseTranslationUnit2', + late final _clang_EvalResult_getAsLongLongPtr = + _lookup>( + 'clang_EvalResult_getAsLongLong', ); - late final _clang_parseTranslationUnit2 = _clang_parseTranslationUnit2Ptr - .asFunction(); + late final _clang_EvalResult_getAsLongLong = + _clang_EvalResult_getAsLongLongPtr + .asFunction(); - /// Same as clang_parseTranslationUnit2 but requires a full command line - /// for \c command_line_args including argv[0]. This is useful if the standard - /// library paths are relative to the binary. - CXErrorCode clang_parseTranslationUnit2FullArgv( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ffi.Pointer out_TU, - ) { - return CXErrorCode.fromValue( - _clang_parseTranslationUnit2FullArgv( - CIdx, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - options, - out_TU, - ), - ); + /// Returns the evaluation result as a constant string if the + /// kind is other than Int or float. User must not free this pointer, + /// instead call clang_EvalResult_dispose on the CXEvalResult returned + /// by clang_Cursor_Evaluate. + ffi.Pointer clang_EvalResult_getAsStr(CXEvalResult E) { + return _clang_EvalResult_getAsStr(E); } - late final _clang_parseTranslationUnit2FullArgvPtr = - _lookup>( - 'clang_parseTranslationUnit2FullArgv', + late final _clang_EvalResult_getAsStrPtr = + _lookup>( + 'clang_EvalResult_getAsStr', ); - late final _clang_parseTranslationUnit2FullArgv = - _clang_parseTranslationUnit2FullArgvPtr - .asFunction(); + late final _clang_EvalResult_getAsStr = _clang_EvalResult_getAsStrPtr + .asFunction(); - /// Returns the set of flags that is suitable for saving a translation - /// unit. - /// - /// The set of flags returned provide options for - /// \c clang_saveTranslationUnit() by default. The returned flag - /// set contains an unspecified set of options that save translation units with - /// the most commonly-requested data. - int clang_defaultSaveOptions(CXTranslationUnit TU) { - return _clang_defaultSaveOptions(TU); + /// Returns the evaluation result as an unsigned integer if + /// the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. + int clang_EvalResult_getAsUnsigned(CXEvalResult E) { + return _clang_EvalResult_getAsUnsigned(E); } - late final _clang_defaultSaveOptionsPtr = - _lookup>( - 'clang_defaultSaveOptions', + late final _clang_EvalResult_getAsUnsignedPtr = + _lookup>( + 'clang_EvalResult_getAsUnsigned', ); - late final _clang_defaultSaveOptions = _clang_defaultSaveOptionsPtr - .asFunction(); + late final _clang_EvalResult_getAsUnsigned = + _clang_EvalResult_getAsUnsignedPtr + .asFunction(); - /// Saves a translation unit into a serialized representation of - /// that translation unit on disk. - /// - /// Any translation unit that was parsed without error can be saved - /// into a file. The translation unit can then be deserialized into a - /// new \c CXTranslationUnit with \c clang_createTranslationUnit() or, - /// if it is an incomplete translation unit that corresponds to a - /// header, used as a precompiled header when parsing other translation - /// units. - /// - /// \param TU The translation unit to save. - /// - /// \param FileName The file to which the translation unit will be saved. - /// - /// \param options A bitmask of options that affects how the translation unit - /// is saved. This should be a bitwise OR of the - /// CXSaveTranslationUnit_XXX flags. - /// - /// \returns A value that will match one of the enumerators of the CXSaveError - /// enumeration. Zero (CXSaveError_None) indicates that the translation unit was - /// saved successfully, while a non-zero value indicates that a problem occurred. - int clang_saveTranslationUnit( - CXTranslationUnit TU, - ffi.Pointer FileName, - int options, - ) { - return _clang_saveTranslationUnit(TU, FileName, options); + /// Returns the kind of the evaluated result. + CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E) { + return CXEvalResultKind.fromValue(_clang_EvalResult_getKind(E)); } - late final _clang_saveTranslationUnitPtr = - _lookup>( - 'clang_saveTranslationUnit', + late final _clang_EvalResult_getKindPtr = + _lookup>( + 'clang_EvalResult_getKind', ); - late final _clang_saveTranslationUnit = _clang_saveTranslationUnitPtr - .asFunction(); + late final _clang_EvalResult_getKind = _clang_EvalResult_getKindPtr + .asFunction(); - /// Suspend a translation unit in order to free memory associated with it. - /// - /// A suspended translation unit uses significantly less memory but on the other - /// side does not support any other calls than \c clang_reparseTranslationUnit - /// to resume it or \c clang_disposeTranslationUnit to dispose it completely. - int clang_suspendTranslationUnit(CXTranslationUnit arg0) { - return _clang_suspendTranslationUnit(arg0); + /// Returns a non-zero value if the kind is Int and the evaluation + /// result resulted in an unsigned integer. + int clang_EvalResult_isUnsignedInt(CXEvalResult E) { + return _clang_EvalResult_isUnsignedInt(E); } - late final _clang_suspendTranslationUnitPtr = - _lookup>( - 'clang_suspendTranslationUnit', + late final _clang_EvalResult_isUnsignedIntPtr = + _lookup>( + 'clang_EvalResult_isUnsignedInt', ); - late final _clang_suspendTranslationUnit = _clang_suspendTranslationUnitPtr - .asFunction(); + late final _clang_EvalResult_isUnsignedInt = + _clang_EvalResult_isUnsignedIntPtr + .asFunction(); - /// Destroy the specified CXTranslationUnit object. - void clang_disposeTranslationUnit(CXTranslationUnit arg0) { - return _clang_disposeTranslationUnit(arg0); + /// Returns non-zero if the \c file1 and \c file2 point to the same file, + /// or they are both NULL. + int clang_File_isEqual(CXFile file1, CXFile file2) { + return _clang_File_isEqual(file1, file2); } - late final _clang_disposeTranslationUnitPtr = - _lookup>( - 'clang_disposeTranslationUnit', + late final _clang_File_isEqualPtr = + _lookup>( + 'clang_File_isEqual', ); - late final _clang_disposeTranslationUnit = _clang_disposeTranslationUnitPtr - .asFunction(); + late final _clang_File_isEqual = _clang_File_isEqualPtr + .asFunction(); - /// Returns the set of flags that is suitable for reparsing a translation - /// unit. + /// Returns the real path name of \c file. /// - /// The set of flags returned provide options for - /// \c clang_reparseTranslationUnit() by default. The returned flag - /// set contains an unspecified set of optimizations geared toward common uses - /// of reparsing. The set of optimizations enabled may change from one version - /// to the next. - int clang_defaultReparseOptions(CXTranslationUnit TU) { - return _clang_defaultReparseOptions(TU); + /// An empty string may be returned. Use \c clang_getFileName() in that case. + CXString clang_File_tryGetRealPathName(CXFile file) { + return _clang_File_tryGetRealPathName(file); } - late final _clang_defaultReparseOptionsPtr = - _lookup>( - 'clang_defaultReparseOptions', + late final _clang_File_tryGetRealPathNamePtr = + _lookup>( + 'clang_File_tryGetRealPathName', ); - late final _clang_defaultReparseOptions = _clang_defaultReparseOptionsPtr - .asFunction(); + late final _clang_File_tryGetRealPathName = _clang_File_tryGetRealPathNamePtr + .asFunction(); - /// Reparse the source files that produced this translation unit. - /// - /// This routine can be used to re-parse the source files that originally - /// created the given translation unit, for example because those source files - /// have changed (either on disk or as passed via \p unsaved_files). The - /// source code will be reparsed with the same command-line options as it - /// was originally parsed. - /// - /// Reparsing a translation unit invalidates all cursors and source locations - /// that refer into that translation unit. This makes reparsing a translation - /// unit semantically equivalent to destroying the translation unit and then - /// creating a new translation unit with the same command-line arguments. - /// However, it may be more efficient to reparse a translation - /// unit using this routine. - /// - /// \param TU The translation unit whose contents will be re-parsed. The - /// translation unit must originally have been built with - /// \c clang_createTranslationUnitFromSourceFile(). - /// - /// \param num_unsaved_files The number of unsaved file entries in \p - /// unsaved_files. - /// - /// \param unsaved_files The files that have not yet been saved to disk - /// but may be required for parsing, including the contents of - /// those files. The contents and name of these files (as specified by - /// CXUnsavedFile) are copied when necessary, so the client only needs to - /// guarantee their validity until the call to this function returns. - /// - /// \param options A bitset of options composed of the flags in CXReparse_Flags. - /// The function \c clang_defaultReparseOptions() produces a default set of - /// options recommended for most uses, based on the translation unit. + /// An indexing action/session, to be applied to one or multiple + /// translation units. /// - /// \returns 0 if the sources could be reparsed. A non-zero error code will be - /// returned if reparsing was impossible, such that the translation unit is - /// invalid. In such cases, the only valid call for \c TU is - /// \c clang_disposeTranslationUnit(TU). The error codes returned by this - /// routine are described by the \c CXErrorCode enum. - int clang_reparseTranslationUnit( - CXTranslationUnit TU, - int num_unsaved_files, - ffi.Pointer unsaved_files, - int options, - ) { - return _clang_reparseTranslationUnit( - TU, - num_unsaved_files, - unsaved_files, - options, - ); + /// \param CIdx The index object with which the index action will be associated. + CXIndexAction clang_IndexAction_create(CXIndex CIdx) { + return _clang_IndexAction_create(CIdx); } - late final _clang_reparseTranslationUnitPtr = - _lookup>( - 'clang_reparseTranslationUnit', + late final _clang_IndexAction_createPtr = + _lookup>( + 'clang_IndexAction_create', ); - late final _clang_reparseTranslationUnit = _clang_reparseTranslationUnitPtr - .asFunction(); + late final _clang_IndexAction_create = _clang_IndexAction_createPtr + .asFunction(); - /// Returns the human-readable null-terminated C string that represents - /// the name of the memory category. This string should never be freed. - ffi.Pointer clang_getTUResourceUsageName( - CXTUResourceUsageKind kind, - ) { - return _clang_getTUResourceUsageName(kind.value); + /// Destroy the given index action. + /// + /// The index action must not be destroyed until all of the translation units + /// created within that index action have been destroyed. + void clang_IndexAction_dispose(CXIndexAction arg0) { + return _clang_IndexAction_dispose(arg0); } - late final _clang_getTUResourceUsageNamePtr = - _lookup>( - 'clang_getTUResourceUsageName', + late final _clang_IndexAction_disposePtr = + _lookup>( + 'clang_IndexAction_dispose', ); - late final _clang_getTUResourceUsageName = _clang_getTUResourceUsageNamePtr - .asFunction(); + late final _clang_IndexAction_dispose = _clang_IndexAction_disposePtr + .asFunction(); - /// Return the memory usage of a translation unit. This object - /// should be released with clang_disposeCXTUResourceUsage(). - CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { - return _clang_getCXTUResourceUsage(TU); + /// Returns non-zero if the given source location is in the main file of + /// the corresponding translation unit. + int clang_Location_isFromMainFile(CXSourceLocation location) { + return _clang_Location_isFromMainFile(location); } - late final _clang_getCXTUResourceUsagePtr = - _lookup>( - 'clang_getCXTUResourceUsage', + late final _clang_Location_isFromMainFilePtr = + _lookup>( + 'clang_Location_isFromMainFile', ); - late final _clang_getCXTUResourceUsage = _clang_getCXTUResourceUsagePtr - .asFunction(); + late final _clang_Location_isFromMainFile = _clang_Location_isFromMainFilePtr + .asFunction(); - void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage) { - return _clang_disposeCXTUResourceUsage(usage); + /// Returns non-zero if the given source location is in a system header. + int clang_Location_isInSystemHeader(CXSourceLocation location) { + return _clang_Location_isInSystemHeader(location); } - late final _clang_disposeCXTUResourceUsagePtr = - _lookup>( - 'clang_disposeCXTUResourceUsage', + late final _clang_Location_isInSystemHeaderPtr = + _lookup>( + 'clang_Location_isInSystemHeader', ); - late final _clang_disposeCXTUResourceUsage = - _clang_disposeCXTUResourceUsagePtr - .asFunction(); + late final _clang_Location_isInSystemHeader = + _clang_Location_isInSystemHeaderPtr + .asFunction(); - /// Get target information for this translation unit. + /// \param Module a module object. /// - /// The CXTargetInfo object cannot outlive the CXTranslationUnit object. - CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit) { - return _clang_getTranslationUnitTargetInfo(CTUnit); + /// \returns the module file where the provided module object came from. + CXFile clang_Module_getASTFile(CXModule Module) { + return _clang_Module_getASTFile(Module); } - late final _clang_getTranslationUnitTargetInfoPtr = - _lookup>( - 'clang_getTranslationUnitTargetInfo', + late final _clang_Module_getASTFilePtr = + _lookup>( + 'clang_Module_getASTFile', ); - late final _clang_getTranslationUnitTargetInfo = - _clang_getTranslationUnitTargetInfoPtr - .asFunction(); + late final _clang_Module_getASTFile = _clang_Module_getASTFilePtr + .asFunction(); - /// Destroy the CXTargetInfo object. - void clang_TargetInfo_dispose(CXTargetInfo Info) { - return _clang_TargetInfo_dispose(Info); + /// \param Module a module object. + /// + /// \returns the full name of the module, e.g. "std.vector". + CXString clang_Module_getFullName(CXModule Module) { + return _clang_Module_getFullName(Module); } - late final _clang_TargetInfo_disposePtr = - _lookup>( - 'clang_TargetInfo_dispose', + late final _clang_Module_getFullNamePtr = + _lookup>( + 'clang_Module_getFullName', ); - late final _clang_TargetInfo_dispose = _clang_TargetInfo_disposePtr - .asFunction(); + late final _clang_Module_getFullName = _clang_Module_getFullNamePtr + .asFunction(); - /// Get the normalized target triple as a string. + /// \param Module a module object. /// - /// Returns the empty string in case of any error. - CXString clang_TargetInfo_getTriple(CXTargetInfo Info) { - return _clang_TargetInfo_getTriple(Info); + /// \returns the name of the module, e.g. for the 'std.vector' sub-module it + /// will return "vector". + CXString clang_Module_getName(CXModule Module) { + return _clang_Module_getName(Module); } - late final _clang_TargetInfo_getTriplePtr = - _lookup>( - 'clang_TargetInfo_getTriple', + late final _clang_Module_getNamePtr = + _lookup>( + 'clang_Module_getName', ); - late final _clang_TargetInfo_getTriple = _clang_TargetInfo_getTriplePtr - .asFunction(); + late final _clang_Module_getName = _clang_Module_getNamePtr + .asFunction(); - /// Get the pointer width of the target in bits. + /// \param Module a module object. /// - /// Returns -1 in case of error. - int clang_TargetInfo_getPointerWidth(CXTargetInfo Info) { - return _clang_TargetInfo_getPointerWidth(Info); + /// \returns the number of top level headers associated with this module. + int clang_Module_getNumTopLevelHeaders( + CXTranslationUnit arg0, + CXModule Module, + ) { + return _clang_Module_getNumTopLevelHeaders(arg0, Module); } - late final _clang_TargetInfo_getPointerWidthPtr = - _lookup>( - 'clang_TargetInfo_getPointerWidth', + late final _clang_Module_getNumTopLevelHeadersPtr = + _lookup>( + 'clang_Module_getNumTopLevelHeaders', ); - late final _clang_TargetInfo_getPointerWidth = - _clang_TargetInfo_getPointerWidthPtr - .asFunction(); + late final _clang_Module_getNumTopLevelHeaders = + _clang_Module_getNumTopLevelHeadersPtr + .asFunction(); - /// Retrieve the NULL cursor, which represents no entity. - CXCursor clang_getNullCursor() { - return _clang_getNullCursor(); + /// \param Module a module object. + /// + /// \returns the parent of a sub-module or NULL if the given module is top-level, + /// e.g. for 'std.vector' it will return the 'std' module. + CXModule clang_Module_getParent(CXModule Module) { + return _clang_Module_getParent(Module); } - late final _clang_getNullCursorPtr = - _lookup>( - 'clang_getNullCursor', + late final _clang_Module_getParentPtr = + _lookup>( + 'clang_Module_getParent', ); - late final _clang_getNullCursor = _clang_getNullCursorPtr - .asFunction(); + late final _clang_Module_getParent = _clang_Module_getParentPtr + .asFunction(); - /// Retrieve the cursor that represents the given translation unit. + /// \param Module a module object. /// - /// The translation unit cursor can be used to start traversing the - /// various declarations within the given translation unit. - CXCursor clang_getTranslationUnitCursor(CXTranslationUnit arg0) { - return _clang_getTranslationUnitCursor(arg0); + /// \param Index top level header index (zero-based). + /// + /// \returns the specified top level header associated with the module. + CXFile clang_Module_getTopLevelHeader( + CXTranslationUnit arg0, + CXModule Module, + int Index, + ) { + return _clang_Module_getTopLevelHeader(arg0, Module, Index); } - late final _clang_getTranslationUnitCursorPtr = - _lookup>( - 'clang_getTranslationUnitCursor', + late final _clang_Module_getTopLevelHeaderPtr = + _lookup>( + 'clang_Module_getTopLevelHeader', ); - late final _clang_getTranslationUnitCursor = - _clang_getTranslationUnitCursorPtr - .asFunction(); + late final _clang_Module_getTopLevelHeader = + _clang_Module_getTopLevelHeaderPtr + .asFunction(); - /// Determine whether two cursors are equivalent. - int clang_equalCursors(CXCursor arg0, CXCursor arg1) { - return _clang_equalCursors(arg0, arg1); + /// \param Module a module object. + /// + /// \returns non-zero if the module is a system one. + int clang_Module_isSystem(CXModule Module) { + return _clang_Module_isSystem(Module); } - late final _clang_equalCursorsPtr = - _lookup>( - 'clang_equalCursors', + late final _clang_Module_isSystemPtr = + _lookup>( + 'clang_Module_isSystem', ); - late final _clang_equalCursors = _clang_equalCursorsPtr - .asFunction(); + late final _clang_Module_isSystem = _clang_Module_isSystemPtr + .asFunction(); - /// Returns non-zero if \p cursor is null. - int clang_Cursor_isNull(CXCursor cursor) { - return _clang_Cursor_isNull(cursor); + /// Release a printing policy. + void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy) { + return _clang_PrintingPolicy_dispose(Policy); } - late final _clang_Cursor_isNullPtr = - _lookup>( - 'clang_Cursor_isNull', + late final _clang_PrintingPolicy_disposePtr = + _lookup>( + 'clang_PrintingPolicy_dispose', ); - late final _clang_Cursor_isNull = _clang_Cursor_isNullPtr - .asFunction(); + late final _clang_PrintingPolicy_dispose = _clang_PrintingPolicy_disposePtr + .asFunction(); - /// Compute a hash value for the given cursor. - int clang_hashCursor(CXCursor arg0) { - return _clang_hashCursor(arg0); + /// Get a property value for the given printing policy. + int clang_PrintingPolicy_getProperty( + CXPrintingPolicy Policy, + CXPrintingPolicyProperty Property, + ) { + return _clang_PrintingPolicy_getProperty(Policy, Property.value); } - late final _clang_hashCursorPtr = - _lookup>('clang_hashCursor'); - late final _clang_hashCursor = _clang_hashCursorPtr - .asFunction(); + late final _clang_PrintingPolicy_getPropertyPtr = + _lookup>( + 'clang_PrintingPolicy_getProperty', + ); + late final _clang_PrintingPolicy_getProperty = + _clang_PrintingPolicy_getPropertyPtr + .asFunction(); - /// Retrieve the kind of the given cursor. - CXCursorKind clang_getCursorKind(CXCursor arg0) { - return CXCursorKind.fromValue(_clang_getCursorKind(arg0)); + /// Set a property value for the given printing policy. + void clang_PrintingPolicy_setProperty( + CXPrintingPolicy Policy, + CXPrintingPolicyProperty Property, + int Value, + ) { + return _clang_PrintingPolicy_setProperty(Policy, Property.value, Value); } - late final _clang_getCursorKindPtr = - _lookup>( - 'clang_getCursorKind', + late final _clang_PrintingPolicy_setPropertyPtr = + _lookup>( + 'clang_PrintingPolicy_setProperty', ); - late final _clang_getCursorKind = _clang_getCursorKindPtr - .asFunction(); + late final _clang_PrintingPolicy_setProperty = + _clang_PrintingPolicy_setPropertyPtr + .asFunction(); - /// Determine whether the given cursor kind represents a declaration. - int clang_isDeclaration(CXCursorKind arg0) { - return _clang_isDeclaration(arg0.value); + /// Returns non-zero if \p range is null. + int clang_Range_isNull(CXSourceRange range) { + return _clang_Range_isNull(range); } - late final _clang_isDeclarationPtr = - _lookup>( - 'clang_isDeclaration', + late final _clang_Range_isNullPtr = + _lookup>( + 'clang_Range_isNull', ); - late final _clang_isDeclaration = _clang_isDeclarationPtr - .asFunction(); + late final _clang_Range_isNull = _clang_Range_isNullPtr + .asFunction(); - /// Determine whether the given declaration is invalid. - /// - /// A declaration is invalid if it could not be parsed successfully. - /// - /// \returns non-zero if the cursor represents a declaration and it is - /// invalid, otherwise NULL. - int clang_isInvalidDeclaration(CXCursor arg0) { - return _clang_isInvalidDeclaration(arg0); + /// Destroy the CXTargetInfo object. + void clang_TargetInfo_dispose(CXTargetInfo Info) { + return _clang_TargetInfo_dispose(Info); } - late final _clang_isInvalidDeclarationPtr = - _lookup>( - 'clang_isInvalidDeclaration', + late final _clang_TargetInfo_disposePtr = + _lookup>( + 'clang_TargetInfo_dispose', ); - late final _clang_isInvalidDeclaration = _clang_isInvalidDeclarationPtr - .asFunction(); + late final _clang_TargetInfo_dispose = _clang_TargetInfo_disposePtr + .asFunction(); - /// Determine whether the given cursor kind represents a simple - /// reference. + /// Get the pointer width of the target in bits. /// - /// Note that other kinds of cursors (such as expressions) can also refer to - /// other cursors. Use clang_getCursorReferenced() to determine whether a - /// particular cursor refers to another entity. - int clang_isReference(CXCursorKind arg0) { - return _clang_isReference(arg0.value); + /// Returns -1 in case of error. + int clang_TargetInfo_getPointerWidth(CXTargetInfo Info) { + return _clang_TargetInfo_getPointerWidth(Info); } - late final _clang_isReferencePtr = - _lookup>('clang_isReference'); - late final _clang_isReference = _clang_isReferencePtr - .asFunction(); + late final _clang_TargetInfo_getPointerWidthPtr = + _lookup>( + 'clang_TargetInfo_getPointerWidth', + ); + late final _clang_TargetInfo_getPointerWidth = + _clang_TargetInfo_getPointerWidthPtr + .asFunction(); - /// Determine whether the given cursor kind represents an expression. - int clang_isExpression(CXCursorKind arg0) { - return _clang_isExpression(arg0.value); + /// Get the normalized target triple as a string. + /// + /// Returns the empty string in case of any error. + CXString clang_TargetInfo_getTriple(CXTargetInfo Info) { + return _clang_TargetInfo_getTriple(Info); } - late final _clang_isExpressionPtr = - _lookup>( - 'clang_isExpression', + late final _clang_TargetInfo_getTriplePtr = + _lookup>( + 'clang_TargetInfo_getTriple', ); - late final _clang_isExpression = _clang_isExpressionPtr - .asFunction(); + late final _clang_TargetInfo_getTriple = _clang_TargetInfo_getTriplePtr + .asFunction(); - /// Determine whether the given cursor kind represents a statement. - int clang_isStatement(CXCursorKind arg0) { - return _clang_isStatement(arg0.value); + /// Return the alignment of a type in bytes as per C++[expr.alignof] + /// standard. + /// + /// If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + /// If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + /// is returned. + /// If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + /// returned. + /// If the type declaration is not a constant size type, + /// CXTypeLayoutError_NotConstantSize is returned. + int clang_Type_getAlignOf(CXType T) { + return _clang_Type_getAlignOf(T); } - late final _clang_isStatementPtr = - _lookup>('clang_isStatement'); - late final _clang_isStatement = _clang_isStatementPtr - .asFunction(); + late final _clang_Type_getAlignOfPtr = + _lookup>( + 'clang_Type_getAlignOf', + ); + late final _clang_Type_getAlignOf = _clang_Type_getAlignOfPtr + .asFunction(); - /// Determine whether the given cursor kind represents an attribute. - int clang_isAttribute(CXCursorKind arg0) { - return _clang_isAttribute(arg0.value); + /// Retrieve the ref-qualifier kind of a function or method. + /// + /// The ref-qualifier is returned for C++ functions or methods. For other types + /// or non-C++ declarations, CXRefQualifier_None is returned. + CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T) { + return CXRefQualifierKind.fromValue(_clang_Type_getCXXRefQualifier(T)); } - late final _clang_isAttributePtr = - _lookup>('clang_isAttribute'); - late final _clang_isAttribute = _clang_isAttributePtr - .asFunction(); + late final _clang_Type_getCXXRefQualifierPtr = + _lookup>( + 'clang_Type_getCXXRefQualifier', + ); + late final _clang_Type_getCXXRefQualifier = _clang_Type_getCXXRefQualifierPtr + .asFunction(); - /// Determine whether the given cursor has any attributes. - int clang_Cursor_hasAttrs(CXCursor C) { - return _clang_Cursor_hasAttrs(C); + /// Return the class type of an member pointer type. + /// + /// If a non-member-pointer type is passed in, an invalid type is returned. + CXType clang_Type_getClassType(CXType T) { + return _clang_Type_getClassType(T); } - late final _clang_Cursor_hasAttrsPtr = - _lookup>( - 'clang_Cursor_hasAttrs', + late final _clang_Type_getClassTypePtr = + _lookup>( + 'clang_Type_getClassType', ); - late final _clang_Cursor_hasAttrs = _clang_Cursor_hasAttrsPtr - .asFunction(); + late final _clang_Type_getClassType = _clang_Type_getClassTypePtr + .asFunction(); - /// Determine whether the given cursor kind represents an invalid - /// cursor. - int clang_isInvalid(CXCursorKind arg0) { - return _clang_isInvalid(arg0.value); + /// Return the type that was modified by this attributed type. + /// + /// If the type is not an attributed type, an invalid type is returned. + CXType clang_Type_getModifiedType(CXType T) { + return _clang_Type_getModifiedType(T); } - late final _clang_isInvalidPtr = - _lookup>('clang_isInvalid'); - late final _clang_isInvalid = _clang_isInvalidPtr - .asFunction(); + late final _clang_Type_getModifiedTypePtr = + _lookup>( + 'clang_Type_getModifiedType', + ); + late final _clang_Type_getModifiedType = _clang_Type_getModifiedTypePtr + .asFunction(); - /// Determine whether the given cursor kind represents a translation - /// unit. - int clang_isTranslationUnit(CXCursorKind arg0) { - return _clang_isTranslationUnit(arg0.value); + /// Retrieve the type named by the qualified-id. + /// + /// If a non-elaborated type is passed in, an invalid type is returned. + CXType clang_Type_getNamedType(CXType T) { + return _clang_Type_getNamedType(T); } - late final _clang_isTranslationUnitPtr = - _lookup>( - 'clang_isTranslationUnit', + late final _clang_Type_getNamedTypePtr = + _lookup>( + 'clang_Type_getNamedType', ); - late final _clang_isTranslationUnit = _clang_isTranslationUnitPtr - .asFunction(); + late final _clang_Type_getNamedType = _clang_Type_getNamedTypePtr + .asFunction(); - /// Determine whether the given cursor represents a preprocessing - /// element, such as a preprocessor directive or macro instantiation. - int clang_isPreprocessing(CXCursorKind arg0) { - return _clang_isPreprocessing(arg0.value); + /// Retrieve the nullability kind of a pointer type. + CXTypeNullabilityKind clang_Type_getNullability(CXType T) { + return CXTypeNullabilityKind.fromValue(_clang_Type_getNullability(T)); } - late final _clang_isPreprocessingPtr = - _lookup>( - 'clang_isPreprocessing', + late final _clang_Type_getNullabilityPtr = + _lookup>( + 'clang_Type_getNullability', ); - late final _clang_isPreprocessing = _clang_isPreprocessingPtr - .asFunction(); + late final _clang_Type_getNullability = _clang_Type_getNullabilityPtr + .asFunction(); - /// Determine whether the given cursor represents a currently - /// unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). - int clang_isUnexposed(CXCursorKind arg0) { - return _clang_isUnexposed(arg0.value); + /// Retrieve the number of protocol references associated with an ObjC object/id. + /// + /// If the type is not an ObjC object, 0 is returned. + int clang_Type_getNumObjCProtocolRefs(CXType T) { + return _clang_Type_getNumObjCProtocolRefs(T); } - late final _clang_isUnexposedPtr = - _lookup>('clang_isUnexposed'); - late final _clang_isUnexposed = _clang_isUnexposedPtr - .asFunction(); + late final _clang_Type_getNumObjCProtocolRefsPtr = + _lookup>( + 'clang_Type_getNumObjCProtocolRefs', + ); + late final _clang_Type_getNumObjCProtocolRefs = + _clang_Type_getNumObjCProtocolRefsPtr + .asFunction(); - /// Determine the linkage of the entity referred to by a given cursor. - CXLinkageKind clang_getCursorLinkage(CXCursor cursor) { - return CXLinkageKind.fromValue(_clang_getCursorLinkage(cursor)); + /// Retreive the number of type arguments associated with an ObjC object. + /// + /// If the type is not an ObjC object, 0 is returned. + int clang_Type_getNumObjCTypeArgs(CXType T) { + return _clang_Type_getNumObjCTypeArgs(T); } - late final _clang_getCursorLinkagePtr = - _lookup>( - 'clang_getCursorLinkage', + late final _clang_Type_getNumObjCTypeArgsPtr = + _lookup>( + 'clang_Type_getNumObjCTypeArgs', ); - late final _clang_getCursorLinkage = _clang_getCursorLinkagePtr - .asFunction(); + late final _clang_Type_getNumObjCTypeArgs = _clang_Type_getNumObjCTypeArgsPtr + .asFunction(); - /// Describe the visibility of the entity referred to by a cursor. - /// - /// This returns the default visibility if not explicitly specified by - /// a visibility attribute. The default visibility may be changed by - /// commandline arguments. - /// - /// \param cursor The cursor to query. - /// - /// \returns The visibility of the cursor. - CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) { - return CXVisibilityKind.fromValue(_clang_getCursorVisibility(cursor)); + /// Returns the number of template arguments for given template + /// specialization, or -1 if type \c T is not a template specialization. + int clang_Type_getNumTemplateArguments(CXType T) { + return _clang_Type_getNumTemplateArguments(T); } - late final _clang_getCursorVisibilityPtr = - _lookup>( - 'clang_getCursorVisibility', + late final _clang_Type_getNumTemplateArgumentsPtr = + _lookup>( + 'clang_Type_getNumTemplateArguments', ); - late final _clang_getCursorVisibility = _clang_getCursorVisibilityPtr - .asFunction(); + late final _clang_Type_getNumTemplateArguments = + _clang_Type_getNumTemplateArgumentsPtr + .asFunction(); - /// Determine the availability of the entity that this cursor refers to, - /// taking the current target platform into account. - /// - /// \param cursor The cursor to query. - /// - /// \returns The availability of the cursor. - CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) { - return CXAvailabilityKind.fromValue(_clang_getCursorAvailability(cursor)); + /// Returns the Objective-C type encoding for the specified CXType. + CXString clang_Type_getObjCEncoding(CXType type) { + return _clang_Type_getObjCEncoding(type); } - late final _clang_getCursorAvailabilityPtr = - _lookup>( - 'clang_getCursorAvailability', + late final _clang_Type_getObjCEncodingPtr = + _lookup>( + 'clang_Type_getObjCEncoding', ); - late final _clang_getCursorAvailability = _clang_getCursorAvailabilityPtr - .asFunction(); + late final _clang_Type_getObjCEncoding = _clang_Type_getObjCEncodingPtr + .asFunction(); - /// Determine the availability of the entity that this cursor refers to - /// on any platforms for which availability information is known. - /// - /// \param cursor The cursor to query. - /// - /// \param always_deprecated If non-NULL, will be set to indicate whether the - /// entity is deprecated on all platforms. - /// - /// \param deprecated_message If non-NULL, will be set to the message text - /// provided along with the unconditional deprecation of this entity. The client - /// is responsible for deallocating this string. - /// - /// \param always_unavailable If non-NULL, will be set to indicate whether the - /// entity is unavailable on all platforms. - /// - /// \param unavailable_message If non-NULL, will be set to the message text - /// provided along with the unconditional unavailability of this entity. The - /// client is responsible for deallocating this string. - /// - /// \param availability If non-NULL, an array of CXPlatformAvailability instances - /// that will be populated with platform availability information, up to either - /// the number of platforms for which availability information is available (as - /// returned by this function) or \c availability_size, whichever is smaller. - /// - /// \param availability_size The number of elements available in the - /// \c availability array. - /// - /// \returns The number of platforms (N) for which availability information is - /// available (which is unrelated to \c availability_size). + /// Retrieves the base type of the ObjCObjectType. /// - /// Note that the client is responsible for calling - /// \c clang_disposeCXPlatformAvailability to free each of the - /// platform-availability structures returned. There are - /// \c min(N, availability_size) such structures. - int clang_getCursorPlatformAvailability( - CXCursor cursor, - ffi.Pointer always_deprecated, - ffi.Pointer deprecated_message, - ffi.Pointer always_unavailable, - ffi.Pointer unavailable_message, - ffi.Pointer availability, - int availability_size, - ) { - return _clang_getCursorPlatformAvailability( - cursor, - always_deprecated, - deprecated_message, - always_unavailable, - unavailable_message, - availability, - availability_size, - ); + /// If the type is not an ObjC object, an invalid type is returned. + CXType clang_Type_getObjCObjectBaseType(CXType T) { + return _clang_Type_getObjCObjectBaseType(T); } - late final _clang_getCursorPlatformAvailabilityPtr = - _lookup>( - 'clang_getCursorPlatformAvailability', + late final _clang_Type_getObjCObjectBaseTypePtr = + _lookup>( + 'clang_Type_getObjCObjectBaseType', ); - late final _clang_getCursorPlatformAvailability = - _clang_getCursorPlatformAvailabilityPtr - .asFunction(); + late final _clang_Type_getObjCObjectBaseType = + _clang_Type_getObjCObjectBaseTypePtr + .asFunction(); - /// Free the memory associated with a \c CXPlatformAvailability structure. - void clang_disposeCXPlatformAvailability( - ffi.Pointer availability, - ) { - return _clang_disposeCXPlatformAvailability(availability); + /// Retrieve the decl for a protocol reference for an ObjC object/id. + /// + /// If the type is not an ObjC object or there are not enough protocol + /// references, an invalid cursor is returned. + CXCursor clang_Type_getObjCProtocolDecl(CXType T, int i) { + return _clang_Type_getObjCProtocolDecl(T, i); } - late final _clang_disposeCXPlatformAvailabilityPtr = - _lookup>( - 'clang_disposeCXPlatformAvailability', + late final _clang_Type_getObjCProtocolDeclPtr = + _lookup>( + 'clang_Type_getObjCProtocolDecl', ); - late final _clang_disposeCXPlatformAvailability = - _clang_disposeCXPlatformAvailabilityPtr - .asFunction(); + late final _clang_Type_getObjCProtocolDecl = + _clang_Type_getObjCProtocolDeclPtr + .asFunction(); - /// Determine the "language" of the entity referred to by a given cursor. - CXLanguageKind clang_getCursorLanguage(CXCursor cursor) { - return CXLanguageKind.fromValue(_clang_getCursorLanguage(cursor)); + /// Retrieve a type argument associated with an ObjC object. + /// + /// If the type is not an ObjC or the index is not valid, + /// an invalid type is returned. + CXType clang_Type_getObjCTypeArg(CXType T, int i) { + return _clang_Type_getObjCTypeArg(T, i); } - late final _clang_getCursorLanguagePtr = - _lookup>( - 'clang_getCursorLanguage', + late final _clang_Type_getObjCTypeArgPtr = + _lookup>( + 'clang_Type_getObjCTypeArg', ); - late final _clang_getCursorLanguage = _clang_getCursorLanguagePtr - .asFunction(); + late final _clang_Type_getObjCTypeArg = _clang_Type_getObjCTypeArgPtr + .asFunction(); - /// Determine the "thread-local storage (TLS) kind" of the declaration - /// referred to by a cursor. - CXTLSKind clang_getCursorTLSKind(CXCursor cursor) { - return CXTLSKind.fromValue(_clang_getCursorTLSKind(cursor)); - } - - late final _clang_getCursorTLSKindPtr = - _lookup>( - 'clang_getCursorTLSKind', - ); - late final _clang_getCursorTLSKind = _clang_getCursorTLSKindPtr - .asFunction(); - - /// Returns the translation unit that a cursor originated from. - CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor arg0) { - return _clang_Cursor_getTranslationUnit(arg0); - } - - late final _clang_Cursor_getTranslationUnitPtr = - _lookup>( - 'clang_Cursor_getTranslationUnit', - ); - late final _clang_Cursor_getTranslationUnit = - _clang_Cursor_getTranslationUnitPtr - .asFunction(); - - /// Creates an empty CXCursorSet. - CXCursorSet clang_createCXCursorSet() { - return _clang_createCXCursorSet(); + /// Return the offset of a field named S in a record of type T in bits + /// as it would be returned by __offsetof__ as per C++11[18.2p4] + /// + /// If the cursor is not a record field declaration, CXTypeLayoutError_Invalid + /// is returned. + /// If the field's type declaration is an incomplete type, + /// CXTypeLayoutError_Incomplete is returned. + /// If the field's type declaration is a dependent type, + /// CXTypeLayoutError_Dependent is returned. + /// If the field's name S is not found, + /// CXTypeLayoutError_InvalidFieldName is returned. + int clang_Type_getOffsetOf(CXType T, ffi.Pointer S) { + return _clang_Type_getOffsetOf(T, S); } - late final _clang_createCXCursorSetPtr = - _lookup>( - 'clang_createCXCursorSet', + late final _clang_Type_getOffsetOfPtr = + _lookup>( + 'clang_Type_getOffsetOf', ); - late final _clang_createCXCursorSet = _clang_createCXCursorSetPtr - .asFunction(); + late final _clang_Type_getOffsetOf = _clang_Type_getOffsetOfPtr + .asFunction(); - /// Disposes a CXCursorSet and releases its associated memory. - void clang_disposeCXCursorSet(CXCursorSet cset) { - return _clang_disposeCXCursorSet(cset); + /// Return the size of a type in bytes as per C++[expr.sizeof] standard. + /// + /// If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. + /// If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete + /// is returned. + /// If the type declaration is a dependent type, CXTypeLayoutError_Dependent is + /// returned. + int clang_Type_getSizeOf(CXType T) { + return _clang_Type_getSizeOf(T); } - late final _clang_disposeCXCursorSetPtr = - _lookup>( - 'clang_disposeCXCursorSet', + late final _clang_Type_getSizeOfPtr = + _lookup>( + 'clang_Type_getSizeOf', ); - late final _clang_disposeCXCursorSet = _clang_disposeCXCursorSetPtr - .asFunction(); + late final _clang_Type_getSizeOf = _clang_Type_getSizeOfPtr + .asFunction(); - /// Queries a CXCursorSet to see if it contains a specific CXCursor. + /// Returns the type template argument of a template class specialization + /// at given index. /// - /// \returns non-zero if the set contains the specified cursor. - int clang_CXCursorSet_contains(CXCursorSet cset, CXCursor cursor) { - return _clang_CXCursorSet_contains(cset, cursor); + /// This function only returns template type arguments and does not handle + /// template template arguments or variadic packs. + CXType clang_Type_getTemplateArgumentAsType(CXType T, int i) { + return _clang_Type_getTemplateArgumentAsType(T, i); } - late final _clang_CXCursorSet_containsPtr = - _lookup>( - 'clang_CXCursorSet_contains', + late final _clang_Type_getTemplateArgumentAsTypePtr = + _lookup>( + 'clang_Type_getTemplateArgumentAsType', ); - late final _clang_CXCursorSet_contains = _clang_CXCursorSet_containsPtr - .asFunction(); + late final _clang_Type_getTemplateArgumentAsType = + _clang_Type_getTemplateArgumentAsTypePtr + .asFunction(); - /// Inserts a CXCursor into a CXCursorSet. + /// Determine if a typedef is 'transparent' tag. /// - /// \returns zero if the CXCursor was already in the set, and non-zero otherwise. - int clang_CXCursorSet_insert(CXCursorSet cset, CXCursor cursor) { - return _clang_CXCursorSet_insert(cset, cursor); + /// A typedef is considered 'transparent' if it shares a name and spelling + /// location with its underlying tag type, as is the case with the NS_ENUM macro. + /// + /// \returns non-zero if transparent and zero otherwise. + int clang_Type_isTransparentTagTypedef(CXType T) { + return _clang_Type_isTransparentTagTypedef(T); } - late final _clang_CXCursorSet_insertPtr = - _lookup>( - 'clang_CXCursorSet_insert', + late final _clang_Type_isTransparentTagTypedefPtr = + _lookup>( + 'clang_Type_isTransparentTagTypedef', ); - late final _clang_CXCursorSet_insert = _clang_CXCursorSet_insertPtr - .asFunction(); + late final _clang_Type_isTransparentTagTypedef = + _clang_Type_isTransparentTagTypedefPtr + .asFunction(); - /// Determine the semantic parent of the given cursor. - /// - /// The semantic parent of a cursor is the cursor that semantically contains - /// the given \p cursor. For many declarations, the lexical and semantic parents - /// are equivalent (the lexical parent is returned by - /// \c clang_getCursorLexicalParent()). They diverge when declarations or - /// definitions are provided out-of-line. For example: + /// Visit the fields of a particular type. /// - /// \code - /// class C { - /// void f(); - /// }; + /// This function visits all the direct fields of the given cursor, + /// invoking the given \p visitor function with the cursors of each + /// visited field. The traversal may be ended prematurely, if + /// the visitor returns \c CXFieldVisit_Break. /// - /// void C::f() { } - /// \endcode + /// \param T the record type whose field may be visited. /// - /// In the out-of-line definition of \c C::f, the semantic parent is - /// the class \c C, of which this function is a member. The lexical parent is - /// the place where the declaration actually occurs in the source code; in this - /// case, the definition occurs in the translation unit. In general, the - /// lexical parent for a given entity can change without affecting the semantics - /// of the program, and the lexical parent of different declarations of the - /// same entity may be different. Changing the semantic parent of a declaration, - /// on the other hand, can have a major impact on semantics, and redeclarations - /// of a particular entity should all have the same semantic context. + /// \param visitor the visitor function that will be invoked for each + /// field of \p T. /// - /// In the example above, both declarations of \c C::f have \c C as their - /// semantic context, while the lexical context of the first \c C::f is \c C - /// and the lexical context of the second \c C::f is the translation unit. + /// \param client_data pointer data supplied by the client, which will + /// be passed to the visitor each time it is invoked. /// - /// For global declarations, the semantic parent is the translation unit. - CXCursor clang_getCursorSemanticParent(CXCursor cursor) { - return _clang_getCursorSemanticParent(cursor); + /// \returns a non-zero value if the traversal was terminated + /// prematurely by the visitor returning \c CXFieldVisit_Break. + int clang_Type_visitFields( + CXType T, + CXFieldVisitor visitor, + CXClientData client_data, + ) { + return _clang_Type_visitFields(T, visitor, client_data); } - late final _clang_getCursorSemanticParentPtr = - _lookup>( - 'clang_getCursorSemanticParent', + late final _clang_Type_visitFieldsPtr = + _lookup>( + 'clang_Type_visitFields', ); - late final _clang_getCursorSemanticParent = _clang_getCursorSemanticParentPtr - .asFunction(); + late final _clang_Type_visitFields = _clang_Type_visitFieldsPtr + .asFunction(); - /// Determine the lexical parent of the given cursor. + /// Annotate the given set of tokens by providing cursors for each token + /// that can be mapped to a specific entity within the abstract syntax tree. /// - /// The lexical parent of a cursor is the cursor in which the given \p cursor - /// was actually written. For many declarations, the lexical and semantic parents - /// are equivalent (the semantic parent is returned by - /// \c clang_getCursorSemanticParent()). They diverge when declarations or - /// definitions are provided out-of-line. For example: + /// This token-annotation routine is equivalent to invoking + /// clang_getCursor() for the source locations of each of the + /// tokens. The cursors provided are filtered, so that only those + /// cursors that have a direct correspondence to the token are + /// accepted. For example, given a function call \c f(x), + /// clang_getCursor() would provide the following cursors: /// - /// \code - /// class C { - /// void f(); - /// }; + /// * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. + /// * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. + /// * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. /// - /// void C::f() { } - /// \endcode + /// Only the first and last of these cursors will occur within the + /// annotate, since the tokens "f" and "x' directly refer to a function + /// and a variable, respectively, but the parentheses are just a small + /// part of the full syntax of the function call expression, which is + /// not provided as an annotation. /// - /// In the out-of-line definition of \c C::f, the semantic parent is - /// the class \c C, of which this function is a member. The lexical parent is - /// the place where the declaration actually occurs in the source code; in this - /// case, the definition occurs in the translation unit. In general, the - /// lexical parent for a given entity can change without affecting the semantics - /// of the program, and the lexical parent of different declarations of the - /// same entity may be different. Changing the semantic parent of a declaration, - /// on the other hand, can have a major impact on semantics, and redeclarations - /// of a particular entity should all have the same semantic context. + /// \param TU the translation unit that owns the given tokens. /// - /// In the example above, both declarations of \c C::f have \c C as their - /// semantic context, while the lexical context of the first \c C::f is \c C - /// and the lexical context of the second \c C::f is the translation unit. + /// \param Tokens the set of tokens to annotate. /// - /// For declarations written in the global scope, the lexical parent is - /// the translation unit. - CXCursor clang_getCursorLexicalParent(CXCursor cursor) { - return _clang_getCursorLexicalParent(cursor); + /// \param NumTokens the number of tokens in \p Tokens. + /// + /// \param Cursors an array of \p NumTokens cursors, whose contents will be + /// replaced with the cursors corresponding to each token. + void clang_annotateTokens( + CXTranslationUnit TU, + ffi.Pointer Tokens, + int NumTokens, + ffi.Pointer Cursors, + ) { + return _clang_annotateTokens(TU, Tokens, NumTokens, Cursors); } - late final _clang_getCursorLexicalParentPtr = - _lookup>( - 'clang_getCursorLexicalParent', + late final _clang_annotateTokensPtr = + _lookup>( + 'clang_annotateTokens', ); - late final _clang_getCursorLexicalParent = _clang_getCursorLexicalParentPtr - .asFunction(); + late final _clang_annotateTokens = _clang_annotateTokensPtr + .asFunction(); - /// Determine the set of methods that are overridden by the given - /// method. - /// - /// In both Objective-C and C++, a method (aka virtual member function, - /// in C++) can override a virtual method in a base class. For - /// Objective-C, a method is said to override any method in the class's - /// base class, its protocols, or its categories' protocols, that has the same - /// selector and is of the same kind (class or instance). - /// If no such method exists, the search continues to the class's superclass, - /// its protocols, and its categories, and so on. A method from an Objective-C - /// implementation is considered to override the same methods as its - /// corresponding method in the interface. - /// - /// For C++, a virtual member function overrides any virtual member - /// function with the same signature that occurs in its base - /// classes. With multiple inheritance, a virtual member function can - /// override several virtual member functions coming from different - /// base classes. + /// Perform code completion at a given location in a translation unit. /// - /// In all cases, this function determines the immediate overridden - /// method, rather than all of the overridden methods. For example, if - /// a method is originally declared in a class A, then overridden in B - /// (which in inherits from A) and also in C (which inherited from B), - /// then the only overridden method returned from this function when - /// invoked on C's method will be B's method. The client may then - /// invoke this function again, given the previously-found overridden - /// methods, to map out the complete method-override set. + /// This function performs code completion at a particular file, line, and + /// column within source code, providing results that suggest potential + /// code snippets based on the context of the completion. The basic model + /// for code completion is that Clang will parse a complete source file, + /// performing syntax checking up to the location where code-completion has + /// been requested. At that point, a special code-completion token is passed + /// to the parser, which recognizes this token and determines, based on the + /// current location in the C/Objective-C/C++ grammar and the state of + /// semantic analysis, what completions to provide. These completions are + /// returned via a new \c CXCodeCompleteResults structure. /// - /// \param cursor A cursor representing an Objective-C or C++ - /// method. This routine will compute the set of methods that this - /// method overrides. + /// Code completion itself is meant to be triggered by the client when the + /// user types punctuation characters or whitespace, at which point the + /// code-completion location will coincide with the cursor. For example, if \c p + /// is a pointer, code-completion might be triggered after the "-" and then + /// after the ">" in \c p->. When the code-completion location is after the ">", + /// the completion results will provide, e.g., the members of the struct that + /// "p" points to. The client is responsible for placing the cursor at the + /// beginning of the token currently being typed, then filtering the results + /// based on the contents of the token. For example, when code-completing for + /// the expression \c p->get, the client should provide the location just after + /// the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the + /// client can filter the results based on the current token text ("get"), only + /// showing those results that start with "get". The intent of this interface + /// is to separate the relatively high-latency acquisition of code-completion + /// results from the filtering of results on a per-character basis, which must + /// have a lower latency. /// - /// \param overridden A pointer whose pointee will be replaced with a - /// pointer to an array of cursors, representing the set of overridden - /// methods. If there are no overridden methods, the pointee will be - /// set to NULL. The pointee must be freed via a call to - /// \c clang_disposeOverriddenCursors(). + /// \param TU The translation unit in which code-completion should + /// occur. The source files for this translation unit need not be + /// completely up-to-date (and the contents of those source files may + /// be overridden via \p unsaved_files). Cursors referring into the + /// translation unit may be invalidated by this invocation. /// - /// \param num_overridden A pointer to the number of overridden - /// functions, will be set to the number of overridden functions in the - /// array pointed to by \p overridden. - void clang_getOverriddenCursors( - CXCursor cursor, - ffi.Pointer> overridden, - ffi.Pointer num_overridden, + /// \param complete_filename The name of the source file where code + /// completion should be performed. This filename may be any file + /// included in the translation unit. + /// + /// \param complete_line The line at which code-completion should occur. + /// + /// \param complete_column The column at which code-completion should occur. + /// Note that the column should point just after the syntactic construct that + /// initiated code completion, and not in the middle of a lexical token. + /// + /// \param unsaved_files the Files that have not yet been saved to disk + /// but may be required for parsing or code completion, including the + /// contents of those files. The contents and name of these files (as + /// specified by CXUnsavedFile) are copied when necessary, so the + /// client only needs to guarantee their validity until the call to + /// this function returns. + /// + /// \param num_unsaved_files The number of unsaved file entries in \p + /// unsaved_files. + /// + /// \param options Extra options that control the behavior of code + /// completion, expressed as a bitwise OR of the enumerators of the + /// CXCodeComplete_Flags enumeration. The + /// \c clang_defaultCodeCompleteOptions() function returns a default set + /// of code-completion options. + /// + /// \returns If successful, a new \c CXCodeCompleteResults structure + /// containing code-completion results, which should eventually be + /// freed with \c clang_disposeCodeCompleteResults(). If code + /// completion fails, returns NULL. + ffi.Pointer clang_codeCompleteAt( + CXTranslationUnit TU, + ffi.Pointer complete_filename, + int complete_line, + int complete_column, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, ) { - return _clang_getOverriddenCursors(cursor, overridden, num_overridden); + return _clang_codeCompleteAt( + TU, + complete_filename, + complete_line, + complete_column, + unsaved_files, + num_unsaved_files, + options, + ); } - late final _clang_getOverriddenCursorsPtr = - _lookup>( - 'clang_getOverriddenCursors', + late final _clang_codeCompleteAtPtr = + _lookup>( + 'clang_codeCompleteAt', ); - late final _clang_getOverriddenCursors = _clang_getOverriddenCursorsPtr - .asFunction(); + late final _clang_codeCompleteAt = _clang_codeCompleteAtPtr + .asFunction(); - /// Free the set of overridden cursors returned by \c - /// clang_getOverriddenCursors(). - void clang_disposeOverriddenCursors(ffi.Pointer overridden) { - return _clang_disposeOverriddenCursors(overridden); + /// Returns the cursor kind for the container for the current code + /// completion context. The container is only guaranteed to be set for + /// contexts where a container exists (i.e. member accesses or Objective-C + /// message sends); if there is not a container, this function will return + /// CXCursor_InvalidCode. + /// + /// \param Results the code completion results to query + /// + /// \param IsIncomplete on return, this value will be false if Clang has complete + /// information about the container. If Clang does not have complete + /// information, this value will be true. + /// + /// \returns the container kind, or CXCursor_InvalidCode if there is not a + /// container + CXCursorKind clang_codeCompleteGetContainerKind( + ffi.Pointer Results, + ffi.Pointer IsIncomplete, + ) { + return CXCursorKind.fromValue( + _clang_codeCompleteGetContainerKind(Results, IsIncomplete), + ); } - late final _clang_disposeOverriddenCursorsPtr = - _lookup>( - 'clang_disposeOverriddenCursors', + late final _clang_codeCompleteGetContainerKindPtr = + _lookup>( + 'clang_codeCompleteGetContainerKind', ); - late final _clang_disposeOverriddenCursors = - _clang_disposeOverriddenCursorsPtr - .asFunction(); + late final _clang_codeCompleteGetContainerKind = + _clang_codeCompleteGetContainerKindPtr + .asFunction(); - /// Retrieve the file that is included by the given inclusion directive - /// cursor. - CXFile clang_getIncludedFile(CXCursor cursor) { - return _clang_getIncludedFile(cursor); + /// Returns the USR for the container for the current code completion + /// context. If there is not a container for the current context, this + /// function will return the empty string. + /// + /// \param Results the code completion results to query + /// + /// \returns the USR for the container + CXString clang_codeCompleteGetContainerUSR( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetContainerUSR(Results); } - late final _clang_getIncludedFilePtr = - _lookup>( - 'clang_getIncludedFile', + late final _clang_codeCompleteGetContainerUSRPtr = + _lookup>( + 'clang_codeCompleteGetContainerUSR', ); - late final _clang_getIncludedFile = _clang_getIncludedFilePtr - .asFunction(); + late final _clang_codeCompleteGetContainerUSR = + _clang_codeCompleteGetContainerUSRPtr + .asFunction(); - /// Map a source location to the cursor that describes the entity at that - /// location in the source code. + /// Determines what completions are appropriate for the context + /// the given code completion. /// - /// clang_getCursor() maps an arbitrary source location within a translation - /// unit down to the most specific cursor that describes the entity at that - /// location. For example, given an expression \c x + y, invoking - /// clang_getCursor() with a source location pointing to "x" will return the - /// cursor for "x"; similarly for "y". If the cursor points anywhere between - /// "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() - /// will return a cursor referring to the "+" expression. + /// \param Results the code completion results to query /// - /// \returns a cursor representing the entity at the given source location, or - /// a NULL cursor if no such entity can be found. - CXCursor clang_getCursor(CXTranslationUnit arg0, CXSourceLocation arg1) { - return _clang_getCursor(arg0, arg1); + /// \returns the kinds of completions that are appropriate for use + /// along with the given code completion results. + int clang_codeCompleteGetContexts( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetContexts(Results); } - late final _clang_getCursorPtr = - _lookup>('clang_getCursor'); - late final _clang_getCursor = _clang_getCursorPtr - .asFunction(); + late final _clang_codeCompleteGetContextsPtr = + _lookup>( + 'clang_codeCompleteGetContexts', + ); + late final _clang_codeCompleteGetContexts = _clang_codeCompleteGetContextsPtr + .asFunction(); - /// Retrieve the physical location of the source constructor referenced - /// by the given cursor. + /// Retrieve a diagnostic associated with the given code completion. /// - /// The location of a declaration is typically the location of the name of that - /// declaration, where the name of that declaration would occur if it is - /// unnamed, or some keyword that introduces that particular declaration. - /// The location of a reference is where that reference occurs within the - /// source code. - CXSourceLocation clang_getCursorLocation(CXCursor arg0) { - return _clang_getCursorLocation(arg0); + /// \param Results the code completion results to query. + /// \param Index the zero-based diagnostic number to retrieve. + /// + /// \returns the requested diagnostic. This diagnostic must be freed + /// via a call to \c clang_disposeDiagnostic(). + CXDiagnostic clang_codeCompleteGetDiagnostic( + ffi.Pointer Results, + int Index, + ) { + return _clang_codeCompleteGetDiagnostic(Results, Index); } - late final _clang_getCursorLocationPtr = - _lookup>( - 'clang_getCursorLocation', + late final _clang_codeCompleteGetDiagnosticPtr = + _lookup>( + 'clang_codeCompleteGetDiagnostic', ); - late final _clang_getCursorLocation = _clang_getCursorLocationPtr - .asFunction(); + late final _clang_codeCompleteGetDiagnostic = + _clang_codeCompleteGetDiagnosticPtr + .asFunction(); - /// Retrieve the physical extent of the source construct referenced by - /// the given cursor. - /// - /// The extent of a cursor starts with the file/line/column pointing at the - /// first character within the source construct that the cursor refers to and - /// ends with the last character within that source construct. For a - /// declaration, the extent covers the declaration itself. For a reference, - /// the extent covers the location of the reference (e.g., where the referenced - /// entity was actually used). - CXSourceRange clang_getCursorExtent(CXCursor arg0) { - return _clang_getCursorExtent(arg0); + /// Determine the number of diagnostics produced prior to the + /// location where code completion was performed. + int clang_codeCompleteGetNumDiagnostics( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetNumDiagnostics(Results); } - late final _clang_getCursorExtentPtr = - _lookup>( - 'clang_getCursorExtent', - ); - late final _clang_getCursorExtent = _clang_getCursorExtentPtr - .asFunction(); - - /// Retrieve the type of a CXCursor (if any). - CXType clang_getCursorType(CXCursor C) { - return _clang_getCursorType(C); - } - - late final _clang_getCursorTypePtr = - _lookup>( - 'clang_getCursorType', + late final _clang_codeCompleteGetNumDiagnosticsPtr = + _lookup>( + 'clang_codeCompleteGetNumDiagnostics', ); - late final _clang_getCursorType = _clang_getCursorTypePtr - .asFunction(); + late final _clang_codeCompleteGetNumDiagnostics = + _clang_codeCompleteGetNumDiagnosticsPtr + .asFunction(); - /// Pretty-print the underlying type using the rules of the - /// language of the translation unit from which it came. + /// Returns the currently-entered selector for an Objective-C message + /// send, formatted like "initWithFoo:bar:". Only guaranteed to return a + /// non-empty string for CXCompletionContext_ObjCInstanceMessage and + /// CXCompletionContext_ObjCClassMessage. /// - /// If the type is invalid, an empty string is returned. - CXString clang_getTypeSpelling(CXType CT) { - return _clang_getTypeSpelling(CT); + /// \param Results the code completion results to query + /// + /// \returns the selector (or partial selector) that has been entered thus far + /// for an Objective-C message send. + CXString clang_codeCompleteGetObjCSelector( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetObjCSelector(Results); } - late final _clang_getTypeSpellingPtr = - _lookup>( - 'clang_getTypeSpelling', + late final _clang_codeCompleteGetObjCSelectorPtr = + _lookup>( + 'clang_codeCompleteGetObjCSelector', ); - late final _clang_getTypeSpelling = _clang_getTypeSpellingPtr - .asFunction(); + late final _clang_codeCompleteGetObjCSelector = + _clang_codeCompleteGetObjCSelectorPtr + .asFunction(); - /// Retrieve the underlying type of a typedef declaration. - /// - /// If the cursor does not reference a typedef declaration, an invalid type is - /// returned. - CXType clang_getTypedefDeclUnderlyingType(CXCursor C) { - return _clang_getTypedefDeclUnderlyingType(C); + /// Construct a USR for a specified Objective-C category. + CXString clang_constructUSR_ObjCCategory( + ffi.Pointer class_name, + ffi.Pointer category_name, + ) { + return _clang_constructUSR_ObjCCategory(class_name, category_name); } - late final _clang_getTypedefDeclUnderlyingTypePtr = - _lookup>( - 'clang_getTypedefDeclUnderlyingType', + late final _clang_constructUSR_ObjCCategoryPtr = + _lookup>( + 'clang_constructUSR_ObjCCategory', ); - late final _clang_getTypedefDeclUnderlyingType = - _clang_getTypedefDeclUnderlyingTypePtr - .asFunction(); + late final _clang_constructUSR_ObjCCategory = + _clang_constructUSR_ObjCCategoryPtr + .asFunction(); - /// Retrieve the integer type of an enum declaration. - /// - /// If the cursor does not reference an enum declaration, an invalid type is - /// returned. - CXType clang_getEnumDeclIntegerType(CXCursor C) { - return _clang_getEnumDeclIntegerType(C); + /// Construct a USR for a specified Objective-C class. + CXString clang_constructUSR_ObjCClass(ffi.Pointer class_name) { + return _clang_constructUSR_ObjCClass(class_name); } - late final _clang_getEnumDeclIntegerTypePtr = - _lookup>( - 'clang_getEnumDeclIntegerType', + late final _clang_constructUSR_ObjCClassPtr = + _lookup>( + 'clang_constructUSR_ObjCClass', ); - late final _clang_getEnumDeclIntegerType = _clang_getEnumDeclIntegerTypePtr - .asFunction(); + late final _clang_constructUSR_ObjCClass = _clang_constructUSR_ObjCClassPtr + .asFunction(); - /// Retrieve the integer value of an enum constant declaration as a signed - /// long long. - /// - /// If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. - /// Since this is also potentially a valid constant value, the kind of the cursor - /// must be verified before calling this function. - int clang_getEnumConstantDeclValue(CXCursor C) { - return _clang_getEnumConstantDeclValue(C); + /// Construct a USR for a specified Objective-C instance variable and + /// the USR for its containing class. + CXString clang_constructUSR_ObjCIvar( + ffi.Pointer name, + CXString classUSR, + ) { + return _clang_constructUSR_ObjCIvar(name, classUSR); } - late final _clang_getEnumConstantDeclValuePtr = - _lookup>( - 'clang_getEnumConstantDeclValue', + late final _clang_constructUSR_ObjCIvarPtr = + _lookup>( + 'clang_constructUSR_ObjCIvar', ); - late final _clang_getEnumConstantDeclValue = - _clang_getEnumConstantDeclValuePtr - .asFunction(); + late final _clang_constructUSR_ObjCIvar = _clang_constructUSR_ObjCIvarPtr + .asFunction(); - /// Retrieve the integer value of an enum constant declaration as an unsigned - /// long long. - /// - /// If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. - /// Since this is also potentially a valid constant value, the kind of the cursor - /// must be verified before calling this function. - int clang_getEnumConstantDeclUnsignedValue(CXCursor C) { - return _clang_getEnumConstantDeclUnsignedValue(C); + /// Construct a USR for a specified Objective-C method and + /// the USR for its containing class. + CXString clang_constructUSR_ObjCMethod( + ffi.Pointer name, + int isInstanceMethod, + CXString classUSR, + ) { + return _clang_constructUSR_ObjCMethod(name, isInstanceMethod, classUSR); } - late final _clang_getEnumConstantDeclUnsignedValuePtr = - _lookup>( - 'clang_getEnumConstantDeclUnsignedValue', + late final _clang_constructUSR_ObjCMethodPtr = + _lookup>( + 'clang_constructUSR_ObjCMethod', ); - late final _clang_getEnumConstantDeclUnsignedValue = - _clang_getEnumConstantDeclUnsignedValuePtr - .asFunction(); + late final _clang_constructUSR_ObjCMethod = _clang_constructUSR_ObjCMethodPtr + .asFunction(); - /// Retrieve the bit width of a bit field declaration as an integer. - /// - /// If a cursor that is not a bit field declaration is passed in, -1 is returned. - int clang_getFieldDeclBitWidth(CXCursor C) { - return _clang_getFieldDeclBitWidth(C); + /// Construct a USR for a specified Objective-C property and the USR + /// for its containing class. + CXString clang_constructUSR_ObjCProperty( + ffi.Pointer property, + CXString classUSR, + ) { + return _clang_constructUSR_ObjCProperty(property, classUSR); } - late final _clang_getFieldDeclBitWidthPtr = - _lookup>( - 'clang_getFieldDeclBitWidth', + late final _clang_constructUSR_ObjCPropertyPtr = + _lookup>( + 'clang_constructUSR_ObjCProperty', ); - late final _clang_getFieldDeclBitWidth = _clang_getFieldDeclBitWidthPtr - .asFunction(); + late final _clang_constructUSR_ObjCProperty = + _clang_constructUSR_ObjCPropertyPtr + .asFunction(); - /// Retrieve the number of non-variadic arguments associated with a given - /// cursor. - /// - /// The number of arguments can be determined for calls as well as for - /// declarations of functions or methods. For other cursors -1 is returned. - int clang_Cursor_getNumArguments(CXCursor C) { - return _clang_Cursor_getNumArguments(C); + /// Construct a USR for a specified Objective-C protocol. + CXString clang_constructUSR_ObjCProtocol( + ffi.Pointer protocol_name, + ) { + return _clang_constructUSR_ObjCProtocol(protocol_name); } - late final _clang_Cursor_getNumArgumentsPtr = - _lookup>( - 'clang_Cursor_getNumArguments', + late final _clang_constructUSR_ObjCProtocolPtr = + _lookup>( + 'clang_constructUSR_ObjCProtocol', ); - late final _clang_Cursor_getNumArguments = _clang_Cursor_getNumArgumentsPtr - .asFunction(); + late final _clang_constructUSR_ObjCProtocol = + _clang_constructUSR_ObjCProtocolPtr + .asFunction(); - /// Retrieve the argument cursor of a function or method. - /// - /// The argument cursor can be determined for calls as well as for declarations - /// of functions or methods. For other cursors and for invalid indices, an - /// invalid cursor is returned. - CXCursor clang_Cursor_getArgument(CXCursor C, int i) { - return _clang_Cursor_getArgument(C, i); + /// Creates an empty CXCursorSet. + CXCursorSet clang_createCXCursorSet() { + return _clang_createCXCursorSet(); } - late final _clang_Cursor_getArgumentPtr = - _lookup>( - 'clang_Cursor_getArgument', + late final _clang_createCXCursorSetPtr = + _lookup>( + 'clang_createCXCursorSet', ); - late final _clang_Cursor_getArgument = _clang_Cursor_getArgumentPtr - .asFunction(); + late final _clang_createCXCursorSet = _clang_createCXCursorSetPtr + .asFunction(); - /// Returns the number of template args of a function decl representing a - /// template specialization. - /// - /// If the argument cursor cannot be converted into a template function - /// declaration, -1 is returned. + /// Provides a shared context for creating translation units. /// - /// For example, for the following declaration and specialization: - /// template - /// void foo() { ... } + /// It provides two options: /// - /// template <> - /// void foo(); + /// - excludeDeclarationsFromPCH: When non-zero, allows enumeration of "local" + /// declarations (when loading any new translation units). A "local" declaration + /// is one that belongs in the translation unit itself and not in a precompiled + /// header that was used by the translation unit. If zero, all declarations + /// will be enumerated. /// - /// The value 3 would be returned from this call. - int clang_Cursor_getNumTemplateArguments(CXCursor C) { - return _clang_Cursor_getNumTemplateArguments(C); - } - - late final _clang_Cursor_getNumTemplateArgumentsPtr = - _lookup>( - 'clang_Cursor_getNumTemplateArguments', - ); - late final _clang_Cursor_getNumTemplateArguments = - _clang_Cursor_getNumTemplateArgumentsPtr - .asFunction(); - - /// Retrieve the kind of the I'th template argument of the CXCursor C. + /// Here is an example: /// - /// If the argument CXCursor does not represent a FunctionDecl, an invalid - /// template argument kind is returned. + /// \code + /// // excludeDeclsFromPCH = 1, displayDiagnostics=1 + /// Idx = clang_createIndex(1, 1); /// - /// For example, for the following declaration and specialization: - /// template - /// void foo() { ... } + /// // IndexTest.pch was produced with the following command: + /// // "clang -x c IndexTest.h -emit-ast -o IndexTest.pch" + /// TU = clang_createTranslationUnit(Idx, "IndexTest.pch"); /// - /// template <> - /// void foo(); + /// // This will load all the symbols from 'IndexTest.pch' + /// clang_visitChildren(clang_getTranslationUnitCursor(TU), + /// TranslationUnitVisitor, 0); + /// clang_disposeTranslationUnit(TU); /// - /// For I = 0, 1, and 2, Type, Integral, and Integral will be returned, - /// respectively. - CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( - CXCursor C, - int I, + /// // This will load all the symbols from 'IndexTest.c', excluding symbols + /// // from 'IndexTest.pch'. + /// char *args[] = { "-Xclang", "-include-pch=IndexTest.pch" }; + /// TU = clang_createTranslationUnitFromSourceFile(Idx, "IndexTest.c", 2, args, + /// 0, 0); + /// clang_visitChildren(clang_getTranslationUnitCursor(TU), + /// TranslationUnitVisitor, 0); + /// clang_disposeTranslationUnit(TU); + /// \endcode + /// + /// This process of creating the 'pch', loading it separately, and using it (via + /// -include-pch) allows 'excludeDeclsFromPCH' to remove redundant callbacks + /// (which gives the indexer the same performance benefit as the compiler). + CXIndex clang_createIndex( + int excludeDeclarationsFromPCH, + int displayDiagnostics, ) { - return CXTemplateArgumentKind.fromValue( - _clang_Cursor_getTemplateArgumentKind(C, I), - ); + return _clang_createIndex(excludeDeclarationsFromPCH, displayDiagnostics); } - late final _clang_Cursor_getTemplateArgumentKindPtr = - _lookup>( - 'clang_Cursor_getTemplateArgumentKind', + late final _clang_createIndexPtr = + _lookup>('clang_createIndex'); + late final _clang_createIndex = _clang_createIndexPtr + .asFunction(); + + /// Same as \c clang_createTranslationUnit2, but returns + /// the \c CXTranslationUnit instead of an error code. In case of an error this + /// routine returns a \c NULL \c CXTranslationUnit, without further detailed + /// error codes. + CXTranslationUnit clang_createTranslationUnit( + CXIndex CIdx, + ffi.Pointer ast_filename, + ) { + return _clang_createTranslationUnit(CIdx, ast_filename); + } + + late final _clang_createTranslationUnitPtr = + _lookup>( + 'clang_createTranslationUnit', ); - late final _clang_Cursor_getTemplateArgumentKind = - _clang_Cursor_getTemplateArgumentKindPtr - .asFunction(); + late final _clang_createTranslationUnit = _clang_createTranslationUnitPtr + .asFunction(); - /// Retrieve a CXType representing the type of a TemplateArgument of a - /// function decl representing a template specialization. - /// - /// If the argument CXCursor does not represent a FunctionDecl whose I'th - /// template argument has a kind of CXTemplateArgKind_Integral, an invalid type - /// is returned. - /// - /// For example, for the following declaration and specialization: - /// template - /// void foo() { ... } + /// Create a translation unit from an AST file (\c -emit-ast). /// - /// template <> - /// void foo(); + /// \param[out] out_TU A non-NULL pointer to store the created + /// \c CXTranslationUnit. /// - /// If called with I = 0, "float", will be returned. - /// Invalid types will be returned for I == 1 or 2. - CXType clang_Cursor_getTemplateArgumentType(CXCursor C, int I) { - return _clang_Cursor_getTemplateArgumentType(C, I); + /// \returns Zero on success, otherwise returns an error code. + CXErrorCode clang_createTranslationUnit2( + CXIndex CIdx, + ffi.Pointer ast_filename, + ffi.Pointer out_TU, + ) { + return CXErrorCode.fromValue( + _clang_createTranslationUnit2(CIdx, ast_filename, out_TU), + ); } - late final _clang_Cursor_getTemplateArgumentTypePtr = - _lookup>( - 'clang_Cursor_getTemplateArgumentType', + late final _clang_createTranslationUnit2Ptr = + _lookup>( + 'clang_createTranslationUnit2', ); - late final _clang_Cursor_getTemplateArgumentType = - _clang_Cursor_getTemplateArgumentTypePtr - .asFunction(); + late final _clang_createTranslationUnit2 = _clang_createTranslationUnit2Ptr + .asFunction(); - /// Retrieve the value of an Integral TemplateArgument (of a function - /// decl representing a template specialization) as a signed long long. + /// Return the CXTranslationUnit for a given source file and the provided + /// command line arguments one would pass to the compiler. /// - /// It is undefined to call this function on a CXCursor that does not represent a - /// FunctionDecl or whose I'th template argument is not an integral value. + /// Note: The 'source_filename' argument is optional. If the caller provides a + /// NULL pointer, the name of the source file is expected to reside in the + /// specified command line arguments. /// - /// For example, for the following declaration and specialization: - /// template - /// void foo() { ... } + /// Note: When encountered in 'clang_command_line_args', the following options + /// are ignored: /// - /// template <> - /// void foo(); + /// '-c' + /// '-emit-ast' + /// '-fsyntax-only' + /// '-o \' (both '-o' and '\' are ignored) /// - /// If called with I = 1 or 2, -7 or true will be returned, respectively. - /// For I == 0, this function's behavior is undefined. - int clang_Cursor_getTemplateArgumentValue(CXCursor C, int I) { - return _clang_Cursor_getTemplateArgumentValue(C, I); - } - - late final _clang_Cursor_getTemplateArgumentValuePtr = - _lookup>( - 'clang_Cursor_getTemplateArgumentValue', - ); - late final _clang_Cursor_getTemplateArgumentValue = - _clang_Cursor_getTemplateArgumentValuePtr - .asFunction(); - - /// Retrieve the value of an Integral TemplateArgument (of a function - /// decl representing a template specialization) as an unsigned long long. + /// \param CIdx The index object with which the translation unit will be + /// associated. /// - /// It is undefined to call this function on a CXCursor that does not represent a - /// FunctionDecl or whose I'th template argument is not an integral value. + /// \param source_filename The name of the source file to load, or NULL if the + /// source file is included in \p clang_command_line_args. /// - /// For example, for the following declaration and specialization: - /// template - /// void foo() { ... } + /// \param num_clang_command_line_args The number of command-line arguments in + /// \p clang_command_line_args. /// - /// template <> - /// void foo(); + /// \param clang_command_line_args The command-line arguments that would be + /// passed to the \c clang executable if it were being invoked out-of-process. + /// These command-line options will be parsed and will affect how the translation + /// unit is parsed. Note that the following options are ignored: '-c', + /// '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. /// - /// If called with I = 1 or 2, 2147483649 or true will be returned, respectively. - /// For I == 0, this function's behavior is undefined. - int clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, int I) { - return _clang_Cursor_getTemplateArgumentUnsignedValue(C, I); + /// \param num_unsaved_files the number of unsaved file entries in \p + /// unsaved_files. + /// + /// \param unsaved_files the files that have not yet been saved to disk + /// but may be required for code completion, including the contents of + /// those files. The contents and name of these files (as specified by + /// CXUnsavedFile) are copied when necessary, so the client only needs to + /// guarantee their validity until the call to this function returns. + CXTranslationUnit clang_createTranslationUnitFromSourceFile( + CXIndex CIdx, + ffi.Pointer source_filename, + int num_clang_command_line_args, + ffi.Pointer> clang_command_line_args, + int num_unsaved_files, + ffi.Pointer unsaved_files, + ) { + return _clang_createTranslationUnitFromSourceFile( + CIdx, + source_filename, + num_clang_command_line_args, + clang_command_line_args, + num_unsaved_files, + unsaved_files, + ); } - late final _clang_Cursor_getTemplateArgumentUnsignedValuePtr = + late final _clang_createTranslationUnitFromSourceFilePtr = _lookup< - ffi.NativeFunction - >('clang_Cursor_getTemplateArgumentUnsignedValue'); - late final _clang_Cursor_getTemplateArgumentUnsignedValue = - _clang_Cursor_getTemplateArgumentUnsignedValuePtr - .asFunction(); + ffi.NativeFunction + >('clang_createTranslationUnitFromSourceFile'); + late final _clang_createTranslationUnitFromSourceFile = + _clang_createTranslationUnitFromSourceFilePtr + .asFunction(); - /// Determine whether two CXTypes represent the same type. - /// - /// \returns non-zero if the CXTypes represent the same type and - /// zero otherwise. - int clang_equalTypes(CXType A, CXType B) { - return _clang_equalTypes(A, B); + /// Returns a default set of code-completion options that can be + /// passed to\c clang_codeCompleteAt(). + int clang_defaultCodeCompleteOptions() { + return _clang_defaultCodeCompleteOptions(); } - late final _clang_equalTypesPtr = - _lookup>('clang_equalTypes'); - late final _clang_equalTypes = _clang_equalTypesPtr - .asFunction(); + late final _clang_defaultCodeCompleteOptionsPtr = + _lookup>( + 'clang_defaultCodeCompleteOptions', + ); + late final _clang_defaultCodeCompleteOptions = + _clang_defaultCodeCompleteOptionsPtr + .asFunction(); - /// Return the canonical type for a CXType. + /// Retrieve the set of display options most similar to the + /// default behavior of the clang compiler. /// - /// Clang's type system explicitly models typedefs and all the ways - /// a specific type can be represented. The canonical type is the underlying - /// type with all the "sugar" removed. For example, if 'T' is a typedef - /// for 'int', the canonical type for 'T' would be 'int'. - CXType clang_getCanonicalType(CXType T) { - return _clang_getCanonicalType(T); + /// \returns A set of display options suitable for use with \c + /// clang_formatDiagnostic(). + int clang_defaultDiagnosticDisplayOptions() { + return _clang_defaultDiagnosticDisplayOptions(); } - late final _clang_getCanonicalTypePtr = - _lookup>( - 'clang_getCanonicalType', + late final _clang_defaultDiagnosticDisplayOptionsPtr = + _lookup>( + 'clang_defaultDiagnosticDisplayOptions', ); - late final _clang_getCanonicalType = _clang_getCanonicalTypePtr - .asFunction(); + late final _clang_defaultDiagnosticDisplayOptions = + _clang_defaultDiagnosticDisplayOptionsPtr + .asFunction(); - /// Determine whether a CXType has the "const" qualifier set, - /// without looking through typedefs that may have added "const" at a - /// different level. - int clang_isConstQualifiedType(CXType T) { - return _clang_isConstQualifiedType(T); + /// Returns the set of flags that is suitable for parsing a translation + /// unit that is being edited. + /// + /// The set of flags returned provide options for \c clang_parseTranslationUnit() + /// to indicate that the translation unit is likely to be reparsed many times, + /// either explicitly (via \c clang_reparseTranslationUnit()) or implicitly + /// (e.g., by code completion (\c clang_codeCompletionAt())). The returned flag + /// set contains an unspecified set of optimizations (e.g., the precompiled + /// preamble) geared toward improving the performance of these routines. The + /// set of optimizations enabled may change from one version to the next. + int clang_defaultEditingTranslationUnitOptions() { + return _clang_defaultEditingTranslationUnitOptions(); } - late final _clang_isConstQualifiedTypePtr = - _lookup>( - 'clang_isConstQualifiedType', - ); - late final _clang_isConstQualifiedType = _clang_isConstQualifiedTypePtr - .asFunction(); + late final _clang_defaultEditingTranslationUnitOptionsPtr = + _lookup< + ffi.NativeFunction + >('clang_defaultEditingTranslationUnitOptions'); + late final _clang_defaultEditingTranslationUnitOptions = + _clang_defaultEditingTranslationUnitOptionsPtr + .asFunction(); - /// Determine whether a CXCursor that is a macro, is - /// function like. - int clang_Cursor_isMacroFunctionLike(CXCursor C) { - return _clang_Cursor_isMacroFunctionLike(C); + /// Returns the set of flags that is suitable for reparsing a translation + /// unit. + /// + /// The set of flags returned provide options for + /// \c clang_reparseTranslationUnit() by default. The returned flag + /// set contains an unspecified set of optimizations geared toward common uses + /// of reparsing. The set of optimizations enabled may change from one version + /// to the next. + int clang_defaultReparseOptions(CXTranslationUnit TU) { + return _clang_defaultReparseOptions(TU); } - late final _clang_Cursor_isMacroFunctionLikePtr = - _lookup>( - 'clang_Cursor_isMacroFunctionLike', + late final _clang_defaultReparseOptionsPtr = + _lookup>( + 'clang_defaultReparseOptions', ); - late final _clang_Cursor_isMacroFunctionLike = - _clang_Cursor_isMacroFunctionLikePtr - .asFunction(); + late final _clang_defaultReparseOptions = _clang_defaultReparseOptionsPtr + .asFunction(); - /// Determine whether a CXCursor that is a macro, is a - /// builtin one. - int clang_Cursor_isMacroBuiltin(CXCursor C) { - return _clang_Cursor_isMacroBuiltin(C); + /// Returns the set of flags that is suitable for saving a translation + /// unit. + /// + /// The set of flags returned provide options for + /// \c clang_saveTranslationUnit() by default. The returned flag + /// set contains an unspecified set of options that save translation units with + /// the most commonly-requested data. + int clang_defaultSaveOptions(CXTranslationUnit TU) { + return _clang_defaultSaveOptions(TU); } - late final _clang_Cursor_isMacroBuiltinPtr = - _lookup>( - 'clang_Cursor_isMacroBuiltin', + late final _clang_defaultSaveOptionsPtr = + _lookup>( + 'clang_defaultSaveOptions', ); - late final _clang_Cursor_isMacroBuiltin = _clang_Cursor_isMacroBuiltinPtr - .asFunction(); + late final _clang_defaultSaveOptions = _clang_defaultSaveOptionsPtr + .asFunction(); - /// Determine whether a CXCursor that is a function declaration, is an - /// inline declaration. - int clang_Cursor_isFunctionInlined(CXCursor C) { - return _clang_Cursor_isFunctionInlined(C); + /// Disposes a CXCursorSet and releases its associated memory. + void clang_disposeCXCursorSet(CXCursorSet cset) { + return _clang_disposeCXCursorSet(cset); } - late final _clang_Cursor_isFunctionInlinedPtr = - _lookup>( - 'clang_Cursor_isFunctionInlined', + late final _clang_disposeCXCursorSetPtr = + _lookup>( + 'clang_disposeCXCursorSet', ); - late final _clang_Cursor_isFunctionInlined = - _clang_Cursor_isFunctionInlinedPtr - .asFunction(); + late final _clang_disposeCXCursorSet = _clang_disposeCXCursorSetPtr + .asFunction(); - /// Determine whether a CXType has the "volatile" qualifier set, - /// without looking through typedefs that may have added "volatile" at - /// a different level. - int clang_isVolatileQualifiedType(CXType T) { - return _clang_isVolatileQualifiedType(T); + /// Free the memory associated with a \c CXPlatformAvailability structure. + void clang_disposeCXPlatformAvailability( + ffi.Pointer availability, + ) { + return _clang_disposeCXPlatformAvailability(availability); } - late final _clang_isVolatileQualifiedTypePtr = - _lookup>( - 'clang_isVolatileQualifiedType', + late final _clang_disposeCXPlatformAvailabilityPtr = + _lookup>( + 'clang_disposeCXPlatformAvailability', ); - late final _clang_isVolatileQualifiedType = _clang_isVolatileQualifiedTypePtr - .asFunction(); + late final _clang_disposeCXPlatformAvailability = + _clang_disposeCXPlatformAvailabilityPtr + .asFunction(); - /// Determine whether a CXType has the "restrict" qualifier set, - /// without looking through typedefs that may have added "restrict" at a - /// different level. - int clang_isRestrictQualifiedType(CXType T) { - return _clang_isRestrictQualifiedType(T); + void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage) { + return _clang_disposeCXTUResourceUsage(usage); } - late final _clang_isRestrictQualifiedTypePtr = - _lookup>( - 'clang_isRestrictQualifiedType', + late final _clang_disposeCXTUResourceUsagePtr = + _lookup>( + 'clang_disposeCXTUResourceUsage', ); - late final _clang_isRestrictQualifiedType = _clang_isRestrictQualifiedTypePtr - .asFunction(); + late final _clang_disposeCXTUResourceUsage = + _clang_disposeCXTUResourceUsagePtr + .asFunction(); - /// Returns the address space of the given type. - int clang_getAddressSpace(CXType T) { - return _clang_getAddressSpace(T); + /// Free the given set of code-completion results. + void clang_disposeCodeCompleteResults( + ffi.Pointer Results, + ) { + return _clang_disposeCodeCompleteResults(Results); } - late final _clang_getAddressSpacePtr = - _lookup>( - 'clang_getAddressSpace', + late final _clang_disposeCodeCompleteResultsPtr = + _lookup>( + 'clang_disposeCodeCompleteResults', ); - late final _clang_getAddressSpace = _clang_getAddressSpacePtr - .asFunction(); + late final _clang_disposeCodeCompleteResults = + _clang_disposeCodeCompleteResultsPtr + .asFunction(); - /// Returns the typedef name of the given type. - CXString clang_getTypedefName(CXType CT) { - return _clang_getTypedefName(CT); + /// Destroy a diagnostic. + void clang_disposeDiagnostic(CXDiagnostic Diagnostic) { + return _clang_disposeDiagnostic(Diagnostic); } - late final _clang_getTypedefNamePtr = - _lookup>( - 'clang_getTypedefName', + late final _clang_disposeDiagnosticPtr = + _lookup>( + 'clang_disposeDiagnostic', ); - late final _clang_getTypedefName = _clang_getTypedefNamePtr - .asFunction(); + late final _clang_disposeDiagnostic = _clang_disposeDiagnosticPtr + .asFunction(); - /// For pointer types, returns the type of the pointee. - CXType clang_getPointeeType(CXType T) { - return _clang_getPointeeType(T); + /// Release a CXDiagnosticSet and all of its contained diagnostics. + void clang_disposeDiagnosticSet(CXDiagnosticSet Diags) { + return _clang_disposeDiagnosticSet(Diags); } - late final _clang_getPointeeTypePtr = - _lookup>( - 'clang_getPointeeType', + late final _clang_disposeDiagnosticSetPtr = + _lookup>( + 'clang_disposeDiagnosticSet', ); - late final _clang_getPointeeType = _clang_getPointeeTypePtr - .asFunction(); + late final _clang_disposeDiagnosticSet = _clang_disposeDiagnosticSetPtr + .asFunction(); - /// Return the cursor for the declaration of the given type. - CXCursor clang_getTypeDeclaration(CXType T) { - return _clang_getTypeDeclaration(T); + /// Destroy the given index. + /// + /// The index must not be destroyed until all of the translation units created + /// within that index have been destroyed. + void clang_disposeIndex(CXIndex index) { + return _clang_disposeIndex(index); } - late final _clang_getTypeDeclarationPtr = - _lookup>( - 'clang_getTypeDeclaration', + late final _clang_disposeIndexPtr = + _lookup>( + 'clang_disposeIndex', ); - late final _clang_getTypeDeclaration = _clang_getTypeDeclarationPtr - .asFunction(); + late final _clang_disposeIndex = _clang_disposeIndexPtr + .asFunction(); - /// Returns the Objective-C type encoding for the specified declaration. - CXString clang_getDeclObjCTypeEncoding(CXCursor C) { - return _clang_getDeclObjCTypeEncoding(C); + /// Free the set of overridden cursors returned by \c + /// clang_getOverriddenCursors(). + void clang_disposeOverriddenCursors(ffi.Pointer overridden) { + return _clang_disposeOverriddenCursors(overridden); } - late final _clang_getDeclObjCTypeEncodingPtr = - _lookup>( - 'clang_getDeclObjCTypeEncoding', + late final _clang_disposeOverriddenCursorsPtr = + _lookup>( + 'clang_disposeOverriddenCursors', ); - late final _clang_getDeclObjCTypeEncoding = _clang_getDeclObjCTypeEncodingPtr - .asFunction(); + late final _clang_disposeOverriddenCursors = + _clang_disposeOverriddenCursorsPtr + .asFunction(); - /// Returns the Objective-C type encoding for the specified CXType. - CXString clang_Type_getObjCEncoding(CXType type) { - return _clang_Type_getObjCEncoding(type); + /// Destroy the given \c CXSourceRangeList. + void clang_disposeSourceRangeList(ffi.Pointer ranges) { + return _clang_disposeSourceRangeList(ranges); } - late final _clang_Type_getObjCEncodingPtr = - _lookup>( - 'clang_Type_getObjCEncoding', + late final _clang_disposeSourceRangeListPtr = + _lookup>( + 'clang_disposeSourceRangeList', ); - late final _clang_Type_getObjCEncoding = _clang_Type_getObjCEncodingPtr - .asFunction(); + late final _clang_disposeSourceRangeList = _clang_disposeSourceRangeListPtr + .asFunction(); - /// Retrieve the spelling of a given CXTypeKind. - CXString clang_getTypeKindSpelling(CXTypeKind K) { - return _clang_getTypeKindSpelling(K.value); + /// Free the given string. + void clang_disposeString(CXString string) { + return _clang_disposeString(string); } - late final _clang_getTypeKindSpellingPtr = - _lookup>( - 'clang_getTypeKindSpelling', + late final _clang_disposeStringPtr = + _lookup>( + 'clang_disposeString', ); - late final _clang_getTypeKindSpelling = _clang_getTypeKindSpellingPtr - .asFunction(); + late final _clang_disposeString = _clang_disposeStringPtr + .asFunction(); - /// Retrieve the calling convention associated with a function type. - /// - /// If a non-function type is passed in, CXCallingConv_Invalid is returned. - CXCallingConv clang_getFunctionTypeCallingConv(CXType T) { - return CXCallingConv.fromValue(_clang_getFunctionTypeCallingConv(T)); + /// Free the given string set. + void clang_disposeStringSet(ffi.Pointer set) { + return _clang_disposeStringSet(set); } - late final _clang_getFunctionTypeCallingConvPtr = - _lookup>( - 'clang_getFunctionTypeCallingConv', + late final _clang_disposeStringSetPtr = + _lookup>( + 'clang_disposeStringSet', ); - late final _clang_getFunctionTypeCallingConv = - _clang_getFunctionTypeCallingConvPtr - .asFunction(); + late final _clang_disposeStringSet = _clang_disposeStringSetPtr + .asFunction(); - /// Retrieve the return type associated with a function type. - /// - /// If a non-function type is passed in, an invalid type is returned. - CXType clang_getResultType(CXType T) { - return _clang_getResultType(T); + /// Free the given set of tokens. + void clang_disposeTokens( + CXTranslationUnit TU, + ffi.Pointer Tokens, + int NumTokens, + ) { + return _clang_disposeTokens(TU, Tokens, NumTokens); } - late final _clang_getResultTypePtr = - _lookup>( - 'clang_getResultType', + late final _clang_disposeTokensPtr = + _lookup>( + 'clang_disposeTokens', ); - late final _clang_getResultType = _clang_getResultTypePtr - .asFunction(); + late final _clang_disposeTokens = _clang_disposeTokensPtr + .asFunction(); - /// Retrieve the exception specification type associated with a function type. - /// This is a value of type CXCursor_ExceptionSpecificationKind. - /// - /// If a non-function type is passed in, an error code of -1 is returned. - int clang_getExceptionSpecificationType(CXType T) { - return _clang_getExceptionSpecificationType(T); + /// Destroy the specified CXTranslationUnit object. + void clang_disposeTranslationUnit(CXTranslationUnit arg0) { + return _clang_disposeTranslationUnit(arg0); } - late final _clang_getExceptionSpecificationTypePtr = - _lookup>( - 'clang_getExceptionSpecificationType', + late final _clang_disposeTranslationUnitPtr = + _lookup>( + 'clang_disposeTranslationUnit', ); - late final _clang_getExceptionSpecificationType = - _clang_getExceptionSpecificationTypePtr - .asFunction(); + late final _clang_disposeTranslationUnit = _clang_disposeTranslationUnitPtr + .asFunction(); - /// Retrieve the number of non-variadic parameters associated with a - /// function type. - /// - /// If a non-function type is passed in, -1 is returned. - int clang_getNumArgTypes(CXType T) { - return _clang_getNumArgTypes(T); + void clang_enableStackTraces() { + return _clang_enableStackTraces(); } - late final _clang_getNumArgTypesPtr = - _lookup>( - 'clang_getNumArgTypes', + late final _clang_enableStackTracesPtr = + _lookup>( + 'clang_enableStackTraces', ); - late final _clang_getNumArgTypes = _clang_getNumArgTypesPtr - .asFunction(); + late final _clang_enableStackTraces = _clang_enableStackTracesPtr + .asFunction(); - /// Retrieve the type of a parameter of a function type. - /// - /// If a non-function type is passed in or the function does not have enough - /// parameters, an invalid type is returned. - CXType clang_getArgType(CXType T, int i) { - return _clang_getArgType(T, i); + /// Determine whether two cursors are equivalent. + int clang_equalCursors(CXCursor arg0, CXCursor arg1) { + return _clang_equalCursors(arg0, arg1); } - late final _clang_getArgTypePtr = - _lookup>('clang_getArgType'); - late final _clang_getArgType = _clang_getArgTypePtr - .asFunction(); + late final _clang_equalCursorsPtr = + _lookup>( + 'clang_equalCursors', + ); + late final _clang_equalCursors = _clang_equalCursorsPtr + .asFunction(); - /// Retrieves the base type of the ObjCObjectType. + /// Determine whether two source locations, which must refer into + /// the same translation unit, refer to exactly the same point in the source + /// code. /// - /// If the type is not an ObjC object, an invalid type is returned. - CXType clang_Type_getObjCObjectBaseType(CXType T) { - return _clang_Type_getObjCObjectBaseType(T); + /// \returns non-zero if the source locations refer to the same location, zero + /// if they refer to different locations. + int clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2) { + return _clang_equalLocations(loc1, loc2); } - late final _clang_Type_getObjCObjectBaseTypePtr = - _lookup>( - 'clang_Type_getObjCObjectBaseType', + late final _clang_equalLocationsPtr = + _lookup>( + 'clang_equalLocations', ); - late final _clang_Type_getObjCObjectBaseType = - _clang_Type_getObjCObjectBaseTypePtr - .asFunction(); + late final _clang_equalLocations = _clang_equalLocationsPtr + .asFunction(); - /// Retrieve the number of protocol references associated with an ObjC object/id. + /// Determine whether two ranges are equivalent. /// - /// If the type is not an ObjC object, 0 is returned. - int clang_Type_getNumObjCProtocolRefs(CXType T) { - return _clang_Type_getNumObjCProtocolRefs(T); + /// \returns non-zero if the ranges are the same, zero if they differ. + int clang_equalRanges(CXSourceRange range1, CXSourceRange range2) { + return _clang_equalRanges(range1, range2); } - late final _clang_Type_getNumObjCProtocolRefsPtr = - _lookup>( - 'clang_Type_getNumObjCProtocolRefs', - ); - late final _clang_Type_getNumObjCProtocolRefs = - _clang_Type_getNumObjCProtocolRefsPtr - .asFunction(); + late final _clang_equalRangesPtr = + _lookup>('clang_equalRanges'); + late final _clang_equalRanges = _clang_equalRangesPtr + .asFunction(); - /// Retrieve the decl for a protocol reference for an ObjC object/id. + /// Determine whether two CXTypes represent the same type. /// - /// If the type is not an ObjC object or there are not enough protocol - /// references, an invalid cursor is returned. - CXCursor clang_Type_getObjCProtocolDecl(CXType T, int i) { - return _clang_Type_getObjCProtocolDecl(T, i); + /// \returns non-zero if the CXTypes represent the same type and + /// zero otherwise. + int clang_equalTypes(CXType A, CXType B) { + return _clang_equalTypes(A, B); } - late final _clang_Type_getObjCProtocolDeclPtr = - _lookup>( - 'clang_Type_getObjCProtocolDecl', - ); - late final _clang_Type_getObjCProtocolDecl = - _clang_Type_getObjCProtocolDeclPtr - .asFunction(); + late final _clang_equalTypesPtr = + _lookup>('clang_equalTypes'); + late final _clang_equalTypes = _clang_equalTypesPtr + .asFunction(); - /// Retreive the number of type arguments associated with an ObjC object. - /// - /// If the type is not an ObjC object, 0 is returned. - int clang_Type_getNumObjCTypeArgs(CXType T) { - return _clang_Type_getNumObjCTypeArgs(T); + void clang_executeOnThread( + ffi.Pointer)>> + fn, + ffi.Pointer user_data, + int stack_size, + ) { + return _clang_executeOnThread(fn, user_data, stack_size); } - late final _clang_Type_getNumObjCTypeArgsPtr = - _lookup>( - 'clang_Type_getNumObjCTypeArgs', + late final _clang_executeOnThreadPtr = + _lookup>( + 'clang_executeOnThread', ); - late final _clang_Type_getNumObjCTypeArgs = _clang_Type_getNumObjCTypeArgsPtr - .asFunction(); + late final _clang_executeOnThread = _clang_executeOnThreadPtr + .asFunction(); - /// Retrieve a type argument associated with an ObjC object. + /// Find #import/#include directives in a specific file. /// - /// If the type is not an ObjC or the index is not valid, - /// an invalid type is returned. - CXType clang_Type_getObjCTypeArg(CXType T, int i) { - return _clang_Type_getObjCTypeArg(T, i); + /// \param TU translation unit containing the file to query. + /// + /// \param file to search for #import/#include directives. + /// + /// \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + /// each directive found. + /// + /// \returns one of the CXResult enumerators. + CXResult clang_findIncludesInFile( + CXTranslationUnit TU, + CXFile file, + CXCursorAndRangeVisitor visitor, + ) { + return CXResult.fromValue(_clang_findIncludesInFile(TU, file, visitor)); } - late final _clang_Type_getObjCTypeArgPtr = - _lookup>( - 'clang_Type_getObjCTypeArg', + late final _clang_findIncludesInFilePtr = + _lookup>( + 'clang_findIncludesInFile', ); - late final _clang_Type_getObjCTypeArg = _clang_Type_getObjCTypeArgPtr - .asFunction(); + late final _clang_findIncludesInFile = _clang_findIncludesInFilePtr + .asFunction(); - /// Return 1 if the CXType is a variadic function type, and 0 otherwise. - int clang_isFunctionTypeVariadic(CXType T) { - return _clang_isFunctionTypeVariadic(T); + /// Find references of a declaration in a specific file. + /// + /// \param cursor pointing to a declaration or a reference of one. + /// + /// \param file to search for references. + /// + /// \param visitor callback that will receive pairs of CXCursor/CXSourceRange for + /// each reference found. + /// The CXSourceRange will point inside the file; if the reference is inside + /// a macro (and not a macro argument) the CXSourceRange will be invalid. + /// + /// \returns one of the CXResult enumerators. + CXResult clang_findReferencesInFile( + CXCursor cursor, + CXFile file, + CXCursorAndRangeVisitor visitor, + ) { + return CXResult.fromValue( + _clang_findReferencesInFile(cursor, file, visitor), + ); } - late final _clang_isFunctionTypeVariadicPtr = - _lookup>( - 'clang_isFunctionTypeVariadic', + late final _clang_findReferencesInFilePtr = + _lookup>( + 'clang_findReferencesInFile', ); - late final _clang_isFunctionTypeVariadic = _clang_isFunctionTypeVariadicPtr - .asFunction(); + late final _clang_findReferencesInFile = _clang_findReferencesInFilePtr + .asFunction(); - /// Retrieve the return type associated with a given cursor. + /// Format the given diagnostic in a manner that is suitable for display. /// - /// This only returns a valid type if the cursor refers to a function or method. - CXType clang_getCursorResultType(CXCursor C) { - return _clang_getCursorResultType(C); + /// This routine will format the given diagnostic to a string, rendering + /// the diagnostic according to the various options given. The + /// \c clang_defaultDiagnosticDisplayOptions() function returns the set of + /// options that most closely mimics the behavior of the clang compiler. + /// + /// \param Diagnostic The diagnostic to print. + /// + /// \param Options A set of options that control the diagnostic display, + /// created by combining \c CXDiagnosticDisplayOptions values. + /// + /// \returns A new string containing for formatted diagnostic. + CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, int Options) { + return _clang_formatDiagnostic(Diagnostic, Options); } - late final _clang_getCursorResultTypePtr = - _lookup>( - 'clang_getCursorResultType', + late final _clang_formatDiagnosticPtr = + _lookup>( + 'clang_formatDiagnostic', ); - late final _clang_getCursorResultType = _clang_getCursorResultTypePtr - .asFunction(); + late final _clang_formatDiagnostic = _clang_formatDiagnosticPtr + .asFunction(); - /// Retrieve the exception specification type associated with a given cursor. - /// This is a value of type CXCursor_ExceptionSpecificationKind. - /// - /// This only returns a valid result if the cursor refers to a function or method. - int clang_getCursorExceptionSpecificationType(CXCursor C) { - return _clang_getCursorExceptionSpecificationType(C); - } - - late final _clang_getCursorExceptionSpecificationTypePtr = - _lookup< - ffi.NativeFunction - >('clang_getCursorExceptionSpecificationType'); - late final _clang_getCursorExceptionSpecificationType = - _clang_getCursorExceptionSpecificationTypePtr - .asFunction(); - - /// Return 1 if the CXType is a POD (plain old data) type, and 0 - /// otherwise. - int clang_isPODType(CXType T) { - return _clang_isPODType(T); + /// Returns the address space of the given type. + int clang_getAddressSpace(CXType T) { + return _clang_getAddressSpace(T); } - late final _clang_isPODTypePtr = - _lookup>('clang_isPODType'); - late final _clang_isPODType = _clang_isPODTypePtr - .asFunction(); + late final _clang_getAddressSpacePtr = + _lookup>( + 'clang_getAddressSpace', + ); + late final _clang_getAddressSpace = _clang_getAddressSpacePtr + .asFunction(); - /// Return the element type of an array, complex, or vector type. + /// Retrieve all ranges from all files that were skipped by the + /// preprocessor. /// - /// If a type is passed in that is not an array, complex, or vector type, - /// an invalid type is returned. - CXType clang_getElementType(CXType T) { - return _clang_getElementType(T); + /// The preprocessor will skip lines when they are surrounded by an + /// if/ifdef/ifndef directive whose condition does not evaluate to true. + ffi.Pointer clang_getAllSkippedRanges( + CXTranslationUnit tu, + ) { + return _clang_getAllSkippedRanges(tu); } - late final _clang_getElementTypePtr = - _lookup>( - 'clang_getElementType', + late final _clang_getAllSkippedRangesPtr = + _lookup>( + 'clang_getAllSkippedRanges', ); - late final _clang_getElementType = _clang_getElementTypePtr - .asFunction(); + late final _clang_getAllSkippedRanges = _clang_getAllSkippedRangesPtr + .asFunction(); - /// Return the number of elements of an array or vector type. + /// Retrieve the type of a parameter of a function type. /// - /// If a type is passed in that is not an array or vector type, - /// -1 is returned. - int clang_getNumElements(CXType T) { - return _clang_getNumElements(T); + /// If a non-function type is passed in or the function does not have enough + /// parameters, an invalid type is returned. + CXType clang_getArgType(CXType T, int i) { + return _clang_getArgType(T, i); } - late final _clang_getNumElementsPtr = - _lookup>( - 'clang_getNumElements', - ); - late final _clang_getNumElements = _clang_getNumElementsPtr - .asFunction(); + late final _clang_getArgTypePtr = + _lookup>('clang_getArgType'); + late final _clang_getArgType = _clang_getArgTypePtr + .asFunction(); /// Return the element type of an array type. /// @@ -3014,602 +2624,734 @@ class LibClang { late final _clang_getArraySize = _clang_getArraySizePtr .asFunction(); - /// Retrieve the type named by the qualified-id. - /// - /// If a non-elaborated type is passed in, an invalid type is returned. - CXType clang_Type_getNamedType(CXType T) { - return _clang_Type_getNamedType(T); + /// Retrieve the character data associated with the given string. + ffi.Pointer clang_getCString(CXString string) { + return _clang_getCString(string); } - late final _clang_Type_getNamedTypePtr = - _lookup>( - 'clang_Type_getNamedType', - ); - late final _clang_Type_getNamedType = _clang_Type_getNamedTypePtr - .asFunction(); + late final _clang_getCStringPtr = + _lookup>('clang_getCString'); + late final _clang_getCString = _clang_getCStringPtr + .asFunction(); - /// Determine if a typedef is 'transparent' tag. - /// - /// A typedef is considered 'transparent' if it shares a name and spelling - /// location with its underlying tag type, as is the case with the NS_ENUM macro. - /// - /// \returns non-zero if transparent and zero otherwise. - int clang_Type_isTransparentTagTypedef(CXType T) { - return _clang_Type_isTransparentTagTypedef(T); + /// Return the memory usage of a translation unit. This object + /// should be released with clang_disposeCXTUResourceUsage(). + CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { + return _clang_getCXTUResourceUsage(TU); } - late final _clang_Type_isTransparentTagTypedefPtr = - _lookup>( - 'clang_Type_isTransparentTagTypedef', + late final _clang_getCXTUResourceUsagePtr = + _lookup>( + 'clang_getCXTUResourceUsage', ); - late final _clang_Type_isTransparentTagTypedef = - _clang_Type_isTransparentTagTypedefPtr - .asFunction(); + late final _clang_getCXTUResourceUsage = _clang_getCXTUResourceUsagePtr + .asFunction(); - /// Retrieve the nullability kind of a pointer type. - CXTypeNullabilityKind clang_Type_getNullability(CXType T) { - return CXTypeNullabilityKind.fromValue(_clang_Type_getNullability(T)); + /// Returns the access control level for the referenced object. + /// + /// If the cursor refers to a C++ declaration, its access control level within its + /// parent scope is returned. Otherwise, if the cursor refers to a base specifier or + /// access specifier, the specifier itself is returned. + CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor arg0) { + return CX_CXXAccessSpecifier.fromValue(_clang_getCXXAccessSpecifier(arg0)); } - late final _clang_Type_getNullabilityPtr = - _lookup>( - 'clang_Type_getNullability', + late final _clang_getCXXAccessSpecifierPtr = + _lookup>( + 'clang_getCXXAccessSpecifier', ); - late final _clang_Type_getNullability = _clang_Type_getNullabilityPtr - .asFunction(); + late final _clang_getCXXAccessSpecifier = _clang_getCXXAccessSpecifierPtr + .asFunction(); - /// Return the alignment of a type in bytes as per C++[expr.alignof] - /// standard. + /// Retrieve the canonical cursor corresponding to the given cursor. /// - /// If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. - /// If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete - /// is returned. - /// If the type declaration is a dependent type, CXTypeLayoutError_Dependent is - /// returned. - /// If the type declaration is not a constant size type, - /// CXTypeLayoutError_NotConstantSize is returned. - int clang_Type_getAlignOf(CXType T) { - return _clang_Type_getAlignOf(T); + /// In the C family of languages, many kinds of entities can be declared several + /// times within a single translation unit. For example, a structure type can + /// be forward-declared (possibly multiple times) and later defined: + /// + /// \code + /// struct X; + /// struct X; + /// struct X { + /// int member; + /// }; + /// \endcode + /// + /// The declarations and the definition of \c X are represented by three + /// different cursors, all of which are declarations of the same underlying + /// entity. One of these cursor is considered the "canonical" cursor, which + /// is effectively the representative for the underlying entity. One can + /// determine if two cursors are declarations of the same underlying entity by + /// comparing their canonical cursors. + /// + /// \returns The canonical cursor for the entity referred to by the given cursor. + CXCursor clang_getCanonicalCursor(CXCursor arg0) { + return _clang_getCanonicalCursor(arg0); } - late final _clang_Type_getAlignOfPtr = - _lookup>( - 'clang_Type_getAlignOf', + late final _clang_getCanonicalCursorPtr = + _lookup>( + 'clang_getCanonicalCursor', ); - late final _clang_Type_getAlignOf = _clang_Type_getAlignOfPtr - .asFunction(); + late final _clang_getCanonicalCursor = _clang_getCanonicalCursorPtr + .asFunction(); - /// Return the class type of an member pointer type. + /// Return the canonical type for a CXType. /// - /// If a non-member-pointer type is passed in, an invalid type is returned. - CXType clang_Type_getClassType(CXType T) { - return _clang_Type_getClassType(T); + /// Clang's type system explicitly models typedefs and all the ways + /// a specific type can be represented. The canonical type is the underlying + /// type with all the "sugar" removed. For example, if 'T' is a typedef + /// for 'int', the canonical type for 'T' would be 'int'. + CXType clang_getCanonicalType(CXType T) { + return _clang_getCanonicalType(T); } - late final _clang_Type_getClassTypePtr = - _lookup>( - 'clang_Type_getClassType', + late final _clang_getCanonicalTypePtr = + _lookup>( + 'clang_getCanonicalType', ); - late final _clang_Type_getClassType = _clang_Type_getClassTypePtr - .asFunction(); + late final _clang_getCanonicalType = _clang_getCanonicalTypePtr + .asFunction(); - /// Return the size of a type in bytes as per C++[expr.sizeof] standard. + /// Retrieve the child diagnostics of a CXDiagnostic. /// - /// If the type declaration is invalid, CXTypeLayoutError_Invalid is returned. - /// If the type declaration is an incomplete type, CXTypeLayoutError_Incomplete - /// is returned. - /// If the type declaration is a dependent type, CXTypeLayoutError_Dependent is - /// returned. - int clang_Type_getSizeOf(CXType T) { - return _clang_Type_getSizeOf(T); + /// This CXDiagnosticSet does not need to be released by + /// clang_disposeDiagnosticSet. + CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D) { + return _clang_getChildDiagnostics(D); } - late final _clang_Type_getSizeOfPtr = - _lookup>( - 'clang_Type_getSizeOf', + late final _clang_getChildDiagnosticsPtr = + _lookup>( + 'clang_getChildDiagnostics', ); - late final _clang_Type_getSizeOf = _clang_Type_getSizeOfPtr - .asFunction(); + late final _clang_getChildDiagnostics = _clang_getChildDiagnosticsPtr + .asFunction(); - /// Return the offset of a field named S in a record of type T in bits - /// as it would be returned by __offsetof__ as per C++11[18.2p4] - /// - /// If the cursor is not a record field declaration, CXTypeLayoutError_Invalid - /// is returned. - /// If the field's type declaration is an incomplete type, - /// CXTypeLayoutError_Incomplete is returned. - /// If the field's type declaration is a dependent type, - /// CXTypeLayoutError_Dependent is returned. - /// If the field's name S is not found, - /// CXTypeLayoutError_InvalidFieldName is returned. - int clang_Type_getOffsetOf(CXType T, ffi.Pointer S) { - return _clang_Type_getOffsetOf(T, S); + /// Return a version string, suitable for showing to a user, but not + /// intended to be parsed (the format is not guaranteed to be stable). + CXString clang_getClangVersion() { + return _clang_getClangVersion(); } - late final _clang_Type_getOffsetOfPtr = - _lookup>( - 'clang_Type_getOffsetOf', + late final _clang_getClangVersionPtr = + _lookup>( + 'clang_getClangVersion', ); - late final _clang_Type_getOffsetOf = _clang_Type_getOffsetOfPtr - .asFunction(); + late final _clang_getClangVersion = _clang_getClangVersionPtr + .asFunction(); - /// Return the type that was modified by this attributed type. + /// Retrieve the annotation associated with the given completion string. /// - /// If the type is not an attributed type, an invalid type is returned. - CXType clang_Type_getModifiedType(CXType T) { - return _clang_Type_getModifiedType(T); - } - - late final _clang_Type_getModifiedTypePtr = - _lookup>( - 'clang_Type_getModifiedType', + /// \param completion_string the completion string to query. + /// + /// \param annotation_number the 0-based index of the annotation of the + /// completion string. + /// + /// \returns annotation string associated with the completion at index + /// \c annotation_number, or a NULL string if that annotation is not available. + CXString clang_getCompletionAnnotation( + CXCompletionString completion_string, + int annotation_number, + ) { + return _clang_getCompletionAnnotation(completion_string, annotation_number); + } + + late final _clang_getCompletionAnnotationPtr = + _lookup>( + 'clang_getCompletionAnnotation', ); - late final _clang_Type_getModifiedType = _clang_Type_getModifiedTypePtr - .asFunction(); + late final _clang_getCompletionAnnotation = _clang_getCompletionAnnotationPtr + .asFunction(); - /// Return the offset of the field represented by the Cursor. + /// Determine the availability of the entity that this code-completion + /// string refers to. /// - /// If the cursor is not a field declaration, -1 is returned. - /// If the cursor semantic parent is not a record field declaration, - /// CXTypeLayoutError_Invalid is returned. - /// If the field's type declaration is an incomplete type, - /// CXTypeLayoutError_Incomplete is returned. - /// If the field's type declaration is a dependent type, - /// CXTypeLayoutError_Dependent is returned. - /// If the field's name S is not found, - /// CXTypeLayoutError_InvalidFieldName is returned. - int clang_Cursor_getOffsetOfField(CXCursor C) { - return _clang_Cursor_getOffsetOfField(C); + /// \param completion_string The completion string to query. + /// + /// \returns The availability of the completion string. + CXAvailabilityKind clang_getCompletionAvailability( + CXCompletionString completion_string, + ) { + return CXAvailabilityKind.fromValue( + _clang_getCompletionAvailability(completion_string), + ); } - late final _clang_Cursor_getOffsetOfFieldPtr = - _lookup>( - 'clang_Cursor_getOffsetOfField', + late final _clang_getCompletionAvailabilityPtr = + _lookup>( + 'clang_getCompletionAvailability', ); - late final _clang_Cursor_getOffsetOfField = _clang_Cursor_getOffsetOfFieldPtr - .asFunction(); + late final _clang_getCompletionAvailability = + _clang_getCompletionAvailabilityPtr + .asFunction(); - /// Determine whether the given cursor represents an anonymous - /// tag or namespace - int clang_Cursor_isAnonymous(CXCursor C) { - return _clang_Cursor_isAnonymous(C); + /// Retrieve the brief documentation comment attached to the declaration + /// that corresponds to the given completion string. + CXString clang_getCompletionBriefComment( + CXCompletionString completion_string, + ) { + return _clang_getCompletionBriefComment(completion_string); } - late final _clang_Cursor_isAnonymousPtr = - _lookup>( - 'clang_Cursor_isAnonymous', + late final _clang_getCompletionBriefCommentPtr = + _lookup>( + 'clang_getCompletionBriefComment', ); - late final _clang_Cursor_isAnonymous = _clang_Cursor_isAnonymousPtr - .asFunction(); + late final _clang_getCompletionBriefComment = + _clang_getCompletionBriefCommentPtr + .asFunction(); - /// Determine whether the given cursor represents an anonymous record - /// declaration. - int clang_Cursor_isAnonymousRecordDecl(CXCursor C) { - return _clang_Cursor_isAnonymousRecordDecl(C); + /// Retrieve the completion string associated with a particular chunk + /// within a completion string. + /// + /// \param completion_string the completion string to query. + /// + /// \param chunk_number the 0-based index of the chunk in the completion string. + /// + /// \returns the completion string associated with the chunk at index + /// \c chunk_number. + CXCompletionString clang_getCompletionChunkCompletionString( + CXCompletionString completion_string, + int chunk_number, + ) { + return _clang_getCompletionChunkCompletionString( + completion_string, + chunk_number, + ); } - late final _clang_Cursor_isAnonymousRecordDeclPtr = - _lookup>( - 'clang_Cursor_isAnonymousRecordDecl', - ); - late final _clang_Cursor_isAnonymousRecordDecl = - _clang_Cursor_isAnonymousRecordDeclPtr - .asFunction(); + late final _clang_getCompletionChunkCompletionStringPtr = + _lookup< + ffi.NativeFunction + >('clang_getCompletionChunkCompletionString'); + late final _clang_getCompletionChunkCompletionString = + _clang_getCompletionChunkCompletionStringPtr + .asFunction(); - /// Determine whether the given cursor represents an inline namespace - /// declaration. - int clang_Cursor_isInlineNamespace(CXCursor C) { - return _clang_Cursor_isInlineNamespace(C); + /// Determine the kind of a particular chunk within a completion string. + /// + /// \param completion_string the completion string to query. + /// + /// \param chunk_number the 0-based index of the chunk in the completion string. + /// + /// \returns the kind of the chunk at the index \c chunk_number. + CXCompletionChunkKind clang_getCompletionChunkKind( + CXCompletionString completion_string, + int chunk_number, + ) { + return CXCompletionChunkKind.fromValue( + _clang_getCompletionChunkKind(completion_string, chunk_number), + ); } - late final _clang_Cursor_isInlineNamespacePtr = - _lookup>( - 'clang_Cursor_isInlineNamespace', + late final _clang_getCompletionChunkKindPtr = + _lookup>( + 'clang_getCompletionChunkKind', ); - late final _clang_Cursor_isInlineNamespace = - _clang_Cursor_isInlineNamespacePtr - .asFunction(); + late final _clang_getCompletionChunkKind = _clang_getCompletionChunkKindPtr + .asFunction(); - /// Returns the number of template arguments for given template - /// specialization, or -1 if type \c T is not a template specialization. - int clang_Type_getNumTemplateArguments(CXType T) { - return _clang_Type_getNumTemplateArguments(T); + /// Retrieve the text associated with a particular chunk within a + /// completion string. + /// + /// \param completion_string the completion string to query. + /// + /// \param chunk_number the 0-based index of the chunk in the completion string. + /// + /// \returns the text associated with the chunk at index \c chunk_number. + CXString clang_getCompletionChunkText( + CXCompletionString completion_string, + int chunk_number, + ) { + return _clang_getCompletionChunkText(completion_string, chunk_number); } - late final _clang_Type_getNumTemplateArgumentsPtr = - _lookup>( - 'clang_Type_getNumTemplateArguments', + late final _clang_getCompletionChunkTextPtr = + _lookup>( + 'clang_getCompletionChunkText', ); - late final _clang_Type_getNumTemplateArguments = - _clang_Type_getNumTemplateArgumentsPtr - .asFunction(); + late final _clang_getCompletionChunkText = _clang_getCompletionChunkTextPtr + .asFunction(); - /// Returns the type template argument of a template class specialization - /// at given index. + /// Fix-its that *must* be applied before inserting the text for the + /// corresponding completion. /// - /// This function only returns template type arguments and does not handle - /// template template arguments or variadic packs. - CXType clang_Type_getTemplateArgumentAsType(CXType T, int i) { - return _clang_Type_getTemplateArgumentAsType(T, i); + /// By default, clang_codeCompleteAt() only returns completions with empty + /// fix-its. Extra completions with non-empty fix-its should be explicitly + /// requested by setting CXCodeComplete_IncludeCompletionsWithFixIts. + /// + /// For the clients to be able to compute position of the cursor after applying + /// fix-its, the following conditions are guaranteed to hold for + /// replacement_range of the stored fix-its: + /// - Ranges in the fix-its are guaranteed to never contain the completion + /// point (or identifier under completion point, if any) inside them, except + /// at the start or at the end of the range. + /// - If a fix-it range starts or ends with completion point (or starts or + /// ends after the identifier under completion point), it will contain at + /// least one character. It allows to unambiguously recompute completion + /// point after applying the fix-it. + /// + /// The intuition is that provided fix-its change code around the identifier we + /// complete, but are not allowed to touch the identifier itself or the + /// completion point. One example of completions with corrections are the ones + /// replacing '.' with '->' and vice versa: + /// + /// std::unique_ptr> vec_ptr; + /// In 'vec_ptr.^', one of the completions is 'push_back', it requires + /// replacing '.' with '->'. + /// In 'vec_ptr->^', one of the completions is 'release', it requires + /// replacing '->' with '.'. + /// + /// \param results The structure keeping all completion results + /// + /// \param completion_index The index of the completion + /// + /// \param fixit_index The index of the fix-it for the completion at + /// completion_index + /// + /// \param replacement_range The fix-it range that must be replaced before the + /// completion at completion_index can be applied + /// + /// \returns The fix-it string that must replace the code at replacement_range + /// before the completion at completion_index can be applied + CXString clang_getCompletionFixIt( + ffi.Pointer results, + int completion_index, + int fixit_index, + ffi.Pointer replacement_range, + ) { + return _clang_getCompletionFixIt( + results, + completion_index, + fixit_index, + replacement_range, + ); } - late final _clang_Type_getTemplateArgumentAsTypePtr = - _lookup>( - 'clang_Type_getTemplateArgumentAsType', + late final _clang_getCompletionFixItPtr = + _lookup>( + 'clang_getCompletionFixIt', ); - late final _clang_Type_getTemplateArgumentAsType = - _clang_Type_getTemplateArgumentAsTypePtr - .asFunction(); + late final _clang_getCompletionFixIt = _clang_getCompletionFixItPtr + .asFunction(); - /// Retrieve the ref-qualifier kind of a function or method. + /// Retrieve the number of annotations associated with the given + /// completion string. /// - /// The ref-qualifier is returned for C++ functions or methods. For other types - /// or non-C++ declarations, CXRefQualifier_None is returned. - CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T) { - return CXRefQualifierKind.fromValue(_clang_Type_getCXXRefQualifier(T)); + /// \param completion_string the completion string to query. + /// + /// \returns the number of annotations associated with the given completion + /// string. + int clang_getCompletionNumAnnotations(CXCompletionString completion_string) { + return _clang_getCompletionNumAnnotations(completion_string); } - late final _clang_Type_getCXXRefQualifierPtr = - _lookup>( - 'clang_Type_getCXXRefQualifier', + late final _clang_getCompletionNumAnnotationsPtr = + _lookup>( + 'clang_getCompletionNumAnnotations', ); - late final _clang_Type_getCXXRefQualifier = _clang_Type_getCXXRefQualifierPtr - .asFunction(); - - /// Returns non-zero if the cursor specifies a Record member that is a - /// bitfield. - int clang_Cursor_isBitField(CXCursor C) { - return _clang_Cursor_isBitField(C); - } - - late final _clang_Cursor_isBitFieldPtr = - _lookup>( - 'clang_Cursor_isBitField', - ); - late final _clang_Cursor_isBitField = _clang_Cursor_isBitFieldPtr - .asFunction(); + late final _clang_getCompletionNumAnnotations = + _clang_getCompletionNumAnnotationsPtr + .asFunction(); - /// Returns 1 if the base class specified by the cursor with kind - /// CX_CXXBaseSpecifier is virtual. - int clang_isVirtualBase(CXCursor arg0) { - return _clang_isVirtualBase(arg0); + /// Retrieve the number of fix-its for the given completion index. + /// + /// Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts + /// option was set. + /// + /// \param results The structure keeping all completion results + /// + /// \param completion_index The index of the completion + /// + /// \return The number of fix-its which must be applied before the completion at + /// completion_index can be applied + int clang_getCompletionNumFixIts( + ffi.Pointer results, + int completion_index, + ) { + return _clang_getCompletionNumFixIts(results, completion_index); } - late final _clang_isVirtualBasePtr = - _lookup>( - 'clang_isVirtualBase', + late final _clang_getCompletionNumFixItsPtr = + _lookup>( + 'clang_getCompletionNumFixIts', ); - late final _clang_isVirtualBase = _clang_isVirtualBasePtr - .asFunction(); + late final _clang_getCompletionNumFixIts = _clang_getCompletionNumFixItsPtr + .asFunction(); - /// Returns the access control level for the referenced object. + /// Retrieve the parent context of the given completion string. /// - /// If the cursor refers to a C++ declaration, its access control level within its - /// parent scope is returned. Otherwise, if the cursor refers to a base specifier or - /// access specifier, the specifier itself is returned. - CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor arg0) { - return CX_CXXAccessSpecifier.fromValue(_clang_getCXXAccessSpecifier(arg0)); + /// The parent context of a completion string is the semantic parent of + /// the declaration (if any) that the code completion represents. For example, + /// a code completion for an Objective-C method would have the method's class + /// or protocol as its context. + /// + /// \param completion_string The code completion string whose parent is + /// being queried. + /// + /// \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. + /// + /// \returns The name of the completion parent, e.g., "NSObject" if + /// the completion string represents a method in the NSObject class. + CXString clang_getCompletionParent( + CXCompletionString completion_string, + ffi.Pointer kind, + ) { + return _clang_getCompletionParent(completion_string, kind); } - late final _clang_getCXXAccessSpecifierPtr = - _lookup>( - 'clang_getCXXAccessSpecifier', + late final _clang_getCompletionParentPtr = + _lookup>( + 'clang_getCompletionParent', ); - late final _clang_getCXXAccessSpecifier = _clang_getCXXAccessSpecifierPtr - .asFunction(); + late final _clang_getCompletionParent = _clang_getCompletionParentPtr + .asFunction(); - /// Returns the storage class for a function or variable declaration. + /// Determine the priority of this code completion. /// - /// If the passed in Cursor is not a function or variable declaration, - /// CX_SC_Invalid is returned else the storage class. - CX_StorageClass clang_Cursor_getStorageClass(CXCursor arg0) { - return CX_StorageClass.fromValue(_clang_Cursor_getStorageClass(arg0)); + /// The priority of a code completion indicates how likely it is that this + /// particular completion is the completion that the user will select. The + /// priority is selected by various internal heuristics. + /// + /// \param completion_string The completion string to query. + /// + /// \returns The priority of this completion string. Smaller values indicate + /// higher-priority (more likely) completions. + int clang_getCompletionPriority(CXCompletionString completion_string) { + return _clang_getCompletionPriority(completion_string); } - late final _clang_Cursor_getStorageClassPtr = - _lookup>( - 'clang_Cursor_getStorageClass', + late final _clang_getCompletionPriorityPtr = + _lookup>( + 'clang_getCompletionPriority', ); - late final _clang_Cursor_getStorageClass = _clang_Cursor_getStorageClassPtr - .asFunction(); + late final _clang_getCompletionPriority = _clang_getCompletionPriorityPtr + .asFunction(); - /// Determine the number of overloaded declarations referenced by a - /// \c CXCursor_OverloadedDeclRef cursor. + /// Map a source location to the cursor that describes the entity at that + /// location in the source code. /// - /// \param cursor The cursor whose overloaded declarations are being queried. + /// clang_getCursor() maps an arbitrary source location within a translation + /// unit down to the most specific cursor that describes the entity at that + /// location. For example, given an expression \c x + y, invoking + /// clang_getCursor() with a source location pointing to "x" will return the + /// cursor for "x"; similarly for "y". If the cursor points anywhere between + /// "x" or "y" (e.g., on the + or the whitespace around it), clang_getCursor() + /// will return a cursor referring to the "+" expression. /// - /// \returns The number of overloaded declarations referenced by \c cursor. If it - /// is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. - int clang_getNumOverloadedDecls(CXCursor cursor) { - return _clang_getNumOverloadedDecls(cursor); + /// \returns a cursor representing the entity at the given source location, or + /// a NULL cursor if no such entity can be found. + CXCursor clang_getCursor(CXTranslationUnit arg0, CXSourceLocation arg1) { + return _clang_getCursor(arg0, arg1); } - late final _clang_getNumOverloadedDeclsPtr = - _lookup>( - 'clang_getNumOverloadedDecls', - ); - late final _clang_getNumOverloadedDecls = _clang_getNumOverloadedDeclsPtr - .asFunction(); + late final _clang_getCursorPtr = + _lookup>('clang_getCursor'); + late final _clang_getCursor = _clang_getCursorPtr + .asFunction(); - /// Retrieve a cursor for one of the overloaded declarations referenced - /// by a \c CXCursor_OverloadedDeclRef cursor. - /// - /// \param cursor The cursor whose overloaded declarations are being queried. + /// Determine the availability of the entity that this cursor refers to, + /// taking the current target platform into account. /// - /// \param index The zero-based index into the set of overloaded declarations in - /// the cursor. + /// \param cursor The cursor to query. /// - /// \returns A cursor representing the declaration referenced by the given - /// \c cursor at the specified \c index. If the cursor does not have an - /// associated set of overloaded declarations, or if the index is out of bounds, - /// returns \c clang_getNullCursor(); - CXCursor clang_getOverloadedDecl(CXCursor cursor, int index) { - return _clang_getOverloadedDecl(cursor, index); + /// \returns The availability of the cursor. + CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) { + return CXAvailabilityKind.fromValue(_clang_getCursorAvailability(cursor)); } - late final _clang_getOverloadedDeclPtr = - _lookup>( - 'clang_getOverloadedDecl', + late final _clang_getCursorAvailabilityPtr = + _lookup>( + 'clang_getCursorAvailability', ); - late final _clang_getOverloadedDecl = _clang_getOverloadedDeclPtr - .asFunction(); + late final _clang_getCursorAvailability = _clang_getCursorAvailabilityPtr + .asFunction(); - /// For cursors representing an iboutletcollection attribute, - /// this function returns the collection element type. - CXType clang_getIBOutletCollectionType(CXCursor arg0) { - return _clang_getIBOutletCollectionType(arg0); + /// Retrieve a completion string for an arbitrary declaration or macro + /// definition cursor. + /// + /// \param cursor The cursor to query. + /// + /// \returns A non-context-sensitive completion string for declaration and macro + /// definition cursors, or NULL for other kinds of cursors. + CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { + return _clang_getCursorCompletionString(cursor); } - late final _clang_getIBOutletCollectionTypePtr = - _lookup>( - 'clang_getIBOutletCollectionType', + late final _clang_getCursorCompletionStringPtr = + _lookup>( + 'clang_getCursorCompletionString', ); - late final _clang_getIBOutletCollectionType = - _clang_getIBOutletCollectionTypePtr - .asFunction(); + late final _clang_getCursorCompletionString = + _clang_getCursorCompletionStringPtr + .asFunction(); - /// Visit the children of a particular cursor. - /// - /// This function visits all the direct children of the given cursor, - /// invoking the given \p visitor function with the cursors of each - /// visited child. The traversal may be recursive, if the visitor returns - /// \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if - /// the visitor returns \c CXChildVisit_Break. + /// For a cursor that is either a reference to or a declaration + /// of some entity, retrieve a cursor that describes the definition of + /// that entity. /// - /// \param parent the cursor whose child may be visited. All kinds of - /// cursors can be visited, including invalid cursors (which, by - /// definition, have no children). + /// Some entities can be declared multiple times within a translation + /// unit, but only one of those declarations can also be a + /// definition. For example, given: /// - /// \param visitor the visitor function that will be invoked for each - /// child of \p parent. + /// \code + /// int f(int, int); + /// int g(int x, int y) { return f(x, y); } + /// int f(int a, int b) { return a + b; } + /// int f(int, int); + /// \endcode /// - /// \param client_data pointer data supplied by the client, which will - /// be passed to the visitor each time it is invoked. + /// there are three declarations of the function "f", but only the + /// second one is a definition. The clang_getCursorDefinition() + /// function will take any cursor pointing to a declaration of "f" + /// (the first or fourth lines of the example) or a cursor referenced + /// that uses "f" (the call to "f' inside "g") and will return a + /// declaration cursor pointing to the definition (the second "f" + /// declaration). /// - /// \returns a non-zero value if the traversal was terminated - /// prematurely by the visitor returning \c CXChildVisit_Break. - int clang_visitChildren( - CXCursor parent, - CXCursorVisitor visitor, - CXClientData client_data, - ) { - return _clang_visitChildren(parent, visitor, client_data); + /// If given a cursor for which there is no corresponding definition, + /// e.g., because there is no definition of that entity within this + /// translation unit, returns a NULL cursor. + CXCursor clang_getCursorDefinition(CXCursor arg0) { + return _clang_getCursorDefinition(arg0); } - late final _clang_visitChildrenPtr = - _lookup>( - 'clang_visitChildren', + late final _clang_getCursorDefinitionPtr = + _lookup>( + 'clang_getCursorDefinition', ); - late final _clang_visitChildren = _clang_visitChildrenPtr - .asFunction(); + late final _clang_getCursorDefinition = _clang_getCursorDefinitionPtr + .asFunction(); - /// Retrieve a Unified Symbol Resolution (USR) for the entity referenced - /// by the given cursor. + /// Retrieve the display name for the entity referenced by this cursor. /// - /// A Unified Symbol Resolution (USR) is a string that identifies a particular - /// entity (function, class, variable, etc.) within a program. USRs can be - /// compared across translation units to determine, e.g., when references in - /// one translation refer to an entity defined in another translation unit. - CXString clang_getCursorUSR(CXCursor arg0) { - return _clang_getCursorUSR(arg0); + /// The display name contains extra information that helps identify the cursor, + /// such as the parameters of a function or template or the arguments of a + /// class template specialization. + CXString clang_getCursorDisplayName(CXCursor arg0) { + return _clang_getCursorDisplayName(arg0); } - late final _clang_getCursorUSRPtr = - _lookup>( - 'clang_getCursorUSR', + late final _clang_getCursorDisplayNamePtr = + _lookup>( + 'clang_getCursorDisplayName', ); - late final _clang_getCursorUSR = _clang_getCursorUSRPtr - .asFunction(); + late final _clang_getCursorDisplayName = _clang_getCursorDisplayNamePtr + .asFunction(); - /// Construct a USR for a specified Objective-C class. - CXString clang_constructUSR_ObjCClass(ffi.Pointer class_name) { - return _clang_constructUSR_ObjCClass(class_name); + /// Retrieve the exception specification type associated with a given cursor. + /// This is a value of type CXCursor_ExceptionSpecificationKind. + /// + /// This only returns a valid result if the cursor refers to a function or method. + int clang_getCursorExceptionSpecificationType(CXCursor C) { + return _clang_getCursorExceptionSpecificationType(C); } - late final _clang_constructUSR_ObjCClassPtr = - _lookup>( - 'clang_constructUSR_ObjCClass', - ); - late final _clang_constructUSR_ObjCClass = _clang_constructUSR_ObjCClassPtr - .asFunction(); + late final _clang_getCursorExceptionSpecificationTypePtr = + _lookup< + ffi.NativeFunction + >('clang_getCursorExceptionSpecificationType'); + late final _clang_getCursorExceptionSpecificationType = + _clang_getCursorExceptionSpecificationTypePtr + .asFunction(); - /// Construct a USR for a specified Objective-C category. - CXString clang_constructUSR_ObjCCategory( - ffi.Pointer class_name, - ffi.Pointer category_name, - ) { - return _clang_constructUSR_ObjCCategory(class_name, category_name); + /// Retrieve the physical extent of the source construct referenced by + /// the given cursor. + /// + /// The extent of a cursor starts with the file/line/column pointing at the + /// first character within the source construct that the cursor refers to and + /// ends with the last character within that source construct. For a + /// declaration, the extent covers the declaration itself. For a reference, + /// the extent covers the location of the reference (e.g., where the referenced + /// entity was actually used). + CXSourceRange clang_getCursorExtent(CXCursor arg0) { + return _clang_getCursorExtent(arg0); } - late final _clang_constructUSR_ObjCCategoryPtr = - _lookup>( - 'clang_constructUSR_ObjCCategory', + late final _clang_getCursorExtentPtr = + _lookup>( + 'clang_getCursorExtent', ); - late final _clang_constructUSR_ObjCCategory = - _clang_constructUSR_ObjCCategoryPtr - .asFunction(); + late final _clang_getCursorExtent = _clang_getCursorExtentPtr + .asFunction(); - /// Construct a USR for a specified Objective-C protocol. - CXString clang_constructUSR_ObjCProtocol( - ffi.Pointer protocol_name, - ) { - return _clang_constructUSR_ObjCProtocol(protocol_name); + /// Retrieve the kind of the given cursor. + CXCursorKind clang_getCursorKind(CXCursor arg0) { + return CXCursorKind.fromValue(_clang_getCursorKind(arg0)); } - late final _clang_constructUSR_ObjCProtocolPtr = - _lookup>( - 'clang_constructUSR_ObjCProtocol', + late final _clang_getCursorKindPtr = + _lookup>( + 'clang_getCursorKind', ); - late final _clang_constructUSR_ObjCProtocol = - _clang_constructUSR_ObjCProtocolPtr - .asFunction(); + late final _clang_getCursorKind = _clang_getCursorKindPtr + .asFunction(); - /// Construct a USR for a specified Objective-C instance variable and - /// the USR for its containing class. - CXString clang_constructUSR_ObjCIvar( - ffi.Pointer name, - CXString classUSR, - ) { - return _clang_constructUSR_ObjCIvar(name, classUSR); + /// \defgroup CINDEX_DEBUG Debugging facilities + /// + /// These routines are used for testing and debugging, only, and should not + /// be relied upon. + /// + /// @{ + CXString clang_getCursorKindSpelling(CXCursorKind Kind) { + return _clang_getCursorKindSpelling(Kind.value); } - late final _clang_constructUSR_ObjCIvarPtr = - _lookup>( - 'clang_constructUSR_ObjCIvar', + late final _clang_getCursorKindSpellingPtr = + _lookup>( + 'clang_getCursorKindSpelling', ); - late final _clang_constructUSR_ObjCIvar = _clang_constructUSR_ObjCIvarPtr - .asFunction(); + late final _clang_getCursorKindSpelling = _clang_getCursorKindSpellingPtr + .asFunction(); - /// Construct a USR for a specified Objective-C method and - /// the USR for its containing class. - CXString clang_constructUSR_ObjCMethod( - ffi.Pointer name, - int isInstanceMethod, - CXString classUSR, - ) { - return _clang_constructUSR_ObjCMethod(name, isInstanceMethod, classUSR); + /// Determine the "language" of the entity referred to by a given cursor. + CXLanguageKind clang_getCursorLanguage(CXCursor cursor) { + return CXLanguageKind.fromValue(_clang_getCursorLanguage(cursor)); } - late final _clang_constructUSR_ObjCMethodPtr = - _lookup>( - 'clang_constructUSR_ObjCMethod', + late final _clang_getCursorLanguagePtr = + _lookup>( + 'clang_getCursorLanguage', ); - late final _clang_constructUSR_ObjCMethod = _clang_constructUSR_ObjCMethodPtr - .asFunction(); + late final _clang_getCursorLanguage = _clang_getCursorLanguagePtr + .asFunction(); - /// Construct a USR for a specified Objective-C property and the USR - /// for its containing class. - CXString clang_constructUSR_ObjCProperty( - ffi.Pointer property, - CXString classUSR, - ) { - return _clang_constructUSR_ObjCProperty(property, classUSR); + /// Determine the lexical parent of the given cursor. + /// + /// The lexical parent of a cursor is the cursor in which the given \p cursor + /// was actually written. For many declarations, the lexical and semantic parents + /// are equivalent (the semantic parent is returned by + /// \c clang_getCursorSemanticParent()). They diverge when declarations or + /// definitions are provided out-of-line. For example: + /// + /// \code + /// class C { + /// void f(); + /// }; + /// + /// void C::f() { } + /// \endcode + /// + /// In the out-of-line definition of \c C::f, the semantic parent is + /// the class \c C, of which this function is a member. The lexical parent is + /// the place where the declaration actually occurs in the source code; in this + /// case, the definition occurs in the translation unit. In general, the + /// lexical parent for a given entity can change without affecting the semantics + /// of the program, and the lexical parent of different declarations of the + /// same entity may be different. Changing the semantic parent of a declaration, + /// on the other hand, can have a major impact on semantics, and redeclarations + /// of a particular entity should all have the same semantic context. + /// + /// In the example above, both declarations of \c C::f have \c C as their + /// semantic context, while the lexical context of the first \c C::f is \c C + /// and the lexical context of the second \c C::f is the translation unit. + /// + /// For declarations written in the global scope, the lexical parent is + /// the translation unit. + CXCursor clang_getCursorLexicalParent(CXCursor cursor) { + return _clang_getCursorLexicalParent(cursor); } - late final _clang_constructUSR_ObjCPropertyPtr = - _lookup>( - 'clang_constructUSR_ObjCProperty', + late final _clang_getCursorLexicalParentPtr = + _lookup>( + 'clang_getCursorLexicalParent', ); - late final _clang_constructUSR_ObjCProperty = - _clang_constructUSR_ObjCPropertyPtr - .asFunction(); + late final _clang_getCursorLexicalParent = _clang_getCursorLexicalParentPtr + .asFunction(); - /// Retrieve a name for the entity referenced by this cursor. - CXString clang_getCursorSpelling(CXCursor arg0) { - return _clang_getCursorSpelling(arg0); + /// Determine the linkage of the entity referred to by a given cursor. + CXLinkageKind clang_getCursorLinkage(CXCursor cursor) { + return CXLinkageKind.fromValue(_clang_getCursorLinkage(cursor)); } - late final _clang_getCursorSpellingPtr = - _lookup>( - 'clang_getCursorSpelling', + late final _clang_getCursorLinkagePtr = + _lookup>( + 'clang_getCursorLinkage', ); - late final _clang_getCursorSpelling = _clang_getCursorSpellingPtr - .asFunction(); + late final _clang_getCursorLinkage = _clang_getCursorLinkagePtr + .asFunction(); - /// Retrieve a range for a piece that forms the cursors spelling name. - /// Most of the times there is only one range for the complete spelling but for - /// Objective-C methods and Objective-C message expressions, there are multiple - /// pieces for each selector identifier. - /// - /// \param pieceIndex the index of the spelling name piece. If this is greater - /// than the actual number of pieces, it will return a NULL (invalid) range. + /// Retrieve the physical location of the source constructor referenced + /// by the given cursor. /// - /// \param options Reserved. - CXSourceRange clang_Cursor_getSpellingNameRange( - CXCursor arg0, - int pieceIndex, - int options, - ) { - return _clang_Cursor_getSpellingNameRange(arg0, pieceIndex, options); - } - - late final _clang_Cursor_getSpellingNameRangePtr = - _lookup>( - 'clang_Cursor_getSpellingNameRange', - ); - late final _clang_Cursor_getSpellingNameRange = - _clang_Cursor_getSpellingNameRangePtr - .asFunction(); - - /// Get a property value for the given printing policy. - int clang_PrintingPolicy_getProperty( - CXPrintingPolicy Policy, - CXPrintingPolicyProperty Property, - ) { - return _clang_PrintingPolicy_getProperty(Policy, Property.value); + /// The location of a declaration is typically the location of the name of that + /// declaration, where the name of that declaration would occur if it is + /// unnamed, or some keyword that introduces that particular declaration. + /// The location of a reference is where that reference occurs within the + /// source code. + CXSourceLocation clang_getCursorLocation(CXCursor arg0) { + return _clang_getCursorLocation(arg0); } - late final _clang_PrintingPolicy_getPropertyPtr = - _lookup>( - 'clang_PrintingPolicy_getProperty', + late final _clang_getCursorLocationPtr = + _lookup>( + 'clang_getCursorLocation', ); - late final _clang_PrintingPolicy_getProperty = - _clang_PrintingPolicy_getPropertyPtr - .asFunction(); + late final _clang_getCursorLocation = _clang_getCursorLocationPtr + .asFunction(); - /// Set a property value for the given printing policy. - void clang_PrintingPolicy_setProperty( - CXPrintingPolicy Policy, - CXPrintingPolicyProperty Property, - int Value, - ) { - return _clang_PrintingPolicy_setProperty(Policy, Property.value, Value); - } - - late final _clang_PrintingPolicy_setPropertyPtr = - _lookup>( - 'clang_PrintingPolicy_setProperty', - ); - late final _clang_PrintingPolicy_setProperty = - _clang_PrintingPolicy_setPropertyPtr - .asFunction(); - - /// Retrieve the default policy for the cursor. + /// Determine the availability of the entity that this cursor refers to + /// on any platforms for which availability information is known. /// - /// The policy should be released after use with \c - /// clang_PrintingPolicy_dispose. - CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor arg0) { - return _clang_getCursorPrintingPolicy(arg0); - } - - late final _clang_getCursorPrintingPolicyPtr = - _lookup>( - 'clang_getCursorPrintingPolicy', - ); - late final _clang_getCursorPrintingPolicy = _clang_getCursorPrintingPolicyPtr - .asFunction(); - - /// Release a printing policy. - void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy) { - return _clang_PrintingPolicy_dispose(Policy); + /// \param cursor The cursor to query. + /// + /// \param always_deprecated If non-NULL, will be set to indicate whether the + /// entity is deprecated on all platforms. + /// + /// \param deprecated_message If non-NULL, will be set to the message text + /// provided along with the unconditional deprecation of this entity. The client + /// is responsible for deallocating this string. + /// + /// \param always_unavailable If non-NULL, will be set to indicate whether the + /// entity is unavailable on all platforms. + /// + /// \param unavailable_message If non-NULL, will be set to the message text + /// provided along with the unconditional unavailability of this entity. The + /// client is responsible for deallocating this string. + /// + /// \param availability If non-NULL, an array of CXPlatformAvailability instances + /// that will be populated with platform availability information, up to either + /// the number of platforms for which availability information is available (as + /// returned by this function) or \c availability_size, whichever is smaller. + /// + /// \param availability_size The number of elements available in the + /// \c availability array. + /// + /// \returns The number of platforms (N) for which availability information is + /// available (which is unrelated to \c availability_size). + /// + /// Note that the client is responsible for calling + /// \c clang_disposeCXPlatformAvailability to free each of the + /// platform-availability structures returned. There are + /// \c min(N, availability_size) such structures. + int clang_getCursorPlatformAvailability( + CXCursor cursor, + ffi.Pointer always_deprecated, + ffi.Pointer deprecated_message, + ffi.Pointer always_unavailable, + ffi.Pointer unavailable_message, + ffi.Pointer availability, + int availability_size, + ) { + return _clang_getCursorPlatformAvailability( + cursor, + always_deprecated, + deprecated_message, + always_unavailable, + unavailable_message, + availability, + availability_size, + ); } - late final _clang_PrintingPolicy_disposePtr = - _lookup>( - 'clang_PrintingPolicy_dispose', + late final _clang_getCursorPlatformAvailabilityPtr = + _lookup>( + 'clang_getCursorPlatformAvailability', ); - late final _clang_PrintingPolicy_dispose = _clang_PrintingPolicy_disposePtr - .asFunction(); + late final _clang_getCursorPlatformAvailability = + _clang_getCursorPlatformAvailabilityPtr + .asFunction(); /// Pretty print declarations. /// @@ -3634,21 +3376,52 @@ class LibClang { late final _clang_getCursorPrettyPrinted = _clang_getCursorPrettyPrintedPtr .asFunction(); - /// Retrieve the display name for the entity referenced by this cursor. + /// Retrieve the default policy for the cursor. /// - /// The display name contains extra information that helps identify the cursor, - /// such as the parameters of a function or template or the arguments of a - /// class template specialization. - CXString clang_getCursorDisplayName(CXCursor arg0) { - return _clang_getCursorDisplayName(arg0); + /// The policy should be released after use with \c + /// clang_PrintingPolicy_dispose. + CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor arg0) { + return _clang_getCursorPrintingPolicy(arg0); } - late final _clang_getCursorDisplayNamePtr = - _lookup>( - 'clang_getCursorDisplayName', + late final _clang_getCursorPrintingPolicyPtr = + _lookup>( + 'clang_getCursorPrintingPolicy', ); - late final _clang_getCursorDisplayName = _clang_getCursorDisplayNamePtr - .asFunction(); + late final _clang_getCursorPrintingPolicy = _clang_getCursorPrintingPolicyPtr + .asFunction(); + + /// Given a cursor that references something else, return the source range + /// covering that reference. + /// + /// \param C A cursor pointing to a member reference, a declaration reference, or + /// an operator call. + /// \param NameFlags A bitset with three independent flags: + /// CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and + /// CXNameRange_WantSinglePiece. + /// \param PieceIndex For contiguous names or when passing the flag + /// CXNameRange_WantSinglePiece, only one piece with index 0 is + /// available. When the CXNameRange_WantSinglePiece flag is not passed for a + /// non-contiguous names, this index can be used to retrieve the individual + /// pieces of the name. See also CXNameRange_WantSinglePiece. + /// + /// \returns The piece of the name pointed to by the given cursor. If there is no + /// name, or if the PieceIndex is out-of-range, a null-cursor will be returned. + CXSourceRange clang_getCursorReferenceNameRange( + CXCursor C, + int NameFlags, + int PieceIndex, + ) { + return _clang_getCursorReferenceNameRange(C, NameFlags, PieceIndex); + } + + late final _clang_getCursorReferenceNameRangePtr = + _lookup>( + 'clang_getCursorReferenceNameRange', + ); + late final _clang_getCursorReferenceNameRange = + _clang_getCursorReferenceNameRangePtr + .asFunction(); /// For a cursor that is a reference, retrieve a cursor representing the /// entity that it references. @@ -3670,1873 +3443,1756 @@ class LibClang { late final _clang_getCursorReferenced = _clang_getCursorReferencedPtr .asFunction(); - /// For a cursor that is either a reference to or a declaration - /// of some entity, retrieve a cursor that describes the definition of - /// that entity. - /// - /// Some entities can be declared multiple times within a translation - /// unit, but only one of those declarations can also be a - /// definition. For example, given: - /// - /// \code - /// int f(int, int); - /// int g(int x, int y) { return f(x, y); } - /// int f(int a, int b) { return a + b; } - /// int f(int, int); - /// \endcode - /// - /// there are three declarations of the function "f", but only the - /// second one is a definition. The clang_getCursorDefinition() - /// function will take any cursor pointing to a declaration of "f" - /// (the first or fourth lines of the example) or a cursor referenced - /// that uses "f" (the call to "f' inside "g") and will return a - /// declaration cursor pointing to the definition (the second "f" - /// declaration). + /// Retrieve the return type associated with a given cursor. /// - /// If given a cursor for which there is no corresponding definition, - /// e.g., because there is no definition of that entity within this - /// translation unit, returns a NULL cursor. - CXCursor clang_getCursorDefinition(CXCursor arg0) { - return _clang_getCursorDefinition(arg0); - } - - late final _clang_getCursorDefinitionPtr = - _lookup>( - 'clang_getCursorDefinition', - ); - late final _clang_getCursorDefinition = _clang_getCursorDefinitionPtr - .asFunction(); - - /// Determine whether the declaration pointed to by this cursor - /// is also a definition of that entity. - int clang_isCursorDefinition(CXCursor arg0) { - return _clang_isCursorDefinition(arg0); + /// This only returns a valid type if the cursor refers to a function or method. + CXType clang_getCursorResultType(CXCursor C) { + return _clang_getCursorResultType(C); } - late final _clang_isCursorDefinitionPtr = - _lookup>( - 'clang_isCursorDefinition', + late final _clang_getCursorResultTypePtr = + _lookup>( + 'clang_getCursorResultType', ); - late final _clang_isCursorDefinition = _clang_isCursorDefinitionPtr - .asFunction(); + late final _clang_getCursorResultType = _clang_getCursorResultTypePtr + .asFunction(); - /// Retrieve the canonical cursor corresponding to the given cursor. + /// Determine the semantic parent of the given cursor. /// - /// In the C family of languages, many kinds of entities can be declared several - /// times within a single translation unit. For example, a structure type can - /// be forward-declared (possibly multiple times) and later defined: + /// The semantic parent of a cursor is the cursor that semantically contains + /// the given \p cursor. For many declarations, the lexical and semantic parents + /// are equivalent (the lexical parent is returned by + /// \c clang_getCursorLexicalParent()). They diverge when declarations or + /// definitions are provided out-of-line. For example: /// /// \code - /// struct X; - /// struct X; - /// struct X { - /// int member; + /// class C { + /// void f(); /// }; + /// + /// void C::f() { } /// \endcode /// - /// The declarations and the definition of \c X are represented by three - /// different cursors, all of which are declarations of the same underlying - /// entity. One of these cursor is considered the "canonical" cursor, which - /// is effectively the representative for the underlying entity. One can - /// determine if two cursors are declarations of the same underlying entity by - /// comparing their canonical cursors. + /// In the out-of-line definition of \c C::f, the semantic parent is + /// the class \c C, of which this function is a member. The lexical parent is + /// the place where the declaration actually occurs in the source code; in this + /// case, the definition occurs in the translation unit. In general, the + /// lexical parent for a given entity can change without affecting the semantics + /// of the program, and the lexical parent of different declarations of the + /// same entity may be different. Changing the semantic parent of a declaration, + /// on the other hand, can have a major impact on semantics, and redeclarations + /// of a particular entity should all have the same semantic context. /// - /// \returns The canonical cursor for the entity referred to by the given cursor. - CXCursor clang_getCanonicalCursor(CXCursor arg0) { - return _clang_getCanonicalCursor(arg0); + /// In the example above, both declarations of \c C::f have \c C as their + /// semantic context, while the lexical context of the first \c C::f is \c C + /// and the lexical context of the second \c C::f is the translation unit. + /// + /// For global declarations, the semantic parent is the translation unit. + CXCursor clang_getCursorSemanticParent(CXCursor cursor) { + return _clang_getCursorSemanticParent(cursor); } - late final _clang_getCanonicalCursorPtr = - _lookup>( - 'clang_getCanonicalCursor', + late final _clang_getCursorSemanticParentPtr = + _lookup>( + 'clang_getCursorSemanticParent', ); - late final _clang_getCanonicalCursor = _clang_getCanonicalCursorPtr - .asFunction(); + late final _clang_getCursorSemanticParent = _clang_getCursorSemanticParentPtr + .asFunction(); - /// If the cursor points to a selector identifier in an Objective-C - /// method or message expression, this returns the selector index. - /// - /// After getting a cursor with #clang_getCursor, this can be called to - /// determine if the location points to a selector identifier. - /// - /// \returns The selector index if the cursor is an Objective-C method or message - /// expression and the cursor is pointing to a selector identifier, or -1 - /// otherwise. - int clang_Cursor_getObjCSelectorIndex(CXCursor arg0) { - return _clang_Cursor_getObjCSelectorIndex(arg0); + /// Retrieve a name for the entity referenced by this cursor. + CXString clang_getCursorSpelling(CXCursor arg0) { + return _clang_getCursorSpelling(arg0); } - late final _clang_Cursor_getObjCSelectorIndexPtr = - _lookup>( - 'clang_Cursor_getObjCSelectorIndex', + late final _clang_getCursorSpellingPtr = + _lookup>( + 'clang_getCursorSpelling', ); - late final _clang_Cursor_getObjCSelectorIndex = - _clang_Cursor_getObjCSelectorIndexPtr - .asFunction(); + late final _clang_getCursorSpelling = _clang_getCursorSpellingPtr + .asFunction(); - /// Given a cursor pointing to a C++ method call or an Objective-C - /// message, returns non-zero if the method/message is "dynamic", meaning: - /// - /// For a C++ method: the call is virtual. - /// For an Objective-C message: the receiver is an object instance, not 'super' - /// or a specific class. - /// - /// If the method/message is "static" or the cursor does not point to a - /// method/message, it will return zero. - int clang_Cursor_isDynamicCall(CXCursor C) { - return _clang_Cursor_isDynamicCall(C); + /// Determine the "thread-local storage (TLS) kind" of the declaration + /// referred to by a cursor. + CXTLSKind clang_getCursorTLSKind(CXCursor cursor) { + return CXTLSKind.fromValue(_clang_getCursorTLSKind(cursor)); } - late final _clang_Cursor_isDynamicCallPtr = - _lookup>( - 'clang_Cursor_isDynamicCall', + late final _clang_getCursorTLSKindPtr = + _lookup>( + 'clang_getCursorTLSKind', ); - late final _clang_Cursor_isDynamicCall = _clang_Cursor_isDynamicCallPtr - .asFunction(); + late final _clang_getCursorTLSKind = _clang_getCursorTLSKindPtr + .asFunction(); - /// Given a cursor pointing to an Objective-C message or property - /// reference, or C++ method call, returns the CXType of the receiver. - CXType clang_Cursor_getReceiverType(CXCursor C) { - return _clang_Cursor_getReceiverType(C); + /// Retrieve the type of a CXCursor (if any). + CXType clang_getCursorType(CXCursor C) { + return _clang_getCursorType(C); } - late final _clang_Cursor_getReceiverTypePtr = - _lookup>( - 'clang_Cursor_getReceiverType', + late final _clang_getCursorTypePtr = + _lookup>( + 'clang_getCursorType', ); - late final _clang_Cursor_getReceiverType = _clang_Cursor_getReceiverTypePtr - .asFunction(); + late final _clang_getCursorType = _clang_getCursorTypePtr + .asFunction(); - /// Given a cursor that represents a property declaration, return the - /// associated property attributes. The bits are formed from - /// \c CXObjCPropertyAttrKind. + /// Retrieve a Unified Symbol Resolution (USR) for the entity referenced + /// by the given cursor. /// - /// \param reserved Reserved for future use, pass 0. - int clang_Cursor_getObjCPropertyAttributes(CXCursor C, int reserved) { - return _clang_Cursor_getObjCPropertyAttributes(C, reserved); + /// A Unified Symbol Resolution (USR) is a string that identifies a particular + /// entity (function, class, variable, etc.) within a program. USRs can be + /// compared across translation units to determine, e.g., when references in + /// one translation refer to an entity defined in another translation unit. + CXString clang_getCursorUSR(CXCursor arg0) { + return _clang_getCursorUSR(arg0); } - late final _clang_Cursor_getObjCPropertyAttributesPtr = - _lookup>( - 'clang_Cursor_getObjCPropertyAttributes', + late final _clang_getCursorUSRPtr = + _lookup>( + 'clang_getCursorUSR', ); - late final _clang_Cursor_getObjCPropertyAttributes = - _clang_Cursor_getObjCPropertyAttributesPtr - .asFunction(); + late final _clang_getCursorUSR = _clang_getCursorUSRPtr + .asFunction(); - /// Given a cursor that represents a property declaration, return the - /// name of the method that implements the getter. - CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C) { - return _clang_Cursor_getObjCPropertyGetterName(C); + /// Describe the visibility of the entity referred to by a cursor. + /// + /// This returns the default visibility if not explicitly specified by + /// a visibility attribute. The default visibility may be changed by + /// commandline arguments. + /// + /// \param cursor The cursor to query. + /// + /// \returns The visibility of the cursor. + CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) { + return CXVisibilityKind.fromValue(_clang_getCursorVisibility(cursor)); } - late final _clang_Cursor_getObjCPropertyGetterNamePtr = - _lookup>( - 'clang_Cursor_getObjCPropertyGetterName', + late final _clang_getCursorVisibilityPtr = + _lookup>( + 'clang_getCursorVisibility', ); - late final _clang_Cursor_getObjCPropertyGetterName = - _clang_Cursor_getObjCPropertyGetterNamePtr - .asFunction(); + late final _clang_getCursorVisibility = _clang_getCursorVisibilityPtr + .asFunction(); - /// Given a cursor that represents a property declaration, return the - /// name of the method that implements the setter, if any. - CXString clang_Cursor_getObjCPropertySetterName(CXCursor C) { - return _clang_Cursor_getObjCPropertySetterName(C); + /// Returns the Objective-C type encoding for the specified declaration. + CXString clang_getDeclObjCTypeEncoding(CXCursor C) { + return _clang_getDeclObjCTypeEncoding(C); } - late final _clang_Cursor_getObjCPropertySetterNamePtr = - _lookup>( - 'clang_Cursor_getObjCPropertySetterName', + late final _clang_getDeclObjCTypeEncodingPtr = + _lookup>( + 'clang_getDeclObjCTypeEncoding', ); - late final _clang_Cursor_getObjCPropertySetterName = - _clang_Cursor_getObjCPropertySetterNamePtr - .asFunction(); + late final _clang_getDeclObjCTypeEncoding = _clang_getDeclObjCTypeEncodingPtr + .asFunction(); - /// Given a cursor that represents an Objective-C method or parameter - /// declaration, return the associated Objective-C qualifiers for the return - /// type or the parameter respectively. The bits are formed from - /// CXObjCDeclQualifierKind. - int clang_Cursor_getObjCDeclQualifiers(CXCursor C) { - return _clang_Cursor_getObjCDeclQualifiers(C); + void clang_getDefinitionSpellingAndExtent( + CXCursor arg0, + ffi.Pointer> startBuf, + ffi.Pointer> endBuf, + ffi.Pointer startLine, + ffi.Pointer startColumn, + ffi.Pointer endLine, + ffi.Pointer endColumn, + ) { + return _clang_getDefinitionSpellingAndExtent( + arg0, + startBuf, + endBuf, + startLine, + startColumn, + endLine, + endColumn, + ); } - late final _clang_Cursor_getObjCDeclQualifiersPtr = - _lookup>( - 'clang_Cursor_getObjCDeclQualifiers', + late final _clang_getDefinitionSpellingAndExtentPtr = + _lookup>( + 'clang_getDefinitionSpellingAndExtent', ); - late final _clang_Cursor_getObjCDeclQualifiers = - _clang_Cursor_getObjCDeclQualifiersPtr - .asFunction(); + late final _clang_getDefinitionSpellingAndExtent = + _clang_getDefinitionSpellingAndExtentPtr + .asFunction(); - /// Given a cursor that represents an Objective-C method or property - /// declaration, return non-zero if the declaration was affected by "\@optional". - /// Returns zero if the cursor is not such a declaration or it is "\@required". - int clang_Cursor_isObjCOptional(CXCursor C) { - return _clang_Cursor_isObjCOptional(C); + /// Retrieve a diagnostic associated with the given translation unit. + /// + /// \param Unit the translation unit to query. + /// \param Index the zero-based diagnostic number to retrieve. + /// + /// \returns the requested diagnostic. This diagnostic must be freed + /// via a call to \c clang_disposeDiagnostic(). + CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, int Index) { + return _clang_getDiagnostic(Unit, Index); } - late final _clang_Cursor_isObjCOptionalPtr = - _lookup>( - 'clang_Cursor_isObjCOptional', + late final _clang_getDiagnosticPtr = + _lookup>( + 'clang_getDiagnostic', ); - late final _clang_Cursor_isObjCOptional = _clang_Cursor_isObjCOptionalPtr - .asFunction(); + late final _clang_getDiagnostic = _clang_getDiagnosticPtr + .asFunction(); - /// Returns non-zero if the given cursor is a variadic function or method. - int clang_Cursor_isVariadic(CXCursor C) { - return _clang_Cursor_isVariadic(C); + /// Retrieve the category number for this diagnostic. + /// + /// Diagnostics can be categorized into groups along with other, related + /// diagnostics (e.g., diagnostics under the same warning flag). This routine + /// retrieves the category number for the given diagnostic. + /// + /// \returns The number of the category that contains this diagnostic, or zero + /// if this diagnostic is uncategorized. + int clang_getDiagnosticCategory(CXDiagnostic arg0) { + return _clang_getDiagnosticCategory(arg0); } - late final _clang_Cursor_isVariadicPtr = - _lookup>( - 'clang_Cursor_isVariadic', + late final _clang_getDiagnosticCategoryPtr = + _lookup>( + 'clang_getDiagnosticCategory', ); - late final _clang_Cursor_isVariadic = _clang_Cursor_isVariadicPtr - .asFunction(); + late final _clang_getDiagnosticCategory = _clang_getDiagnosticCategoryPtr + .asFunction(); - /// Returns non-zero if the given cursor points to a symbol marked with - /// external_source_symbol attribute. - /// - /// \param language If non-NULL, and the attribute is present, will be set to - /// the 'language' string from the attribute. + /// Retrieve the name of a particular diagnostic category. This + /// is now deprecated. Use clang_getDiagnosticCategoryText() + /// instead. /// - /// \param definedIn If non-NULL, and the attribute is present, will be set to - /// the 'definedIn' string from the attribute. + /// \param Category A diagnostic category number, as returned by + /// \c clang_getDiagnosticCategory(). /// - /// \param isGenerated If non-NULL, and the attribute is present, will be set to - /// non-zero if the 'generated_declaration' is set in the attribute. - int clang_Cursor_isExternalSymbol( - CXCursor C, - ffi.Pointer language, - ffi.Pointer definedIn, - ffi.Pointer isGenerated, - ) { - return _clang_Cursor_isExternalSymbol(C, language, definedIn, isGenerated); + /// \returns The name of the given diagnostic category. + CXString clang_getDiagnosticCategoryName(int Category) { + return _clang_getDiagnosticCategoryName(Category); } - late final _clang_Cursor_isExternalSymbolPtr = - _lookup>( - 'clang_Cursor_isExternalSymbol', + late final _clang_getDiagnosticCategoryNamePtr = + _lookup>( + 'clang_getDiagnosticCategoryName', ); - late final _clang_Cursor_isExternalSymbol = _clang_Cursor_isExternalSymbolPtr - .asFunction(); + late final _clang_getDiagnosticCategoryName = + _clang_getDiagnosticCategoryNamePtr + .asFunction(); - /// Given a cursor that represents a declaration, return the associated - /// comment's source range. The range may include multiple consecutive comments - /// with whitespace in between. - CXSourceRange clang_Cursor_getCommentRange(CXCursor C) { - return _clang_Cursor_getCommentRange(C); + /// Retrieve the diagnostic category text for a given diagnostic. + /// + /// \returns The text of the given diagnostic category. + CXString clang_getDiagnosticCategoryText(CXDiagnostic arg0) { + return _clang_getDiagnosticCategoryText(arg0); } - late final _clang_Cursor_getCommentRangePtr = - _lookup>( - 'clang_Cursor_getCommentRange', + late final _clang_getDiagnosticCategoryTextPtr = + _lookup>( + 'clang_getDiagnosticCategoryText', ); - late final _clang_Cursor_getCommentRange = _clang_Cursor_getCommentRangePtr - .asFunction(); + late final _clang_getDiagnosticCategoryText = + _clang_getDiagnosticCategoryTextPtr + .asFunction(); - /// Given a cursor that represents a declaration, return the associated - /// comment text, including comment markers. - CXString clang_Cursor_getRawCommentText(CXCursor C) { - return _clang_Cursor_getRawCommentText(C); + /// Retrieve the replacement information for a given fix-it. + /// + /// Fix-its are described in terms of a source range whose contents + /// should be replaced by a string. This approach generalizes over + /// three kinds of operations: removal of source code (the range covers + /// the code to be removed and the replacement string is empty), + /// replacement of source code (the range covers the code to be + /// replaced and the replacement string provides the new code), and + /// insertion (both the start and end of the range point at the + /// insertion location, and the replacement string provides the text to + /// insert). + /// + /// \param Diagnostic The diagnostic whose fix-its are being queried. + /// + /// \param FixIt The zero-based index of the fix-it. + /// + /// \param ReplacementRange The source range whose contents will be + /// replaced with the returned replacement string. Note that source + /// ranges are half-open ranges [a, b), so the source code should be + /// replaced from a and up to (but not including) b. + /// + /// \returns A string containing text that should be replace the source + /// code indicated by the \c ReplacementRange. + CXString clang_getDiagnosticFixIt( + CXDiagnostic Diagnostic, + int FixIt, + ffi.Pointer ReplacementRange, + ) { + return _clang_getDiagnosticFixIt(Diagnostic, FixIt, ReplacementRange); } - late final _clang_Cursor_getRawCommentTextPtr = - _lookup>( - 'clang_Cursor_getRawCommentText', + late final _clang_getDiagnosticFixItPtr = + _lookup>( + 'clang_getDiagnosticFixIt', ); - late final _clang_Cursor_getRawCommentText = - _clang_Cursor_getRawCommentTextPtr - .asFunction(); + late final _clang_getDiagnosticFixIt = _clang_getDiagnosticFixItPtr + .asFunction(); - /// Given a cursor that represents a documentable entity (e.g., - /// declaration), return the associated \paragraph; otherwise return the - /// first paragraph. - CXString clang_Cursor_getBriefCommentText(CXCursor C) { - return _clang_Cursor_getBriefCommentText(C); + /// Retrieve a diagnostic associated with the given CXDiagnosticSet. + /// + /// \param Diags the CXDiagnosticSet to query. + /// \param Index the zero-based diagnostic number to retrieve. + /// + /// \returns the requested diagnostic. This diagnostic must be freed + /// via a call to \c clang_disposeDiagnostic(). + CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, int Index) { + return _clang_getDiagnosticInSet(Diags, Index); } - late final _clang_Cursor_getBriefCommentTextPtr = - _lookup>( - 'clang_Cursor_getBriefCommentText', + late final _clang_getDiagnosticInSetPtr = + _lookup>( + 'clang_getDiagnosticInSet', ); - late final _clang_Cursor_getBriefCommentText = - _clang_Cursor_getBriefCommentTextPtr - .asFunction(); + late final _clang_getDiagnosticInSet = _clang_getDiagnosticInSetPtr + .asFunction(); - /// Retrieve the CXString representing the mangled name of the cursor. - CXString clang_Cursor_getMangling(CXCursor arg0) { - return _clang_Cursor_getMangling(arg0); + /// Retrieve the source location of the given diagnostic. + /// + /// This location is where Clang would print the caret ('^') when + /// displaying the diagnostic on the command line. + CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic arg0) { + return _clang_getDiagnosticLocation(arg0); } - late final _clang_Cursor_getManglingPtr = - _lookup>( - 'clang_Cursor_getMangling', + late final _clang_getDiagnosticLocationPtr = + _lookup>( + 'clang_getDiagnosticLocation', ); - late final _clang_Cursor_getMangling = _clang_Cursor_getManglingPtr - .asFunction(); + late final _clang_getDiagnosticLocation = _clang_getDiagnosticLocationPtr + .asFunction(); - /// Retrieve the CXStrings representing the mangled symbols of the C++ - /// constructor or destructor at the cursor. - ffi.Pointer clang_Cursor_getCXXManglings(CXCursor arg0) { - return _clang_Cursor_getCXXManglings(arg0); + /// Determine the number of fix-it hints associated with the + /// given diagnostic. + int clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic) { + return _clang_getDiagnosticNumFixIts(Diagnostic); } - late final _clang_Cursor_getCXXManglingsPtr = - _lookup>( - 'clang_Cursor_getCXXManglings', + late final _clang_getDiagnosticNumFixItsPtr = + _lookup>( + 'clang_getDiagnosticNumFixIts', ); - late final _clang_Cursor_getCXXManglings = _clang_Cursor_getCXXManglingsPtr - .asFunction(); + late final _clang_getDiagnosticNumFixIts = _clang_getDiagnosticNumFixItsPtr + .asFunction(); - /// Retrieve the CXStrings representing the mangled symbols of the ObjC - /// class interface or implementation at the cursor. - ffi.Pointer clang_Cursor_getObjCManglings(CXCursor arg0) { - return _clang_Cursor_getObjCManglings(arg0); + /// Determine the number of source ranges associated with the given + /// diagnostic. + int clang_getDiagnosticNumRanges(CXDiagnostic arg0) { + return _clang_getDiagnosticNumRanges(arg0); } - late final _clang_Cursor_getObjCManglingsPtr = - _lookup>( - 'clang_Cursor_getObjCManglings', + late final _clang_getDiagnosticNumRangesPtr = + _lookup>( + 'clang_getDiagnosticNumRanges', ); - late final _clang_Cursor_getObjCManglings = _clang_Cursor_getObjCManglingsPtr - .asFunction(); + late final _clang_getDiagnosticNumRanges = _clang_getDiagnosticNumRangesPtr + .asFunction(); - /// Given a CXCursor_ModuleImportDecl cursor, return the associated module. - CXModule clang_Cursor_getModule(CXCursor C) { - return _clang_Cursor_getModule(C); + /// Retrieve the name of the command-line option that enabled this + /// diagnostic. + /// + /// \param Diag The diagnostic to be queried. + /// + /// \param Disable If non-NULL, will be set to the option that disables this + /// diagnostic (if any). + /// + /// \returns A string that contains the command-line option used to enable this + /// warning, such as "-Wconversion" or "-pedantic". + CXString clang_getDiagnosticOption( + CXDiagnostic Diag, + ffi.Pointer Disable, + ) { + return _clang_getDiagnosticOption(Diag, Disable); } - late final _clang_Cursor_getModulePtr = - _lookup>( - 'clang_Cursor_getModule', + late final _clang_getDiagnosticOptionPtr = + _lookup>( + 'clang_getDiagnosticOption', ); - late final _clang_Cursor_getModule = _clang_Cursor_getModulePtr - .asFunction(); + late final _clang_getDiagnosticOption = _clang_getDiagnosticOptionPtr + .asFunction(); - /// Given a CXFile header file, return the module that contains it, if one - /// exists. - CXModule clang_getModuleForFile(CXTranslationUnit arg0, CXFile arg1) { - return _clang_getModuleForFile(arg0, arg1); + /// Retrieve a source range associated with the diagnostic. + /// + /// A diagnostic's source ranges highlight important elements in the source + /// code. On the command line, Clang displays source ranges by + /// underlining them with '~' characters. + /// + /// \param Diagnostic the diagnostic whose range is being extracted. + /// + /// \param Range the zero-based index specifying which range to + /// + /// \returns the requested source range. + CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, int Range) { + return _clang_getDiagnosticRange(Diagnostic, Range); } - late final _clang_getModuleForFilePtr = - _lookup>( - 'clang_getModuleForFile', + late final _clang_getDiagnosticRangePtr = + _lookup>( + 'clang_getDiagnosticRange', ); - late final _clang_getModuleForFile = _clang_getModuleForFilePtr - .asFunction(); + late final _clang_getDiagnosticRange = _clang_getDiagnosticRangePtr + .asFunction(); - /// \param Module a module object. + /// Retrieve the complete set of diagnostics associated with a + /// translation unit. /// - /// \returns the module file where the provided module object came from. - CXFile clang_Module_getASTFile(CXModule Module) { - return _clang_Module_getASTFile(Module); + /// \param Unit the translation unit to query. + CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) { + return _clang_getDiagnosticSetFromTU(Unit); } - late final _clang_Module_getASTFilePtr = - _lookup>( - 'clang_Module_getASTFile', + late final _clang_getDiagnosticSetFromTUPtr = + _lookup>( + 'clang_getDiagnosticSetFromTU', ); - late final _clang_Module_getASTFile = _clang_Module_getASTFilePtr - .asFunction(); + late final _clang_getDiagnosticSetFromTU = _clang_getDiagnosticSetFromTUPtr + .asFunction(); - /// \param Module a module object. - /// - /// \returns the parent of a sub-module or NULL if the given module is top-level, - /// e.g. for 'std.vector' it will return the 'std' module. - CXModule clang_Module_getParent(CXModule Module) { - return _clang_Module_getParent(Module); + /// Determine the severity of the given diagnostic. + CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic arg0) { + return CXDiagnosticSeverity.fromValue(_clang_getDiagnosticSeverity(arg0)); } - late final _clang_Module_getParentPtr = - _lookup>( - 'clang_Module_getParent', + late final _clang_getDiagnosticSeverityPtr = + _lookup>( + 'clang_getDiagnosticSeverity', ); - late final _clang_Module_getParent = _clang_Module_getParentPtr - .asFunction(); + late final _clang_getDiagnosticSeverity = _clang_getDiagnosticSeverityPtr + .asFunction(); - /// \param Module a module object. - /// - /// \returns the name of the module, e.g. for the 'std.vector' sub-module it - /// will return "vector". - CXString clang_Module_getName(CXModule Module) { - return _clang_Module_getName(Module); + /// Retrieve the text of the given diagnostic. + CXString clang_getDiagnosticSpelling(CXDiagnostic arg0) { + return _clang_getDiagnosticSpelling(arg0); } - late final _clang_Module_getNamePtr = - _lookup>( - 'clang_Module_getName', + late final _clang_getDiagnosticSpellingPtr = + _lookup>( + 'clang_getDiagnosticSpelling', ); - late final _clang_Module_getName = _clang_Module_getNamePtr - .asFunction(); + late final _clang_getDiagnosticSpelling = _clang_getDiagnosticSpellingPtr + .asFunction(); - /// \param Module a module object. + /// Return the element type of an array, complex, or vector type. /// - /// \returns the full name of the module, e.g. "std.vector". - CXString clang_Module_getFullName(CXModule Module) { - return _clang_Module_getFullName(Module); + /// If a type is passed in that is not an array, complex, or vector type, + /// an invalid type is returned. + CXType clang_getElementType(CXType T) { + return _clang_getElementType(T); } - late final _clang_Module_getFullNamePtr = - _lookup>( - 'clang_Module_getFullName', + late final _clang_getElementTypePtr = + _lookup>( + 'clang_getElementType', ); - late final _clang_Module_getFullName = _clang_Module_getFullNamePtr - .asFunction(); + late final _clang_getElementType = _clang_getElementTypePtr + .asFunction(); - /// \param Module a module object. + /// Retrieve the integer value of an enum constant declaration as an unsigned + /// long long. /// - /// \returns non-zero if the module is a system one. - int clang_Module_isSystem(CXModule Module) { - return _clang_Module_isSystem(Module); + /// If the cursor does not reference an enum constant declaration, ULLONG_MAX is returned. + /// Since this is also potentially a valid constant value, the kind of the cursor + /// must be verified before calling this function. + int clang_getEnumConstantDeclUnsignedValue(CXCursor C) { + return _clang_getEnumConstantDeclUnsignedValue(C); } - late final _clang_Module_isSystemPtr = - _lookup>( - 'clang_Module_isSystem', + late final _clang_getEnumConstantDeclUnsignedValuePtr = + _lookup>( + 'clang_getEnumConstantDeclUnsignedValue', ); - late final _clang_Module_isSystem = _clang_Module_isSystemPtr - .asFunction(); + late final _clang_getEnumConstantDeclUnsignedValue = + _clang_getEnumConstantDeclUnsignedValuePtr + .asFunction(); - /// \param Module a module object. + /// Retrieve the integer value of an enum constant declaration as a signed + /// long long. /// - /// \returns the number of top level headers associated with this module. - int clang_Module_getNumTopLevelHeaders( - CXTranslationUnit arg0, - CXModule Module, - ) { - return _clang_Module_getNumTopLevelHeaders(arg0, Module); + /// If the cursor does not reference an enum constant declaration, LLONG_MIN is returned. + /// Since this is also potentially a valid constant value, the kind of the cursor + /// must be verified before calling this function. + int clang_getEnumConstantDeclValue(CXCursor C) { + return _clang_getEnumConstantDeclValue(C); } - late final _clang_Module_getNumTopLevelHeadersPtr = - _lookup>( - 'clang_Module_getNumTopLevelHeaders', + late final _clang_getEnumConstantDeclValuePtr = + _lookup>( + 'clang_getEnumConstantDeclValue', ); - late final _clang_Module_getNumTopLevelHeaders = - _clang_Module_getNumTopLevelHeadersPtr - .asFunction(); + late final _clang_getEnumConstantDeclValue = + _clang_getEnumConstantDeclValuePtr + .asFunction(); - /// \param Module a module object. - /// - /// \param Index top level header index (zero-based). + /// Retrieve the integer type of an enum declaration. /// - /// \returns the specified top level header associated with the module. - CXFile clang_Module_getTopLevelHeader( - CXTranslationUnit arg0, - CXModule Module, - int Index, - ) { - return _clang_Module_getTopLevelHeader(arg0, Module, Index); - } - - late final _clang_Module_getTopLevelHeaderPtr = - _lookup>( - 'clang_Module_getTopLevelHeader', - ); - late final _clang_Module_getTopLevelHeader = - _clang_Module_getTopLevelHeaderPtr - .asFunction(); - - /// Determine if a C++ constructor is a converting constructor. - int clang_CXXConstructor_isConvertingConstructor(CXCursor C) { - return _clang_CXXConstructor_isConvertingConstructor(C); - } - - late final _clang_CXXConstructor_isConvertingConstructorPtr = - _lookup< - ffi.NativeFunction - >('clang_CXXConstructor_isConvertingConstructor'); - late final _clang_CXXConstructor_isConvertingConstructor = - _clang_CXXConstructor_isConvertingConstructorPtr - .asFunction(); - - /// Determine if a C++ constructor is a copy constructor. - int clang_CXXConstructor_isCopyConstructor(CXCursor C) { - return _clang_CXXConstructor_isCopyConstructor(C); + /// If the cursor does not reference an enum declaration, an invalid type is + /// returned. + CXType clang_getEnumDeclIntegerType(CXCursor C) { + return _clang_getEnumDeclIntegerType(C); } - late final _clang_CXXConstructor_isCopyConstructorPtr = - _lookup>( - 'clang_CXXConstructor_isCopyConstructor', + late final _clang_getEnumDeclIntegerTypePtr = + _lookup>( + 'clang_getEnumDeclIntegerType', ); - late final _clang_CXXConstructor_isCopyConstructor = - _clang_CXXConstructor_isCopyConstructorPtr - .asFunction(); - - /// Determine if a C++ constructor is the default constructor. - int clang_CXXConstructor_isDefaultConstructor(CXCursor C) { - return _clang_CXXConstructor_isDefaultConstructor(C); - } - - late final _clang_CXXConstructor_isDefaultConstructorPtr = - _lookup< - ffi.NativeFunction - >('clang_CXXConstructor_isDefaultConstructor'); - late final _clang_CXXConstructor_isDefaultConstructor = - _clang_CXXConstructor_isDefaultConstructorPtr - .asFunction(); + late final _clang_getEnumDeclIntegerType = _clang_getEnumDeclIntegerTypePtr + .asFunction(); - /// Determine if a C++ constructor is a move constructor. - int clang_CXXConstructor_isMoveConstructor(CXCursor C) { - return _clang_CXXConstructor_isMoveConstructor(C); + /// Retrieve the exception specification type associated with a function type. + /// This is a value of type CXCursor_ExceptionSpecificationKind. + /// + /// If a non-function type is passed in, an error code of -1 is returned. + int clang_getExceptionSpecificationType(CXType T) { + return _clang_getExceptionSpecificationType(T); } - late final _clang_CXXConstructor_isMoveConstructorPtr = - _lookup>( - 'clang_CXXConstructor_isMoveConstructor', + late final _clang_getExceptionSpecificationTypePtr = + _lookup>( + 'clang_getExceptionSpecificationType', ); - late final _clang_CXXConstructor_isMoveConstructor = - _clang_CXXConstructor_isMoveConstructorPtr - .asFunction(); + late final _clang_getExceptionSpecificationType = + _clang_getExceptionSpecificationTypePtr + .asFunction(); - /// Determine if a C++ field is declared 'mutable'. - int clang_CXXField_isMutable(CXCursor C) { - return _clang_CXXField_isMutable(C); + /// Retrieve the file, line, column, and offset represented by + /// the given source location. + /// + /// If the location refers into a macro expansion, retrieves the + /// location of the macro expansion. + /// + /// \param location the location within a source file that will be decomposed + /// into its parts. + /// + /// \param file [out] if non-NULL, will be set to the file to which the given + /// source location points. + /// + /// \param line [out] if non-NULL, will be set to the line to which the given + /// source location points. + /// + /// \param column [out] if non-NULL, will be set to the column to which the given + /// source location points. + /// + /// \param offset [out] if non-NULL, will be set to the offset into the + /// buffer to which the given source location points. + void clang_getExpansionLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ) { + return _clang_getExpansionLocation(location, file, line, column, offset); } - late final _clang_CXXField_isMutablePtr = - _lookup>( - 'clang_CXXField_isMutable', + late final _clang_getExpansionLocationPtr = + _lookup>( + 'clang_getExpansionLocation', ); - late final _clang_CXXField_isMutable = _clang_CXXField_isMutablePtr - .asFunction(); + late final _clang_getExpansionLocation = _clang_getExpansionLocationPtr + .asFunction(); - /// Determine if a C++ method is declared '= default'. - int clang_CXXMethod_isDefaulted(CXCursor C) { - return _clang_CXXMethod_isDefaulted(C); + /// Retrieve the bit width of a bit field declaration as an integer. + /// + /// If a cursor that is not a bit field declaration is passed in, -1 is returned. + int clang_getFieldDeclBitWidth(CXCursor C) { + return _clang_getFieldDeclBitWidth(C); } - late final _clang_CXXMethod_isDefaultedPtr = - _lookup>( - 'clang_CXXMethod_isDefaulted', + late final _clang_getFieldDeclBitWidthPtr = + _lookup>( + 'clang_getFieldDeclBitWidth', ); - late final _clang_CXXMethod_isDefaulted = _clang_CXXMethod_isDefaultedPtr - .asFunction(); + late final _clang_getFieldDeclBitWidth = _clang_getFieldDeclBitWidthPtr + .asFunction(); - /// Determine if a C++ member function or member function template is - /// pure virtual. - int clang_CXXMethod_isPureVirtual(CXCursor C) { - return _clang_CXXMethod_isPureVirtual(C); + /// Retrieve a file handle within the given translation unit. + /// + /// \param tu the translation unit + /// + /// \param file_name the name of the file. + /// + /// \returns the file handle for the named file in the translation unit \p tu, + /// or a NULL file handle if the file was not a part of this translation unit. + CXFile clang_getFile(CXTranslationUnit tu, ffi.Pointer file_name) { + return _clang_getFile(tu, file_name); } - late final _clang_CXXMethod_isPureVirtualPtr = - _lookup>( - 'clang_CXXMethod_isPureVirtual', - ); - late final _clang_CXXMethod_isPureVirtual = _clang_CXXMethod_isPureVirtualPtr - .asFunction(); + late final _clang_getFilePtr = + _lookup>('clang_getFile'); + late final _clang_getFile = _clang_getFilePtr.asFunction(); - /// Determine if a C++ member function or member function template is - /// declared 'static'. - int clang_CXXMethod_isStatic(CXCursor C) { - return _clang_CXXMethod_isStatic(C); + /// Retrieve the buffer associated with the given file. + /// + /// \param tu the translation unit + /// + /// \param file the file for which to retrieve the buffer. + /// + /// \param size [out] if non-NULL, will be set to the size of the buffer. + /// + /// \returns a pointer to the buffer in memory that holds the contents of + /// \p file, or a NULL pointer when the file is not loaded. + ffi.Pointer clang_getFileContents( + CXTranslationUnit tu, + CXFile file, + ffi.Pointer size, + ) { + return _clang_getFileContents(tu, file, size); } - late final _clang_CXXMethod_isStaticPtr = - _lookup>( - 'clang_CXXMethod_isStatic', + late final _clang_getFileContentsPtr = + _lookup>( + 'clang_getFileContents', ); - late final _clang_CXXMethod_isStatic = _clang_CXXMethod_isStaticPtr - .asFunction(); + late final _clang_getFileContents = _clang_getFileContentsPtr + .asFunction(); - /// Determine if a C++ member function or member function template is - /// explicitly declared 'virtual' or if it overrides a virtual method from - /// one of the base classes. - int clang_CXXMethod_isVirtual(CXCursor C) { - return _clang_CXXMethod_isVirtual(C); + /// Retrieve the file, line, column, and offset represented by + /// the given source location. + /// + /// If the location refers into a macro expansion, return where the macro was + /// expanded or where the macro argument was written, if the location points at + /// a macro argument. + /// + /// \param location the location within a source file that will be decomposed + /// into its parts. + /// + /// \param file [out] if non-NULL, will be set to the file to which the given + /// source location points. + /// + /// \param line [out] if non-NULL, will be set to the line to which the given + /// source location points. + /// + /// \param column [out] if non-NULL, will be set to the column to which the given + /// source location points. + /// + /// \param offset [out] if non-NULL, will be set to the offset into the + /// buffer to which the given source location points. + void clang_getFileLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ) { + return _clang_getFileLocation(location, file, line, column, offset); } - late final _clang_CXXMethod_isVirtualPtr = - _lookup>( - 'clang_CXXMethod_isVirtual', + late final _clang_getFileLocationPtr = + _lookup>( + 'clang_getFileLocation', ); - late final _clang_CXXMethod_isVirtual = _clang_CXXMethod_isVirtualPtr - .asFunction(); + late final _clang_getFileLocation = _clang_getFileLocationPtr + .asFunction(); - /// Determine if a C++ record is abstract, i.e. whether a class or struct - /// has a pure virtual member function. - int clang_CXXRecord_isAbstract(CXCursor C) { - return _clang_CXXRecord_isAbstract(C); + /// Retrieve the complete file and path name of the given file. + CXString clang_getFileName(CXFile SFile) { + return _clang_getFileName(SFile); } - late final _clang_CXXRecord_isAbstractPtr = - _lookup>( - 'clang_CXXRecord_isAbstract', - ); - late final _clang_CXXRecord_isAbstract = _clang_CXXRecord_isAbstractPtr - .asFunction(); + late final _clang_getFileNamePtr = + _lookup>('clang_getFileName'); + late final _clang_getFileName = _clang_getFileNamePtr + .asFunction(); - /// Determine if an enum declaration refers to a scoped enum. - int clang_EnumDecl_isScoped(CXCursor C) { - return _clang_EnumDecl_isScoped(C); + /// Retrieve the last modification time of the given file. + int clang_getFileTime(CXFile SFile) { + return _clang_getFileTime(SFile); } - late final _clang_EnumDecl_isScopedPtr = - _lookup>( - 'clang_EnumDecl_isScoped', - ); - late final _clang_EnumDecl_isScoped = _clang_EnumDecl_isScopedPtr - .asFunction(); + late final _clang_getFileTimePtr = + _lookup>('clang_getFileTime'); + late final _clang_getFileTime = _clang_getFileTimePtr + .asFunction(); - /// Determine if a C++ member function or member function template is - /// declared 'const'. - int clang_CXXMethod_isConst(CXCursor C) { - return _clang_CXXMethod_isConst(C); + /// Retrieve the unique ID for the given \c file. + /// + /// \param file the file to get the ID for. + /// \param outID stores the returned CXFileUniqueID. + /// \returns If there was a failure getting the unique ID, returns non-zero, + /// otherwise returns 0. + int clang_getFileUniqueID(CXFile file, ffi.Pointer outID) { + return _clang_getFileUniqueID(file, outID); } - late final _clang_CXXMethod_isConstPtr = - _lookup>( - 'clang_CXXMethod_isConst', + late final _clang_getFileUniqueIDPtr = + _lookup>( + 'clang_getFileUniqueID', ); - late final _clang_CXXMethod_isConst = _clang_CXXMethod_isConstPtr - .asFunction(); + late final _clang_getFileUniqueID = _clang_getFileUniqueIDPtr + .asFunction(); - /// Given a cursor that represents a template, determine - /// the cursor kind of the specializations would be generated by instantiating - /// the template. - /// - /// This routine can be used to determine what flavor of function template, - /// class template, or class template partial specialization is stored in the - /// cursor. For example, it can describe whether a class template cursor is - /// declared with "struct", "class" or "union". - /// - /// \param C The cursor to query. This cursor should represent a template - /// declaration. + /// Retrieve the calling convention associated with a function type. /// - /// \returns The cursor kind of the specializations that would be generated - /// by instantiating the template \p C. If \p C is not a template, returns - /// \c CXCursor_NoDeclFound. - CXCursorKind clang_getTemplateCursorKind(CXCursor C) { - return CXCursorKind.fromValue(_clang_getTemplateCursorKind(C)); + /// If a non-function type is passed in, CXCallingConv_Invalid is returned. + CXCallingConv clang_getFunctionTypeCallingConv(CXType T) { + return CXCallingConv.fromValue(_clang_getFunctionTypeCallingConv(T)); } - late final _clang_getTemplateCursorKindPtr = - _lookup>( - 'clang_getTemplateCursorKind', + late final _clang_getFunctionTypeCallingConvPtr = + _lookup>( + 'clang_getFunctionTypeCallingConv', ); - late final _clang_getTemplateCursorKind = _clang_getTemplateCursorKindPtr - .asFunction(); + late final _clang_getFunctionTypeCallingConv = + _clang_getFunctionTypeCallingConvPtr + .asFunction(); - /// Given a cursor that may represent a specialization or instantiation - /// of a template, retrieve the cursor that represents the template that it - /// specializes or from which it was instantiated. - /// - /// This routine determines the template involved both for explicit - /// specializations of templates and for implicit instantiations of the template, - /// both of which are referred to as "specializations". For a class template - /// specialization (e.g., \c std::vector), this routine will return - /// either the primary template (\c std::vector) or, if the specialization was - /// instantiated from a class template partial specialization, the class template - /// partial specialization. For a class template partial specialization and a - /// function template specialization (including instantiations), this - /// this routine will return the specialized template. - /// - /// For members of a class template (e.g., member functions, member classes, or - /// static data members), returns the specialized or instantiated member. - /// Although not strictly "templates" in the C++ language, members of class - /// templates have the same notions of specializations and instantiations that - /// templates do, so this routine treats them similarly. - /// - /// \param C A cursor that may be a specialization of a template or a member - /// of a template. - /// - /// \returns If the given cursor is a specialization or instantiation of a - /// template or a member thereof, the template or member that it specializes or - /// from which it was instantiated. Otherwise, returns a NULL cursor. - CXCursor clang_getSpecializedCursorTemplate(CXCursor C) { - return _clang_getSpecializedCursorTemplate(C); + /// For cursors representing an iboutletcollection attribute, + /// this function returns the collection element type. + CXType clang_getIBOutletCollectionType(CXCursor arg0) { + return _clang_getIBOutletCollectionType(arg0); } - late final _clang_getSpecializedCursorTemplatePtr = - _lookup>( - 'clang_getSpecializedCursorTemplate', + late final _clang_getIBOutletCollectionTypePtr = + _lookup>( + 'clang_getIBOutletCollectionType', ); - late final _clang_getSpecializedCursorTemplate = - _clang_getSpecializedCursorTemplatePtr - .asFunction(); + late final _clang_getIBOutletCollectionType = + _clang_getIBOutletCollectionTypePtr + .asFunction(); - /// Given a cursor that references something else, return the source range - /// covering that reference. - /// - /// \param C A cursor pointing to a member reference, a declaration reference, or - /// an operator call. - /// \param NameFlags A bitset with three independent flags: - /// CXNameRange_WantQualifier, CXNameRange_WantTemplateArgs, and - /// CXNameRange_WantSinglePiece. - /// \param PieceIndex For contiguous names or when passing the flag - /// CXNameRange_WantSinglePiece, only one piece with index 0 is - /// available. When the CXNameRange_WantSinglePiece flag is not passed for a - /// non-contiguous names, this index can be used to retrieve the individual - /// pieces of the name. See also CXNameRange_WantSinglePiece. - /// - /// \returns The piece of the name pointed to by the given cursor. If there is no - /// name, or if the PieceIndex is out-of-range, a null-cursor will be returned. - CXSourceRange clang_getCursorReferenceNameRange( - CXCursor C, - int NameFlags, - int PieceIndex, - ) { - return _clang_getCursorReferenceNameRange(C, NameFlags, PieceIndex); + /// Retrieve the file that is included by the given inclusion directive + /// cursor. + CXFile clang_getIncludedFile(CXCursor cursor) { + return _clang_getIncludedFile(cursor); } - late final _clang_getCursorReferenceNameRangePtr = - _lookup>( - 'clang_getCursorReferenceNameRange', + late final _clang_getIncludedFilePtr = + _lookup>( + 'clang_getIncludedFile', ); - late final _clang_getCursorReferenceNameRange = - _clang_getCursorReferenceNameRangePtr - .asFunction(); + late final _clang_getIncludedFile = _clang_getIncludedFilePtr + .asFunction(); - /// Get the raw lexical token starting with the given location. - /// - /// \param TU the translation unit whose text is being tokenized. - /// - /// \param Location the source location with which the token starts. - /// - /// \returns The token starting with the given location or NULL if no such token - /// exist. The returned pointer must be freed with clang_disposeTokens before the - /// translation unit is destroyed. - ffi.Pointer clang_getToken( - CXTranslationUnit TU, - CXSourceLocation Location, + /// Visit the set of preprocessor inclusions in a translation unit. + /// The visitor function is called with the provided data for every included + /// file. This does not include headers included by the PCH file (unless one + /// is inspecting the inclusions in the PCH file itself). + void clang_getInclusions( + CXTranslationUnit tu, + CXInclusionVisitor visitor, + CXClientData client_data, ) { - return _clang_getToken(TU, Location); - } - - late final _clang_getTokenPtr = - _lookup>('clang_getToken'); - late final _clang_getToken = _clang_getTokenPtr - .asFunction(); - - /// Determine the kind of the given token. - CXTokenKind clang_getTokenKind(CXToken arg0) { - return CXTokenKind.fromValue(_clang_getTokenKind(arg0)); + return _clang_getInclusions(tu, visitor, client_data); } - late final _clang_getTokenKindPtr = - _lookup>( - 'clang_getTokenKind', + late final _clang_getInclusionsPtr = + _lookup>( + 'clang_getInclusions', ); - late final _clang_getTokenKind = _clang_getTokenKindPtr - .asFunction(); + late final _clang_getInclusions = _clang_getInclusionsPtr + .asFunction(); - /// Determine the spelling of the given token. + /// Legacy API to retrieve the file, line, column, and offset represented + /// by the given source location. /// - /// The spelling of a token is the textual representation of that token, e.g., - /// the text of an identifier or keyword. - CXString clang_getTokenSpelling(CXTranslationUnit arg0, CXToken arg1) { - return _clang_getTokenSpelling(arg0, arg1); + /// This interface has been replaced by the newer interface + /// #clang_getExpansionLocation(). See that interface's documentation for + /// details. + void clang_getInstantiationLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ) { + return _clang_getInstantiationLocation( + location, + file, + line, + column, + offset, + ); } - late final _clang_getTokenSpellingPtr = - _lookup>( - 'clang_getTokenSpelling', + late final _clang_getInstantiationLocationPtr = + _lookup>( + 'clang_getInstantiationLocation', ); - late final _clang_getTokenSpelling = _clang_getTokenSpellingPtr - .asFunction(); + late final _clang_getInstantiationLocation = + _clang_getInstantiationLocationPtr + .asFunction(); - /// Retrieve the source location of the given token. - CXSourceLocation clang_getTokenLocation( - CXTranslationUnit arg0, - CXToken arg1, + /// Retrieves the source location associated with a given file/line/column + /// in a particular translation unit. + CXSourceLocation clang_getLocation( + CXTranslationUnit tu, + CXFile file, + int line, + int column, ) { - return _clang_getTokenLocation(arg0, arg1); + return _clang_getLocation(tu, file, line, column); } - late final _clang_getTokenLocationPtr = - _lookup>( - 'clang_getTokenLocation', + late final _clang_getLocationPtr = + _lookup>('clang_getLocation'); + late final _clang_getLocation = _clang_getLocationPtr + .asFunction(); + + /// Retrieves the source location associated with a given character offset + /// in a particular translation unit. + CXSourceLocation clang_getLocationForOffset( + CXTranslationUnit tu, + CXFile file, + int offset, + ) { + return _clang_getLocationForOffset(tu, file, offset); + } + + late final _clang_getLocationForOffsetPtr = + _lookup>( + 'clang_getLocationForOffset', ); - late final _clang_getTokenLocation = _clang_getTokenLocationPtr - .asFunction(); + late final _clang_getLocationForOffset = _clang_getLocationForOffsetPtr + .asFunction(); - /// Retrieve a source range that covers the given token. - CXSourceRange clang_getTokenExtent(CXTranslationUnit arg0, CXToken arg1) { - return _clang_getTokenExtent(arg0, arg1); + /// Given a CXFile header file, return the module that contains it, if one + /// exists. + CXModule clang_getModuleForFile(CXTranslationUnit arg0, CXFile arg1) { + return _clang_getModuleForFile(arg0, arg1); } - late final _clang_getTokenExtentPtr = - _lookup>( - 'clang_getTokenExtent', + late final _clang_getModuleForFilePtr = + _lookup>( + 'clang_getModuleForFile', ); - late final _clang_getTokenExtent = _clang_getTokenExtentPtr - .asFunction(); + late final _clang_getModuleForFile = _clang_getModuleForFilePtr + .asFunction(); - /// Tokenize the source code described by the given range into raw - /// lexical tokens. - /// - /// \param TU the translation unit whose text is being tokenized. - /// - /// \param Range the source range in which text should be tokenized. All of the - /// tokens produced by tokenization will fall within this source range, - /// - /// \param Tokens this pointer will be set to point to the array of tokens - /// that occur within the given source range. The returned pointer must be - /// freed with clang_disposeTokens() before the translation unit is destroyed. - /// - /// \param NumTokens will be set to the number of tokens in the \c *Tokens - /// array. - void clang_tokenize( - CXTranslationUnit TU, - CXSourceRange Range, - ffi.Pointer> Tokens, - ffi.Pointer NumTokens, - ) { - return _clang_tokenize(TU, Range, Tokens, NumTokens); + /// Retrieve the NULL cursor, which represents no entity. + CXCursor clang_getNullCursor() { + return _clang_getNullCursor(); } - late final _clang_tokenizePtr = - _lookup>('clang_tokenize'); - late final _clang_tokenize = _clang_tokenizePtr - .asFunction(); + late final _clang_getNullCursorPtr = + _lookup>( + 'clang_getNullCursor', + ); + late final _clang_getNullCursor = _clang_getNullCursorPtr + .asFunction(); - /// Annotate the given set of tokens by providing cursors for each token - /// that can be mapped to a specific entity within the abstract syntax tree. - /// - /// This token-annotation routine is equivalent to invoking - /// clang_getCursor() for the source locations of each of the - /// tokens. The cursors provided are filtered, so that only those - /// cursors that have a direct correspondence to the token are - /// accepted. For example, given a function call \c f(x), - /// clang_getCursor() would provide the following cursors: - /// - /// * when the cursor is over the 'f', a DeclRefExpr cursor referring to 'f'. - /// * when the cursor is over the '(' or the ')', a CallExpr referring to 'f'. - /// * when the cursor is over the 'x', a DeclRefExpr cursor referring to 'x'. - /// - /// Only the first and last of these cursors will occur within the - /// annotate, since the tokens "f" and "x' directly refer to a function - /// and a variable, respectively, but the parentheses are just a small - /// part of the full syntax of the function call expression, which is - /// not provided as an annotation. - /// - /// \param TU the translation unit that owns the given tokens. - /// - /// \param Tokens the set of tokens to annotate. - /// - /// \param NumTokens the number of tokens in \p Tokens. - /// - /// \param Cursors an array of \p NumTokens cursors, whose contents will be - /// replaced with the cursors corresponding to each token. - void clang_annotateTokens( - CXTranslationUnit TU, - ffi.Pointer Tokens, - int NumTokens, - ffi.Pointer Cursors, - ) { - return _clang_annotateTokens(TU, Tokens, NumTokens, Cursors); + /// Retrieve a NULL (invalid) source location. + CXSourceLocation clang_getNullLocation() { + return _clang_getNullLocation(); } - late final _clang_annotateTokensPtr = - _lookup>( - 'clang_annotateTokens', + late final _clang_getNullLocationPtr = + _lookup>( + 'clang_getNullLocation', ); - late final _clang_annotateTokens = _clang_annotateTokensPtr - .asFunction(); + late final _clang_getNullLocation = _clang_getNullLocationPtr + .asFunction(); - /// Free the given set of tokens. - void clang_disposeTokens( - CXTranslationUnit TU, - ffi.Pointer Tokens, - int NumTokens, - ) { - return _clang_disposeTokens(TU, Tokens, NumTokens); + /// Retrieve a NULL (invalid) source range. + CXSourceRange clang_getNullRange() { + return _clang_getNullRange(); } - late final _clang_disposeTokensPtr = - _lookup>( - 'clang_disposeTokens', + late final _clang_getNullRangePtr = + _lookup>( + 'clang_getNullRange', ); - late final _clang_disposeTokens = _clang_disposeTokensPtr - .asFunction(); + late final _clang_getNullRange = _clang_getNullRangePtr + .asFunction(); - /// \defgroup CINDEX_DEBUG Debugging facilities - /// - /// These routines are used for testing and debugging, only, and should not - /// be relied upon. + /// Retrieve the number of non-variadic parameters associated with a + /// function type. /// - /// @{ - CXString clang_getCursorKindSpelling(CXCursorKind Kind) { - return _clang_getCursorKindSpelling(Kind.value); + /// If a non-function type is passed in, -1 is returned. + int clang_getNumArgTypes(CXType T) { + return _clang_getNumArgTypes(T); } - late final _clang_getCursorKindSpellingPtr = - _lookup>( - 'clang_getCursorKindSpelling', + late final _clang_getNumArgTypesPtr = + _lookup>( + 'clang_getNumArgTypes', ); - late final _clang_getCursorKindSpelling = _clang_getCursorKindSpellingPtr - .asFunction(); + late final _clang_getNumArgTypes = _clang_getNumArgTypesPtr + .asFunction(); - void clang_getDefinitionSpellingAndExtent( - CXCursor arg0, - ffi.Pointer> startBuf, - ffi.Pointer> endBuf, - ffi.Pointer startLine, - ffi.Pointer startColumn, - ffi.Pointer endLine, - ffi.Pointer endColumn, - ) { - return _clang_getDefinitionSpellingAndExtent( - arg0, - startBuf, - endBuf, - startLine, - startColumn, - endLine, - endColumn, - ); + /// Retrieve the number of chunks in the given code-completion string. + int clang_getNumCompletionChunks(CXCompletionString completion_string) { + return _clang_getNumCompletionChunks(completion_string); } - late final _clang_getDefinitionSpellingAndExtentPtr = - _lookup>( - 'clang_getDefinitionSpellingAndExtent', + late final _clang_getNumCompletionChunksPtr = + _lookup>( + 'clang_getNumCompletionChunks', ); - late final _clang_getDefinitionSpellingAndExtent = - _clang_getDefinitionSpellingAndExtentPtr - .asFunction(); + late final _clang_getNumCompletionChunks = _clang_getNumCompletionChunksPtr + .asFunction(); - void clang_enableStackTraces() { - return _clang_enableStackTraces(); + /// Determine the number of diagnostics produced for the given + /// translation unit. + int clang_getNumDiagnostics(CXTranslationUnit Unit) { + return _clang_getNumDiagnostics(Unit); } - late final _clang_enableStackTracesPtr = - _lookup>( - 'clang_enableStackTraces', + late final _clang_getNumDiagnosticsPtr = + _lookup>( + 'clang_getNumDiagnostics', ); - late final _clang_enableStackTraces = _clang_enableStackTracesPtr - .asFunction(); + late final _clang_getNumDiagnostics = _clang_getNumDiagnosticsPtr + .asFunction(); - void clang_executeOnThread( - ffi.Pointer)>> - fn, - ffi.Pointer user_data, - int stack_size, - ) { - return _clang_executeOnThread(fn, user_data, stack_size); + /// Determine the number of diagnostics in a CXDiagnosticSet. + int clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags) { + return _clang_getNumDiagnosticsInSet(Diags); } - late final _clang_executeOnThreadPtr = - _lookup>( - 'clang_executeOnThread', + late final _clang_getNumDiagnosticsInSetPtr = + _lookup>( + 'clang_getNumDiagnosticsInSet', ); - late final _clang_executeOnThread = _clang_executeOnThreadPtr - .asFunction(); + late final _clang_getNumDiagnosticsInSet = _clang_getNumDiagnosticsInSetPtr + .asFunction(); - /// Determine the kind of a particular chunk within a completion string. - /// - /// \param completion_string the completion string to query. - /// - /// \param chunk_number the 0-based index of the chunk in the completion string. + /// Return the number of elements of an array or vector type. /// - /// \returns the kind of the chunk at the index \c chunk_number. - CXCompletionChunkKind clang_getCompletionChunkKind( - CXCompletionString completion_string, - int chunk_number, - ) { - return CXCompletionChunkKind.fromValue( - _clang_getCompletionChunkKind(completion_string, chunk_number), - ); + /// If a type is passed in that is not an array or vector type, + /// -1 is returned. + int clang_getNumElements(CXType T) { + return _clang_getNumElements(T); } - late final _clang_getCompletionChunkKindPtr = - _lookup>( - 'clang_getCompletionChunkKind', + late final _clang_getNumElementsPtr = + _lookup>( + 'clang_getNumElements', ); - late final _clang_getCompletionChunkKind = _clang_getCompletionChunkKindPtr - .asFunction(); + late final _clang_getNumElements = _clang_getNumElementsPtr + .asFunction(); - /// Retrieve the text associated with a particular chunk within a - /// completion string. - /// - /// \param completion_string the completion string to query. + /// Determine the number of overloaded declarations referenced by a + /// \c CXCursor_OverloadedDeclRef cursor. /// - /// \param chunk_number the 0-based index of the chunk in the completion string. + /// \param cursor The cursor whose overloaded declarations are being queried. /// - /// \returns the text associated with the chunk at index \c chunk_number. - CXString clang_getCompletionChunkText( - CXCompletionString completion_string, - int chunk_number, - ) { - return _clang_getCompletionChunkText(completion_string, chunk_number); + /// \returns The number of overloaded declarations referenced by \c cursor. If it + /// is not a \c CXCursor_OverloadedDeclRef cursor, returns 0. + int clang_getNumOverloadedDecls(CXCursor cursor) { + return _clang_getNumOverloadedDecls(cursor); } - late final _clang_getCompletionChunkTextPtr = - _lookup>( - 'clang_getCompletionChunkText', + late final _clang_getNumOverloadedDeclsPtr = + _lookup>( + 'clang_getNumOverloadedDecls', ); - late final _clang_getCompletionChunkText = _clang_getCompletionChunkTextPtr - .asFunction(); + late final _clang_getNumOverloadedDecls = _clang_getNumOverloadedDeclsPtr + .asFunction(); - /// Retrieve the completion string associated with a particular chunk - /// within a completion string. + /// Retrieve a cursor for one of the overloaded declarations referenced + /// by a \c CXCursor_OverloadedDeclRef cursor. /// - /// \param completion_string the completion string to query. + /// \param cursor The cursor whose overloaded declarations are being queried. /// - /// \param chunk_number the 0-based index of the chunk in the completion string. + /// \param index The zero-based index into the set of overloaded declarations in + /// the cursor. /// - /// \returns the completion string associated with the chunk at index - /// \c chunk_number. - CXCompletionString clang_getCompletionChunkCompletionString( - CXCompletionString completion_string, - int chunk_number, - ) { - return _clang_getCompletionChunkCompletionString( - completion_string, - chunk_number, - ); - } - - late final _clang_getCompletionChunkCompletionStringPtr = - _lookup< - ffi.NativeFunction - >('clang_getCompletionChunkCompletionString'); - late final _clang_getCompletionChunkCompletionString = - _clang_getCompletionChunkCompletionStringPtr - .asFunction(); - - /// Retrieve the number of chunks in the given code-completion string. - int clang_getNumCompletionChunks(CXCompletionString completion_string) { - return _clang_getNumCompletionChunks(completion_string); + /// \returns A cursor representing the declaration referenced by the given + /// \c cursor at the specified \c index. If the cursor does not have an + /// associated set of overloaded declarations, or if the index is out of bounds, + /// returns \c clang_getNullCursor(); + CXCursor clang_getOverloadedDecl(CXCursor cursor, int index) { + return _clang_getOverloadedDecl(cursor, index); } - late final _clang_getNumCompletionChunksPtr = - _lookup>( - 'clang_getNumCompletionChunks', + late final _clang_getOverloadedDeclPtr = + _lookup>( + 'clang_getOverloadedDecl', ); - late final _clang_getNumCompletionChunks = _clang_getNumCompletionChunksPtr - .asFunction(); + late final _clang_getOverloadedDecl = _clang_getOverloadedDeclPtr + .asFunction(); - /// Determine the priority of this code completion. + /// Determine the set of methods that are overridden by the given + /// method. /// - /// The priority of a code completion indicates how likely it is that this - /// particular completion is the completion that the user will select. The - /// priority is selected by various internal heuristics. + /// In both Objective-C and C++, a method (aka virtual member function, + /// in C++) can override a virtual method in a base class. For + /// Objective-C, a method is said to override any method in the class's + /// base class, its protocols, or its categories' protocols, that has the same + /// selector and is of the same kind (class or instance). + /// If no such method exists, the search continues to the class's superclass, + /// its protocols, and its categories, and so on. A method from an Objective-C + /// implementation is considered to override the same methods as its + /// corresponding method in the interface. /// - /// \param completion_string The completion string to query. + /// For C++, a virtual member function overrides any virtual member + /// function with the same signature that occurs in its base + /// classes. With multiple inheritance, a virtual member function can + /// override several virtual member functions coming from different + /// base classes. /// - /// \returns The priority of this completion string. Smaller values indicate - /// higher-priority (more likely) completions. - int clang_getCompletionPriority(CXCompletionString completion_string) { - return _clang_getCompletionPriority(completion_string); - } - - late final _clang_getCompletionPriorityPtr = - _lookup>( - 'clang_getCompletionPriority', - ); - late final _clang_getCompletionPriority = _clang_getCompletionPriorityPtr - .asFunction(); - - /// Determine the availability of the entity that this code-completion - /// string refers to. + /// In all cases, this function determines the immediate overridden + /// method, rather than all of the overridden methods. For example, if + /// a method is originally declared in a class A, then overridden in B + /// (which in inherits from A) and also in C (which inherited from B), + /// then the only overridden method returned from this function when + /// invoked on C's method will be B's method. The client may then + /// invoke this function again, given the previously-found overridden + /// methods, to map out the complete method-override set. /// - /// \param completion_string The completion string to query. + /// \param cursor A cursor representing an Objective-C or C++ + /// method. This routine will compute the set of methods that this + /// method overrides. /// - /// \returns The availability of the completion string. - CXAvailabilityKind clang_getCompletionAvailability( - CXCompletionString completion_string, + /// \param overridden A pointer whose pointee will be replaced with a + /// pointer to an array of cursors, representing the set of overridden + /// methods. If there are no overridden methods, the pointee will be + /// set to NULL. The pointee must be freed via a call to + /// \c clang_disposeOverriddenCursors(). + /// + /// \param num_overridden A pointer to the number of overridden + /// functions, will be set to the number of overridden functions in the + /// array pointed to by \p overridden. + void clang_getOverriddenCursors( + CXCursor cursor, + ffi.Pointer> overridden, + ffi.Pointer num_overridden, ) { - return CXAvailabilityKind.fromValue( - _clang_getCompletionAvailability(completion_string), - ); + return _clang_getOverriddenCursors(cursor, overridden, num_overridden); } - late final _clang_getCompletionAvailabilityPtr = - _lookup>( - 'clang_getCompletionAvailability', + late final _clang_getOverriddenCursorsPtr = + _lookup>( + 'clang_getOverriddenCursors', ); - late final _clang_getCompletionAvailability = - _clang_getCompletionAvailabilityPtr - .asFunction(); + late final _clang_getOverriddenCursors = _clang_getOverriddenCursorsPtr + .asFunction(); - /// Retrieve the number of annotations associated with the given - /// completion string. - /// - /// \param completion_string the completion string to query. - /// - /// \returns the number of annotations associated with the given completion - /// string. - int clang_getCompletionNumAnnotations(CXCompletionString completion_string) { - return _clang_getCompletionNumAnnotations(completion_string); + /// For pointer types, returns the type of the pointee. + CXType clang_getPointeeType(CXType T) { + return _clang_getPointeeType(T); } - late final _clang_getCompletionNumAnnotationsPtr = - _lookup>( - 'clang_getCompletionNumAnnotations', + late final _clang_getPointeeTypePtr = + _lookup>( + 'clang_getPointeeType', ); - late final _clang_getCompletionNumAnnotations = - _clang_getCompletionNumAnnotationsPtr - .asFunction(); + late final _clang_getPointeeType = _clang_getPointeeTypePtr + .asFunction(); - /// Retrieve the annotation associated with the given completion string. - /// - /// \param completion_string the completion string to query. + /// Retrieve the file, line and column represented by the given source + /// location, as specified in a # line directive. /// - /// \param annotation_number the 0-based index of the annotation of the - /// completion string. + /// Example: given the following source code in a file somefile.c /// - /// \returns annotation string associated with the completion at index - /// \c annotation_number, or a NULL string if that annotation is not available. - CXString clang_getCompletionAnnotation( - CXCompletionString completion_string, - int annotation_number, - ) { - return _clang_getCompletionAnnotation(completion_string, annotation_number); - } - - late final _clang_getCompletionAnnotationPtr = - _lookup>( - 'clang_getCompletionAnnotation', - ); - late final _clang_getCompletionAnnotation = _clang_getCompletionAnnotationPtr - .asFunction(); - - /// Retrieve the parent context of the given completion string. + /// \code + /// #123 "dummy.c" 1 /// - /// The parent context of a completion string is the semantic parent of - /// the declaration (if any) that the code completion represents. For example, - /// a code completion for an Objective-C method would have the method's class - /// or protocol as its context. + /// static int func(void) + /// { + /// return 0; + /// } + /// \endcode /// - /// \param completion_string The code completion string whose parent is - /// being queried. + /// the location information returned by this function would be /// - /// \param kind DEPRECATED: always set to CXCursor_NotImplemented if non-NULL. + /// File: dummy.c Line: 124 Column: 12 /// - /// \returns The name of the completion parent, e.g., "NSObject" if - /// the completion string represents a method in the NSObject class. - CXString clang_getCompletionParent( - CXCompletionString completion_string, - ffi.Pointer kind, + /// whereas clang_getExpansionLocation would have returned + /// + /// File: somefile.c Line: 3 Column: 12 + /// + /// \param location the location within a source file that will be decomposed + /// into its parts. + /// + /// \param filename [out] if non-NULL, will be set to the filename of the + /// source location. Note that filenames returned will be for "virtual" files, + /// which don't necessarily exist on the machine running clang - e.g. when + /// parsing preprocessed output obtained from a different environment. If + /// a non-NULL value is passed in, remember to dispose of the returned value + /// using \c clang_disposeString() once you've finished with it. For an invalid + /// source location, an empty string is returned. + /// + /// \param line [out] if non-NULL, will be set to the line number of the + /// source location. For an invalid source location, zero is returned. + /// + /// \param column [out] if non-NULL, will be set to the column number of the + /// source location. For an invalid source location, zero is returned. + void clang_getPresumedLocation( + CXSourceLocation location, + ffi.Pointer filename, + ffi.Pointer line, + ffi.Pointer column, ) { - return _clang_getCompletionParent(completion_string, kind); + return _clang_getPresumedLocation(location, filename, line, column); } - late final _clang_getCompletionParentPtr = - _lookup>( - 'clang_getCompletionParent', + late final _clang_getPresumedLocationPtr = + _lookup>( + 'clang_getPresumedLocation', ); - late final _clang_getCompletionParent = _clang_getCompletionParentPtr - .asFunction(); + late final _clang_getPresumedLocation = _clang_getPresumedLocationPtr + .asFunction(); - /// Retrieve the brief documentation comment attached to the declaration - /// that corresponds to the given completion string. - CXString clang_getCompletionBriefComment( - CXCompletionString completion_string, - ) { - return _clang_getCompletionBriefComment(completion_string); + /// Retrieve a source range given the beginning and ending source + /// locations. + CXSourceRange clang_getRange(CXSourceLocation begin, CXSourceLocation end) { + return _clang_getRange(begin, end); } - late final _clang_getCompletionBriefCommentPtr = - _lookup>( - 'clang_getCompletionBriefComment', + late final _clang_getRangePtr = + _lookup>('clang_getRange'); + late final _clang_getRange = _clang_getRangePtr + .asFunction(); + + /// Retrieve a source location representing the last character within a + /// source range. + CXSourceLocation clang_getRangeEnd(CXSourceRange range) { + return _clang_getRangeEnd(range); + } + + late final _clang_getRangeEndPtr = + _lookup>('clang_getRangeEnd'); + late final _clang_getRangeEnd = _clang_getRangeEndPtr + .asFunction(); + + /// Retrieve a source location representing the first character within a + /// source range. + CXSourceLocation clang_getRangeStart(CXSourceRange range) { + return _clang_getRangeStart(range); + } + + late final _clang_getRangeStartPtr = + _lookup>( + 'clang_getRangeStart', ); - late final _clang_getCompletionBriefComment = - _clang_getCompletionBriefCommentPtr - .asFunction(); + late final _clang_getRangeStart = _clang_getRangeStartPtr + .asFunction(); - /// Retrieve a completion string for an arbitrary declaration or macro - /// definition cursor. + /// Retrieve a remapping. /// - /// \param cursor The cursor to query. + /// \param path the path that contains metadata about remappings. /// - /// \returns A non-context-sensitive completion string for declaration and macro - /// definition cursors, or NULL for other kinds of cursors. - CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { - return _clang_getCursorCompletionString(cursor); + /// \returns the requested remapping. This remapping must be freed + /// via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. + CXRemapping clang_getRemappings(ffi.Pointer path) { + return _clang_getRemappings(path); } - late final _clang_getCursorCompletionStringPtr = - _lookup>( - 'clang_getCursorCompletionString', + late final _clang_getRemappingsPtr = + _lookup>( + 'clang_getRemappings', ); - late final _clang_getCursorCompletionString = - _clang_getCursorCompletionStringPtr - .asFunction(); + late final _clang_getRemappings = _clang_getRemappingsPtr + .asFunction(); - /// Retrieve the number of fix-its for the given completion index. - /// - /// Calling this makes sense only if CXCodeComplete_IncludeCompletionsWithFixIts - /// option was set. + /// Retrieve a remapping. /// - /// \param results The structure keeping all completion results + /// \param filePaths pointer to an array of file paths containing remapping info. /// - /// \param completion_index The index of the completion + /// \param numFiles number of file paths. /// - /// \return The number of fix-its which must be applied before the completion at - /// completion_index can be applied - int clang_getCompletionNumFixIts( - ffi.Pointer results, - int completion_index, + /// \returns the requested remapping. This remapping must be freed + /// via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. + CXRemapping clang_getRemappingsFromFileList( + ffi.Pointer> filePaths, + int numFiles, ) { - return _clang_getCompletionNumFixIts(results, completion_index); + return _clang_getRemappingsFromFileList(filePaths, numFiles); } - late final _clang_getCompletionNumFixItsPtr = - _lookup>( - 'clang_getCompletionNumFixIts', + late final _clang_getRemappingsFromFileListPtr = + _lookup>( + 'clang_getRemappingsFromFileList', ); - late final _clang_getCompletionNumFixIts = _clang_getCompletionNumFixItsPtr - .asFunction(); + late final _clang_getRemappingsFromFileList = + _clang_getRemappingsFromFileListPtr + .asFunction(); - /// Fix-its that *must* be applied before inserting the text for the - /// corresponding completion. - /// - /// By default, clang_codeCompleteAt() only returns completions with empty - /// fix-its. Extra completions with non-empty fix-its should be explicitly - /// requested by setting CXCodeComplete_IncludeCompletionsWithFixIts. - /// - /// For the clients to be able to compute position of the cursor after applying - /// fix-its, the following conditions are guaranteed to hold for - /// replacement_range of the stored fix-its: - /// - Ranges in the fix-its are guaranteed to never contain the completion - /// point (or identifier under completion point, if any) inside them, except - /// at the start or at the end of the range. - /// - If a fix-it range starts or ends with completion point (or starts or - /// ends after the identifier under completion point), it will contain at - /// least one character. It allows to unambiguously recompute completion - /// point after applying the fix-it. - /// - /// The intuition is that provided fix-its change code around the identifier we - /// complete, but are not allowed to touch the identifier itself or the - /// completion point. One example of completions with corrections are the ones - /// replacing '.' with '->' and vice versa: - /// - /// std::unique_ptr> vec_ptr; - /// In 'vec_ptr.^', one of the completions is 'push_back', it requires - /// replacing '.' with '->'. - /// In 'vec_ptr->^', one of the completions is 'release', it requires - /// replacing '->' with '.'. - /// - /// \param results The structure keeping all completion results - /// - /// \param completion_index The index of the completion - /// - /// \param fixit_index The index of the fix-it for the completion at - /// completion_index - /// - /// \param replacement_range The fix-it range that must be replaced before the - /// completion at completion_index can be applied + /// Retrieve the return type associated with a function type. /// - /// \returns The fix-it string that must replace the code at replacement_range - /// before the completion at completion_index can be applied - CXString clang_getCompletionFixIt( - ffi.Pointer results, - int completion_index, - int fixit_index, - ffi.Pointer replacement_range, - ) { - return _clang_getCompletionFixIt( - results, - completion_index, - fixit_index, - replacement_range, - ); + /// If a non-function type is passed in, an invalid type is returned. + CXType clang_getResultType(CXType T) { + return _clang_getResultType(T); } - late final _clang_getCompletionFixItPtr = - _lookup>( - 'clang_getCompletionFixIt', + late final _clang_getResultTypePtr = + _lookup>( + 'clang_getResultType', ); - late final _clang_getCompletionFixIt = _clang_getCompletionFixItPtr - .asFunction(); + late final _clang_getResultType = _clang_getResultTypePtr + .asFunction(); - /// Returns a default set of code-completion options that can be - /// passed to\c clang_codeCompleteAt(). - int clang_defaultCodeCompleteOptions() { - return _clang_defaultCodeCompleteOptions(); + /// Retrieve all ranges that were skipped by the preprocessor. + /// + /// The preprocessor will skip lines when they are surrounded by an + /// if/ifdef/ifndef directive whose condition does not evaluate to true. + ffi.Pointer clang_getSkippedRanges( + CXTranslationUnit tu, + CXFile file, + ) { + return _clang_getSkippedRanges(tu, file); } - late final _clang_defaultCodeCompleteOptionsPtr = - _lookup>( - 'clang_defaultCodeCompleteOptions', + late final _clang_getSkippedRangesPtr = + _lookup>( + 'clang_getSkippedRanges', ); - late final _clang_defaultCodeCompleteOptions = - _clang_defaultCodeCompleteOptionsPtr - .asFunction(); + late final _clang_getSkippedRanges = _clang_getSkippedRangesPtr + .asFunction(); - /// Perform code completion at a given location in a translation unit. + /// Given a cursor that may represent a specialization or instantiation + /// of a template, retrieve the cursor that represents the template that it + /// specializes or from which it was instantiated. /// - /// This function performs code completion at a particular file, line, and - /// column within source code, providing results that suggest potential - /// code snippets based on the context of the completion. The basic model - /// for code completion is that Clang will parse a complete source file, - /// performing syntax checking up to the location where code-completion has - /// been requested. At that point, a special code-completion token is passed - /// to the parser, which recognizes this token and determines, based on the - /// current location in the C/Objective-C/C++ grammar and the state of - /// semantic analysis, what completions to provide. These completions are - /// returned via a new \c CXCodeCompleteResults structure. - /// - /// Code completion itself is meant to be triggered by the client when the - /// user types punctuation characters or whitespace, at which point the - /// code-completion location will coincide with the cursor. For example, if \c p - /// is a pointer, code-completion might be triggered after the "-" and then - /// after the ">" in \c p->. When the code-completion location is after the ">", - /// the completion results will provide, e.g., the members of the struct that - /// "p" points to. The client is responsible for placing the cursor at the - /// beginning of the token currently being typed, then filtering the results - /// based on the contents of the token. For example, when code-completing for - /// the expression \c p->get, the client should provide the location just after - /// the ">" (e.g., pointing at the "g") to this code-completion hook. Then, the - /// client can filter the results based on the current token text ("get"), only - /// showing those results that start with "get". The intent of this interface - /// is to separate the relatively high-latency acquisition of code-completion - /// results from the filtering of results on a per-character basis, which must - /// have a lower latency. + /// This routine determines the template involved both for explicit + /// specializations of templates and for implicit instantiations of the template, + /// both of which are referred to as "specializations". For a class template + /// specialization (e.g., \c std::vector), this routine will return + /// either the primary template (\c std::vector) or, if the specialization was + /// instantiated from a class template partial specialization, the class template + /// partial specialization. For a class template partial specialization and a + /// function template specialization (including instantiations), this + /// this routine will return the specialized template. /// - /// \param TU The translation unit in which code-completion should - /// occur. The source files for this translation unit need not be - /// completely up-to-date (and the contents of those source files may - /// be overridden via \p unsaved_files). Cursors referring into the - /// translation unit may be invalidated by this invocation. + /// For members of a class template (e.g., member functions, member classes, or + /// static data members), returns the specialized or instantiated member. + /// Although not strictly "templates" in the C++ language, members of class + /// templates have the same notions of specializations and instantiations that + /// templates do, so this routine treats them similarly. /// - /// \param complete_filename The name of the source file where code - /// completion should be performed. This filename may be any file - /// included in the translation unit. + /// \param C A cursor that may be a specialization of a template or a member + /// of a template. /// - /// \param complete_line The line at which code-completion should occur. + /// \returns If the given cursor is a specialization or instantiation of a + /// template or a member thereof, the template or member that it specializes or + /// from which it was instantiated. Otherwise, returns a NULL cursor. + CXCursor clang_getSpecializedCursorTemplate(CXCursor C) { + return _clang_getSpecializedCursorTemplate(C); + } + + late final _clang_getSpecializedCursorTemplatePtr = + _lookup>( + 'clang_getSpecializedCursorTemplate', + ); + late final _clang_getSpecializedCursorTemplate = + _clang_getSpecializedCursorTemplatePtr + .asFunction(); + + /// Retrieve the file, line, column, and offset represented by + /// the given source location. /// - /// \param complete_column The column at which code-completion should occur. - /// Note that the column should point just after the syntactic construct that - /// initiated code completion, and not in the middle of a lexical token. + /// If the location refers into a macro instantiation, return where the + /// location was originally spelled in the source file. /// - /// \param unsaved_files the Files that have not yet been saved to disk - /// but may be required for parsing or code completion, including the - /// contents of those files. The contents and name of these files (as - /// specified by CXUnsavedFile) are copied when necessary, so the - /// client only needs to guarantee their validity until the call to - /// this function returns. + /// \param location the location within a source file that will be decomposed + /// into its parts. /// - /// \param num_unsaved_files The number of unsaved file entries in \p - /// unsaved_files. + /// \param file [out] if non-NULL, will be set to the file to which the given + /// source location points. /// - /// \param options Extra options that control the behavior of code - /// completion, expressed as a bitwise OR of the enumerators of the - /// CXCodeComplete_Flags enumeration. The - /// \c clang_defaultCodeCompleteOptions() function returns a default set - /// of code-completion options. + /// \param line [out] if non-NULL, will be set to the line to which the given + /// source location points. /// - /// \returns If successful, a new \c CXCodeCompleteResults structure - /// containing code-completion results, which should eventually be - /// freed with \c clang_disposeCodeCompleteResults(). If code - /// completion fails, returns NULL. - ffi.Pointer clang_codeCompleteAt( - CXTranslationUnit TU, - ffi.Pointer complete_filename, - int complete_line, - int complete_column, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ) { - return _clang_codeCompleteAt( - TU, - complete_filename, - complete_line, - complete_column, - unsaved_files, - num_unsaved_files, - options, - ); - } - - late final _clang_codeCompleteAtPtr = - _lookup>( - 'clang_codeCompleteAt', - ); - late final _clang_codeCompleteAt = _clang_codeCompleteAtPtr - .asFunction(); - - /// Sort the code-completion results in case-insensitive alphabetical - /// order. + /// \param column [out] if non-NULL, will be set to the column to which the given + /// source location points. /// - /// \param Results The set of results to sort. - /// \param NumResults The number of results in \p Results. - void clang_sortCodeCompletionResults( - ffi.Pointer Results, - int NumResults, + /// \param offset [out] if non-NULL, will be set to the offset into the + /// buffer to which the given source location points. + void clang_getSpellingLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, ) { - return _clang_sortCodeCompletionResults(Results, NumResults); + return _clang_getSpellingLocation(location, file, line, column, offset); } - late final _clang_sortCodeCompletionResultsPtr = - _lookup>( - 'clang_sortCodeCompletionResults', + late final _clang_getSpellingLocationPtr = + _lookup>( + 'clang_getSpellingLocation', ); - late final _clang_sortCodeCompletionResults = - _clang_sortCodeCompletionResultsPtr - .asFunction(); + late final _clang_getSpellingLocation = _clang_getSpellingLocationPtr + .asFunction(); - /// Free the given set of code-completion results. - void clang_disposeCodeCompleteResults( - ffi.Pointer Results, + /// Returns the human-readable null-terminated C string that represents + /// the name of the memory category. This string should never be freed. + ffi.Pointer clang_getTUResourceUsageName( + CXTUResourceUsageKind kind, ) { - return _clang_disposeCodeCompleteResults(Results); + return _clang_getTUResourceUsageName(kind.value); } - late final _clang_disposeCodeCompleteResultsPtr = - _lookup>( - 'clang_disposeCodeCompleteResults', + late final _clang_getTUResourceUsageNamePtr = + _lookup>( + 'clang_getTUResourceUsageName', ); - late final _clang_disposeCodeCompleteResults = - _clang_disposeCodeCompleteResultsPtr - .asFunction(); + late final _clang_getTUResourceUsageName = _clang_getTUResourceUsageNamePtr + .asFunction(); - /// Determine the number of diagnostics produced prior to the - /// location where code completion was performed. - int clang_codeCompleteGetNumDiagnostics( - ffi.Pointer Results, - ) { - return _clang_codeCompleteGetNumDiagnostics(Results); + /// Given a cursor that represents a template, determine + /// the cursor kind of the specializations would be generated by instantiating + /// the template. + /// + /// This routine can be used to determine what flavor of function template, + /// class template, or class template partial specialization is stored in the + /// cursor. For example, it can describe whether a class template cursor is + /// declared with "struct", "class" or "union". + /// + /// \param C The cursor to query. This cursor should represent a template + /// declaration. + /// + /// \returns The cursor kind of the specializations that would be generated + /// by instantiating the template \p C. If \p C is not a template, returns + /// \c CXCursor_NoDeclFound. + CXCursorKind clang_getTemplateCursorKind(CXCursor C) { + return CXCursorKind.fromValue(_clang_getTemplateCursorKind(C)); } - late final _clang_codeCompleteGetNumDiagnosticsPtr = - _lookup>( - 'clang_codeCompleteGetNumDiagnostics', + late final _clang_getTemplateCursorKindPtr = + _lookup>( + 'clang_getTemplateCursorKind', ); - late final _clang_codeCompleteGetNumDiagnostics = - _clang_codeCompleteGetNumDiagnosticsPtr - .asFunction(); + late final _clang_getTemplateCursorKind = _clang_getTemplateCursorKindPtr + .asFunction(); - /// Retrieve a diagnostic associated with the given code completion. + /// Get the raw lexical token starting with the given location. /// - /// \param Results the code completion results to query. - /// \param Index the zero-based diagnostic number to retrieve. + /// \param TU the translation unit whose text is being tokenized. /// - /// \returns the requested diagnostic. This diagnostic must be freed - /// via a call to \c clang_disposeDiagnostic(). - CXDiagnostic clang_codeCompleteGetDiagnostic( - ffi.Pointer Results, - int Index, + /// \param Location the source location with which the token starts. + /// + /// \returns The token starting with the given location or NULL if no such token + /// exist. The returned pointer must be freed with clang_disposeTokens before the + /// translation unit is destroyed. + ffi.Pointer clang_getToken( + CXTranslationUnit TU, + CXSourceLocation Location, ) { - return _clang_codeCompleteGetDiagnostic(Results, Index); + return _clang_getToken(TU, Location); } - late final _clang_codeCompleteGetDiagnosticPtr = - _lookup>( - 'clang_codeCompleteGetDiagnostic', - ); - late final _clang_codeCompleteGetDiagnostic = - _clang_codeCompleteGetDiagnosticPtr - .asFunction(); + late final _clang_getTokenPtr = + _lookup>('clang_getToken'); + late final _clang_getToken = _clang_getTokenPtr + .asFunction(); - /// Determines what completions are appropriate for the context - /// the given code completion. - /// - /// \param Results the code completion results to query - /// - /// \returns the kinds of completions that are appropriate for use - /// along with the given code completion results. - int clang_codeCompleteGetContexts( - ffi.Pointer Results, - ) { - return _clang_codeCompleteGetContexts(Results); + /// Retrieve a source range that covers the given token. + CXSourceRange clang_getTokenExtent(CXTranslationUnit arg0, CXToken arg1) { + return _clang_getTokenExtent(arg0, arg1); } - late final _clang_codeCompleteGetContextsPtr = - _lookup>( - 'clang_codeCompleteGetContexts', + late final _clang_getTokenExtentPtr = + _lookup>( + 'clang_getTokenExtent', ); - late final _clang_codeCompleteGetContexts = _clang_codeCompleteGetContextsPtr - .asFunction(); + late final _clang_getTokenExtent = _clang_getTokenExtentPtr + .asFunction(); - /// Returns the cursor kind for the container for the current code - /// completion context. The container is only guaranteed to be set for - /// contexts where a container exists (i.e. member accesses or Objective-C - /// message sends); if there is not a container, this function will return - /// CXCursor_InvalidCode. - /// - /// \param Results the code completion results to query - /// - /// \param IsIncomplete on return, this value will be false if Clang has complete - /// information about the container. If Clang does not have complete - /// information, this value will be true. - /// - /// \returns the container kind, or CXCursor_InvalidCode if there is not a - /// container - CXCursorKind clang_codeCompleteGetContainerKind( - ffi.Pointer Results, - ffi.Pointer IsIncomplete, - ) { - return CXCursorKind.fromValue( - _clang_codeCompleteGetContainerKind(Results, IsIncomplete), - ); + /// Determine the kind of the given token. + CXTokenKind clang_getTokenKind(CXToken arg0) { + return CXTokenKind.fromValue(_clang_getTokenKind(arg0)); } - late final _clang_codeCompleteGetContainerKindPtr = - _lookup>( - 'clang_codeCompleteGetContainerKind', + late final _clang_getTokenKindPtr = + _lookup>( + 'clang_getTokenKind', ); - late final _clang_codeCompleteGetContainerKind = - _clang_codeCompleteGetContainerKindPtr - .asFunction(); + late final _clang_getTokenKind = _clang_getTokenKindPtr + .asFunction(); - /// Returns the USR for the container for the current code completion - /// context. If there is not a container for the current context, this - /// function will return the empty string. - /// - /// \param Results the code completion results to query - /// - /// \returns the USR for the container - CXString clang_codeCompleteGetContainerUSR( - ffi.Pointer Results, + /// Retrieve the source location of the given token. + CXSourceLocation clang_getTokenLocation( + CXTranslationUnit arg0, + CXToken arg1, ) { - return _clang_codeCompleteGetContainerUSR(Results); + return _clang_getTokenLocation(arg0, arg1); } - late final _clang_codeCompleteGetContainerUSRPtr = - _lookup>( - 'clang_codeCompleteGetContainerUSR', + late final _clang_getTokenLocationPtr = + _lookup>( + 'clang_getTokenLocation', ); - late final _clang_codeCompleteGetContainerUSR = - _clang_codeCompleteGetContainerUSRPtr - .asFunction(); + late final _clang_getTokenLocation = _clang_getTokenLocationPtr + .asFunction(); - /// Returns the currently-entered selector for an Objective-C message - /// send, formatted like "initWithFoo:bar:". Only guaranteed to return a - /// non-empty string for CXCompletionContext_ObjCInstanceMessage and - /// CXCompletionContext_ObjCClassMessage. - /// - /// \param Results the code completion results to query + /// Determine the spelling of the given token. /// - /// \returns the selector (or partial selector) that has been entered thus far - /// for an Objective-C message send. - CXString clang_codeCompleteGetObjCSelector( - ffi.Pointer Results, - ) { - return _clang_codeCompleteGetObjCSelector(Results); + /// The spelling of a token is the textual representation of that token, e.g., + /// the text of an identifier or keyword. + CXString clang_getTokenSpelling(CXTranslationUnit arg0, CXToken arg1) { + return _clang_getTokenSpelling(arg0, arg1); } - late final _clang_codeCompleteGetObjCSelectorPtr = - _lookup>( - 'clang_codeCompleteGetObjCSelector', + late final _clang_getTokenSpellingPtr = + _lookup>( + 'clang_getTokenSpelling', ); - late final _clang_codeCompleteGetObjCSelector = - _clang_codeCompleteGetObjCSelectorPtr - .asFunction(); + late final _clang_getTokenSpelling = _clang_getTokenSpellingPtr + .asFunction(); - /// Return a version string, suitable for showing to a user, but not - /// intended to be parsed (the format is not guaranteed to be stable). - CXString clang_getClangVersion() { - return _clang_getClangVersion(); + /// Retrieve the cursor that represents the given translation unit. + /// + /// The translation unit cursor can be used to start traversing the + /// various declarations within the given translation unit. + CXCursor clang_getTranslationUnitCursor(CXTranslationUnit arg0) { + return _clang_getTranslationUnitCursor(arg0); } - late final _clang_getClangVersionPtr = - _lookup>( - 'clang_getClangVersion', + late final _clang_getTranslationUnitCursorPtr = + _lookup>( + 'clang_getTranslationUnitCursor', ); - late final _clang_getClangVersion = _clang_getClangVersionPtr - .asFunction(); + late final _clang_getTranslationUnitCursor = + _clang_getTranslationUnitCursorPtr + .asFunction(); - /// Enable/disable crash recovery. - /// - /// \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero - /// value enables crash recovery, while 0 disables it. - void clang_toggleCrashRecovery(int isEnabled) { - return _clang_toggleCrashRecovery(isEnabled); + /// Get the original translation unit source file name. + CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) { + return _clang_getTranslationUnitSpelling(CTUnit); } - late final _clang_toggleCrashRecoveryPtr = - _lookup>( - 'clang_toggleCrashRecovery', + late final _clang_getTranslationUnitSpellingPtr = + _lookup>( + 'clang_getTranslationUnitSpelling', ); - late final _clang_toggleCrashRecovery = _clang_toggleCrashRecoveryPtr - .asFunction(); + late final _clang_getTranslationUnitSpelling = + _clang_getTranslationUnitSpellingPtr + .asFunction(); - /// Visit the set of preprocessor inclusions in a translation unit. - /// The visitor function is called with the provided data for every included - /// file. This does not include headers included by the PCH file (unless one - /// is inspecting the inclusions in the PCH file itself). - void clang_getInclusions( - CXTranslationUnit tu, - CXInclusionVisitor visitor, - CXClientData client_data, - ) { - return _clang_getInclusions(tu, visitor, client_data); + /// Get target information for this translation unit. + /// + /// The CXTargetInfo object cannot outlive the CXTranslationUnit object. + CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit) { + return _clang_getTranslationUnitTargetInfo(CTUnit); } - late final _clang_getInclusionsPtr = - _lookup>( - 'clang_getInclusions', + late final _clang_getTranslationUnitTargetInfoPtr = + _lookup>( + 'clang_getTranslationUnitTargetInfo', ); - late final _clang_getInclusions = _clang_getInclusionsPtr - .asFunction(); + late final _clang_getTranslationUnitTargetInfo = + _clang_getTranslationUnitTargetInfoPtr + .asFunction(); - /// If cursor is a statement declaration tries to evaluate the - /// statement and if its variable, tries to evaluate its initializer, - /// into its corresponding type. - CXEvalResult clang_Cursor_Evaluate(CXCursor C) { - return _clang_Cursor_Evaluate(C); + /// Return the cursor for the declaration of the given type. + CXCursor clang_getTypeDeclaration(CXType T) { + return _clang_getTypeDeclaration(T); } - late final _clang_Cursor_EvaluatePtr = - _lookup>( - 'clang_Cursor_Evaluate', + late final _clang_getTypeDeclarationPtr = + _lookup>( + 'clang_getTypeDeclaration', ); - late final _clang_Cursor_Evaluate = _clang_Cursor_EvaluatePtr - .asFunction(); + late final _clang_getTypeDeclaration = _clang_getTypeDeclarationPtr + .asFunction(); - /// Returns the kind of the evaluated result. - CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E) { - return CXEvalResultKind.fromValue(_clang_EvalResult_getKind(E)); + /// Retrieve the spelling of a given CXTypeKind. + CXString clang_getTypeKindSpelling(CXTypeKind K) { + return _clang_getTypeKindSpelling(K.value); } - late final _clang_EvalResult_getKindPtr = - _lookup>( - 'clang_EvalResult_getKind', + late final _clang_getTypeKindSpellingPtr = + _lookup>( + 'clang_getTypeKindSpelling', ); - late final _clang_EvalResult_getKind = _clang_EvalResult_getKindPtr - .asFunction(); + late final _clang_getTypeKindSpelling = _clang_getTypeKindSpellingPtr + .asFunction(); - /// Returns the evaluation result as integer if the - /// kind is Int. - int clang_EvalResult_getAsInt(CXEvalResult E) { - return _clang_EvalResult_getAsInt(E); + /// Pretty-print the underlying type using the rules of the + /// language of the translation unit from which it came. + /// + /// If the type is invalid, an empty string is returned. + CXString clang_getTypeSpelling(CXType CT) { + return _clang_getTypeSpelling(CT); } - late final _clang_EvalResult_getAsIntPtr = - _lookup>( - 'clang_EvalResult_getAsInt', + late final _clang_getTypeSpellingPtr = + _lookup>( + 'clang_getTypeSpelling', ); - late final _clang_EvalResult_getAsInt = _clang_EvalResult_getAsIntPtr - .asFunction(); + late final _clang_getTypeSpelling = _clang_getTypeSpellingPtr + .asFunction(); - /// Returns the evaluation result as a long long integer if the - /// kind is Int. This prevents overflows that may happen if the result is - /// returned with clang_EvalResult_getAsInt. - int clang_EvalResult_getAsLongLong(CXEvalResult E) { - return _clang_EvalResult_getAsLongLong(E); + /// Retrieve the underlying type of a typedef declaration. + /// + /// If the cursor does not reference a typedef declaration, an invalid type is + /// returned. + CXType clang_getTypedefDeclUnderlyingType(CXCursor C) { + return _clang_getTypedefDeclUnderlyingType(C); } - late final _clang_EvalResult_getAsLongLongPtr = - _lookup>( - 'clang_EvalResult_getAsLongLong', + late final _clang_getTypedefDeclUnderlyingTypePtr = + _lookup>( + 'clang_getTypedefDeclUnderlyingType', ); - late final _clang_EvalResult_getAsLongLong = - _clang_EvalResult_getAsLongLongPtr - .asFunction(); + late final _clang_getTypedefDeclUnderlyingType = + _clang_getTypedefDeclUnderlyingTypePtr + .asFunction(); - /// Returns a non-zero value if the kind is Int and the evaluation - /// result resulted in an unsigned integer. - int clang_EvalResult_isUnsignedInt(CXEvalResult E) { - return _clang_EvalResult_isUnsignedInt(E); + /// Returns the typedef name of the given type. + CXString clang_getTypedefName(CXType CT) { + return _clang_getTypedefName(CT); } - late final _clang_EvalResult_isUnsignedIntPtr = - _lookup>( - 'clang_EvalResult_isUnsignedInt', + late final _clang_getTypedefNamePtr = + _lookup>( + 'clang_getTypedefName', ); - late final _clang_EvalResult_isUnsignedInt = - _clang_EvalResult_isUnsignedIntPtr - .asFunction(); + late final _clang_getTypedefName = _clang_getTypedefNamePtr + .asFunction(); - /// Returns the evaluation result as an unsigned integer if - /// the kind is Int and clang_EvalResult_isUnsignedInt is non-zero. - int clang_EvalResult_getAsUnsigned(CXEvalResult E) { - return _clang_EvalResult_getAsUnsigned(E); - } - - late final _clang_EvalResult_getAsUnsignedPtr = - _lookup>( - 'clang_EvalResult_getAsUnsigned', - ); - late final _clang_EvalResult_getAsUnsigned = - _clang_EvalResult_getAsUnsignedPtr - .asFunction(); - - /// Returns the evaluation result as double if the - /// kind is double. - double clang_EvalResult_getAsDouble(CXEvalResult E) { - return _clang_EvalResult_getAsDouble(E); + /// Compute a hash value for the given cursor. + int clang_hashCursor(CXCursor arg0) { + return _clang_hashCursor(arg0); } - late final _clang_EvalResult_getAsDoublePtr = - _lookup>( - 'clang_EvalResult_getAsDouble', - ); - late final _clang_EvalResult_getAsDouble = _clang_EvalResult_getAsDoublePtr - .asFunction(); + late final _clang_hashCursorPtr = + _lookup>('clang_hashCursor'); + late final _clang_hashCursor = _clang_hashCursorPtr + .asFunction(); - /// Returns the evaluation result as a constant string if the - /// kind is other than Int or float. User must not free this pointer, - /// instead call clang_EvalResult_dispose on the CXEvalResult returned - /// by clang_Cursor_Evaluate. - ffi.Pointer clang_EvalResult_getAsStr(CXEvalResult E) { - return _clang_EvalResult_getAsStr(E); + /// Retrieve the CXSourceLocation represented by the given CXIdxLoc. + CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc) { + return _clang_indexLoc_getCXSourceLocation(loc); } - late final _clang_EvalResult_getAsStrPtr = - _lookup>( - 'clang_EvalResult_getAsStr', + late final _clang_indexLoc_getCXSourceLocationPtr = + _lookup>( + 'clang_indexLoc_getCXSourceLocation', ); - late final _clang_EvalResult_getAsStr = _clang_EvalResult_getAsStrPtr - .asFunction(); + late final _clang_indexLoc_getCXSourceLocation = + _clang_indexLoc_getCXSourceLocationPtr + .asFunction(); - /// Disposes the created Eval memory. - void clang_EvalResult_dispose(CXEvalResult E) { - return _clang_EvalResult_dispose(E); + /// Retrieve the CXIdxFile, file, line, column, and offset represented by + /// the given CXIdxLoc. + /// + /// If the location refers into a macro expansion, retrieves the + /// location of the macro expansion and if it refers into a macro argument + /// retrieves the location of the argument. + void clang_indexLoc_getFileLocation( + CXIdxLoc loc, + ffi.Pointer indexFile, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ) { + return _clang_indexLoc_getFileLocation( + loc, + indexFile, + file, + line, + column, + offset, + ); } - late final _clang_EvalResult_disposePtr = - _lookup>( - 'clang_EvalResult_dispose', + late final _clang_indexLoc_getFileLocationPtr = + _lookup>( + 'clang_indexLoc_getFileLocation', ); - late final _clang_EvalResult_dispose = _clang_EvalResult_disposePtr - .asFunction(); + late final _clang_indexLoc_getFileLocation = + _clang_indexLoc_getFileLocationPtr + .asFunction(); - /// Retrieve a remapping. + /// Index the given source file and the translation unit corresponding + /// to that file via callbacks implemented through #IndexerCallbacks. /// - /// \param path the path that contains metadata about remappings. + /// \param client_data pointer data supplied by the client, which will + /// be passed to the invoked callbacks. /// - /// \returns the requested remapping. This remapping must be freed - /// via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. - CXRemapping clang_getRemappings(ffi.Pointer path) { - return _clang_getRemappings(path); - } - - late final _clang_getRemappingsPtr = - _lookup>( - 'clang_getRemappings', - ); - late final _clang_getRemappings = _clang_getRemappingsPtr - .asFunction(); - - /// Retrieve a remapping. + /// \param index_callbacks Pointer to indexing callbacks that the client + /// implements. /// - /// \param filePaths pointer to an array of file paths containing remapping info. + /// \param index_callbacks_size Size of #IndexerCallbacks structure that gets + /// passed in index_callbacks. /// - /// \param numFiles number of file paths. + /// \param index_options A bitmask of options that affects how indexing is + /// performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. /// - /// \returns the requested remapping. This remapping must be freed - /// via a call to \c clang_remap_dispose(). Can return NULL if an error occurred. - CXRemapping clang_getRemappingsFromFileList( - ffi.Pointer> filePaths, - int numFiles, + /// \param[out] out_TU pointer to store a \c CXTranslationUnit that can be + /// reused after indexing is finished. Set to \c NULL if you do not require it. + /// + /// \returns 0 on success or if there were errors from which the compiler could + /// recover. If there is a failure from which there is no recovery, returns + /// a non-zero \c CXErrorCode. + /// + /// The rest of the parameters are the same as #clang_parseTranslationUnit. + int clang_indexSourceFile( + CXIndexAction arg0, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + ffi.Pointer out_TU, + int TU_options, ) { - return _clang_getRemappingsFromFileList(filePaths, numFiles); + return _clang_indexSourceFile( + arg0, + client_data, + index_callbacks, + index_callbacks_size, + index_options, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + out_TU, + TU_options, + ); } - late final _clang_getRemappingsFromFileListPtr = - _lookup>( - 'clang_getRemappingsFromFileList', + late final _clang_indexSourceFilePtr = + _lookup>( + 'clang_indexSourceFile', ); - late final _clang_getRemappingsFromFileList = - _clang_getRemappingsFromFileListPtr - .asFunction(); + late final _clang_indexSourceFile = _clang_indexSourceFilePtr + .asFunction(); - /// Determine the number of remappings. - int clang_remap_getNumFiles(CXRemapping arg0) { - return _clang_remap_getNumFiles(arg0); + /// Same as clang_indexSourceFile but requires a full command line + /// for \c command_line_args including argv[0]. This is useful if the standard + /// library paths are relative to the binary. + int clang_indexSourceFileFullArgv( + CXIndexAction arg0, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + ffi.Pointer out_TU, + int TU_options, + ) { + return _clang_indexSourceFileFullArgv( + arg0, + client_data, + index_callbacks, + index_callbacks_size, + index_options, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + out_TU, + TU_options, + ); } - late final _clang_remap_getNumFilesPtr = - _lookup>( - 'clang_remap_getNumFiles', + late final _clang_indexSourceFileFullArgvPtr = + _lookup>( + 'clang_indexSourceFileFullArgv', ); - late final _clang_remap_getNumFiles = _clang_remap_getNumFilesPtr - .asFunction(); + late final _clang_indexSourceFileFullArgv = _clang_indexSourceFileFullArgvPtr + .asFunction(); - /// Get the original and the associated filename from the remapping. + /// Index the given translation unit via callbacks implemented through + /// #IndexerCallbacks. /// - /// \param original If non-NULL, will be set to the original filename. + /// The order of callback invocations is not guaranteed to be the same as + /// when indexing a source file. The high level order will be: /// - /// \param transformed If non-NULL, will be set to the filename that the original - /// is associated with. - void clang_remap_getFilenames( - CXRemapping arg0, - int index, - ffi.Pointer original, - ffi.Pointer transformed, + /// -Preprocessor callbacks invocations + /// -Declaration/reference callbacks invocations + /// -Diagnostic callback invocations + /// + /// The parameters are the same as #clang_indexSourceFile. + /// + /// \returns If there is a failure from which there is no recovery, returns + /// non-zero, otherwise returns 0. + int clang_indexTranslationUnit( + CXIndexAction arg0, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + CXTranslationUnit arg5, ) { - return _clang_remap_getFilenames(arg0, index, original, transformed); + return _clang_indexTranslationUnit( + arg0, + client_data, + index_callbacks, + index_callbacks_size, + index_options, + arg5, + ); } - late final _clang_remap_getFilenamesPtr = - _lookup>( - 'clang_remap_getFilenames', + late final _clang_indexTranslationUnitPtr = + _lookup>( + 'clang_indexTranslationUnit', ); - late final _clang_remap_getFilenames = _clang_remap_getFilenamesPtr - .asFunction(); + late final _clang_indexTranslationUnit = _clang_indexTranslationUnitPtr + .asFunction(); - /// Dispose the remapping. - void clang_remap_dispose(CXRemapping arg0) { - return _clang_remap_dispose(arg0); + ffi.Pointer clang_index_getCXXClassDeclInfo( + ffi.Pointer arg0, + ) { + return _clang_index_getCXXClassDeclInfo(arg0); } - late final _clang_remap_disposePtr = - _lookup>( - 'clang_remap_dispose', + late final _clang_index_getCXXClassDeclInfoPtr = + _lookup>( + 'clang_index_getCXXClassDeclInfo', ); - late final _clang_remap_dispose = _clang_remap_disposePtr - .asFunction(); + late final _clang_index_getCXXClassDeclInfo = + _clang_index_getCXXClassDeclInfoPtr + .asFunction(); - /// Find references of a declaration in a specific file. - /// - /// \param cursor pointing to a declaration or a reference of one. - /// - /// \param file to search for references. - /// - /// \param visitor callback that will receive pairs of CXCursor/CXSourceRange for - /// each reference found. - /// The CXSourceRange will point inside the file; if the reference is inside - /// a macro (and not a macro argument) the CXSourceRange will be invalid. - /// - /// \returns one of the CXResult enumerators. - CXResult clang_findReferencesInFile( - CXCursor cursor, - CXFile file, - CXCursorAndRangeVisitor visitor, + /// For retrieving a custom CXIdxClientContainer attached to a + /// container. + CXIdxClientContainer clang_index_getClientContainer( + ffi.Pointer arg0, ) { - return CXResult.fromValue( - _clang_findReferencesInFile(cursor, file, visitor), - ); + return _clang_index_getClientContainer(arg0); } - late final _clang_findReferencesInFilePtr = - _lookup>( - 'clang_findReferencesInFile', + late final _clang_index_getClientContainerPtr = + _lookup>( + 'clang_index_getClientContainer', ); - late final _clang_findReferencesInFile = _clang_findReferencesInFilePtr - .asFunction(); + late final _clang_index_getClientContainer = + _clang_index_getClientContainerPtr + .asFunction(); - /// Find #import/#include directives in a specific file. - /// - /// \param TU translation unit containing the file to query. - /// - /// \param file to search for #import/#include directives. - /// - /// \param visitor callback that will receive pairs of CXCursor/CXSourceRange for - /// each directive found. - /// - /// \returns one of the CXResult enumerators. - CXResult clang_findIncludesInFile( - CXTranslationUnit TU, - CXFile file, - CXCursorAndRangeVisitor visitor, + /// For retrieving a custom CXIdxClientEntity attached to an entity. + CXIdxClientEntity clang_index_getClientEntity( + ffi.Pointer arg0, ) { - return CXResult.fromValue(_clang_findIncludesInFile(TU, file, visitor)); + return _clang_index_getClientEntity(arg0); } - late final _clang_findIncludesInFilePtr = - _lookup>( - 'clang_findIncludesInFile', + late final _clang_index_getClientEntityPtr = + _lookup>( + 'clang_index_getClientEntity', ); - late final _clang_findIncludesInFile = _clang_findIncludesInFilePtr - .asFunction(); + late final _clang_index_getClientEntity = _clang_index_getClientEntityPtr + .asFunction(); - int clang_index_isEntityObjCContainerKind(CXIdxEntityKind arg0) { - return _clang_index_isEntityObjCContainerKind(arg0.value); + ffi.Pointer + clang_index_getIBOutletCollectionAttrInfo(ffi.Pointer arg0) { + return _clang_index_getIBOutletCollectionAttrInfo(arg0); } - late final _clang_index_isEntityObjCContainerKindPtr = - _lookup>( - 'clang_index_isEntityObjCContainerKind', + late final _clang_index_getIBOutletCollectionAttrInfoPtr = + _lookup< + ffi.NativeFunction + >('clang_index_getIBOutletCollectionAttrInfo'); + late final _clang_index_getIBOutletCollectionAttrInfo = + _clang_index_getIBOutletCollectionAttrInfoPtr + .asFunction(); + + ffi.Pointer clang_index_getObjCCategoryDeclInfo( + ffi.Pointer arg0, + ) { + return _clang_index_getObjCCategoryDeclInfo(arg0); + } + + late final _clang_index_getObjCCategoryDeclInfoPtr = + _lookup>( + 'clang_index_getObjCCategoryDeclInfo', ); - late final _clang_index_isEntityObjCContainerKind = - _clang_index_isEntityObjCContainerKindPtr - .asFunction(); + late final _clang_index_getObjCCategoryDeclInfo = + _clang_index_getObjCCategoryDeclInfoPtr + .asFunction(); ffi.Pointer clang_index_getObjCContainerDeclInfo( ffi.Pointer arg0, @@ -5566,19 +5222,19 @@ class LibClang { _clang_index_getObjCInterfaceDeclInfoPtr .asFunction(); - ffi.Pointer clang_index_getObjCCategoryDeclInfo( + ffi.Pointer clang_index_getObjCPropertyDeclInfo( ffi.Pointer arg0, ) { - return _clang_index_getObjCCategoryDeclInfo(arg0); + return _clang_index_getObjCPropertyDeclInfo(arg0); } - late final _clang_index_getObjCCategoryDeclInfoPtr = - _lookup>( - 'clang_index_getObjCCategoryDeclInfo', + late final _clang_index_getObjCPropertyDeclInfoPtr = + _lookup>( + 'clang_index_getObjCPropertyDeclInfo', ); - late final _clang_index_getObjCCategoryDeclInfo = - _clang_index_getObjCCategoryDeclInfoPtr - .asFunction(); + late final _clang_index_getObjCPropertyDeclInfo = + _clang_index_getObjCPropertyDeclInfoPtr + .asFunction(); ffi.Pointer clang_index_getObjCProtocolRefListInfo(ffi.Pointer arg0) { @@ -5593,62 +5249,17 @@ class LibClang { _clang_index_getObjCProtocolRefListInfoPtr .asFunction(); - ffi.Pointer clang_index_getObjCPropertyDeclInfo( - ffi.Pointer arg0, - ) { - return _clang_index_getObjCPropertyDeclInfo(arg0); - } - - late final _clang_index_getObjCPropertyDeclInfoPtr = - _lookup>( - 'clang_index_getObjCPropertyDeclInfo', - ); - late final _clang_index_getObjCPropertyDeclInfo = - _clang_index_getObjCPropertyDeclInfoPtr - .asFunction(); - - ffi.Pointer - clang_index_getIBOutletCollectionAttrInfo(ffi.Pointer arg0) { - return _clang_index_getIBOutletCollectionAttrInfo(arg0); - } - - late final _clang_index_getIBOutletCollectionAttrInfoPtr = - _lookup< - ffi.NativeFunction - >('clang_index_getIBOutletCollectionAttrInfo'); - late final _clang_index_getIBOutletCollectionAttrInfo = - _clang_index_getIBOutletCollectionAttrInfoPtr - .asFunction(); - - ffi.Pointer clang_index_getCXXClassDeclInfo( - ffi.Pointer arg0, - ) { - return _clang_index_getCXXClassDeclInfo(arg0); - } - - late final _clang_index_getCXXClassDeclInfoPtr = - _lookup>( - 'clang_index_getCXXClassDeclInfo', - ); - late final _clang_index_getCXXClassDeclInfo = - _clang_index_getCXXClassDeclInfoPtr - .asFunction(); - - /// For retrieving a custom CXIdxClientContainer attached to a - /// container. - CXIdxClientContainer clang_index_getClientContainer( - ffi.Pointer arg0, - ) { - return _clang_index_getClientContainer(arg0); + int clang_index_isEntityObjCContainerKind(CXIdxEntityKind arg0) { + return _clang_index_isEntityObjCContainerKind(arg0.value); } - late final _clang_index_getClientContainerPtr = - _lookup>( - 'clang_index_getClientContainer', + late final _clang_index_isEntityObjCContainerKindPtr = + _lookup>( + 'clang_index_isEntityObjCContainerKind', ); - late final _clang_index_getClientContainer = - _clang_index_getClientContainerPtr - .asFunction(); + late final _clang_index_isEntityObjCContainerKind = + _clang_index_isEntityObjCContainerKindPtr + .asFunction(); /// For setting a custom CXIdxClientContainer attached to a /// container. @@ -5667,20 +5278,6 @@ class LibClang { _clang_index_setClientContainerPtr .asFunction(); - /// For retrieving a custom CXIdxClientEntity attached to an entity. - CXIdxClientEntity clang_index_getClientEntity( - ffi.Pointer arg0, - ) { - return _clang_index_getClientEntity(arg0); - } - - late final _clang_index_getClientEntityPtr = - _lookup>( - 'clang_index_getClientEntity', - ); - late final _clang_index_getClientEntity = _clang_index_getClientEntityPtr - .asFunction(); - /// For setting a custom CXIdxClientEntity attached to an entity. void clang_index_setClientEntity( ffi.Pointer arg0, @@ -5696,1881 +5293,1852 @@ class LibClang { late final _clang_index_setClientEntity = _clang_index_setClientEntityPtr .asFunction(); - /// An indexing action/session, to be applied to one or multiple - /// translation units. - /// - /// \param CIdx The index object with which the index action will be associated. - CXIndexAction clang_IndexAction_create(CXIndex CIdx) { - return _clang_IndexAction_create(CIdx); + /// Determine whether the given cursor kind represents an attribute. + int clang_isAttribute(CXCursorKind arg0) { + return _clang_isAttribute(arg0.value); } - late final _clang_IndexAction_createPtr = - _lookup>( - 'clang_IndexAction_create', + late final _clang_isAttributePtr = + _lookup>('clang_isAttribute'); + late final _clang_isAttribute = _clang_isAttributePtr + .asFunction(); + + /// Determine whether a CXType has the "const" qualifier set, + /// without looking through typedefs that may have added "const" at a + /// different level. + int clang_isConstQualifiedType(CXType T) { + return _clang_isConstQualifiedType(T); + } + + late final _clang_isConstQualifiedTypePtr = + _lookup>( + 'clang_isConstQualifiedType', ); - late final _clang_IndexAction_create = _clang_IndexAction_createPtr - .asFunction(); + late final _clang_isConstQualifiedType = _clang_isConstQualifiedTypePtr + .asFunction(); - /// Destroy the given index action. - /// - /// The index action must not be destroyed until all of the translation units - /// created within that index action have been destroyed. - void clang_IndexAction_dispose(CXIndexAction arg0) { - return _clang_IndexAction_dispose(arg0); + /// Determine whether the declaration pointed to by this cursor + /// is also a definition of that entity. + int clang_isCursorDefinition(CXCursor arg0) { + return _clang_isCursorDefinition(arg0); } - late final _clang_IndexAction_disposePtr = - _lookup>( - 'clang_IndexAction_dispose', + late final _clang_isCursorDefinitionPtr = + _lookup>( + 'clang_isCursorDefinition', ); - late final _clang_IndexAction_dispose = _clang_IndexAction_disposePtr - .asFunction(); + late final _clang_isCursorDefinition = _clang_isCursorDefinitionPtr + .asFunction(); - /// Index the given source file and the translation unit corresponding - /// to that file via callbacks implemented through #IndexerCallbacks. - /// - /// \param client_data pointer data supplied by the client, which will - /// be passed to the invoked callbacks. - /// - /// \param index_callbacks Pointer to indexing callbacks that the client - /// implements. - /// - /// \param index_callbacks_size Size of #IndexerCallbacks structure that gets - /// passed in index_callbacks. - /// - /// \param index_options A bitmask of options that affects how indexing is - /// performed. This should be a bitwise OR of the CXIndexOpt_XXX flags. - /// - /// \param[out] out_TU pointer to store a \c CXTranslationUnit that can be - /// reused after indexing is finished. Set to \c NULL if you do not require it. - /// - /// \returns 0 on success or if there were errors from which the compiler could - /// recover. If there is a failure from which there is no recovery, returns - /// a non-zero \c CXErrorCode. - /// - /// The rest of the parameters are the same as #clang_parseTranslationUnit. - int clang_indexSourceFile( - CXIndexAction arg0, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - ffi.Pointer out_TU, - int TU_options, - ) { - return _clang_indexSourceFile( - arg0, - client_data, - index_callbacks, - index_callbacks_size, - index_options, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - out_TU, - TU_options, - ); + /// Determine whether the given cursor kind represents a declaration. + int clang_isDeclaration(CXCursorKind arg0) { + return _clang_isDeclaration(arg0.value); } - late final _clang_indexSourceFilePtr = - _lookup>( - 'clang_indexSourceFile', + late final _clang_isDeclarationPtr = + _lookup>( + 'clang_isDeclaration', ); - late final _clang_indexSourceFile = _clang_indexSourceFilePtr - .asFunction(); + late final _clang_isDeclaration = _clang_isDeclarationPtr + .asFunction(); - /// Same as clang_indexSourceFile but requires a full command line - /// for \c command_line_args including argv[0]. This is useful if the standard - /// library paths are relative to the binary. - int clang_indexSourceFileFullArgv( - CXIndexAction arg0, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - ffi.Pointer out_TU, - int TU_options, - ) { - return _clang_indexSourceFileFullArgv( - arg0, - client_data, - index_callbacks, - index_callbacks_size, - index_options, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - out_TU, - TU_options, - ); + /// Determine whether the given cursor kind represents an expression. + int clang_isExpression(CXCursorKind arg0) { + return _clang_isExpression(arg0.value); } - late final _clang_indexSourceFileFullArgvPtr = - _lookup>( - 'clang_indexSourceFileFullArgv', + late final _clang_isExpressionPtr = + _lookup>( + 'clang_isExpression', ); - late final _clang_indexSourceFileFullArgv = _clang_indexSourceFileFullArgvPtr - .asFunction(); + late final _clang_isExpression = _clang_isExpressionPtr + .asFunction(); - /// Index the given translation unit via callbacks implemented through - /// #IndexerCallbacks. - /// - /// The order of callback invocations is not guaranteed to be the same as - /// when indexing a source file. The high level order will be: - /// - /// -Preprocessor callbacks invocations - /// -Declaration/reference callbacks invocations - /// -Diagnostic callback invocations - /// - /// The parameters are the same as #clang_indexSourceFile. - /// - /// \returns If there is a failure from which there is no recovery, returns - /// non-zero, otherwise returns 0. - int clang_indexTranslationUnit( - CXIndexAction arg0, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - CXTranslationUnit arg5, - ) { - return _clang_indexTranslationUnit( - arg0, - client_data, - index_callbacks, - index_callbacks_size, - index_options, - arg5, - ); + /// Determine whether the given header is guarded against + /// multiple inclusions, either with the conventional + /// \#ifndef/\#define/\#endif macro guards or with \#pragma once. + int clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file) { + return _clang_isFileMultipleIncludeGuarded(tu, file); } - late final _clang_indexTranslationUnitPtr = - _lookup>( - 'clang_indexTranslationUnit', + late final _clang_isFileMultipleIncludeGuardedPtr = + _lookup>( + 'clang_isFileMultipleIncludeGuarded', ); - late final _clang_indexTranslationUnit = _clang_indexTranslationUnitPtr - .asFunction(); + late final _clang_isFileMultipleIncludeGuarded = + _clang_isFileMultipleIncludeGuardedPtr + .asFunction(); - /// Retrieve the CXIdxFile, file, line, column, and offset represented by - /// the given CXIdxLoc. - /// - /// If the location refers into a macro expansion, retrieves the - /// location of the macro expansion and if it refers into a macro argument - /// retrieves the location of the argument. - void clang_indexLoc_getFileLocation( - CXIdxLoc loc, - ffi.Pointer indexFile, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_indexLoc_getFileLocation( - loc, - indexFile, - file, - line, - column, - offset, - ); + /// Return 1 if the CXType is a variadic function type, and 0 otherwise. + int clang_isFunctionTypeVariadic(CXType T) { + return _clang_isFunctionTypeVariadic(T); } - late final _clang_indexLoc_getFileLocationPtr = - _lookup>( - 'clang_indexLoc_getFileLocation', + late final _clang_isFunctionTypeVariadicPtr = + _lookup>( + 'clang_isFunctionTypeVariadic', ); - late final _clang_indexLoc_getFileLocation = - _clang_indexLoc_getFileLocationPtr - .asFunction(); + late final _clang_isFunctionTypeVariadic = _clang_isFunctionTypeVariadicPtr + .asFunction(); - /// Retrieve the CXSourceLocation represented by the given CXIdxLoc. - CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc) { - return _clang_indexLoc_getCXSourceLocation(loc); + /// Determine whether the given cursor kind represents an invalid + /// cursor. + int clang_isInvalid(CXCursorKind arg0) { + return _clang_isInvalid(arg0.value); } - late final _clang_indexLoc_getCXSourceLocationPtr = - _lookup>( - 'clang_indexLoc_getCXSourceLocation', - ); - late final _clang_indexLoc_getCXSourceLocation = - _clang_indexLoc_getCXSourceLocationPtr - .asFunction(); + late final _clang_isInvalidPtr = + _lookup>('clang_isInvalid'); + late final _clang_isInvalid = _clang_isInvalidPtr + .asFunction(); - /// Visit the fields of a particular type. - /// - /// This function visits all the direct fields of the given cursor, - /// invoking the given \p visitor function with the cursors of each - /// visited field. The traversal may be ended prematurely, if - /// the visitor returns \c CXFieldVisit_Break. - /// - /// \param T the record type whose field may be visited. - /// - /// \param visitor the visitor function that will be invoked for each - /// field of \p T. + /// Determine whether the given declaration is invalid. /// - /// \param client_data pointer data supplied by the client, which will - /// be passed to the visitor each time it is invoked. + /// A declaration is invalid if it could not be parsed successfully. /// - /// \returns a non-zero value if the traversal was terminated - /// prematurely by the visitor returning \c CXFieldVisit_Break. - int clang_Type_visitFields( - CXType T, - CXFieldVisitor visitor, - CXClientData client_data, - ) { - return _clang_Type_visitFields(T, visitor, client_data); + /// \returns non-zero if the cursor represents a declaration and it is + /// invalid, otherwise NULL. + int clang_isInvalidDeclaration(CXCursor arg0) { + return _clang_isInvalidDeclaration(arg0); } - late final _clang_Type_visitFieldsPtr = - _lookup>( - 'clang_Type_visitFields', + late final _clang_isInvalidDeclarationPtr = + _lookup>( + 'clang_isInvalidDeclaration', ); - late final _clang_Type_visitFields = _clang_Type_visitFieldsPtr - .asFunction(); + late final _clang_isInvalidDeclaration = _clang_isInvalidDeclarationPtr + .asFunction(); - late final addresses = _SymbolAddresses(this); -} + /// Return 1 if the CXType is a POD (plain old data) type, and 0 + /// otherwise. + int clang_isPODType(CXType T) { + return _clang_isPODType(T); + } -class _SymbolAddresses { - final LibClang _library; - _SymbolAddresses(this._library); - ffi.Pointer> - get clang_getCString => _library._clang_getCStringPtr; - ffi.Pointer> - get clang_disposeString => _library._clang_disposeStringPtr; - ffi.Pointer> - get clang_disposeStringSet => _library._clang_disposeStringSetPtr; - ffi.Pointer> - get clang_createIndex => _library._clang_createIndexPtr; - ffi.Pointer> - get clang_disposeIndex => _library._clang_disposeIndexPtr; - ffi.Pointer> - get clang_CXIndex_setGlobalOptions => - _library._clang_CXIndex_setGlobalOptionsPtr; - ffi.Pointer> - get clang_CXIndex_getGlobalOptions => - _library._clang_CXIndex_getGlobalOptionsPtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_CXIndex_setInvocationEmissionPathOption => - _library._clang_CXIndex_setInvocationEmissionPathOptionPtr; - ffi.Pointer> - get clang_getFileName => _library._clang_getFileNamePtr; - ffi.Pointer> - get clang_getFileTime => _library._clang_getFileTimePtr; - ffi.Pointer> - get clang_getFileUniqueID => _library._clang_getFileUniqueIDPtr; - ffi.Pointer> - get clang_isFileMultipleIncludeGuarded => - _library._clang_isFileMultipleIncludeGuardedPtr; - ffi.Pointer> get clang_getFile => - _library._clang_getFilePtr; - ffi.Pointer> - get clang_getFileContents => _library._clang_getFileContentsPtr; - ffi.Pointer> - get clang_File_isEqual => _library._clang_File_isEqualPtr; - ffi.Pointer> - get clang_File_tryGetRealPathName => - _library._clang_File_tryGetRealPathNamePtr; - ffi.Pointer> - get clang_getNullLocation => _library._clang_getNullLocationPtr; - ffi.Pointer> - get clang_equalLocations => _library._clang_equalLocationsPtr; - ffi.Pointer> - get clang_getLocation => _library._clang_getLocationPtr; - ffi.Pointer> - get clang_getLocationForOffset => _library._clang_getLocationForOffsetPtr; - ffi.Pointer> - get clang_Location_isInSystemHeader => - _library._clang_Location_isInSystemHeaderPtr; - ffi.Pointer> - get clang_Location_isFromMainFile => - _library._clang_Location_isFromMainFilePtr; - ffi.Pointer> - get clang_getNullRange => _library._clang_getNullRangePtr; - ffi.Pointer> get clang_getRange => - _library._clang_getRangePtr; - ffi.Pointer> - get clang_equalRanges => _library._clang_equalRangesPtr; - ffi.Pointer> - get clang_Range_isNull => _library._clang_Range_isNullPtr; - ffi.Pointer> - get clang_getExpansionLocation => _library._clang_getExpansionLocationPtr; - ffi.Pointer> - get clang_getPresumedLocation => _library._clang_getPresumedLocationPtr; - ffi.Pointer> - get clang_getInstantiationLocation => - _library._clang_getInstantiationLocationPtr; - ffi.Pointer> - get clang_getSpellingLocation => _library._clang_getSpellingLocationPtr; - ffi.Pointer> - get clang_getFileLocation => _library._clang_getFileLocationPtr; - ffi.Pointer> - get clang_getRangeStart => _library._clang_getRangeStartPtr; - ffi.Pointer> - get clang_getRangeEnd => _library._clang_getRangeEndPtr; - ffi.Pointer> - get clang_getSkippedRanges => _library._clang_getSkippedRangesPtr; - ffi.Pointer> - get clang_getAllSkippedRanges => _library._clang_getAllSkippedRangesPtr; - ffi.Pointer> - get clang_disposeSourceRangeList => _library._clang_disposeSourceRangeListPtr; - ffi.Pointer> - get clang_getNumDiagnosticsInSet => _library._clang_getNumDiagnosticsInSetPtr; - ffi.Pointer> - get clang_getDiagnosticInSet => _library._clang_getDiagnosticInSetPtr; - ffi.Pointer> - get clang_loadDiagnostics => _library._clang_loadDiagnosticsPtr; - ffi.Pointer> - get clang_disposeDiagnosticSet => _library._clang_disposeDiagnosticSetPtr; - ffi.Pointer> - get clang_getChildDiagnostics => _library._clang_getChildDiagnosticsPtr; - ffi.Pointer> - get clang_getNumDiagnostics => _library._clang_getNumDiagnosticsPtr; - ffi.Pointer> - get clang_getDiagnostic => _library._clang_getDiagnosticPtr; - ffi.Pointer> - get clang_getDiagnosticSetFromTU => _library._clang_getDiagnosticSetFromTUPtr; - ffi.Pointer> - get clang_disposeDiagnostic => _library._clang_disposeDiagnosticPtr; - ffi.Pointer> - get clang_formatDiagnostic => _library._clang_formatDiagnosticPtr; - ffi.Pointer> - get clang_defaultDiagnosticDisplayOptions => - _library._clang_defaultDiagnosticDisplayOptionsPtr; - ffi.Pointer> - get clang_getDiagnosticSeverity => _library._clang_getDiagnosticSeverityPtr; - ffi.Pointer> - get clang_getDiagnosticLocation => _library._clang_getDiagnosticLocationPtr; - ffi.Pointer> - get clang_getDiagnosticSpelling => _library._clang_getDiagnosticSpellingPtr; - ffi.Pointer> - get clang_getDiagnosticOption => _library._clang_getDiagnosticOptionPtr; - ffi.Pointer> - get clang_getDiagnosticCategory => _library._clang_getDiagnosticCategoryPtr; - ffi.Pointer> - get clang_getDiagnosticCategoryName => - _library._clang_getDiagnosticCategoryNamePtr; - ffi.Pointer> - get clang_getDiagnosticCategoryText => - _library._clang_getDiagnosticCategoryTextPtr; - ffi.Pointer> - get clang_getDiagnosticNumRanges => _library._clang_getDiagnosticNumRangesPtr; - ffi.Pointer> - get clang_getDiagnosticRange => _library._clang_getDiagnosticRangePtr; - ffi.Pointer> - get clang_getDiagnosticNumFixIts => _library._clang_getDiagnosticNumFixItsPtr; - ffi.Pointer> - get clang_getDiagnosticFixIt => _library._clang_getDiagnosticFixItPtr; - ffi.Pointer> - get clang_getTranslationUnitSpelling => - _library._clang_getTranslationUnitSpellingPtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_createTranslationUnitFromSourceFile => - _library._clang_createTranslationUnitFromSourceFilePtr; - ffi.Pointer> - get clang_createTranslationUnit => _library._clang_createTranslationUnitPtr; - ffi.Pointer> - get clang_createTranslationUnit2 => _library._clang_createTranslationUnit2Ptr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_defaultEditingTranslationUnitOptions => - _library._clang_defaultEditingTranslationUnitOptionsPtr; - ffi.Pointer> - get clang_parseTranslationUnit => _library._clang_parseTranslationUnitPtr; - ffi.Pointer> - get clang_parseTranslationUnit2 => _library._clang_parseTranslationUnit2Ptr; - ffi.Pointer> - get clang_parseTranslationUnit2FullArgv => - _library._clang_parseTranslationUnit2FullArgvPtr; - ffi.Pointer> - get clang_defaultSaveOptions => _library._clang_defaultSaveOptionsPtr; - ffi.Pointer> - get clang_saveTranslationUnit => _library._clang_saveTranslationUnitPtr; - ffi.Pointer> - get clang_suspendTranslationUnit => _library._clang_suspendTranslationUnitPtr; - ffi.Pointer> - get clang_disposeTranslationUnit => _library._clang_disposeTranslationUnitPtr; - ffi.Pointer> - get clang_defaultReparseOptions => _library._clang_defaultReparseOptionsPtr; - ffi.Pointer> - get clang_reparseTranslationUnit => _library._clang_reparseTranslationUnitPtr; - ffi.Pointer> - get clang_getTUResourceUsageName => _library._clang_getTUResourceUsageNamePtr; - ffi.Pointer> - get clang_getCXTUResourceUsage => _library._clang_getCXTUResourceUsagePtr; - ffi.Pointer> - get clang_disposeCXTUResourceUsage => - _library._clang_disposeCXTUResourceUsagePtr; - ffi.Pointer> - get clang_getTranslationUnitTargetInfo => - _library._clang_getTranslationUnitTargetInfoPtr; - ffi.Pointer> - get clang_TargetInfo_dispose => _library._clang_TargetInfo_disposePtr; - ffi.Pointer> - get clang_TargetInfo_getTriple => _library._clang_TargetInfo_getTriplePtr; - ffi.Pointer> - get clang_TargetInfo_getPointerWidth => - _library._clang_TargetInfo_getPointerWidthPtr; - ffi.Pointer> - get clang_getNullCursor => _library._clang_getNullCursorPtr; - ffi.Pointer> - get clang_getTranslationUnitCursor => - _library._clang_getTranslationUnitCursorPtr; - ffi.Pointer> - get clang_equalCursors => _library._clang_equalCursorsPtr; - ffi.Pointer> - get clang_Cursor_isNull => _library._clang_Cursor_isNullPtr; - ffi.Pointer> - get clang_hashCursor => _library._clang_hashCursorPtr; - ffi.Pointer> - get clang_getCursorKind => _library._clang_getCursorKindPtr; - ffi.Pointer> - get clang_isDeclaration => _library._clang_isDeclarationPtr; - ffi.Pointer> - get clang_isInvalidDeclaration => _library._clang_isInvalidDeclarationPtr; - ffi.Pointer> - get clang_isReference => _library._clang_isReferencePtr; - ffi.Pointer> - get clang_isExpression => _library._clang_isExpressionPtr; - ffi.Pointer> - get clang_isStatement => _library._clang_isStatementPtr; - ffi.Pointer> - get clang_isAttribute => _library._clang_isAttributePtr; - ffi.Pointer> - get clang_Cursor_hasAttrs => _library._clang_Cursor_hasAttrsPtr; - ffi.Pointer> get clang_isInvalid => - _library._clang_isInvalidPtr; - ffi.Pointer> - get clang_isTranslationUnit => _library._clang_isTranslationUnitPtr; - ffi.Pointer> - get clang_isPreprocessing => _library._clang_isPreprocessingPtr; - ffi.Pointer> - get clang_isUnexposed => _library._clang_isUnexposedPtr; - ffi.Pointer> - get clang_getCursorLinkage => _library._clang_getCursorLinkagePtr; - ffi.Pointer> - get clang_getCursorVisibility => _library._clang_getCursorVisibilityPtr; - ffi.Pointer> - get clang_getCursorAvailability => _library._clang_getCursorAvailabilityPtr; - ffi.Pointer> - get clang_getCursorPlatformAvailability => - _library._clang_getCursorPlatformAvailabilityPtr; - ffi.Pointer> - get clang_disposeCXPlatformAvailability => - _library._clang_disposeCXPlatformAvailabilityPtr; - ffi.Pointer> - get clang_getCursorLanguage => _library._clang_getCursorLanguagePtr; - ffi.Pointer> - get clang_getCursorTLSKind => _library._clang_getCursorTLSKindPtr; - ffi.Pointer> - get clang_Cursor_getTranslationUnit => - _library._clang_Cursor_getTranslationUnitPtr; - ffi.Pointer> - get clang_createCXCursorSet => _library._clang_createCXCursorSetPtr; - ffi.Pointer> - get clang_disposeCXCursorSet => _library._clang_disposeCXCursorSetPtr; - ffi.Pointer> - get clang_CXCursorSet_contains => _library._clang_CXCursorSet_containsPtr; - ffi.Pointer> - get clang_CXCursorSet_insert => _library._clang_CXCursorSet_insertPtr; - ffi.Pointer> - get clang_getCursorSemanticParent => - _library._clang_getCursorSemanticParentPtr; - ffi.Pointer> - get clang_getCursorLexicalParent => _library._clang_getCursorLexicalParentPtr; - ffi.Pointer> - get clang_getOverriddenCursors => _library._clang_getOverriddenCursorsPtr; - ffi.Pointer> - get clang_disposeOverriddenCursors => - _library._clang_disposeOverriddenCursorsPtr; - ffi.Pointer> - get clang_getIncludedFile => _library._clang_getIncludedFilePtr; - ffi.Pointer> get clang_getCursor => - _library._clang_getCursorPtr; - ffi.Pointer> - get clang_getCursorLocation => _library._clang_getCursorLocationPtr; - ffi.Pointer> - get clang_getCursorExtent => _library._clang_getCursorExtentPtr; - ffi.Pointer> - get clang_getCursorType => _library._clang_getCursorTypePtr; - ffi.Pointer> - get clang_getTypeSpelling => _library._clang_getTypeSpellingPtr; - ffi.Pointer> - get clang_getTypedefDeclUnderlyingType => - _library._clang_getTypedefDeclUnderlyingTypePtr; - ffi.Pointer> - get clang_getEnumDeclIntegerType => _library._clang_getEnumDeclIntegerTypePtr; - ffi.Pointer> - get clang_getEnumConstantDeclValue => - _library._clang_getEnumConstantDeclValuePtr; - ffi.Pointer> - get clang_getEnumConstantDeclUnsignedValue => - _library._clang_getEnumConstantDeclUnsignedValuePtr; - ffi.Pointer> - get clang_getFieldDeclBitWidth => _library._clang_getFieldDeclBitWidthPtr; - ffi.Pointer> - get clang_Cursor_getNumArguments => _library._clang_Cursor_getNumArgumentsPtr; - ffi.Pointer> - get clang_Cursor_getArgument => _library._clang_Cursor_getArgumentPtr; - ffi.Pointer> - get clang_Cursor_getNumTemplateArguments => - _library._clang_Cursor_getNumTemplateArgumentsPtr; - ffi.Pointer> - get clang_Cursor_getTemplateArgumentKind => - _library._clang_Cursor_getTemplateArgumentKindPtr; - ffi.Pointer> - get clang_Cursor_getTemplateArgumentType => - _library._clang_Cursor_getTemplateArgumentTypePtr; - ffi.Pointer> - get clang_Cursor_getTemplateArgumentValue => - _library._clang_Cursor_getTemplateArgumentValuePtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_Cursor_getTemplateArgumentUnsignedValue => - _library._clang_Cursor_getTemplateArgumentUnsignedValuePtr; - ffi.Pointer> - get clang_equalTypes => _library._clang_equalTypesPtr; - ffi.Pointer> - get clang_getCanonicalType => _library._clang_getCanonicalTypePtr; - ffi.Pointer> - get clang_isConstQualifiedType => _library._clang_isConstQualifiedTypePtr; - ffi.Pointer> - get clang_Cursor_isMacroFunctionLike => - _library._clang_Cursor_isMacroFunctionLikePtr; - ffi.Pointer> - get clang_Cursor_isMacroBuiltin => _library._clang_Cursor_isMacroBuiltinPtr; - ffi.Pointer> - get clang_Cursor_isFunctionInlined => - _library._clang_Cursor_isFunctionInlinedPtr; - ffi.Pointer> - get clang_isVolatileQualifiedType => - _library._clang_isVolatileQualifiedTypePtr; - ffi.Pointer> - get clang_isRestrictQualifiedType => - _library._clang_isRestrictQualifiedTypePtr; - ffi.Pointer> - get clang_getAddressSpace => _library._clang_getAddressSpacePtr; - ffi.Pointer> - get clang_getTypedefName => _library._clang_getTypedefNamePtr; - ffi.Pointer> - get clang_getPointeeType => _library._clang_getPointeeTypePtr; - ffi.Pointer> - get clang_getTypeDeclaration => _library._clang_getTypeDeclarationPtr; - ffi.Pointer> - get clang_getDeclObjCTypeEncoding => - _library._clang_getDeclObjCTypeEncodingPtr; - ffi.Pointer> - get clang_Type_getObjCEncoding => _library._clang_Type_getObjCEncodingPtr; - ffi.Pointer> - get clang_getTypeKindSpelling => _library._clang_getTypeKindSpellingPtr; - ffi.Pointer> - get clang_getFunctionTypeCallingConv => - _library._clang_getFunctionTypeCallingConvPtr; - ffi.Pointer> - get clang_getResultType => _library._clang_getResultTypePtr; - ffi.Pointer> - get clang_getExceptionSpecificationType => - _library._clang_getExceptionSpecificationTypePtr; - ffi.Pointer> - get clang_getNumArgTypes => _library._clang_getNumArgTypesPtr; - ffi.Pointer> - get clang_getArgType => _library._clang_getArgTypePtr; - ffi.Pointer> - get clang_Type_getObjCObjectBaseType => - _library._clang_Type_getObjCObjectBaseTypePtr; - ffi.Pointer> - get clang_Type_getNumObjCProtocolRefs => - _library._clang_Type_getNumObjCProtocolRefsPtr; - ffi.Pointer> - get clang_Type_getObjCProtocolDecl => - _library._clang_Type_getObjCProtocolDeclPtr; - ffi.Pointer> - get clang_Type_getNumObjCTypeArgs => - _library._clang_Type_getNumObjCTypeArgsPtr; - ffi.Pointer> - get clang_Type_getObjCTypeArg => _library._clang_Type_getObjCTypeArgPtr; - ffi.Pointer> - get clang_isFunctionTypeVariadic => _library._clang_isFunctionTypeVariadicPtr; - ffi.Pointer> - get clang_getCursorResultType => _library._clang_getCursorResultTypePtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_getCursorExceptionSpecificationType => - _library._clang_getCursorExceptionSpecificationTypePtr; - ffi.Pointer> get clang_isPODType => - _library._clang_isPODTypePtr; - ffi.Pointer> - get clang_getElementType => _library._clang_getElementTypePtr; - ffi.Pointer> - get clang_getNumElements => _library._clang_getNumElementsPtr; - ffi.Pointer> - get clang_getArrayElementType => _library._clang_getArrayElementTypePtr; - ffi.Pointer> - get clang_getArraySize => _library._clang_getArraySizePtr; - ffi.Pointer> - get clang_Type_getNamedType => _library._clang_Type_getNamedTypePtr; - ffi.Pointer> - get clang_Type_isTransparentTagTypedef => - _library._clang_Type_isTransparentTagTypedefPtr; - ffi.Pointer> - get clang_Type_getNullability => _library._clang_Type_getNullabilityPtr; - ffi.Pointer> - get clang_Type_getAlignOf => _library._clang_Type_getAlignOfPtr; - ffi.Pointer> - get clang_Type_getClassType => _library._clang_Type_getClassTypePtr; - ffi.Pointer> - get clang_Type_getSizeOf => _library._clang_Type_getSizeOfPtr; - ffi.Pointer> - get clang_Type_getOffsetOf => _library._clang_Type_getOffsetOfPtr; - ffi.Pointer> - get clang_Type_getModifiedType => _library._clang_Type_getModifiedTypePtr; - ffi.Pointer> - get clang_Cursor_getOffsetOfField => - _library._clang_Cursor_getOffsetOfFieldPtr; - ffi.Pointer> - get clang_Cursor_isAnonymous => _library._clang_Cursor_isAnonymousPtr; - ffi.Pointer> - get clang_Cursor_isAnonymousRecordDecl => - _library._clang_Cursor_isAnonymousRecordDeclPtr; - ffi.Pointer> - get clang_Cursor_isInlineNamespace => - _library._clang_Cursor_isInlineNamespacePtr; - ffi.Pointer> - get clang_Type_getNumTemplateArguments => - _library._clang_Type_getNumTemplateArgumentsPtr; - ffi.Pointer> - get clang_Type_getTemplateArgumentAsType => - _library._clang_Type_getTemplateArgumentAsTypePtr; - ffi.Pointer> - get clang_Type_getCXXRefQualifier => - _library._clang_Type_getCXXRefQualifierPtr; - ffi.Pointer> - get clang_Cursor_isBitField => _library._clang_Cursor_isBitFieldPtr; - ffi.Pointer> - get clang_isVirtualBase => _library._clang_isVirtualBasePtr; - ffi.Pointer> - get clang_getCXXAccessSpecifier => _library._clang_getCXXAccessSpecifierPtr; - ffi.Pointer> - get clang_Cursor_getStorageClass => _library._clang_Cursor_getStorageClassPtr; - ffi.Pointer> - get clang_getNumOverloadedDecls => _library._clang_getNumOverloadedDeclsPtr; - ffi.Pointer> - get clang_getOverloadedDecl => _library._clang_getOverloadedDeclPtr; - ffi.Pointer> - get clang_getIBOutletCollectionType => - _library._clang_getIBOutletCollectionTypePtr; - ffi.Pointer> - get clang_visitChildren => _library._clang_visitChildrenPtr; - ffi.Pointer> - get clang_getCursorUSR => _library._clang_getCursorUSRPtr; - ffi.Pointer> - get clang_constructUSR_ObjCClass => _library._clang_constructUSR_ObjCClassPtr; - ffi.Pointer> - get clang_constructUSR_ObjCCategory => - _library._clang_constructUSR_ObjCCategoryPtr; - ffi.Pointer> - get clang_constructUSR_ObjCProtocol => - _library._clang_constructUSR_ObjCProtocolPtr; - ffi.Pointer> - get clang_constructUSR_ObjCIvar => _library._clang_constructUSR_ObjCIvarPtr; - ffi.Pointer> - get clang_constructUSR_ObjCMethod => - _library._clang_constructUSR_ObjCMethodPtr; - ffi.Pointer> - get clang_constructUSR_ObjCProperty => - _library._clang_constructUSR_ObjCPropertyPtr; - ffi.Pointer> - get clang_getCursorSpelling => _library._clang_getCursorSpellingPtr; - ffi.Pointer> - get clang_Cursor_getSpellingNameRange => - _library._clang_Cursor_getSpellingNameRangePtr; - ffi.Pointer> - get clang_PrintingPolicy_getProperty => - _library._clang_PrintingPolicy_getPropertyPtr; - ffi.Pointer> - get clang_PrintingPolicy_setProperty => - _library._clang_PrintingPolicy_setPropertyPtr; - ffi.Pointer> - get clang_getCursorPrintingPolicy => - _library._clang_getCursorPrintingPolicyPtr; - ffi.Pointer> - get clang_PrintingPolicy_dispose => _library._clang_PrintingPolicy_disposePtr; - ffi.Pointer> - get clang_getCursorPrettyPrinted => _library._clang_getCursorPrettyPrintedPtr; - ffi.Pointer> - get clang_getCursorDisplayName => _library._clang_getCursorDisplayNamePtr; - ffi.Pointer> - get clang_getCursorReferenced => _library._clang_getCursorReferencedPtr; - ffi.Pointer> - get clang_getCursorDefinition => _library._clang_getCursorDefinitionPtr; - ffi.Pointer> - get clang_isCursorDefinition => _library._clang_isCursorDefinitionPtr; - ffi.Pointer> - get clang_getCanonicalCursor => _library._clang_getCanonicalCursorPtr; - ffi.Pointer> - get clang_Cursor_getObjCSelectorIndex => - _library._clang_Cursor_getObjCSelectorIndexPtr; - ffi.Pointer> - get clang_Cursor_isDynamicCall => _library._clang_Cursor_isDynamicCallPtr; - ffi.Pointer> - get clang_Cursor_getReceiverType => _library._clang_Cursor_getReceiverTypePtr; - ffi.Pointer> - get clang_Cursor_getObjCPropertyAttributes => - _library._clang_Cursor_getObjCPropertyAttributesPtr; - ffi.Pointer> - get clang_Cursor_getObjCPropertyGetterName => - _library._clang_Cursor_getObjCPropertyGetterNamePtr; - ffi.Pointer> - get clang_Cursor_getObjCPropertySetterName => - _library._clang_Cursor_getObjCPropertySetterNamePtr; - ffi.Pointer> - get clang_Cursor_getObjCDeclQualifiers => - _library._clang_Cursor_getObjCDeclQualifiersPtr; - ffi.Pointer> - get clang_Cursor_isObjCOptional => _library._clang_Cursor_isObjCOptionalPtr; - ffi.Pointer> - get clang_Cursor_isVariadic => _library._clang_Cursor_isVariadicPtr; - ffi.Pointer> - get clang_Cursor_isExternalSymbol => - _library._clang_Cursor_isExternalSymbolPtr; - ffi.Pointer> - get clang_Cursor_getCommentRange => _library._clang_Cursor_getCommentRangePtr; - ffi.Pointer> - get clang_Cursor_getRawCommentText => - _library._clang_Cursor_getRawCommentTextPtr; - ffi.Pointer> - get clang_Cursor_getBriefCommentText => - _library._clang_Cursor_getBriefCommentTextPtr; - ffi.Pointer> - get clang_Cursor_getMangling => _library._clang_Cursor_getManglingPtr; - ffi.Pointer> - get clang_Cursor_getCXXManglings => _library._clang_Cursor_getCXXManglingsPtr; - ffi.Pointer> - get clang_Cursor_getObjCManglings => - _library._clang_Cursor_getObjCManglingsPtr; - ffi.Pointer> - get clang_Cursor_getModule => _library._clang_Cursor_getModulePtr; - ffi.Pointer> - get clang_getModuleForFile => _library._clang_getModuleForFilePtr; - ffi.Pointer> - get clang_Module_getASTFile => _library._clang_Module_getASTFilePtr; - ffi.Pointer> - get clang_Module_getParent => _library._clang_Module_getParentPtr; - ffi.Pointer> - get clang_Module_getName => _library._clang_Module_getNamePtr; - ffi.Pointer> - get clang_Module_getFullName => _library._clang_Module_getFullNamePtr; - ffi.Pointer> - get clang_Module_isSystem => _library._clang_Module_isSystemPtr; - ffi.Pointer> - get clang_Module_getNumTopLevelHeaders => - _library._clang_Module_getNumTopLevelHeadersPtr; - ffi.Pointer> - get clang_Module_getTopLevelHeader => - _library._clang_Module_getTopLevelHeaderPtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_CXXConstructor_isConvertingConstructor => - _library._clang_CXXConstructor_isConvertingConstructorPtr; - ffi.Pointer> - get clang_CXXConstructor_isCopyConstructor => - _library._clang_CXXConstructor_isCopyConstructorPtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_CXXConstructor_isDefaultConstructor => - _library._clang_CXXConstructor_isDefaultConstructorPtr; - ffi.Pointer> - get clang_CXXConstructor_isMoveConstructor => - _library._clang_CXXConstructor_isMoveConstructorPtr; - ffi.Pointer> - get clang_CXXField_isMutable => _library._clang_CXXField_isMutablePtr; - ffi.Pointer> - get clang_CXXMethod_isDefaulted => _library._clang_CXXMethod_isDefaultedPtr; - ffi.Pointer> - get clang_CXXMethod_isPureVirtual => - _library._clang_CXXMethod_isPureVirtualPtr; - ffi.Pointer> - get clang_CXXMethod_isStatic => _library._clang_CXXMethod_isStaticPtr; - ffi.Pointer> - get clang_CXXMethod_isVirtual => _library._clang_CXXMethod_isVirtualPtr; - ffi.Pointer> - get clang_CXXRecord_isAbstract => _library._clang_CXXRecord_isAbstractPtr; - ffi.Pointer> - get clang_EnumDecl_isScoped => _library._clang_EnumDecl_isScopedPtr; - ffi.Pointer> - get clang_CXXMethod_isConst => _library._clang_CXXMethod_isConstPtr; - ffi.Pointer> - get clang_getTemplateCursorKind => _library._clang_getTemplateCursorKindPtr; - ffi.Pointer> - get clang_getSpecializedCursorTemplate => - _library._clang_getSpecializedCursorTemplatePtr; - ffi.Pointer> - get clang_getCursorReferenceNameRange => - _library._clang_getCursorReferenceNameRangePtr; - ffi.Pointer> get clang_getToken => - _library._clang_getTokenPtr; - ffi.Pointer> - get clang_getTokenKind => _library._clang_getTokenKindPtr; - ffi.Pointer> - get clang_getTokenSpelling => _library._clang_getTokenSpellingPtr; - ffi.Pointer> - get clang_getTokenLocation => _library._clang_getTokenLocationPtr; - ffi.Pointer> - get clang_getTokenExtent => _library._clang_getTokenExtentPtr; - ffi.Pointer> get clang_tokenize => - _library._clang_tokenizePtr; - ffi.Pointer> - get clang_annotateTokens => _library._clang_annotateTokensPtr; - ffi.Pointer> - get clang_disposeTokens => _library._clang_disposeTokensPtr; - ffi.Pointer> - get clang_getCursorKindSpelling => _library._clang_getCursorKindSpellingPtr; - ffi.Pointer> - get clang_getDefinitionSpellingAndExtent => - _library._clang_getDefinitionSpellingAndExtentPtr; - ffi.Pointer> - get clang_enableStackTraces => _library._clang_enableStackTracesPtr; - ffi.Pointer> - get clang_executeOnThread => _library._clang_executeOnThreadPtr; - ffi.Pointer> - get clang_getCompletionChunkKind => _library._clang_getCompletionChunkKindPtr; - ffi.Pointer> - get clang_getCompletionChunkText => _library._clang_getCompletionChunkTextPtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_getCompletionChunkCompletionString => - _library._clang_getCompletionChunkCompletionStringPtr; - ffi.Pointer> - get clang_getNumCompletionChunks => _library._clang_getNumCompletionChunksPtr; - ffi.Pointer> - get clang_getCompletionPriority => _library._clang_getCompletionPriorityPtr; - ffi.Pointer> - get clang_getCompletionAvailability => - _library._clang_getCompletionAvailabilityPtr; - ffi.Pointer> - get clang_getCompletionNumAnnotations => - _library._clang_getCompletionNumAnnotationsPtr; - ffi.Pointer> - get clang_getCompletionAnnotation => - _library._clang_getCompletionAnnotationPtr; - ffi.Pointer> - get clang_getCompletionParent => _library._clang_getCompletionParentPtr; - ffi.Pointer> - get clang_getCompletionBriefComment => - _library._clang_getCompletionBriefCommentPtr; - ffi.Pointer> - get clang_getCursorCompletionString => - _library._clang_getCursorCompletionStringPtr; - ffi.Pointer> - get clang_getCompletionNumFixIts => _library._clang_getCompletionNumFixItsPtr; - ffi.Pointer> - get clang_getCompletionFixIt => _library._clang_getCompletionFixItPtr; - ffi.Pointer> - get clang_defaultCodeCompleteOptions => - _library._clang_defaultCodeCompleteOptionsPtr; - ffi.Pointer> - get clang_codeCompleteAt => _library._clang_codeCompleteAtPtr; - ffi.Pointer> - get clang_sortCodeCompletionResults => - _library._clang_sortCodeCompletionResultsPtr; - ffi.Pointer> - get clang_disposeCodeCompleteResults => - _library._clang_disposeCodeCompleteResultsPtr; - ffi.Pointer> - get clang_codeCompleteGetNumDiagnostics => - _library._clang_codeCompleteGetNumDiagnosticsPtr; - ffi.Pointer> - get clang_codeCompleteGetDiagnostic => - _library._clang_codeCompleteGetDiagnosticPtr; - ffi.Pointer> - get clang_codeCompleteGetContexts => - _library._clang_codeCompleteGetContextsPtr; - ffi.Pointer> - get clang_codeCompleteGetContainerKind => - _library._clang_codeCompleteGetContainerKindPtr; - ffi.Pointer> - get clang_codeCompleteGetContainerUSR => - _library._clang_codeCompleteGetContainerUSRPtr; - ffi.Pointer> - get clang_codeCompleteGetObjCSelector => - _library._clang_codeCompleteGetObjCSelectorPtr; - ffi.Pointer> - get clang_getClangVersion => _library._clang_getClangVersionPtr; - ffi.Pointer> - get clang_toggleCrashRecovery => _library._clang_toggleCrashRecoveryPtr; - ffi.Pointer> - get clang_getInclusions => _library._clang_getInclusionsPtr; - ffi.Pointer> - get clang_Cursor_Evaluate => _library._clang_Cursor_EvaluatePtr; - ffi.Pointer> - get clang_EvalResult_getKind => _library._clang_EvalResult_getKindPtr; - ffi.Pointer> - get clang_EvalResult_getAsInt => _library._clang_EvalResult_getAsIntPtr; - ffi.Pointer> - get clang_EvalResult_getAsLongLong => - _library._clang_EvalResult_getAsLongLongPtr; - ffi.Pointer> - get clang_EvalResult_isUnsignedInt => - _library._clang_EvalResult_isUnsignedIntPtr; - ffi.Pointer> - get clang_EvalResult_getAsUnsigned => - _library._clang_EvalResult_getAsUnsignedPtr; - ffi.Pointer> - get clang_EvalResult_getAsDouble => _library._clang_EvalResult_getAsDoublePtr; - ffi.Pointer> - get clang_EvalResult_getAsStr => _library._clang_EvalResult_getAsStrPtr; - ffi.Pointer> - get clang_EvalResult_dispose => _library._clang_EvalResult_disposePtr; - ffi.Pointer> - get clang_getRemappings => _library._clang_getRemappingsPtr; - ffi.Pointer> - get clang_getRemappingsFromFileList => - _library._clang_getRemappingsFromFileListPtr; - ffi.Pointer> - get clang_remap_getNumFiles => _library._clang_remap_getNumFilesPtr; - ffi.Pointer> - get clang_remap_getFilenames => _library._clang_remap_getFilenamesPtr; - ffi.Pointer> - get clang_remap_dispose => _library._clang_remap_disposePtr; - ffi.Pointer> - get clang_findReferencesInFile => _library._clang_findReferencesInFilePtr; - ffi.Pointer> - get clang_findIncludesInFile => _library._clang_findIncludesInFilePtr; - ffi.Pointer> - get clang_index_isEntityObjCContainerKind => - _library._clang_index_isEntityObjCContainerKindPtr; - ffi.Pointer> - get clang_index_getObjCContainerDeclInfo => - _library._clang_index_getObjCContainerDeclInfoPtr; - ffi.Pointer> - get clang_index_getObjCInterfaceDeclInfo => - _library._clang_index_getObjCInterfaceDeclInfoPtr; - ffi.Pointer> - get clang_index_getObjCCategoryDeclInfo => - _library._clang_index_getObjCCategoryDeclInfoPtr; - ffi.Pointer> - get clang_index_getObjCProtocolRefListInfo => - _library._clang_index_getObjCProtocolRefListInfoPtr; - ffi.Pointer> - get clang_index_getObjCPropertyDeclInfo => - _library._clang_index_getObjCPropertyDeclInfoPtr; - ffi.Pointer< - ffi.NativeFunction - > - get clang_index_getIBOutletCollectionAttrInfo => - _library._clang_index_getIBOutletCollectionAttrInfoPtr; - ffi.Pointer> - get clang_index_getCXXClassDeclInfo => - _library._clang_index_getCXXClassDeclInfoPtr; - ffi.Pointer> - get clang_index_getClientContainer => - _library._clang_index_getClientContainerPtr; - ffi.Pointer> - get clang_index_setClientContainer => - _library._clang_index_setClientContainerPtr; - ffi.Pointer> - get clang_index_getClientEntity => _library._clang_index_getClientEntityPtr; - ffi.Pointer> - get clang_index_setClientEntity => _library._clang_index_setClientEntityPtr; - ffi.Pointer> - get clang_IndexAction_create => _library._clang_IndexAction_createPtr; - ffi.Pointer> - get clang_IndexAction_dispose => _library._clang_IndexAction_disposePtr; - ffi.Pointer> - get clang_indexSourceFile => _library._clang_indexSourceFilePtr; - ffi.Pointer> - get clang_indexSourceFileFullArgv => - _library._clang_indexSourceFileFullArgvPtr; - ffi.Pointer> - get clang_indexTranslationUnit => _library._clang_indexTranslationUnitPtr; - ffi.Pointer> - get clang_indexLoc_getFileLocation => - _library._clang_indexLoc_getFileLocationPtr; - ffi.Pointer> - get clang_indexLoc_getCXSourceLocation => - _library._clang_indexLoc_getCXSourceLocationPtr; - ffi.Pointer> - get clang_Type_visitFields => _library._clang_Type_visitFieldsPtr; -} + late final _clang_isPODTypePtr = + _lookup>('clang_isPODType'); + late final _clang_isPODType = _clang_isPODTypePtr + .asFunction(); -/// A character string. -/// -/// The \c CXString type is used to return strings from the interface when -/// the ownership of that string might differ from one call to the next. -/// Use \c clang_getCString() to retrieve the string data and, once finished -/// with the string data, call \c clang_disposeString() to free the string. -final class CXString extends ffi.Struct { - external ffi.Pointer data; + /// Determine whether the given cursor represents a preprocessing + /// element, such as a preprocessor directive or macro instantiation. + int clang_isPreprocessing(CXCursorKind arg0) { + return _clang_isPreprocessing(arg0.value); + } - @ffi.UnsignedInt() - external int private_flags; -} + late final _clang_isPreprocessingPtr = + _lookup>( + 'clang_isPreprocessing', + ); + late final _clang_isPreprocessing = _clang_isPreprocessingPtr + .asFunction(); + + /// Determine whether the given cursor kind represents a simple + /// reference. + /// + /// Note that other kinds of cursors (such as expressions) can also refer to + /// other cursors. Use clang_getCursorReferenced() to determine whether a + /// particular cursor refers to another entity. + int clang_isReference(CXCursorKind arg0) { + return _clang_isReference(arg0.value); + } + + late final _clang_isReferencePtr = + _lookup>('clang_isReference'); + late final _clang_isReference = _clang_isReferencePtr + .asFunction(); + + /// Determine whether a CXType has the "restrict" qualifier set, + /// without looking through typedefs that may have added "restrict" at a + /// different level. + int clang_isRestrictQualifiedType(CXType T) { + return _clang_isRestrictQualifiedType(T); + } + + late final _clang_isRestrictQualifiedTypePtr = + _lookup>( + 'clang_isRestrictQualifiedType', + ); + late final _clang_isRestrictQualifiedType = _clang_isRestrictQualifiedTypePtr + .asFunction(); -final class CXStringSet extends ffi.Struct { - external ffi.Pointer Strings; + /// Determine whether the given cursor kind represents a statement. + int clang_isStatement(CXCursorKind arg0) { + return _clang_isStatement(arg0.value); + } - @ffi.UnsignedInt() - external int Count; -} + late final _clang_isStatementPtr = + _lookup>('clang_isStatement'); + late final _clang_isStatement = _clang_isStatementPtr + .asFunction(); -typedef NativeClang_getCString = - ffi.Pointer Function(CXString string); -typedef DartClang_getCString = ffi.Pointer Function(CXString string); -typedef NativeClang_disposeString = ffi.Void Function(CXString string); -typedef DartClang_disposeString = void Function(CXString string); -typedef NativeClang_disposeStringSet = - ffi.Void Function(ffi.Pointer set); -typedef DartClang_disposeStringSet = - void Function(ffi.Pointer set); + /// Determine whether the given cursor kind represents a translation + /// unit. + int clang_isTranslationUnit(CXCursorKind arg0) { + return _clang_isTranslationUnit(arg0.value); + } -/// An "index" that consists of a set of translation units that would -/// typically be linked together into an executable or library. -typedef CXIndex = ffi.Pointer; + late final _clang_isTranslationUnitPtr = + _lookup>( + 'clang_isTranslationUnit', + ); + late final _clang_isTranslationUnit = _clang_isTranslationUnitPtr + .asFunction(); -final class CXTargetInfoImpl extends ffi.Opaque {} + /// Determine whether the given cursor represents a currently + /// unexposed piece of the AST (e.g., CXCursor_UnexposedStmt). + int clang_isUnexposed(CXCursorKind arg0) { + return _clang_isUnexposed(arg0.value); + } -/// An opaque type representing target information for a given translation -/// unit. -typedef CXTargetInfo = ffi.Pointer; + late final _clang_isUnexposedPtr = + _lookup>('clang_isUnexposed'); + late final _clang_isUnexposed = _clang_isUnexposedPtr + .asFunction(); -final class CXTranslationUnitImpl extends ffi.Opaque {} + /// Returns 1 if the base class specified by the cursor with kind + /// CX_CXXBaseSpecifier is virtual. + int clang_isVirtualBase(CXCursor arg0) { + return _clang_isVirtualBase(arg0); + } -/// A single translation unit, which resides in an index. -typedef CXTranslationUnit = ffi.Pointer; + late final _clang_isVirtualBasePtr = + _lookup>( + 'clang_isVirtualBase', + ); + late final _clang_isVirtualBase = _clang_isVirtualBasePtr + .asFunction(); -/// Opaque pointer representing client data that will be passed through -/// to various callbacks and visitors. -typedef CXClientData = ffi.Pointer; + /// Determine whether a CXType has the "volatile" qualifier set, + /// without looking through typedefs that may have added "volatile" at + /// a different level. + int clang_isVolatileQualifiedType(CXType T) { + return _clang_isVolatileQualifiedType(T); + } -/// Provides the contents of a file that has not yet been saved to disk. -/// -/// Each CXUnsavedFile instance provides the name of a file on the -/// system along with the current contents of that file that have not -/// yet been saved to disk. -final class CXUnsavedFile extends ffi.Struct { - /// The file whose contents have not yet been saved. + late final _clang_isVolatileQualifiedTypePtr = + _lookup>( + 'clang_isVolatileQualifiedType', + ); + late final _clang_isVolatileQualifiedType = _clang_isVolatileQualifiedTypePtr + .asFunction(); + + /// Deserialize a set of diagnostics from a Clang diagnostics bitcode + /// file. /// - /// This file must already exist in the file system. - external ffi.Pointer Filename; + /// \param file The name of the file to deserialize. + /// \param error A pointer to a enum value recording if there was a problem + /// deserializing the diagnostics. + /// \param errorString A pointer to a CXString for recording the error string + /// if the file was not successfully loaded. + /// + /// \returns A loaded CXDiagnosticSet if successful, and NULL otherwise. These + /// diagnostics should be released using clang_disposeDiagnosticSet(). + CXDiagnosticSet clang_loadDiagnostics( + ffi.Pointer file, + ffi.Pointer error, + ffi.Pointer errorString, + ) { + return _clang_loadDiagnostics(file, error, errorString); + } - /// A buffer containing the unsaved contents of this file. - external ffi.Pointer Contents; + late final _clang_loadDiagnosticsPtr = + _lookup>( + 'clang_loadDiagnostics', + ); + late final _clang_loadDiagnostics = _clang_loadDiagnosticsPtr + .asFunction(); - /// The length of the unsaved contents of this buffer. - @ffi.UnsignedLong() - external int Length; -} + /// Same as \c clang_parseTranslationUnit2, but returns + /// the \c CXTranslationUnit instead of an error code. In case of an error this + /// routine returns a \c NULL \c CXTranslationUnit, without further detailed + /// error codes. + CXTranslationUnit clang_parseTranslationUnit( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ) { + return _clang_parseTranslationUnit( + CIdx, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + options, + ); + } -/// Describes the availability of a particular entity, which indicates -/// whether the use of this entity will result in a warning or error due to -/// it being deprecated or unavailable. -enum CXAvailabilityKind { - /// The entity is available. - CXAvailability_Available(0), + late final _clang_parseTranslationUnitPtr = + _lookup>( + 'clang_parseTranslationUnit', + ); + late final _clang_parseTranslationUnit = _clang_parseTranslationUnitPtr + .asFunction(); - /// The entity is available, but has been deprecated (and its use is - /// not recommended). - CXAvailability_Deprecated(1), + /// Parse the given source file and the translation unit corresponding + /// to that file. + /// + /// This routine is the main entry point for the Clang C API, providing the + /// ability to parse a source file into a translation unit that can then be + /// queried by other functions in the API. This routine accepts a set of + /// command-line arguments so that the compilation can be configured in the same + /// way that the compiler is configured on the command line. + /// + /// \param CIdx The index object with which the translation unit will be + /// associated. + /// + /// \param source_filename The name of the source file to load, or NULL if the + /// source file is included in \c command_line_args. + /// + /// \param command_line_args The command-line arguments that would be + /// passed to the \c clang executable if it were being invoked out-of-process. + /// These command-line options will be parsed and will affect how the translation + /// unit is parsed. Note that the following options are ignored: '-c', + /// '-emit-ast', '-fsyntax-only' (which is the default), and '-o \'. + /// + /// \param num_command_line_args The number of command-line arguments in + /// \c command_line_args. + /// + /// \param unsaved_files the files that have not yet been saved to disk + /// but may be required for parsing, including the contents of + /// those files. The contents and name of these files (as specified by + /// CXUnsavedFile) are copied when necessary, so the client only needs to + /// guarantee their validity until the call to this function returns. + /// + /// \param num_unsaved_files the number of unsaved file entries in \p + /// unsaved_files. + /// + /// \param options A bitmask of options that affects how the translation unit + /// is managed but not its compilation. This should be a bitwise OR of the + /// CXTranslationUnit_XXX flags. + /// + /// \param[out] out_TU A non-NULL pointer to store the created + /// \c CXTranslationUnit, describing the parsed code and containing any + /// diagnostics produced by the compiler. + /// + /// \returns Zero on success, otherwise returns an error code. + CXErrorCode clang_parseTranslationUnit2( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ffi.Pointer out_TU, + ) { + return CXErrorCode.fromValue( + _clang_parseTranslationUnit2( + CIdx, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + options, + out_TU, + ), + ); + } - /// The entity is not available; any use of it will be an error. - CXAvailability_NotAvailable(2), + late final _clang_parseTranslationUnit2Ptr = + _lookup>( + 'clang_parseTranslationUnit2', + ); + late final _clang_parseTranslationUnit2 = _clang_parseTranslationUnit2Ptr + .asFunction(); - /// The entity is available, but not accessible; any use of it will be - /// an error. - CXAvailability_NotAccessible(3); + /// Same as clang_parseTranslationUnit2 but requires a full command line + /// for \c command_line_args including argv[0]. This is useful if the standard + /// library paths are relative to the binary. + CXErrorCode clang_parseTranslationUnit2FullArgv( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ffi.Pointer out_TU, + ) { + return CXErrorCode.fromValue( + _clang_parseTranslationUnit2FullArgv( + CIdx, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + options, + out_TU, + ), + ); + } - final int value; - const CXAvailabilityKind(this.value); + late final _clang_parseTranslationUnit2FullArgvPtr = + _lookup>( + 'clang_parseTranslationUnit2FullArgv', + ); + late final _clang_parseTranslationUnit2FullArgv = + _clang_parseTranslationUnit2FullArgvPtr + .asFunction(); - static CXAvailabilityKind fromValue(int value) => switch (value) { - 0 => CXAvailability_Available, - 1 => CXAvailability_Deprecated, - 2 => CXAvailability_NotAvailable, - 3 => CXAvailability_NotAccessible, - _ => throw ArgumentError('Unknown value for CXAvailabilityKind: $value'), - }; -} + /// Dispose the remapping. + void clang_remap_dispose(CXRemapping arg0) { + return _clang_remap_dispose(arg0); + } -/// Describes a version number of the form major.minor.subminor. -final class CXVersion extends ffi.Struct { - /// The major version number, e.g., the '10' in '10.7.3'. A negative - /// value indicates that there is no version number at all. - @ffi.Int() - external int Major; + late final _clang_remap_disposePtr = + _lookup>( + 'clang_remap_dispose', + ); + late final _clang_remap_dispose = _clang_remap_disposePtr + .asFunction(); - /// The minor version number, e.g., the '7' in '10.7.3'. This value - /// will be negative if no minor version number was provided, e.g., for - /// version '10'. - @ffi.Int() - external int Minor; + /// Get the original and the associated filename from the remapping. + /// + /// \param original If non-NULL, will be set to the original filename. + /// + /// \param transformed If non-NULL, will be set to the filename that the original + /// is associated with. + void clang_remap_getFilenames( + CXRemapping arg0, + int index, + ffi.Pointer original, + ffi.Pointer transformed, + ) { + return _clang_remap_getFilenames(arg0, index, original, transformed); + } - /// The subminor version number, e.g., the '3' in '10.7.3'. This value - /// will be negative if no minor or subminor version number was provided, - /// e.g., in version '10' or '10.7'. - @ffi.Int() - external int Subminor; -} + late final _clang_remap_getFilenamesPtr = + _lookup>( + 'clang_remap_getFilenames', + ); + late final _clang_remap_getFilenames = _clang_remap_getFilenamesPtr + .asFunction(); -typedef NativeClang_createIndex = - CXIndex Function( - ffi.Int excludeDeclarationsFromPCH, - ffi.Int displayDiagnostics, - ); -typedef DartClang_createIndex = - CXIndex Function(int excludeDeclarationsFromPCH, int displayDiagnostics); -typedef NativeClang_disposeIndex = ffi.Void Function(CXIndex index); -typedef DartClang_disposeIndex = void Function(CXIndex index); + /// Determine the number of remappings. + int clang_remap_getNumFiles(CXRemapping arg0) { + return _clang_remap_getNumFiles(arg0); + } -enum CXGlobalOptFlags { - /// Used to indicate that no special CXIndex options are needed. - CXGlobalOpt_None(0), + late final _clang_remap_getNumFilesPtr = + _lookup>( + 'clang_remap_getNumFiles', + ); + late final _clang_remap_getNumFiles = _clang_remap_getNumFilesPtr + .asFunction(); - /// Used to indicate that threads that libclang creates for indexing - /// purposes should use background priority. + /// Reparse the source files that produced this translation unit. /// - /// Affects #clang_indexSourceFile, #clang_indexTranslationUnit, - /// #clang_parseTranslationUnit, #clang_saveTranslationUnit. - CXGlobalOpt_ThreadBackgroundPriorityForIndexing(1), - - /// Used to indicate that threads that libclang creates for editing - /// purposes should use background priority. + /// This routine can be used to re-parse the source files that originally + /// created the given translation unit, for example because those source files + /// have changed (either on disk or as passed via \p unsaved_files). The + /// source code will be reparsed with the same command-line options as it + /// was originally parsed. /// - /// Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, - /// #clang_annotateTokens - CXGlobalOpt_ThreadBackgroundPriorityForEditing(2), - - /// Used to indicate that all threads that libclang creates should use - /// background priority. - CXGlobalOpt_ThreadBackgroundPriorityForAll(3); - - final int value; - const CXGlobalOptFlags(this.value); - - static CXGlobalOptFlags fromValue(int value) => switch (value) { - 0 => CXGlobalOpt_None, - 1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing, - 2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing, - 3 => CXGlobalOpt_ThreadBackgroundPriorityForAll, - _ => throw ArgumentError('Unknown value for CXGlobalOptFlags: $value'), - }; -} + /// Reparsing a translation unit invalidates all cursors and source locations + /// that refer into that translation unit. This makes reparsing a translation + /// unit semantically equivalent to destroying the translation unit and then + /// creating a new translation unit with the same command-line arguments. + /// However, it may be more efficient to reparse a translation + /// unit using this routine. + /// + /// \param TU The translation unit whose contents will be re-parsed. The + /// translation unit must originally have been built with + /// \c clang_createTranslationUnitFromSourceFile(). + /// + /// \param num_unsaved_files The number of unsaved file entries in \p + /// unsaved_files. + /// + /// \param unsaved_files The files that have not yet been saved to disk + /// but may be required for parsing, including the contents of + /// those files. The contents and name of these files (as specified by + /// CXUnsavedFile) are copied when necessary, so the client only needs to + /// guarantee their validity until the call to this function returns. + /// + /// \param options A bitset of options composed of the flags in CXReparse_Flags. + /// The function \c clang_defaultReparseOptions() produces a default set of + /// options recommended for most uses, based on the translation unit. + /// + /// \returns 0 if the sources could be reparsed. A non-zero error code will be + /// returned if reparsing was impossible, such that the translation unit is + /// invalid. In such cases, the only valid call for \c TU is + /// \c clang_disposeTranslationUnit(TU). The error codes returned by this + /// routine are described by the \c CXErrorCode enum. + int clang_reparseTranslationUnit( + CXTranslationUnit TU, + int num_unsaved_files, + ffi.Pointer unsaved_files, + int options, + ) { + return _clang_reparseTranslationUnit( + TU, + num_unsaved_files, + unsaved_files, + options, + ); + } -typedef NativeClang_CXIndex_setGlobalOptions = - ffi.Void Function(CXIndex, ffi.UnsignedInt options); -typedef DartClang_CXIndex_setGlobalOptions = - void Function(CXIndex, int options); -typedef NativeClang_CXIndex_getGlobalOptions = - ffi.UnsignedInt Function(CXIndex); -typedef DartClang_CXIndex_getGlobalOptions = int Function(CXIndex); -typedef NativeClang_CXIndex_setInvocationEmissionPathOption = - ffi.Void Function(CXIndex, ffi.Pointer Path); -typedef DartClang_CXIndex_setInvocationEmissionPathOption = - void Function(CXIndex, ffi.Pointer Path); + late final _clang_reparseTranslationUnitPtr = + _lookup>( + 'clang_reparseTranslationUnit', + ); + late final _clang_reparseTranslationUnit = _clang_reparseTranslationUnitPtr + .asFunction(); -/// A particular source file that is part of a translation unit. -typedef CXFile = ffi.Pointer; -typedef NativeClang_getFileName = CXString Function(CXFile SFile); -typedef DartClang_getFileName = CXString Function(CXFile SFile); -typedef NativeClang_getFileTime = ffi.Int64 Function(CXFile SFile); -typedef DartClang_getFileTime = int Function(CXFile SFile); + /// Saves a translation unit into a serialized representation of + /// that translation unit on disk. + /// + /// Any translation unit that was parsed without error can be saved + /// into a file. The translation unit can then be deserialized into a + /// new \c CXTranslationUnit with \c clang_createTranslationUnit() or, + /// if it is an incomplete translation unit that corresponds to a + /// header, used as a precompiled header when parsing other translation + /// units. + /// + /// \param TU The translation unit to save. + /// + /// \param FileName The file to which the translation unit will be saved. + /// + /// \param options A bitmask of options that affects how the translation unit + /// is saved. This should be a bitwise OR of the + /// CXSaveTranslationUnit_XXX flags. + /// + /// \returns A value that will match one of the enumerators of the CXSaveError + /// enumeration. Zero (CXSaveError_None) indicates that the translation unit was + /// saved successfully, while a non-zero value indicates that a problem occurred. + int clang_saveTranslationUnit( + CXTranslationUnit TU, + ffi.Pointer FileName, + int options, + ) { + return _clang_saveTranslationUnit(TU, FileName, options); + } -/// Uniquely identifies a CXFile, that refers to the same underlying file, -/// across an indexing session. -final class CXFileUniqueID extends ffi.Struct { - @ffi.Array.multi([3]) - external ffi.Array data; -} + late final _clang_saveTranslationUnitPtr = + _lookup>( + 'clang_saveTranslationUnit', + ); + late final _clang_saveTranslationUnit = _clang_saveTranslationUnitPtr + .asFunction(); -typedef NativeClang_getFileUniqueID = - ffi.Int Function(CXFile file, ffi.Pointer outID); -typedef DartClang_getFileUniqueID = - int Function(CXFile file, ffi.Pointer outID); -typedef NativeClang_isFileMultipleIncludeGuarded = - ffi.UnsignedInt Function(CXTranslationUnit tu, CXFile file); -typedef DartClang_isFileMultipleIncludeGuarded = - int Function(CXTranslationUnit tu, CXFile file); -typedef NativeClang_getFile = - CXFile Function(CXTranslationUnit tu, ffi.Pointer file_name); -typedef DartClang_getFile = - CXFile Function(CXTranslationUnit tu, ffi.Pointer file_name); -typedef NativeClang_getFileContents = - ffi.Pointer Function( - CXTranslationUnit tu, - CXFile file, - ffi.Pointer size, - ); -typedef DartClang_getFileContents = - ffi.Pointer Function( - CXTranslationUnit tu, - CXFile file, - ffi.Pointer size, - ); -typedef NativeClang_File_isEqual = ffi.Int Function(CXFile file1, CXFile file2); -typedef DartClang_File_isEqual = int Function(CXFile file1, CXFile file2); -typedef NativeClang_File_tryGetRealPathName = CXString Function(CXFile file); -typedef DartClang_File_tryGetRealPathName = CXString Function(CXFile file); + /// Sort the code-completion results in case-insensitive alphabetical + /// order. + /// + /// \param Results The set of results to sort. + /// \param NumResults The number of results in \p Results. + void clang_sortCodeCompletionResults( + ffi.Pointer Results, + int NumResults, + ) { + return _clang_sortCodeCompletionResults(Results, NumResults); + } -/// Identifies a specific source location within a translation -/// unit. -/// -/// Use clang_getExpansionLocation() or clang_getSpellingLocation() -/// to map a source location to a particular file, line, and column. -final class CXSourceLocation extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array> ptr_data; + late final _clang_sortCodeCompletionResultsPtr = + _lookup>( + 'clang_sortCodeCompletionResults', + ); + late final _clang_sortCodeCompletionResults = + _clang_sortCodeCompletionResultsPtr + .asFunction(); - @ffi.UnsignedInt() - external int int_data; -} + /// Suspend a translation unit in order to free memory associated with it. + /// + /// A suspended translation unit uses significantly less memory but on the other + /// side does not support any other calls than \c clang_reparseTranslationUnit + /// to resume it or \c clang_disposeTranslationUnit to dispose it completely. + int clang_suspendTranslationUnit(CXTranslationUnit arg0) { + return _clang_suspendTranslationUnit(arg0); + } -/// Identifies a half-open character range in the source code. -/// -/// Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the -/// starting and end locations from a source range, respectively. -final class CXSourceRange extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array> ptr_data; + late final _clang_suspendTranslationUnitPtr = + _lookup>( + 'clang_suspendTranslationUnit', + ); + late final _clang_suspendTranslationUnit = _clang_suspendTranslationUnitPtr + .asFunction(); - @ffi.UnsignedInt() - external int begin_int_data; + /// Enable/disable crash recovery. + /// + /// \param isEnabled Flag to indicate if crash recovery is enabled. A non-zero + /// value enables crash recovery, while 0 disables it. + void clang_toggleCrashRecovery(int isEnabled) { + return _clang_toggleCrashRecovery(isEnabled); + } - @ffi.UnsignedInt() - external int end_int_data; -} + late final _clang_toggleCrashRecoveryPtr = + _lookup>( + 'clang_toggleCrashRecovery', + ); + late final _clang_toggleCrashRecovery = _clang_toggleCrashRecoveryPtr + .asFunction(); -typedef NativeClang_getNullLocation = CXSourceLocation Function(); -typedef DartClang_getNullLocation = CXSourceLocation Function(); -typedef NativeClang_equalLocations = - ffi.UnsignedInt Function(CXSourceLocation loc1, CXSourceLocation loc2); -typedef DartClang_equalLocations = - int Function(CXSourceLocation loc1, CXSourceLocation loc2); -typedef NativeClang_getLocation = - CXSourceLocation Function( - CXTranslationUnit tu, - CXFile file, - ffi.UnsignedInt line, - ffi.UnsignedInt column, - ); -typedef DartClang_getLocation = - CXSourceLocation Function( - CXTranslationUnit tu, - CXFile file, - int line, - int column, - ); -typedef NativeClang_getLocationForOffset = - CXSourceLocation Function( - CXTranslationUnit tu, - CXFile file, - ffi.UnsignedInt offset, - ); -typedef DartClang_getLocationForOffset = - CXSourceLocation Function(CXTranslationUnit tu, CXFile file, int offset); -typedef NativeClang_Location_isInSystemHeader = - ffi.Int Function(CXSourceLocation location); -typedef DartClang_Location_isInSystemHeader = - int Function(CXSourceLocation location); -typedef NativeClang_Location_isFromMainFile = - ffi.Int Function(CXSourceLocation location); -typedef DartClang_Location_isFromMainFile = - int Function(CXSourceLocation location); -typedef NativeClang_getNullRange = CXSourceRange Function(); -typedef DartClang_getNullRange = CXSourceRange Function(); -typedef NativeClang_getRange = - CXSourceRange Function(CXSourceLocation begin, CXSourceLocation end); -typedef DartClang_getRange = - CXSourceRange Function(CXSourceLocation begin, CXSourceLocation end); -typedef NativeClang_equalRanges = - ffi.UnsignedInt Function(CXSourceRange range1, CXSourceRange range2); -typedef DartClang_equalRanges = - int Function(CXSourceRange range1, CXSourceRange range2); -typedef NativeClang_Range_isNull = ffi.Int Function(CXSourceRange range); -typedef DartClang_Range_isNull = int Function(CXSourceRange range); -typedef NativeClang_getExpansionLocation = - ffi.Void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef DartClang_getExpansionLocation = - void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef NativeClang_getPresumedLocation = - ffi.Void Function( - CXSourceLocation location, - ffi.Pointer filename, - ffi.Pointer line, - ffi.Pointer column, - ); -typedef DartClang_getPresumedLocation = - void Function( - CXSourceLocation location, - ffi.Pointer filename, - ffi.Pointer line, - ffi.Pointer column, - ); -typedef NativeClang_getInstantiationLocation = - ffi.Void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef DartClang_getInstantiationLocation = - void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef NativeClang_getSpellingLocation = - ffi.Void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef DartClang_getSpellingLocation = - void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef NativeClang_getFileLocation = - ffi.Void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef DartClang_getFileLocation = - void Function( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ); -typedef NativeClang_getRangeStart = - CXSourceLocation Function(CXSourceRange range); -typedef DartClang_getRangeStart = - CXSourceLocation Function(CXSourceRange range); -typedef NativeClang_getRangeEnd = - CXSourceLocation Function(CXSourceRange range); -typedef DartClang_getRangeEnd = CXSourceLocation Function(CXSourceRange range); + /// Tokenize the source code described by the given range into raw + /// lexical tokens. + /// + /// \param TU the translation unit whose text is being tokenized. + /// + /// \param Range the source range in which text should be tokenized. All of the + /// tokens produced by tokenization will fall within this source range, + /// + /// \param Tokens this pointer will be set to point to the array of tokens + /// that occur within the given source range. The returned pointer must be + /// freed with clang_disposeTokens() before the translation unit is destroyed. + /// + /// \param NumTokens will be set to the number of tokens in the \c *Tokens + /// array. + void clang_tokenize( + CXTranslationUnit TU, + CXSourceRange Range, + ffi.Pointer> Tokens, + ffi.Pointer NumTokens, + ) { + return _clang_tokenize(TU, Range, Tokens, NumTokens); + } + + late final _clang_tokenizePtr = + _lookup>('clang_tokenize'); + late final _clang_tokenize = _clang_tokenizePtr + .asFunction(); + + /// Visit the children of a particular cursor. + /// + /// This function visits all the direct children of the given cursor, + /// invoking the given \p visitor function with the cursors of each + /// visited child. The traversal may be recursive, if the visitor returns + /// \c CXChildVisit_Recurse. The traversal may also be ended prematurely, if + /// the visitor returns \c CXChildVisit_Break. + /// + /// \param parent the cursor whose child may be visited. All kinds of + /// cursors can be visited, including invalid cursors (which, by + /// definition, have no children). + /// + /// \param visitor the visitor function that will be invoked for each + /// child of \p parent. + /// + /// \param client_data pointer data supplied by the client, which will + /// be passed to the visitor each time it is invoked. + /// + /// \returns a non-zero value if the traversal was terminated + /// prematurely by the visitor returning \c CXChildVisit_Break. + int clang_visitChildren( + CXCursor parent, + CXCursorVisitor visitor, + CXClientData client_data, + ) { + return _clang_visitChildren(parent, visitor, client_data); + } + + late final _clang_visitChildrenPtr = + _lookup>( + 'clang_visitChildren', + ); + late final _clang_visitChildren = _clang_visitChildrenPtr + .asFunction(); -/// Identifies an array of ranges. -final class CXSourceRangeList extends ffi.Struct { - /// The number of ranges in the \c ranges array. - @ffi.UnsignedInt() - external int count; + late final addresses = _SymbolAddresses(this); +} - /// An array of \c CXSourceRanges. - external ffi.Pointer ranges; +class _SymbolAddresses { + final LibClang _library; + _SymbolAddresses(this._library); + ffi.Pointer> + get clang_CXCursorSet_contains => _library._clang_CXCursorSet_containsPtr; + ffi.Pointer> + get clang_CXCursorSet_insert => _library._clang_CXCursorSet_insertPtr; + ffi.Pointer> + get clang_CXIndex_getGlobalOptions => + _library._clang_CXIndex_getGlobalOptionsPtr; + ffi.Pointer> + get clang_CXIndex_setGlobalOptions => + _library._clang_CXIndex_setGlobalOptionsPtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_CXIndex_setInvocationEmissionPathOption => + _library._clang_CXIndex_setInvocationEmissionPathOptionPtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_CXXConstructor_isConvertingConstructor => + _library._clang_CXXConstructor_isConvertingConstructorPtr; + ffi.Pointer> + get clang_CXXConstructor_isCopyConstructor => + _library._clang_CXXConstructor_isCopyConstructorPtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_CXXConstructor_isDefaultConstructor => + _library._clang_CXXConstructor_isDefaultConstructorPtr; + ffi.Pointer> + get clang_CXXConstructor_isMoveConstructor => + _library._clang_CXXConstructor_isMoveConstructorPtr; + ffi.Pointer> + get clang_CXXField_isMutable => _library._clang_CXXField_isMutablePtr; + ffi.Pointer> + get clang_CXXMethod_isConst => _library._clang_CXXMethod_isConstPtr; + ffi.Pointer> + get clang_CXXMethod_isDefaulted => _library._clang_CXXMethod_isDefaultedPtr; + ffi.Pointer> + get clang_CXXMethod_isPureVirtual => + _library._clang_CXXMethod_isPureVirtualPtr; + ffi.Pointer> + get clang_CXXMethod_isStatic => _library._clang_CXXMethod_isStaticPtr; + ffi.Pointer> + get clang_CXXMethod_isVirtual => _library._clang_CXXMethod_isVirtualPtr; + ffi.Pointer> + get clang_CXXRecord_isAbstract => _library._clang_CXXRecord_isAbstractPtr; + ffi.Pointer> + get clang_Cursor_Evaluate => _library._clang_Cursor_EvaluatePtr; + ffi.Pointer> + get clang_Cursor_getArgument => _library._clang_Cursor_getArgumentPtr; + ffi.Pointer> + get clang_Cursor_getBriefCommentText => + _library._clang_Cursor_getBriefCommentTextPtr; + ffi.Pointer> + get clang_Cursor_getCXXManglings => _library._clang_Cursor_getCXXManglingsPtr; + ffi.Pointer> + get clang_Cursor_getCommentRange => _library._clang_Cursor_getCommentRangePtr; + ffi.Pointer> + get clang_Cursor_getMangling => _library._clang_Cursor_getManglingPtr; + ffi.Pointer> + get clang_Cursor_getModule => _library._clang_Cursor_getModulePtr; + ffi.Pointer> + get clang_Cursor_getNumArguments => _library._clang_Cursor_getNumArgumentsPtr; + ffi.Pointer> + get clang_Cursor_getNumTemplateArguments => + _library._clang_Cursor_getNumTemplateArgumentsPtr; + ffi.Pointer> + get clang_Cursor_getObjCDeclQualifiers => + _library._clang_Cursor_getObjCDeclQualifiersPtr; + ffi.Pointer> + get clang_Cursor_getObjCManglings => + _library._clang_Cursor_getObjCManglingsPtr; + ffi.Pointer> + get clang_Cursor_getObjCPropertyAttributes => + _library._clang_Cursor_getObjCPropertyAttributesPtr; + ffi.Pointer> + get clang_Cursor_getObjCPropertyGetterName => + _library._clang_Cursor_getObjCPropertyGetterNamePtr; + ffi.Pointer> + get clang_Cursor_getObjCPropertySetterName => + _library._clang_Cursor_getObjCPropertySetterNamePtr; + ffi.Pointer> + get clang_Cursor_getObjCSelectorIndex => + _library._clang_Cursor_getObjCSelectorIndexPtr; + ffi.Pointer> + get clang_Cursor_getOffsetOfField => + _library._clang_Cursor_getOffsetOfFieldPtr; + ffi.Pointer> + get clang_Cursor_getRawCommentText => + _library._clang_Cursor_getRawCommentTextPtr; + ffi.Pointer> + get clang_Cursor_getReceiverType => _library._clang_Cursor_getReceiverTypePtr; + ffi.Pointer> + get clang_Cursor_getSpellingNameRange => + _library._clang_Cursor_getSpellingNameRangePtr; + ffi.Pointer> + get clang_Cursor_getStorageClass => _library._clang_Cursor_getStorageClassPtr; + ffi.Pointer> + get clang_Cursor_getTemplateArgumentKind => + _library._clang_Cursor_getTemplateArgumentKindPtr; + ffi.Pointer> + get clang_Cursor_getTemplateArgumentType => + _library._clang_Cursor_getTemplateArgumentTypePtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_Cursor_getTemplateArgumentUnsignedValue => + _library._clang_Cursor_getTemplateArgumentUnsignedValuePtr; + ffi.Pointer> + get clang_Cursor_getTemplateArgumentValue => + _library._clang_Cursor_getTemplateArgumentValuePtr; + ffi.Pointer> + get clang_Cursor_getTranslationUnit => + _library._clang_Cursor_getTranslationUnitPtr; + ffi.Pointer> + get clang_Cursor_hasAttrs => _library._clang_Cursor_hasAttrsPtr; + ffi.Pointer> + get clang_Cursor_isAnonymous => _library._clang_Cursor_isAnonymousPtr; + ffi.Pointer> + get clang_Cursor_isAnonymousRecordDecl => + _library._clang_Cursor_isAnonymousRecordDeclPtr; + ffi.Pointer> + get clang_Cursor_isBitField => _library._clang_Cursor_isBitFieldPtr; + ffi.Pointer> + get clang_Cursor_isDynamicCall => _library._clang_Cursor_isDynamicCallPtr; + ffi.Pointer> + get clang_Cursor_isExternalSymbol => + _library._clang_Cursor_isExternalSymbolPtr; + ffi.Pointer> + get clang_Cursor_isFunctionInlined => + _library._clang_Cursor_isFunctionInlinedPtr; + ffi.Pointer> + get clang_Cursor_isInlineNamespace => + _library._clang_Cursor_isInlineNamespacePtr; + ffi.Pointer> + get clang_Cursor_isMacroBuiltin => _library._clang_Cursor_isMacroBuiltinPtr; + ffi.Pointer> + get clang_Cursor_isMacroFunctionLike => + _library._clang_Cursor_isMacroFunctionLikePtr; + ffi.Pointer> + get clang_Cursor_isNull => _library._clang_Cursor_isNullPtr; + ffi.Pointer> + get clang_Cursor_isObjCOptional => _library._clang_Cursor_isObjCOptionalPtr; + ffi.Pointer> + get clang_Cursor_isVariadic => _library._clang_Cursor_isVariadicPtr; + ffi.Pointer> + get clang_EnumDecl_isScoped => _library._clang_EnumDecl_isScopedPtr; + ffi.Pointer> + get clang_EvalResult_dispose => _library._clang_EvalResult_disposePtr; + ffi.Pointer> + get clang_EvalResult_getAsDouble => _library._clang_EvalResult_getAsDoublePtr; + ffi.Pointer> + get clang_EvalResult_getAsInt => _library._clang_EvalResult_getAsIntPtr; + ffi.Pointer> + get clang_EvalResult_getAsLongLong => + _library._clang_EvalResult_getAsLongLongPtr; + ffi.Pointer> + get clang_EvalResult_getAsStr => _library._clang_EvalResult_getAsStrPtr; + ffi.Pointer> + get clang_EvalResult_getAsUnsigned => + _library._clang_EvalResult_getAsUnsignedPtr; + ffi.Pointer> + get clang_EvalResult_getKind => _library._clang_EvalResult_getKindPtr; + ffi.Pointer> + get clang_EvalResult_isUnsignedInt => + _library._clang_EvalResult_isUnsignedIntPtr; + ffi.Pointer> + get clang_File_isEqual => _library._clang_File_isEqualPtr; + ffi.Pointer> + get clang_File_tryGetRealPathName => + _library._clang_File_tryGetRealPathNamePtr; + ffi.Pointer> + get clang_IndexAction_create => _library._clang_IndexAction_createPtr; + ffi.Pointer> + get clang_IndexAction_dispose => _library._clang_IndexAction_disposePtr; + ffi.Pointer> + get clang_Location_isFromMainFile => + _library._clang_Location_isFromMainFilePtr; + ffi.Pointer> + get clang_Location_isInSystemHeader => + _library._clang_Location_isInSystemHeaderPtr; + ffi.Pointer> + get clang_Module_getASTFile => _library._clang_Module_getASTFilePtr; + ffi.Pointer> + get clang_Module_getFullName => _library._clang_Module_getFullNamePtr; + ffi.Pointer> + get clang_Module_getName => _library._clang_Module_getNamePtr; + ffi.Pointer> + get clang_Module_getNumTopLevelHeaders => + _library._clang_Module_getNumTopLevelHeadersPtr; + ffi.Pointer> + get clang_Module_getParent => _library._clang_Module_getParentPtr; + ffi.Pointer> + get clang_Module_getTopLevelHeader => + _library._clang_Module_getTopLevelHeaderPtr; + ffi.Pointer> + get clang_Module_isSystem => _library._clang_Module_isSystemPtr; + ffi.Pointer> + get clang_PrintingPolicy_dispose => _library._clang_PrintingPolicy_disposePtr; + ffi.Pointer> + get clang_PrintingPolicy_getProperty => + _library._clang_PrintingPolicy_getPropertyPtr; + ffi.Pointer> + get clang_PrintingPolicy_setProperty => + _library._clang_PrintingPolicy_setPropertyPtr; + ffi.Pointer> + get clang_Range_isNull => _library._clang_Range_isNullPtr; + ffi.Pointer> + get clang_TargetInfo_dispose => _library._clang_TargetInfo_disposePtr; + ffi.Pointer> + get clang_TargetInfo_getPointerWidth => + _library._clang_TargetInfo_getPointerWidthPtr; + ffi.Pointer> + get clang_TargetInfo_getTriple => _library._clang_TargetInfo_getTriplePtr; + ffi.Pointer> + get clang_Type_getAlignOf => _library._clang_Type_getAlignOfPtr; + ffi.Pointer> + get clang_Type_getCXXRefQualifier => + _library._clang_Type_getCXXRefQualifierPtr; + ffi.Pointer> + get clang_Type_getClassType => _library._clang_Type_getClassTypePtr; + ffi.Pointer> + get clang_Type_getModifiedType => _library._clang_Type_getModifiedTypePtr; + ffi.Pointer> + get clang_Type_getNamedType => _library._clang_Type_getNamedTypePtr; + ffi.Pointer> + get clang_Type_getNullability => _library._clang_Type_getNullabilityPtr; + ffi.Pointer> + get clang_Type_getNumObjCProtocolRefs => + _library._clang_Type_getNumObjCProtocolRefsPtr; + ffi.Pointer> + get clang_Type_getNumObjCTypeArgs => + _library._clang_Type_getNumObjCTypeArgsPtr; + ffi.Pointer> + get clang_Type_getNumTemplateArguments => + _library._clang_Type_getNumTemplateArgumentsPtr; + ffi.Pointer> + get clang_Type_getObjCEncoding => _library._clang_Type_getObjCEncodingPtr; + ffi.Pointer> + get clang_Type_getObjCObjectBaseType => + _library._clang_Type_getObjCObjectBaseTypePtr; + ffi.Pointer> + get clang_Type_getObjCProtocolDecl => + _library._clang_Type_getObjCProtocolDeclPtr; + ffi.Pointer> + get clang_Type_getObjCTypeArg => _library._clang_Type_getObjCTypeArgPtr; + ffi.Pointer> + get clang_Type_getOffsetOf => _library._clang_Type_getOffsetOfPtr; + ffi.Pointer> + get clang_Type_getSizeOf => _library._clang_Type_getSizeOfPtr; + ffi.Pointer> + get clang_Type_getTemplateArgumentAsType => + _library._clang_Type_getTemplateArgumentAsTypePtr; + ffi.Pointer> + get clang_Type_isTransparentTagTypedef => + _library._clang_Type_isTransparentTagTypedefPtr; + ffi.Pointer> + get clang_Type_visitFields => _library._clang_Type_visitFieldsPtr; + ffi.Pointer> + get clang_annotateTokens => _library._clang_annotateTokensPtr; + ffi.Pointer> + get clang_codeCompleteAt => _library._clang_codeCompleteAtPtr; + ffi.Pointer> + get clang_codeCompleteGetContainerKind => + _library._clang_codeCompleteGetContainerKindPtr; + ffi.Pointer> + get clang_codeCompleteGetContainerUSR => + _library._clang_codeCompleteGetContainerUSRPtr; + ffi.Pointer> + get clang_codeCompleteGetContexts => + _library._clang_codeCompleteGetContextsPtr; + ffi.Pointer> + get clang_codeCompleteGetDiagnostic => + _library._clang_codeCompleteGetDiagnosticPtr; + ffi.Pointer> + get clang_codeCompleteGetNumDiagnostics => + _library._clang_codeCompleteGetNumDiagnosticsPtr; + ffi.Pointer> + get clang_codeCompleteGetObjCSelector => + _library._clang_codeCompleteGetObjCSelectorPtr; + ffi.Pointer> + get clang_constructUSR_ObjCCategory => + _library._clang_constructUSR_ObjCCategoryPtr; + ffi.Pointer> + get clang_constructUSR_ObjCClass => _library._clang_constructUSR_ObjCClassPtr; + ffi.Pointer> + get clang_constructUSR_ObjCIvar => _library._clang_constructUSR_ObjCIvarPtr; + ffi.Pointer> + get clang_constructUSR_ObjCMethod => + _library._clang_constructUSR_ObjCMethodPtr; + ffi.Pointer> + get clang_constructUSR_ObjCProperty => + _library._clang_constructUSR_ObjCPropertyPtr; + ffi.Pointer> + get clang_constructUSR_ObjCProtocol => + _library._clang_constructUSR_ObjCProtocolPtr; + ffi.Pointer> + get clang_createCXCursorSet => _library._clang_createCXCursorSetPtr; + ffi.Pointer> + get clang_createIndex => _library._clang_createIndexPtr; + ffi.Pointer> + get clang_createTranslationUnit => _library._clang_createTranslationUnitPtr; + ffi.Pointer> + get clang_createTranslationUnit2 => _library._clang_createTranslationUnit2Ptr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_createTranslationUnitFromSourceFile => + _library._clang_createTranslationUnitFromSourceFilePtr; + ffi.Pointer> + get clang_defaultCodeCompleteOptions => + _library._clang_defaultCodeCompleteOptionsPtr; + ffi.Pointer> + get clang_defaultDiagnosticDisplayOptions => + _library._clang_defaultDiagnosticDisplayOptionsPtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_defaultEditingTranslationUnitOptions => + _library._clang_defaultEditingTranslationUnitOptionsPtr; + ffi.Pointer> + get clang_defaultReparseOptions => _library._clang_defaultReparseOptionsPtr; + ffi.Pointer> + get clang_defaultSaveOptions => _library._clang_defaultSaveOptionsPtr; + ffi.Pointer> + get clang_disposeCXCursorSet => _library._clang_disposeCXCursorSetPtr; + ffi.Pointer> + get clang_disposeCXPlatformAvailability => + _library._clang_disposeCXPlatformAvailabilityPtr; + ffi.Pointer> + get clang_disposeCXTUResourceUsage => + _library._clang_disposeCXTUResourceUsagePtr; + ffi.Pointer> + get clang_disposeCodeCompleteResults => + _library._clang_disposeCodeCompleteResultsPtr; + ffi.Pointer> + get clang_disposeDiagnostic => _library._clang_disposeDiagnosticPtr; + ffi.Pointer> + get clang_disposeDiagnosticSet => _library._clang_disposeDiagnosticSetPtr; + ffi.Pointer> + get clang_disposeIndex => _library._clang_disposeIndexPtr; + ffi.Pointer> + get clang_disposeOverriddenCursors => + _library._clang_disposeOverriddenCursorsPtr; + ffi.Pointer> + get clang_disposeSourceRangeList => _library._clang_disposeSourceRangeListPtr; + ffi.Pointer> + get clang_disposeString => _library._clang_disposeStringPtr; + ffi.Pointer> + get clang_disposeStringSet => _library._clang_disposeStringSetPtr; + ffi.Pointer> + get clang_disposeTokens => _library._clang_disposeTokensPtr; + ffi.Pointer> + get clang_disposeTranslationUnit => _library._clang_disposeTranslationUnitPtr; + ffi.Pointer> + get clang_enableStackTraces => _library._clang_enableStackTracesPtr; + ffi.Pointer> + get clang_equalCursors => _library._clang_equalCursorsPtr; + ffi.Pointer> + get clang_equalLocations => _library._clang_equalLocationsPtr; + ffi.Pointer> + get clang_equalRanges => _library._clang_equalRangesPtr; + ffi.Pointer> + get clang_equalTypes => _library._clang_equalTypesPtr; + ffi.Pointer> + get clang_executeOnThread => _library._clang_executeOnThreadPtr; + ffi.Pointer> + get clang_findIncludesInFile => _library._clang_findIncludesInFilePtr; + ffi.Pointer> + get clang_findReferencesInFile => _library._clang_findReferencesInFilePtr; + ffi.Pointer> + get clang_formatDiagnostic => _library._clang_formatDiagnosticPtr; + ffi.Pointer> + get clang_getAddressSpace => _library._clang_getAddressSpacePtr; + ffi.Pointer> + get clang_getAllSkippedRanges => _library._clang_getAllSkippedRangesPtr; + ffi.Pointer> + get clang_getArgType => _library._clang_getArgTypePtr; + ffi.Pointer> + get clang_getArrayElementType => _library._clang_getArrayElementTypePtr; + ffi.Pointer> + get clang_getArraySize => _library._clang_getArraySizePtr; + ffi.Pointer> + get clang_getCString => _library._clang_getCStringPtr; + ffi.Pointer> + get clang_getCXTUResourceUsage => _library._clang_getCXTUResourceUsagePtr; + ffi.Pointer> + get clang_getCXXAccessSpecifier => _library._clang_getCXXAccessSpecifierPtr; + ffi.Pointer> + get clang_getCanonicalCursor => _library._clang_getCanonicalCursorPtr; + ffi.Pointer> + get clang_getCanonicalType => _library._clang_getCanonicalTypePtr; + ffi.Pointer> + get clang_getChildDiagnostics => _library._clang_getChildDiagnosticsPtr; + ffi.Pointer> + get clang_getClangVersion => _library._clang_getClangVersionPtr; + ffi.Pointer> + get clang_getCompletionAnnotation => + _library._clang_getCompletionAnnotationPtr; + ffi.Pointer> + get clang_getCompletionAvailability => + _library._clang_getCompletionAvailabilityPtr; + ffi.Pointer> + get clang_getCompletionBriefComment => + _library._clang_getCompletionBriefCommentPtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_getCompletionChunkCompletionString => + _library._clang_getCompletionChunkCompletionStringPtr; + ffi.Pointer> + get clang_getCompletionChunkKind => _library._clang_getCompletionChunkKindPtr; + ffi.Pointer> + get clang_getCompletionChunkText => _library._clang_getCompletionChunkTextPtr; + ffi.Pointer> + get clang_getCompletionFixIt => _library._clang_getCompletionFixItPtr; + ffi.Pointer> + get clang_getCompletionNumAnnotations => + _library._clang_getCompletionNumAnnotationsPtr; + ffi.Pointer> + get clang_getCompletionNumFixIts => _library._clang_getCompletionNumFixItsPtr; + ffi.Pointer> + get clang_getCompletionParent => _library._clang_getCompletionParentPtr; + ffi.Pointer> + get clang_getCompletionPriority => _library._clang_getCompletionPriorityPtr; + ffi.Pointer> get clang_getCursor => + _library._clang_getCursorPtr; + ffi.Pointer> + get clang_getCursorAvailability => _library._clang_getCursorAvailabilityPtr; + ffi.Pointer> + get clang_getCursorCompletionString => + _library._clang_getCursorCompletionStringPtr; + ffi.Pointer> + get clang_getCursorDefinition => _library._clang_getCursorDefinitionPtr; + ffi.Pointer> + get clang_getCursorDisplayName => _library._clang_getCursorDisplayNamePtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_getCursorExceptionSpecificationType => + _library._clang_getCursorExceptionSpecificationTypePtr; + ffi.Pointer> + get clang_getCursorExtent => _library._clang_getCursorExtentPtr; + ffi.Pointer> + get clang_getCursorKind => _library._clang_getCursorKindPtr; + ffi.Pointer> + get clang_getCursorKindSpelling => _library._clang_getCursorKindSpellingPtr; + ffi.Pointer> + get clang_getCursorLanguage => _library._clang_getCursorLanguagePtr; + ffi.Pointer> + get clang_getCursorLexicalParent => _library._clang_getCursorLexicalParentPtr; + ffi.Pointer> + get clang_getCursorLinkage => _library._clang_getCursorLinkagePtr; + ffi.Pointer> + get clang_getCursorLocation => _library._clang_getCursorLocationPtr; + ffi.Pointer> + get clang_getCursorPlatformAvailability => + _library._clang_getCursorPlatformAvailabilityPtr; + ffi.Pointer> + get clang_getCursorPrettyPrinted => _library._clang_getCursorPrettyPrintedPtr; + ffi.Pointer> + get clang_getCursorPrintingPolicy => + _library._clang_getCursorPrintingPolicyPtr; + ffi.Pointer> + get clang_getCursorReferenceNameRange => + _library._clang_getCursorReferenceNameRangePtr; + ffi.Pointer> + get clang_getCursorReferenced => _library._clang_getCursorReferencedPtr; + ffi.Pointer> + get clang_getCursorResultType => _library._clang_getCursorResultTypePtr; + ffi.Pointer> + get clang_getCursorSemanticParent => + _library._clang_getCursorSemanticParentPtr; + ffi.Pointer> + get clang_getCursorSpelling => _library._clang_getCursorSpellingPtr; + ffi.Pointer> + get clang_getCursorTLSKind => _library._clang_getCursorTLSKindPtr; + ffi.Pointer> + get clang_getCursorType => _library._clang_getCursorTypePtr; + ffi.Pointer> + get clang_getCursorUSR => _library._clang_getCursorUSRPtr; + ffi.Pointer> + get clang_getCursorVisibility => _library._clang_getCursorVisibilityPtr; + ffi.Pointer> + get clang_getDeclObjCTypeEncoding => + _library._clang_getDeclObjCTypeEncodingPtr; + ffi.Pointer> + get clang_getDefinitionSpellingAndExtent => + _library._clang_getDefinitionSpellingAndExtentPtr; + ffi.Pointer> + get clang_getDiagnostic => _library._clang_getDiagnosticPtr; + ffi.Pointer> + get clang_getDiagnosticCategory => _library._clang_getDiagnosticCategoryPtr; + ffi.Pointer> + get clang_getDiagnosticCategoryName => + _library._clang_getDiagnosticCategoryNamePtr; + ffi.Pointer> + get clang_getDiagnosticCategoryText => + _library._clang_getDiagnosticCategoryTextPtr; + ffi.Pointer> + get clang_getDiagnosticFixIt => _library._clang_getDiagnosticFixItPtr; + ffi.Pointer> + get clang_getDiagnosticInSet => _library._clang_getDiagnosticInSetPtr; + ffi.Pointer> + get clang_getDiagnosticLocation => _library._clang_getDiagnosticLocationPtr; + ffi.Pointer> + get clang_getDiagnosticNumFixIts => _library._clang_getDiagnosticNumFixItsPtr; + ffi.Pointer> + get clang_getDiagnosticNumRanges => _library._clang_getDiagnosticNumRangesPtr; + ffi.Pointer> + get clang_getDiagnosticOption => _library._clang_getDiagnosticOptionPtr; + ffi.Pointer> + get clang_getDiagnosticRange => _library._clang_getDiagnosticRangePtr; + ffi.Pointer> + get clang_getDiagnosticSetFromTU => _library._clang_getDiagnosticSetFromTUPtr; + ffi.Pointer> + get clang_getDiagnosticSeverity => _library._clang_getDiagnosticSeverityPtr; + ffi.Pointer> + get clang_getDiagnosticSpelling => _library._clang_getDiagnosticSpellingPtr; + ffi.Pointer> + get clang_getElementType => _library._clang_getElementTypePtr; + ffi.Pointer> + get clang_getEnumConstantDeclUnsignedValue => + _library._clang_getEnumConstantDeclUnsignedValuePtr; + ffi.Pointer> + get clang_getEnumConstantDeclValue => + _library._clang_getEnumConstantDeclValuePtr; + ffi.Pointer> + get clang_getEnumDeclIntegerType => _library._clang_getEnumDeclIntegerTypePtr; + ffi.Pointer> + get clang_getExceptionSpecificationType => + _library._clang_getExceptionSpecificationTypePtr; + ffi.Pointer> + get clang_getExpansionLocation => _library._clang_getExpansionLocationPtr; + ffi.Pointer> + get clang_getFieldDeclBitWidth => _library._clang_getFieldDeclBitWidthPtr; + ffi.Pointer> get clang_getFile => + _library._clang_getFilePtr; + ffi.Pointer> + get clang_getFileContents => _library._clang_getFileContentsPtr; + ffi.Pointer> + get clang_getFileLocation => _library._clang_getFileLocationPtr; + ffi.Pointer> + get clang_getFileName => _library._clang_getFileNamePtr; + ffi.Pointer> + get clang_getFileTime => _library._clang_getFileTimePtr; + ffi.Pointer> + get clang_getFileUniqueID => _library._clang_getFileUniqueIDPtr; + ffi.Pointer> + get clang_getFunctionTypeCallingConv => + _library._clang_getFunctionTypeCallingConvPtr; + ffi.Pointer> + get clang_getIBOutletCollectionType => + _library._clang_getIBOutletCollectionTypePtr; + ffi.Pointer> + get clang_getIncludedFile => _library._clang_getIncludedFilePtr; + ffi.Pointer> + get clang_getInclusions => _library._clang_getInclusionsPtr; + ffi.Pointer> + get clang_getInstantiationLocation => + _library._clang_getInstantiationLocationPtr; + ffi.Pointer> + get clang_getLocation => _library._clang_getLocationPtr; + ffi.Pointer> + get clang_getLocationForOffset => _library._clang_getLocationForOffsetPtr; + ffi.Pointer> + get clang_getModuleForFile => _library._clang_getModuleForFilePtr; + ffi.Pointer> + get clang_getNullCursor => _library._clang_getNullCursorPtr; + ffi.Pointer> + get clang_getNullLocation => _library._clang_getNullLocationPtr; + ffi.Pointer> + get clang_getNullRange => _library._clang_getNullRangePtr; + ffi.Pointer> + get clang_getNumArgTypes => _library._clang_getNumArgTypesPtr; + ffi.Pointer> + get clang_getNumCompletionChunks => _library._clang_getNumCompletionChunksPtr; + ffi.Pointer> + get clang_getNumDiagnostics => _library._clang_getNumDiagnosticsPtr; + ffi.Pointer> + get clang_getNumDiagnosticsInSet => _library._clang_getNumDiagnosticsInSetPtr; + ffi.Pointer> + get clang_getNumElements => _library._clang_getNumElementsPtr; + ffi.Pointer> + get clang_getNumOverloadedDecls => _library._clang_getNumOverloadedDeclsPtr; + ffi.Pointer> + get clang_getOverloadedDecl => _library._clang_getOverloadedDeclPtr; + ffi.Pointer> + get clang_getOverriddenCursors => _library._clang_getOverriddenCursorsPtr; + ffi.Pointer> + get clang_getPointeeType => _library._clang_getPointeeTypePtr; + ffi.Pointer> + get clang_getPresumedLocation => _library._clang_getPresumedLocationPtr; + ffi.Pointer> get clang_getRange => + _library._clang_getRangePtr; + ffi.Pointer> + get clang_getRangeEnd => _library._clang_getRangeEndPtr; + ffi.Pointer> + get clang_getRangeStart => _library._clang_getRangeStartPtr; + ffi.Pointer> + get clang_getRemappings => _library._clang_getRemappingsPtr; + ffi.Pointer> + get clang_getRemappingsFromFileList => + _library._clang_getRemappingsFromFileListPtr; + ffi.Pointer> + get clang_getResultType => _library._clang_getResultTypePtr; + ffi.Pointer> + get clang_getSkippedRanges => _library._clang_getSkippedRangesPtr; + ffi.Pointer> + get clang_getSpecializedCursorTemplate => + _library._clang_getSpecializedCursorTemplatePtr; + ffi.Pointer> + get clang_getSpellingLocation => _library._clang_getSpellingLocationPtr; + ffi.Pointer> + get clang_getTUResourceUsageName => _library._clang_getTUResourceUsageNamePtr; + ffi.Pointer> + get clang_getTemplateCursorKind => _library._clang_getTemplateCursorKindPtr; + ffi.Pointer> get clang_getToken => + _library._clang_getTokenPtr; + ffi.Pointer> + get clang_getTokenExtent => _library._clang_getTokenExtentPtr; + ffi.Pointer> + get clang_getTokenKind => _library._clang_getTokenKindPtr; + ffi.Pointer> + get clang_getTokenLocation => _library._clang_getTokenLocationPtr; + ffi.Pointer> + get clang_getTokenSpelling => _library._clang_getTokenSpellingPtr; + ffi.Pointer> + get clang_getTranslationUnitCursor => + _library._clang_getTranslationUnitCursorPtr; + ffi.Pointer> + get clang_getTranslationUnitSpelling => + _library._clang_getTranslationUnitSpellingPtr; + ffi.Pointer> + get clang_getTranslationUnitTargetInfo => + _library._clang_getTranslationUnitTargetInfoPtr; + ffi.Pointer> + get clang_getTypeDeclaration => _library._clang_getTypeDeclarationPtr; + ffi.Pointer> + get clang_getTypeKindSpelling => _library._clang_getTypeKindSpellingPtr; + ffi.Pointer> + get clang_getTypeSpelling => _library._clang_getTypeSpellingPtr; + ffi.Pointer> + get clang_getTypedefDeclUnderlyingType => + _library._clang_getTypedefDeclUnderlyingTypePtr; + ffi.Pointer> + get clang_getTypedefName => _library._clang_getTypedefNamePtr; + ffi.Pointer> + get clang_hashCursor => _library._clang_hashCursorPtr; + ffi.Pointer> + get clang_indexLoc_getCXSourceLocation => + _library._clang_indexLoc_getCXSourceLocationPtr; + ffi.Pointer> + get clang_indexLoc_getFileLocation => + _library._clang_indexLoc_getFileLocationPtr; + ffi.Pointer> + get clang_indexSourceFile => _library._clang_indexSourceFilePtr; + ffi.Pointer> + get clang_indexSourceFileFullArgv => + _library._clang_indexSourceFileFullArgvPtr; + ffi.Pointer> + get clang_indexTranslationUnit => _library._clang_indexTranslationUnitPtr; + ffi.Pointer> + get clang_index_getCXXClassDeclInfo => + _library._clang_index_getCXXClassDeclInfoPtr; + ffi.Pointer> + get clang_index_getClientContainer => + _library._clang_index_getClientContainerPtr; + ffi.Pointer> + get clang_index_getClientEntity => _library._clang_index_getClientEntityPtr; + ffi.Pointer< + ffi.NativeFunction + > + get clang_index_getIBOutletCollectionAttrInfo => + _library._clang_index_getIBOutletCollectionAttrInfoPtr; + ffi.Pointer> + get clang_index_getObjCCategoryDeclInfo => + _library._clang_index_getObjCCategoryDeclInfoPtr; + ffi.Pointer> + get clang_index_getObjCContainerDeclInfo => + _library._clang_index_getObjCContainerDeclInfoPtr; + ffi.Pointer> + get clang_index_getObjCInterfaceDeclInfo => + _library._clang_index_getObjCInterfaceDeclInfoPtr; + ffi.Pointer> + get clang_index_getObjCPropertyDeclInfo => + _library._clang_index_getObjCPropertyDeclInfoPtr; + ffi.Pointer> + get clang_index_getObjCProtocolRefListInfo => + _library._clang_index_getObjCProtocolRefListInfoPtr; + ffi.Pointer> + get clang_index_isEntityObjCContainerKind => + _library._clang_index_isEntityObjCContainerKindPtr; + ffi.Pointer> + get clang_index_setClientContainer => + _library._clang_index_setClientContainerPtr; + ffi.Pointer> + get clang_index_setClientEntity => _library._clang_index_setClientEntityPtr; + ffi.Pointer> + get clang_isAttribute => _library._clang_isAttributePtr; + ffi.Pointer> + get clang_isConstQualifiedType => _library._clang_isConstQualifiedTypePtr; + ffi.Pointer> + get clang_isCursorDefinition => _library._clang_isCursorDefinitionPtr; + ffi.Pointer> + get clang_isDeclaration => _library._clang_isDeclarationPtr; + ffi.Pointer> + get clang_isExpression => _library._clang_isExpressionPtr; + ffi.Pointer> + get clang_isFileMultipleIncludeGuarded => + _library._clang_isFileMultipleIncludeGuardedPtr; + ffi.Pointer> + get clang_isFunctionTypeVariadic => _library._clang_isFunctionTypeVariadicPtr; + ffi.Pointer> get clang_isInvalid => + _library._clang_isInvalidPtr; + ffi.Pointer> + get clang_isInvalidDeclaration => _library._clang_isInvalidDeclarationPtr; + ffi.Pointer> get clang_isPODType => + _library._clang_isPODTypePtr; + ffi.Pointer> + get clang_isPreprocessing => _library._clang_isPreprocessingPtr; + ffi.Pointer> + get clang_isReference => _library._clang_isReferencePtr; + ffi.Pointer> + get clang_isRestrictQualifiedType => + _library._clang_isRestrictQualifiedTypePtr; + ffi.Pointer> + get clang_isStatement => _library._clang_isStatementPtr; + ffi.Pointer> + get clang_isTranslationUnit => _library._clang_isTranslationUnitPtr; + ffi.Pointer> + get clang_isUnexposed => _library._clang_isUnexposedPtr; + ffi.Pointer> + get clang_isVirtualBase => _library._clang_isVirtualBasePtr; + ffi.Pointer> + get clang_isVolatileQualifiedType => + _library._clang_isVolatileQualifiedTypePtr; + ffi.Pointer> + get clang_loadDiagnostics => _library._clang_loadDiagnosticsPtr; + ffi.Pointer> + get clang_parseTranslationUnit => _library._clang_parseTranslationUnitPtr; + ffi.Pointer> + get clang_parseTranslationUnit2 => _library._clang_parseTranslationUnit2Ptr; + ffi.Pointer> + get clang_parseTranslationUnit2FullArgv => + _library._clang_parseTranslationUnit2FullArgvPtr; + ffi.Pointer> + get clang_remap_dispose => _library._clang_remap_disposePtr; + ffi.Pointer> + get clang_remap_getFilenames => _library._clang_remap_getFilenamesPtr; + ffi.Pointer> + get clang_remap_getNumFiles => _library._clang_remap_getNumFilesPtr; + ffi.Pointer> + get clang_reparseTranslationUnit => _library._clang_reparseTranslationUnitPtr; + ffi.Pointer> + get clang_saveTranslationUnit => _library._clang_saveTranslationUnitPtr; + ffi.Pointer> + get clang_sortCodeCompletionResults => + _library._clang_sortCodeCompletionResultsPtr; + ffi.Pointer> + get clang_suspendTranslationUnit => _library._clang_suspendTranslationUnitPtr; + ffi.Pointer> + get clang_toggleCrashRecovery => _library._clang_toggleCrashRecoveryPtr; + ffi.Pointer> get clang_tokenize => + _library._clang_tokenizePtr; + ffi.Pointer> + get clang_visitChildren => _library._clang_visitChildrenPtr; } -typedef NativeClang_getSkippedRanges = - ffi.Pointer Function(CXTranslationUnit tu, CXFile file); -typedef DartClang_getSkippedRanges = - ffi.Pointer Function(CXTranslationUnit tu, CXFile file); -typedef NativeClang_getAllSkippedRanges = - ffi.Pointer Function(CXTranslationUnit tu); -typedef DartClang_getAllSkippedRanges = - ffi.Pointer Function(CXTranslationUnit tu); -typedef NativeClang_disposeSourceRangeList = - ffi.Void Function(ffi.Pointer ranges); -typedef DartClang_disposeSourceRangeList = - void Function(ffi.Pointer ranges); - -/// Describes the severity of a particular diagnostic. -enum CXDiagnosticSeverity { - /// A diagnostic that has been suppressed, e.g., by a command-line - /// option. - CXDiagnostic_Ignored(0), - - /// This diagnostic is a note that should be attached to the - /// previous (non-note) diagnostic. - CXDiagnostic_Note(1), - - /// This diagnostic indicates suspicious code that may not be - /// wrong. - CXDiagnostic_Warning(2), - - /// This diagnostic indicates that the code is ill-formed. - CXDiagnostic_Error(3), - - /// This diagnostic indicates that the code is ill-formed such - /// that future parser recovery is unlikely to produce useful - /// results. - CXDiagnostic_Fatal(4); - - final int value; - const CXDiagnosticSeverity(this.value); +const int CINDEX_VERSION = 59; - static CXDiagnosticSeverity fromValue(int value) => switch (value) { - 0 => CXDiagnostic_Ignored, - 1 => CXDiagnostic_Note, - 2 => CXDiagnostic_Warning, - 3 => CXDiagnostic_Error, - 4 => CXDiagnostic_Fatal, - _ => throw ArgumentError('Unknown value for CXDiagnosticSeverity: $value'), - }; -} +const int CINDEX_VERSION_MAJOR = 0; -/// A single diagnostic, containing the diagnostic's severity, -/// location, text, source ranges, and fix-it hints. -typedef CXDiagnostic = ffi.Pointer; +const int CINDEX_VERSION_MINOR = 59; -/// A group of CXDiagnostics. -typedef CXDiagnosticSet = ffi.Pointer; -typedef NativeClang_getNumDiagnosticsInSet = - ffi.UnsignedInt Function(CXDiagnosticSet Diags); -typedef DartClang_getNumDiagnosticsInSet = int Function(CXDiagnosticSet Diags); -typedef NativeClang_getDiagnosticInSet = - CXDiagnostic Function(CXDiagnosticSet Diags, ffi.UnsignedInt Index); -typedef DartClang_getDiagnosticInSet = - CXDiagnostic Function(CXDiagnosticSet Diags, int Index); +const String CINDEX_VERSION_STRING = '0.59'; -/// Describes the kind of error that occurred (if any) in a call to -/// \c clang_loadDiagnostics. -enum CXLoadDiag_Error { - /// Indicates that no error occurred. - CXLoadDiag_None(0), +/// Describes the availability of a particular entity, which indicates +/// whether the use of this entity will result in a warning or error due to +/// it being deprecated or unavailable. +enum CXAvailabilityKind { + /// The entity is available. + CXAvailability_Available(0), - /// Indicates that an unknown error occurred while attempting to - /// deserialize diagnostics. - CXLoadDiag_Unknown(1), + /// The entity is available, but has been deprecated (and its use is + /// not recommended). + CXAvailability_Deprecated(1), - /// Indicates that the file containing the serialized diagnostics - /// could not be opened. - CXLoadDiag_CannotLoad(2), + /// The entity is not available; any use of it will be an error. + CXAvailability_NotAvailable(2), - /// Indicates that the serialized diagnostics file is invalid or - /// corrupt. - CXLoadDiag_InvalidFile(3); + /// The entity is available, but not accessible; any use of it will be + /// an error. + CXAvailability_NotAccessible(3); final int value; - const CXLoadDiag_Error(this.value); + const CXAvailabilityKind(this.value); - static CXLoadDiag_Error fromValue(int value) => switch (value) { - 0 => CXLoadDiag_None, - 1 => CXLoadDiag_Unknown, - 2 => CXLoadDiag_CannotLoad, - 3 => CXLoadDiag_InvalidFile, - _ => throw ArgumentError('Unknown value for CXLoadDiag_Error: $value'), + static CXAvailabilityKind fromValue(int value) => switch (value) { + 0 => CXAvailability_Available, + 1 => CXAvailability_Deprecated, + 2 => CXAvailability_NotAvailable, + 3 => CXAvailability_NotAccessible, + _ => throw ArgumentError('Unknown value for CXAvailabilityKind: $value'), }; } -typedef NativeClang_loadDiagnostics = - CXDiagnosticSet Function( - ffi.Pointer file, - ffi.Pointer error, - ffi.Pointer errorString, - ); -typedef DartClang_loadDiagnostics = - CXDiagnosticSet Function( - ffi.Pointer file, - ffi.Pointer error, - ffi.Pointer errorString, - ); -typedef NativeClang_disposeDiagnosticSet = - ffi.Void Function(CXDiagnosticSet Diags); -typedef DartClang_disposeDiagnosticSet = void Function(CXDiagnosticSet Diags); -typedef NativeClang_getChildDiagnostics = - CXDiagnosticSet Function(CXDiagnostic D); -typedef DartClang_getChildDiagnostics = - CXDiagnosticSet Function(CXDiagnostic D); -typedef NativeClang_getNumDiagnostics = - ffi.UnsignedInt Function(CXTranslationUnit Unit); -typedef DartClang_getNumDiagnostics = int Function(CXTranslationUnit Unit); -typedef NativeClang_getDiagnostic = - CXDiagnostic Function(CXTranslationUnit Unit, ffi.UnsignedInt Index); -typedef DartClang_getDiagnostic = - CXDiagnostic Function(CXTranslationUnit Unit, int Index); -typedef NativeClang_getDiagnosticSetFromTU = - CXDiagnosticSet Function(CXTranslationUnit Unit); -typedef DartClang_getDiagnosticSetFromTU = - CXDiagnosticSet Function(CXTranslationUnit Unit); -typedef NativeClang_disposeDiagnostic = - ffi.Void Function(CXDiagnostic Diagnostic); -typedef DartClang_disposeDiagnostic = void Function(CXDiagnostic Diagnostic); -typedef NativeClang_formatDiagnostic = - CXString Function(CXDiagnostic Diagnostic, ffi.UnsignedInt Options); -typedef DartClang_formatDiagnostic = - CXString Function(CXDiagnostic Diagnostic, int Options); -typedef NativeClang_defaultDiagnosticDisplayOptions = - ffi.UnsignedInt Function(); -typedef DartClang_defaultDiagnosticDisplayOptions = int Function(); -typedef NativeClang_getDiagnosticSeverity = - ffi.UnsignedInt Function(CXDiagnostic); -typedef DartClang_getDiagnosticSeverity = int Function(CXDiagnostic); -typedef NativeClang_getDiagnosticLocation = - CXSourceLocation Function(CXDiagnostic); -typedef DartClang_getDiagnosticLocation = - CXSourceLocation Function(CXDiagnostic); -typedef NativeClang_getDiagnosticSpelling = CXString Function(CXDiagnostic); -typedef DartClang_getDiagnosticSpelling = CXString Function(CXDiagnostic); -typedef NativeClang_getDiagnosticOption = - CXString Function(CXDiagnostic Diag, ffi.Pointer Disable); -typedef DartClang_getDiagnosticOption = - CXString Function(CXDiagnostic Diag, ffi.Pointer Disable); -typedef NativeClang_getDiagnosticCategory = - ffi.UnsignedInt Function(CXDiagnostic); -typedef DartClang_getDiagnosticCategory = int Function(CXDiagnostic); -typedef NativeClang_getDiagnosticCategoryName = - CXString Function(ffi.UnsignedInt Category); -typedef DartClang_getDiagnosticCategoryName = CXString Function(int Category); -typedef NativeClang_getDiagnosticCategoryText = CXString Function(CXDiagnostic); -typedef DartClang_getDiagnosticCategoryText = CXString Function(CXDiagnostic); -typedef NativeClang_getDiagnosticNumRanges = - ffi.UnsignedInt Function(CXDiagnostic); -typedef DartClang_getDiagnosticNumRanges = int Function(CXDiagnostic); -typedef NativeClang_getDiagnosticRange = - CXSourceRange Function(CXDiagnostic Diagnostic, ffi.UnsignedInt Range); -typedef DartClang_getDiagnosticRange = - CXSourceRange Function(CXDiagnostic Diagnostic, int Range); -typedef NativeClang_getDiagnosticNumFixIts = - ffi.UnsignedInt Function(CXDiagnostic Diagnostic); -typedef DartClang_getDiagnosticNumFixIts = - int Function(CXDiagnostic Diagnostic); -typedef NativeClang_getDiagnosticFixIt = - CXString Function( - CXDiagnostic Diagnostic, - ffi.UnsignedInt FixIt, - ffi.Pointer ReplacementRange, - ); -typedef DartClang_getDiagnosticFixIt = - CXString Function( - CXDiagnostic Diagnostic, - int FixIt, - ffi.Pointer ReplacementRange, - ); -typedef NativeClang_getTranslationUnitSpelling = - CXString Function(CXTranslationUnit CTUnit); -typedef DartClang_getTranslationUnitSpelling = - CXString Function(CXTranslationUnit CTUnit); -typedef NativeClang_createTranslationUnitFromSourceFile = - CXTranslationUnit Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Int num_clang_command_line_args, - ffi.Pointer> clang_command_line_args, - ffi.UnsignedInt num_unsaved_files, - ffi.Pointer unsaved_files, - ); -typedef DartClang_createTranslationUnitFromSourceFile = - CXTranslationUnit Function( - CXIndex CIdx, - ffi.Pointer source_filename, - int num_clang_command_line_args, - ffi.Pointer> clang_command_line_args, - int num_unsaved_files, - ffi.Pointer unsaved_files, - ); -typedef NativeClang_createTranslationUnit = - CXTranslationUnit Function( - CXIndex CIdx, - ffi.Pointer ast_filename, - ); -typedef DartClang_createTranslationUnit = - CXTranslationUnit Function( - CXIndex CIdx, - ffi.Pointer ast_filename, - ); +/// Describes the calling convention of a function type +enum CXCallingConv { + CXCallingConv_Default(0), + CXCallingConv_C(1), + CXCallingConv_X86StdCall(2), + CXCallingConv_X86FastCall(3), + CXCallingConv_X86ThisCall(4), + CXCallingConv_X86Pascal(5), + CXCallingConv_AAPCS(6), + CXCallingConv_AAPCS_VFP(7), + CXCallingConv_X86RegCall(8), + CXCallingConv_IntelOclBicc(9), + CXCallingConv_Win64(10), + CXCallingConv_X86_64SysV(11), + CXCallingConv_X86VectorCall(12), + CXCallingConv_Swift(13), + CXCallingConv_PreserveMost(14), + CXCallingConv_PreserveAll(15), + CXCallingConv_AArch64VectorCall(16), + CXCallingConv_Invalid(100), + CXCallingConv_Unexposed(200); -/// Error codes returned by libclang routines. -/// -/// Zero (\c CXError_Success) is the only error code indicating success. Other -/// error codes, including not yet assigned non-zero values, indicate errors. -enum CXErrorCode { - /// No error. - CXError_Success(0), + static const CXCallingConv_X86_64Win64 = CXCallingConv_Win64; - /// A generic error code, no further details are available. - /// - /// Errors of this kind can get their own specific error codes in future - /// libclang versions. - CXError_Failure(1), + final int value; + const CXCallingConv(this.value); - /// libclang crashed while performing the requested operation. - CXError_Crashed(2), + static CXCallingConv fromValue(int value) => switch (value) { + 0 => CXCallingConv_Default, + 1 => CXCallingConv_C, + 2 => CXCallingConv_X86StdCall, + 3 => CXCallingConv_X86FastCall, + 4 => CXCallingConv_X86ThisCall, + 5 => CXCallingConv_X86Pascal, + 6 => CXCallingConv_AAPCS, + 7 => CXCallingConv_AAPCS_VFP, + 8 => CXCallingConv_X86RegCall, + 9 => CXCallingConv_IntelOclBicc, + 10 => CXCallingConv_Win64, + 11 => CXCallingConv_X86_64SysV, + 12 => CXCallingConv_X86VectorCall, + 13 => CXCallingConv_Swift, + 14 => CXCallingConv_PreserveMost, + 15 => CXCallingConv_PreserveAll, + 16 => CXCallingConv_AArch64VectorCall, + 100 => CXCallingConv_Invalid, + 200 => CXCallingConv_Unexposed, + _ => throw ArgumentError('Unknown value for CXCallingConv: $value'), + }; - /// The function detected that the arguments violate the function - /// contract. - CXError_InvalidArguments(3), + @override + String toString() { + if (this == CXCallingConv_Win64) + return "CXCallingConv.CXCallingConv_Win64, CXCallingConv.CXCallingConv_X86_64Win64"; + return super.toString(); + } +} - /// An AST deserialization error has occurred. - CXError_ASTReadError(4); +/// Describes how the traversal of the children of a particular +/// cursor should proceed after visiting a particular child cursor. +/// +/// A value of this enumeration type should be returned by each +/// \c CXCursorVisitor to indicate how clang_visitChildren() proceed. +enum CXChildVisitResult { + /// Terminates the cursor traversal. + CXChildVisit_Break(0), + + /// Continues the cursor traversal with the next sibling of + /// the cursor just visited, without visiting its children. + CXChildVisit_Continue(1), + + /// Recursively traverse the children of this cursor, using + /// the same visitor and client data. + CXChildVisit_Recurse(2); final int value; - const CXErrorCode(this.value); + const CXChildVisitResult(this.value); - static CXErrorCode fromValue(int value) => switch (value) { - 0 => CXError_Success, - 1 => CXError_Failure, - 2 => CXError_Crashed, - 3 => CXError_InvalidArguments, - 4 => CXError_ASTReadError, - _ => throw ArgumentError('Unknown value for CXErrorCode: $value'), + static CXChildVisitResult fromValue(int value) => switch (value) { + 0 => CXChildVisit_Break, + 1 => CXChildVisit_Continue, + 2 => CXChildVisit_Recurse, + _ => throw ArgumentError('Unknown value for CXChildVisitResult: $value'), }; } -typedef NativeClang_createTranslationUnit2 = - ffi.UnsignedInt Function( - CXIndex CIdx, - ffi.Pointer ast_filename, - ffi.Pointer out_TU, - ); -typedef DartClang_createTranslationUnit2 = - int Function( - CXIndex CIdx, - ffi.Pointer ast_filename, - ffi.Pointer out_TU, - ); -typedef NativeClang_defaultEditingTranslationUnitOptions = - ffi.UnsignedInt Function(); -typedef DartClang_defaultEditingTranslationUnitOptions = int Function(); -typedef NativeClang_parseTranslationUnit = - CXTranslationUnit Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - ffi.Int num_command_line_args, - ffi.Pointer unsaved_files, - ffi.UnsignedInt num_unsaved_files, - ffi.UnsignedInt options, - ); -typedef DartClang_parseTranslationUnit = - CXTranslationUnit Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ); -typedef NativeClang_parseTranslationUnit2 = - ffi.UnsignedInt Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - ffi.Int num_command_line_args, - ffi.Pointer unsaved_files, - ffi.UnsignedInt num_unsaved_files, - ffi.UnsignedInt options, - ffi.Pointer out_TU, - ); -typedef DartClang_parseTranslationUnit2 = - int Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ffi.Pointer out_TU, - ); -typedef NativeClang_parseTranslationUnit2FullArgv = - ffi.UnsignedInt Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - ffi.Int num_command_line_args, - ffi.Pointer unsaved_files, - ffi.UnsignedInt num_unsaved_files, - ffi.UnsignedInt options, - ffi.Pointer out_TU, - ); -typedef DartClang_parseTranslationUnit2FullArgv = - int Function( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ffi.Pointer out_TU, - ); -typedef NativeClang_defaultSaveOptions = - ffi.UnsignedInt Function(CXTranslationUnit TU); -typedef DartClang_defaultSaveOptions = int Function(CXTranslationUnit TU); -typedef NativeClang_saveTranslationUnit = - ffi.Int Function( - CXTranslationUnit TU, - ffi.Pointer FileName, - ffi.UnsignedInt options, - ); -typedef DartClang_saveTranslationUnit = - int Function( - CXTranslationUnit TU, - ffi.Pointer FileName, - int options, - ); -typedef NativeClang_suspendTranslationUnit = - ffi.UnsignedInt Function(CXTranslationUnit); -typedef DartClang_suspendTranslationUnit = int Function(CXTranslationUnit); -typedef NativeClang_disposeTranslationUnit = - ffi.Void Function(CXTranslationUnit); -typedef DartClang_disposeTranslationUnit = void Function(CXTranslationUnit); -typedef NativeClang_defaultReparseOptions = - ffi.UnsignedInt Function(CXTranslationUnit TU); -typedef DartClang_defaultReparseOptions = int Function(CXTranslationUnit TU); -typedef NativeClang_reparseTranslationUnit = - ffi.Int Function( - CXTranslationUnit TU, - ffi.UnsignedInt num_unsaved_files, - ffi.Pointer unsaved_files, - ffi.UnsignedInt options, - ); -typedef DartClang_reparseTranslationUnit = - int Function( - CXTranslationUnit TU, - int num_unsaved_files, - ffi.Pointer unsaved_files, - int options, - ); +/// Opaque pointer representing client data that will be passed through +/// to various callbacks and visitors. +typedef CXClientData = ffi.Pointer; + +/// Contains the results of code-completion. +/// +/// This data structure contains the results of code completion, as +/// produced by \c clang_codeCompleteAt(). Its contents must be freed by +/// \c clang_disposeCodeCompleteResults. +final class CXCodeCompleteResults extends ffi.Struct { + /// The code-completion results. + external ffi.Pointer Results; + + /// The number of code-completion results stored in the + /// \c Results array. + @ffi.UnsignedInt() + external int NumResults; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer Results, + required int NumResults, + }) => $allocator() + ..ref.Results = Results + ..ref.NumResults = NumResults; +} + +/// Describes a single piece of text within a code-completion string. +/// +/// Each "chunk" within a code-completion string (\c CXCompletionString) is +/// either a piece of text with a specific "kind" that describes how that text +/// should be interpreted by the client or is another completion string. +enum CXCompletionChunkKind { + /// A code-completion string that describes "optional" text that + /// could be a part of the template (but is not required). + /// + /// The Optional chunk is the only kind of chunk that has a code-completion + /// string for its representation, which is accessible via + /// \c clang_getCompletionChunkCompletionString(). The code-completion string + /// describes an additional part of the template that is completely optional. + /// For example, optional chunks can be used to describe the placeholders for + /// arguments that match up with defaulted function parameters, e.g. given: + /// + /// \code + /// void f(int x, float y = 3.14, double z = 2.71828); + /// \endcode + /// + /// The code-completion string for this function would contain: + /// - a TypedText chunk for "f". + /// - a LeftParen chunk for "(". + /// - a Placeholder chunk for "int x" + /// - an Optional chunk containing the remaining defaulted arguments, e.g., + /// - a Comma chunk for "," + /// - a Placeholder chunk for "float y" + /// - an Optional chunk containing the last defaulted argument: + /// - a Comma chunk for "," + /// - a Placeholder chunk for "double z" + /// - a RightParen chunk for ")" + /// + /// There are many ways to handle Optional chunks. Two simple approaches are: + /// - Completely ignore optional chunks, in which case the template for the + /// function "f" would only include the first parameter ("int x"). + /// - Fully expand all optional chunks, in which case the template for the + /// function "f" would have all of the parameters. + CXCompletionChunk_Optional(0), -/// Categorizes how memory is being used by a translation unit. -enum CXTUResourceUsageKind { - CXTUResourceUsage_AST(1), - CXTUResourceUsage_Identifiers(2), - CXTUResourceUsage_Selectors(3), - CXTUResourceUsage_GlobalCompletionResults(4), - CXTUResourceUsage_SourceManagerContentCache(5), - CXTUResourceUsage_AST_SideTables(6), - CXTUResourceUsage_SourceManager_Membuffer_Malloc(7), - CXTUResourceUsage_SourceManager_Membuffer_MMap(8), - CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc(9), - CXTUResourceUsage_ExternalASTSource_Membuffer_MMap(10), - CXTUResourceUsage_Preprocessor(11), - CXTUResourceUsage_PreprocessingRecord(12), - CXTUResourceUsage_SourceManager_DataStructures(13), - CXTUResourceUsage_Preprocessor_HeaderSearch(14); + /// Text that a user would be expected to type to get this + /// code-completion result. + /// + /// There will be exactly one "typed text" chunk in a semantic string, which + /// will typically provide the spelling of a keyword or the name of a + /// declaration that could be used at the current code point. Clients are + /// expected to filter the code-completion results based on the text in this + /// chunk. + CXCompletionChunk_TypedText(1), - static const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST; - static const CXTUResourceUsage_MEMORY_IN_BYTES_END = - CXTUResourceUsage_Preprocessor_HeaderSearch; - static const CXTUResourceUsage_First = CXTUResourceUsage_AST; - static const CXTUResourceUsage_Last = - CXTUResourceUsage_Preprocessor_HeaderSearch; + /// Text that should be inserted as part of a code-completion result. + /// + /// A "text" chunk represents text that is part of the template to be + /// inserted into user code should this particular code-completion result + /// be selected. + CXCompletionChunk_Text(2), + + /// Placeholder text that should be replaced by the user. + /// + /// A "placeholder" chunk marks a place where the user should insert text + /// into the code-completion template. For example, placeholders might mark + /// the function parameters for a function declaration, to indicate that the + /// user should provide arguments for each of those parameters. The actual + /// text in a placeholder is a suggestion for the text to display before + /// the user replaces the placeholder with real code. + CXCompletionChunk_Placeholder(3), + + /// Informative text that should be displayed but never inserted as + /// part of the template. + /// + /// An "informative" chunk contains annotations that can be displayed to + /// help the user decide whether a particular code-completion result is the + /// right option, but which is not part of the actual template to be inserted + /// by code completion. + CXCompletionChunk_Informative(4), + + /// Text that describes the current parameter when code-completion is + /// referring to function call, message send, or template specialization. + /// + /// A "current parameter" chunk occurs when code-completion is providing + /// information about a parameter corresponding to the argument at the + /// code-completion point. For example, given a function + /// + /// \code + /// int add(int x, int y); + /// \endcode + /// + /// and the source code \c add(, where the code-completion point is after the + /// "(", the code-completion string will contain a "current parameter" chunk + /// for "int x", indicating that the current argument will initialize that + /// parameter. After typing further, to \c add(17, (where the code-completion + /// point is after the ","), the code-completion string will contain a + /// "current parameter" chunk to "int y". + CXCompletionChunk_CurrentParameter(5), + + /// A left parenthesis ('('), used to initiate a function call or + /// signal the beginning of a function parameter list. + CXCompletionChunk_LeftParen(6), + + /// A right parenthesis (')'), used to finish a function call or + /// signal the end of a function parameter list. + CXCompletionChunk_RightParen(7), + + /// A left bracket ('['). + CXCompletionChunk_LeftBracket(8), + + /// A right bracket (']'). + CXCompletionChunk_RightBracket(9), + + /// A left brace ('{'). + CXCompletionChunk_LeftBrace(10), + + /// A right brace ('}'). + CXCompletionChunk_RightBrace(11), + + /// A left angle bracket ('<'). + CXCompletionChunk_LeftAngle(12), + + /// A right angle bracket ('>'). + CXCompletionChunk_RightAngle(13), + + /// A comma separator (','). + CXCompletionChunk_Comma(14), + + /// Text that specifies the result type of a given result. + /// + /// This special kind of informative chunk is not meant to be inserted into + /// the text buffer. Rather, it is meant to illustrate the type that an + /// expression using the given completion string would have. + CXCompletionChunk_ResultType(15), + + /// A colon (':'). + CXCompletionChunk_Colon(16), + + /// A semicolon (';'). + CXCompletionChunk_SemiColon(17), + + /// An '=' sign. + CXCompletionChunk_Equal(18), + + /// Horizontal space (' '). + CXCompletionChunk_HorizontalSpace(19), + + /// Vertical space ('\\n'), after which it is generally a good idea to + /// perform indentation. + CXCompletionChunk_VerticalSpace(20); final int value; - const CXTUResourceUsageKind(this.value); + const CXCompletionChunkKind(this.value); - static CXTUResourceUsageKind fromValue(int value) => switch (value) { - 1 => CXTUResourceUsage_AST, - 2 => CXTUResourceUsage_Identifiers, - 3 => CXTUResourceUsage_Selectors, - 4 => CXTUResourceUsage_GlobalCompletionResults, - 5 => CXTUResourceUsage_SourceManagerContentCache, - 6 => CXTUResourceUsage_AST_SideTables, - 7 => CXTUResourceUsage_SourceManager_Membuffer_Malloc, - 8 => CXTUResourceUsage_SourceManager_Membuffer_MMap, - 9 => CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc, - 10 => CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, - 11 => CXTUResourceUsage_Preprocessor, - 12 => CXTUResourceUsage_PreprocessingRecord, - 13 => CXTUResourceUsage_SourceManager_DataStructures, - 14 => CXTUResourceUsage_Preprocessor_HeaderSearch, - _ => throw ArgumentError('Unknown value for CXTUResourceUsageKind: $value'), + static CXCompletionChunkKind fromValue(int value) => switch (value) { + 0 => CXCompletionChunk_Optional, + 1 => CXCompletionChunk_TypedText, + 2 => CXCompletionChunk_Text, + 3 => CXCompletionChunk_Placeholder, + 4 => CXCompletionChunk_Informative, + 5 => CXCompletionChunk_CurrentParameter, + 6 => CXCompletionChunk_LeftParen, + 7 => CXCompletionChunk_RightParen, + 8 => CXCompletionChunk_LeftBracket, + 9 => CXCompletionChunk_RightBracket, + 10 => CXCompletionChunk_LeftBrace, + 11 => CXCompletionChunk_RightBrace, + 12 => CXCompletionChunk_LeftAngle, + 13 => CXCompletionChunk_RightAngle, + 14 => CXCompletionChunk_Comma, + 15 => CXCompletionChunk_ResultType, + 16 => CXCompletionChunk_Colon, + 17 => CXCompletionChunk_SemiColon, + 18 => CXCompletionChunk_Equal, + 19 => CXCompletionChunk_HorizontalSpace, + 20 => CXCompletionChunk_VerticalSpace, + _ => throw ArgumentError('Unknown value for CXCompletionChunkKind: $value'), }; +} - @override - String toString() { - if (this == CXTUResourceUsage_AST) - return "CXTUResourceUsageKind.CXTUResourceUsage_AST, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN, CXTUResourceUsageKind.CXTUResourceUsage_First"; - if (this == CXTUResourceUsage_Preprocessor_HeaderSearch) - return "CXTUResourceUsageKind.CXTUResourceUsage_Preprocessor_HeaderSearch, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_END, CXTUResourceUsageKind.CXTUResourceUsage_Last"; - return super.toString(); - } +/// A single result of code completion. +final class CXCompletionResult extends ffi.Struct { + /// The kind of entity that this completion refers to. + /// + /// The cursor kind will be a macro, keyword, or a declaration (one of the + /// *Decl cursor kinds), describing the entity that the completion is + /// referring to. + /// + /// \todo In the future, we would like to provide a full cursor, to allow + /// the client to extract additional information from declaration. + @ffi.UnsignedInt() + external int CursorKindAsInt; + + CXCursorKind get CursorKind => CXCursorKind.fromValue(CursorKindAsInt); + set CursorKind(CXCursorKind value) => CursorKindAsInt = value.value; + + /// The code-completion string that describes how to insert this + /// code-completion result into the editing buffer. + external CXCompletionString CompletionString; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required CXCursorKind CursorKind, + required CXCompletionString CompletionString, + }) => $allocator() + ..ref.CursorKind = CursorKind + ..ref.CompletionString = CompletionString; } -typedef NativeClang_getTUResourceUsageName = - ffi.Pointer Function(ffi.UnsignedInt kind); -typedef DartClang_getTUResourceUsageName = - ffi.Pointer Function(int kind); +/// A semantic string that describes a code-completion result. +/// +/// A semantic string that describes the formatting of a code-completion +/// result as a single "template" of text that should be inserted into the +/// source buffer when a particular code-completion result is selected. +/// Each semantic string is made up of some number of "chunks", each of which +/// contains some text along with a description of what that text means, e.g., +/// the name of the entity being referenced, whether the text chunk is part of +/// the template, or whether it is a "placeholder" that the user should replace +/// with actual code,of a specific kind. See \c CXCompletionChunkKind for a +/// description of the different kinds of chunks. +typedef CXCompletionString = ffi.Pointer; -final class CXTUResourceUsageEntry extends ffi.Struct { +/// A cursor representing some element in the abstract syntax tree for +/// a translation unit. +/// +/// The cursor abstraction unifies the different kinds of entities in a +/// program--declaration, statements, expressions, references to declarations, +/// etc.--under a single "cursor" abstraction with a common set of operations. +/// Common operation for a cursor include: getting the physical location in +/// a source file where the cursor points, getting the name associated with a +/// cursor, and retrieving cursors for any child nodes of a particular cursor. +/// +/// Cursors can be produced in two specific ways. +/// clang_getTranslationUnitCursor() produces a cursor for a translation unit, +/// from which one can use clang_visitChildren() to explore the rest of the +/// translation unit. clang_getCursor() maps from a physical source location +/// to the entity that resides at that location, allowing one to map from the +/// source code into the AST. +final class CXCursor extends ffi.Struct { @ffi.UnsignedInt() external int kindAsInt; - CXTUResourceUsageKind get kind => CXTUResourceUsageKind.fromValue(kindAsInt); - set kind(CXTUResourceUsageKind value) => kindAsInt = value.value; + CXCursorKind get kind => CXCursorKind.fromValue(kindAsInt); + set kind(CXCursorKind value) => kindAsInt = value.value; - @ffi.UnsignedLong() - external int amount; + @ffi.Int() + external int xdata; + + @ffi.Array.multi([3]) + external ffi.Array> data; } -/// The memory usage of a CXTranslationUnit, broken into categories. -final class CXTUResourceUsage extends ffi.Struct { - external ffi.Pointer data; +final class CXCursorAndRangeVisitor extends ffi.Struct { + external ffi.Pointer context; - @ffi.UnsignedInt() - external int numEntries; + external ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.Pointer, CXCursor, CXSourceRange) + > + > + visit; - external ffi.Pointer entries; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer context, + required ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.Pointer, CXCursor, CXSourceRange) + > + > + visit, + }) => $allocator() + ..ref.context = context + ..ref.visit = visit; } -typedef NativeClang_getCXTUResourceUsage = - CXTUResourceUsage Function(CXTranslationUnit TU); -typedef DartClang_getCXTUResourceUsage = - CXTUResourceUsage Function(CXTranslationUnit TU); -typedef NativeClang_disposeCXTUResourceUsage = - ffi.Void Function(CXTUResourceUsage usage); -typedef DartClang_disposeCXTUResourceUsage = - void Function(CXTUResourceUsage usage); -typedef NativeClang_getTranslationUnitTargetInfo = - CXTargetInfo Function(CXTranslationUnit CTUnit); -typedef DartClang_getTranslationUnitTargetInfo = - CXTargetInfo Function(CXTranslationUnit CTUnit); -typedef NativeClang_TargetInfo_dispose = ffi.Void Function(CXTargetInfo Info); -typedef DartClang_TargetInfo_dispose = void Function(CXTargetInfo Info); -typedef NativeClang_TargetInfo_getTriple = CXString Function(CXTargetInfo Info); -typedef DartClang_TargetInfo_getTriple = CXString Function(CXTargetInfo Info); -typedef NativeClang_TargetInfo_getPointerWidth = - ffi.Int Function(CXTargetInfo Info); -typedef DartClang_TargetInfo_getPointerWidth = int Function(CXTargetInfo Info); - /// Describes the kind of entity that a cursor refers to. enum CXCursorKind { /// A declaration whose specific kind is not exposed via this @@ -8121,2375 +7689,1210 @@ enum CXCursorKind { /// OpenMP master directive. CXCursor_OMPMasterDirective(241), - /// OpenMP critical directive. - CXCursor_OMPCriticalDirective(242), - - /// OpenMP taskyield directive. - CXCursor_OMPTaskyieldDirective(243), - - /// OpenMP barrier directive. - CXCursor_OMPBarrierDirective(244), - - /// OpenMP taskwait directive. - CXCursor_OMPTaskwaitDirective(245), - - /// OpenMP flush directive. - CXCursor_OMPFlushDirective(246), - - /// Windows Structured Exception Handling's leave statement. - CXCursor_SEHLeaveStmt(247), - - /// OpenMP ordered directive. - CXCursor_OMPOrderedDirective(248), - - /// OpenMP atomic directive. - CXCursor_OMPAtomicDirective(249), - - /// OpenMP for SIMD directive. - CXCursor_OMPForSimdDirective(250), - - /// OpenMP parallel for SIMD directive. - CXCursor_OMPParallelForSimdDirective(251), - - /// OpenMP target directive. - CXCursor_OMPTargetDirective(252), - - /// OpenMP teams directive. - CXCursor_OMPTeamsDirective(253), - - /// OpenMP taskgroup directive. - CXCursor_OMPTaskgroupDirective(254), - - /// OpenMP cancellation point directive. - CXCursor_OMPCancellationPointDirective(255), - - /// OpenMP cancel directive. - CXCursor_OMPCancelDirective(256), - - /// OpenMP target data directive. - CXCursor_OMPTargetDataDirective(257), - - /// OpenMP taskloop directive. - CXCursor_OMPTaskLoopDirective(258), - - /// OpenMP taskloop simd directive. - CXCursor_OMPTaskLoopSimdDirective(259), - - /// OpenMP distribute directive. - CXCursor_OMPDistributeDirective(260), - - /// OpenMP target enter data directive. - CXCursor_OMPTargetEnterDataDirective(261), - - /// OpenMP target exit data directive. - CXCursor_OMPTargetExitDataDirective(262), - - /// OpenMP target parallel directive. - CXCursor_OMPTargetParallelDirective(263), - - /// OpenMP target parallel for directive. - CXCursor_OMPTargetParallelForDirective(264), - - /// OpenMP target update directive. - CXCursor_OMPTargetUpdateDirective(265), - - /// OpenMP distribute parallel for directive. - CXCursor_OMPDistributeParallelForDirective(266), - - /// OpenMP distribute parallel for simd directive. - CXCursor_OMPDistributeParallelForSimdDirective(267), - - /// OpenMP distribute simd directive. - CXCursor_OMPDistributeSimdDirective(268), - - /// OpenMP target parallel for simd directive. - CXCursor_OMPTargetParallelForSimdDirective(269), - - /// OpenMP target simd directive. - CXCursor_OMPTargetSimdDirective(270), - - /// OpenMP teams distribute directive. - CXCursor_OMPTeamsDistributeDirective(271), - - /// OpenMP teams distribute simd directive. - CXCursor_OMPTeamsDistributeSimdDirective(272), - - /// OpenMP teams distribute parallel for simd directive. - CXCursor_OMPTeamsDistributeParallelForSimdDirective(273), - - /// OpenMP teams distribute parallel for directive. - CXCursor_OMPTeamsDistributeParallelForDirective(274), - - /// OpenMP target teams directive. - CXCursor_OMPTargetTeamsDirective(275), - - /// OpenMP target teams distribute directive. - CXCursor_OMPTargetTeamsDistributeDirective(276), - - /// OpenMP target teams distribute parallel for directive. - CXCursor_OMPTargetTeamsDistributeParallelForDirective(277), - - /// OpenMP target teams distribute parallel for simd directive. - CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective(278), - - /// OpenMP target teams distribute simd directive. - CXCursor_OMPTargetTeamsDistributeSimdDirective(279), - - /// C++2a std::bit_cast expression. - CXCursor_BuiltinBitCastExpr(280), - - /// OpenMP master taskloop directive. - CXCursor_OMPMasterTaskLoopDirective(281), - - /// OpenMP parallel master taskloop directive. - CXCursor_OMPParallelMasterTaskLoopDirective(282), - - /// OpenMP master taskloop simd directive. - CXCursor_OMPMasterTaskLoopSimdDirective(283), - - /// OpenMP parallel master taskloop simd directive. - CXCursor_OMPParallelMasterTaskLoopSimdDirective(284), - - /// OpenMP parallel master directive. - CXCursor_OMPParallelMasterDirective(285), - - /// Cursor that represents the translation unit itself. - /// - /// The translation unit cursor exists primarily to act as the root - /// cursor for traversing the contents of a translation unit. - CXCursor_TranslationUnit(300), - CXCursor_FirstAttr(400), - CXCursor_IBActionAttr(401), - CXCursor_IBOutletAttr(402), - CXCursor_IBOutletCollectionAttr(403), - CXCursor_CXXFinalAttr(404), - CXCursor_CXXOverrideAttr(405), - CXCursor_AnnotateAttr(406), - CXCursor_AsmLabelAttr(407), - CXCursor_PackedAttr(408), - CXCursor_PureAttr(409), - CXCursor_ConstAttr(410), - CXCursor_NoDuplicateAttr(411), - CXCursor_CUDAConstantAttr(412), - CXCursor_CUDADeviceAttr(413), - CXCursor_CUDAGlobalAttr(414), - CXCursor_CUDAHostAttr(415), - CXCursor_CUDASharedAttr(416), - CXCursor_VisibilityAttr(417), - CXCursor_DLLExport(418), - CXCursor_DLLImport(419), - CXCursor_NSReturnsRetained(420), - CXCursor_NSReturnsNotRetained(421), - CXCursor_NSReturnsAutoreleased(422), - CXCursor_NSConsumesSelf(423), - CXCursor_NSConsumed(424), - CXCursor_ObjCException(425), - CXCursor_ObjCNSObject(426), - CXCursor_ObjCIndependentClass(427), - CXCursor_ObjCPreciseLifetime(428), - CXCursor_ObjCReturnsInnerPointer(429), - CXCursor_ObjCRequiresSuper(430), - CXCursor_ObjCRootClass(431), - CXCursor_ObjCSubclassingRestricted(432), - CXCursor_ObjCExplicitProtocolImpl(433), - CXCursor_ObjCDesignatedInitializer(434), - CXCursor_ObjCRuntimeVisible(435), - CXCursor_ObjCBoxable(436), - CXCursor_FlagEnum(437), - CXCursor_ConvergentAttr(438), - CXCursor_WarnUnusedAttr(439), - CXCursor_WarnUnusedResultAttr(440), - CXCursor_AlignedAttr(441), - CXCursor_PreprocessingDirective(500), - CXCursor_MacroDefinition(501), - CXCursor_MacroExpansion(502), - CXCursor_InclusionDirective(503), - - /// A module import declaration. - CXCursor_ModuleImportDecl(600), - CXCursor_TypeAliasTemplateDecl(601), - - /// A static_assert or _Static_assert node - CXCursor_StaticAssert(602), - - /// a friend declaration. - CXCursor_FriendDecl(603), - - /// A code completion overload candidate. - CXCursor_OverloadCandidate(700); - - static const CXCursor_FirstDecl = CXCursor_UnexposedDecl; - static const CXCursor_LastDecl = CXCursor_CXXAccessSpecifier; - static const CXCursor_ObjCSuperClassRef = CXCursor_FirstRef; - static const CXCursor_LastRef = CXCursor_VariableRef; - static const CXCursor_InvalidFile = CXCursor_FirstInvalid; - static const CXCursor_LastInvalid = CXCursor_InvalidCode; - - /// An expression whose specific kind is not exposed via this - /// interface. - /// - /// Unexposed expressions have the same operations as any other kind - /// of expression; one can extract their location information, - /// spelling, children, etc. However, the specific kind of the - /// expression is not reported. - static const CXCursor_UnexposedExpr = CXCursor_FirstExpr; - static const CXCursor_LastExpr = CXCursor_FixedPointLiteral; - - /// A statement whose specific kind is not exposed via this - /// interface. - /// - /// Unexposed statements have the same operations as any other kind of - /// statement; one can extract their location information, spelling, - /// children, etc. However, the specific kind of the statement is not - /// reported. - static const CXCursor_UnexposedStmt = CXCursor_FirstStmt; - static const CXCursor_AsmStmt = CXCursor_GCCAsmStmt; - static const CXCursor_LastStmt = CXCursor_OMPParallelMasterDirective; - - /// An attribute whose specific kind is not exposed via this - /// interface. - static const CXCursor_UnexposedAttr = CXCursor_FirstAttr; - static const CXCursor_LastAttr = CXCursor_AlignedAttr; - static const CXCursor_MacroInstantiation = CXCursor_MacroExpansion; - static const CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective; - static const CXCursor_LastPreprocessing = CXCursor_InclusionDirective; - static const CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl; - static const CXCursor_LastExtraDecl = CXCursor_FriendDecl; + /// OpenMP critical directive. + CXCursor_OMPCriticalDirective(242), - final int value; - const CXCursorKind(this.value); + /// OpenMP taskyield directive. + CXCursor_OMPTaskyieldDirective(243), - static CXCursorKind fromValue(int value) => switch (value) { - 1 => CXCursor_UnexposedDecl, - 2 => CXCursor_StructDecl, - 3 => CXCursor_UnionDecl, - 4 => CXCursor_ClassDecl, - 5 => CXCursor_EnumDecl, - 6 => CXCursor_FieldDecl, - 7 => CXCursor_EnumConstantDecl, - 8 => CXCursor_FunctionDecl, - 9 => CXCursor_VarDecl, - 10 => CXCursor_ParmDecl, - 11 => CXCursor_ObjCInterfaceDecl, - 12 => CXCursor_ObjCCategoryDecl, - 13 => CXCursor_ObjCProtocolDecl, - 14 => CXCursor_ObjCPropertyDecl, - 15 => CXCursor_ObjCIvarDecl, - 16 => CXCursor_ObjCInstanceMethodDecl, - 17 => CXCursor_ObjCClassMethodDecl, - 18 => CXCursor_ObjCImplementationDecl, - 19 => CXCursor_ObjCCategoryImplDecl, - 20 => CXCursor_TypedefDecl, - 21 => CXCursor_CXXMethod, - 22 => CXCursor_Namespace, - 23 => CXCursor_LinkageSpec, - 24 => CXCursor_Constructor, - 25 => CXCursor_Destructor, - 26 => CXCursor_ConversionFunction, - 27 => CXCursor_TemplateTypeParameter, - 28 => CXCursor_NonTypeTemplateParameter, - 29 => CXCursor_TemplateTemplateParameter, - 30 => CXCursor_FunctionTemplate, - 31 => CXCursor_ClassTemplate, - 32 => CXCursor_ClassTemplatePartialSpecialization, - 33 => CXCursor_NamespaceAlias, - 34 => CXCursor_UsingDirective, - 35 => CXCursor_UsingDeclaration, - 36 => CXCursor_TypeAliasDecl, - 37 => CXCursor_ObjCSynthesizeDecl, - 38 => CXCursor_ObjCDynamicDecl, - 39 => CXCursor_CXXAccessSpecifier, - 40 => CXCursor_FirstRef, - 41 => CXCursor_ObjCProtocolRef, - 42 => CXCursor_ObjCClassRef, - 43 => CXCursor_TypeRef, - 44 => CXCursor_CXXBaseSpecifier, - 45 => CXCursor_TemplateRef, - 46 => CXCursor_NamespaceRef, - 47 => CXCursor_MemberRef, - 48 => CXCursor_LabelRef, - 49 => CXCursor_OverloadedDeclRef, - 50 => CXCursor_VariableRef, - 70 => CXCursor_FirstInvalid, - 71 => CXCursor_NoDeclFound, - 72 => CXCursor_NotImplemented, - 73 => CXCursor_InvalidCode, - 100 => CXCursor_FirstExpr, - 101 => CXCursor_DeclRefExpr, - 102 => CXCursor_MemberRefExpr, - 103 => CXCursor_CallExpr, - 104 => CXCursor_ObjCMessageExpr, - 105 => CXCursor_BlockExpr, - 106 => CXCursor_IntegerLiteral, - 107 => CXCursor_FloatingLiteral, - 108 => CXCursor_ImaginaryLiteral, - 109 => CXCursor_StringLiteral, - 110 => CXCursor_CharacterLiteral, - 111 => CXCursor_ParenExpr, - 112 => CXCursor_UnaryOperator, - 113 => CXCursor_ArraySubscriptExpr, - 114 => CXCursor_BinaryOperator, - 115 => CXCursor_CompoundAssignOperator, - 116 => CXCursor_ConditionalOperator, - 117 => CXCursor_CStyleCastExpr, - 118 => CXCursor_CompoundLiteralExpr, - 119 => CXCursor_InitListExpr, - 120 => CXCursor_AddrLabelExpr, - 121 => CXCursor_StmtExpr, - 122 => CXCursor_GenericSelectionExpr, - 123 => CXCursor_GNUNullExpr, - 124 => CXCursor_CXXStaticCastExpr, - 125 => CXCursor_CXXDynamicCastExpr, - 126 => CXCursor_CXXReinterpretCastExpr, - 127 => CXCursor_CXXConstCastExpr, - 128 => CXCursor_CXXFunctionalCastExpr, - 129 => CXCursor_CXXTypeidExpr, - 130 => CXCursor_CXXBoolLiteralExpr, - 131 => CXCursor_CXXNullPtrLiteralExpr, - 132 => CXCursor_CXXThisExpr, - 133 => CXCursor_CXXThrowExpr, - 134 => CXCursor_CXXNewExpr, - 135 => CXCursor_CXXDeleteExpr, - 136 => CXCursor_UnaryExpr, - 137 => CXCursor_ObjCStringLiteral, - 138 => CXCursor_ObjCEncodeExpr, - 139 => CXCursor_ObjCSelectorExpr, - 140 => CXCursor_ObjCProtocolExpr, - 141 => CXCursor_ObjCBridgedCastExpr, - 142 => CXCursor_PackExpansionExpr, - 143 => CXCursor_SizeOfPackExpr, - 144 => CXCursor_LambdaExpr, - 145 => CXCursor_ObjCBoolLiteralExpr, - 146 => CXCursor_ObjCSelfExpr, - 147 => CXCursor_OMPArraySectionExpr, - 148 => CXCursor_ObjCAvailabilityCheckExpr, - 149 => CXCursor_FixedPointLiteral, - 200 => CXCursor_FirstStmt, - 201 => CXCursor_LabelStmt, - 202 => CXCursor_CompoundStmt, - 203 => CXCursor_CaseStmt, - 204 => CXCursor_DefaultStmt, - 205 => CXCursor_IfStmt, - 206 => CXCursor_SwitchStmt, - 207 => CXCursor_WhileStmt, - 208 => CXCursor_DoStmt, - 209 => CXCursor_ForStmt, - 210 => CXCursor_GotoStmt, - 211 => CXCursor_IndirectGotoStmt, - 212 => CXCursor_ContinueStmt, - 213 => CXCursor_BreakStmt, - 214 => CXCursor_ReturnStmt, - 215 => CXCursor_GCCAsmStmt, - 216 => CXCursor_ObjCAtTryStmt, - 217 => CXCursor_ObjCAtCatchStmt, - 218 => CXCursor_ObjCAtFinallyStmt, - 219 => CXCursor_ObjCAtThrowStmt, - 220 => CXCursor_ObjCAtSynchronizedStmt, - 221 => CXCursor_ObjCAutoreleasePoolStmt, - 222 => CXCursor_ObjCForCollectionStmt, - 223 => CXCursor_CXXCatchStmt, - 224 => CXCursor_CXXTryStmt, - 225 => CXCursor_CXXForRangeStmt, - 226 => CXCursor_SEHTryStmt, - 227 => CXCursor_SEHExceptStmt, - 228 => CXCursor_SEHFinallyStmt, - 229 => CXCursor_MSAsmStmt, - 230 => CXCursor_NullStmt, - 231 => CXCursor_DeclStmt, - 232 => CXCursor_OMPParallelDirective, - 233 => CXCursor_OMPSimdDirective, - 234 => CXCursor_OMPForDirective, - 235 => CXCursor_OMPSectionsDirective, - 236 => CXCursor_OMPSectionDirective, - 237 => CXCursor_OMPSingleDirective, - 238 => CXCursor_OMPParallelForDirective, - 239 => CXCursor_OMPParallelSectionsDirective, - 240 => CXCursor_OMPTaskDirective, - 241 => CXCursor_OMPMasterDirective, - 242 => CXCursor_OMPCriticalDirective, - 243 => CXCursor_OMPTaskyieldDirective, - 244 => CXCursor_OMPBarrierDirective, - 245 => CXCursor_OMPTaskwaitDirective, - 246 => CXCursor_OMPFlushDirective, - 247 => CXCursor_SEHLeaveStmt, - 248 => CXCursor_OMPOrderedDirective, - 249 => CXCursor_OMPAtomicDirective, - 250 => CXCursor_OMPForSimdDirective, - 251 => CXCursor_OMPParallelForSimdDirective, - 252 => CXCursor_OMPTargetDirective, - 253 => CXCursor_OMPTeamsDirective, - 254 => CXCursor_OMPTaskgroupDirective, - 255 => CXCursor_OMPCancellationPointDirective, - 256 => CXCursor_OMPCancelDirective, - 257 => CXCursor_OMPTargetDataDirective, - 258 => CXCursor_OMPTaskLoopDirective, - 259 => CXCursor_OMPTaskLoopSimdDirective, - 260 => CXCursor_OMPDistributeDirective, - 261 => CXCursor_OMPTargetEnterDataDirective, - 262 => CXCursor_OMPTargetExitDataDirective, - 263 => CXCursor_OMPTargetParallelDirective, - 264 => CXCursor_OMPTargetParallelForDirective, - 265 => CXCursor_OMPTargetUpdateDirective, - 266 => CXCursor_OMPDistributeParallelForDirective, - 267 => CXCursor_OMPDistributeParallelForSimdDirective, - 268 => CXCursor_OMPDistributeSimdDirective, - 269 => CXCursor_OMPTargetParallelForSimdDirective, - 270 => CXCursor_OMPTargetSimdDirective, - 271 => CXCursor_OMPTeamsDistributeDirective, - 272 => CXCursor_OMPTeamsDistributeSimdDirective, - 273 => CXCursor_OMPTeamsDistributeParallelForSimdDirective, - 274 => CXCursor_OMPTeamsDistributeParallelForDirective, - 275 => CXCursor_OMPTargetTeamsDirective, - 276 => CXCursor_OMPTargetTeamsDistributeDirective, - 277 => CXCursor_OMPTargetTeamsDistributeParallelForDirective, - 278 => CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, - 279 => CXCursor_OMPTargetTeamsDistributeSimdDirective, - 280 => CXCursor_BuiltinBitCastExpr, - 281 => CXCursor_OMPMasterTaskLoopDirective, - 282 => CXCursor_OMPParallelMasterTaskLoopDirective, - 283 => CXCursor_OMPMasterTaskLoopSimdDirective, - 284 => CXCursor_OMPParallelMasterTaskLoopSimdDirective, - 285 => CXCursor_OMPParallelMasterDirective, - 300 => CXCursor_TranslationUnit, - 400 => CXCursor_FirstAttr, - 401 => CXCursor_IBActionAttr, - 402 => CXCursor_IBOutletAttr, - 403 => CXCursor_IBOutletCollectionAttr, - 404 => CXCursor_CXXFinalAttr, - 405 => CXCursor_CXXOverrideAttr, - 406 => CXCursor_AnnotateAttr, - 407 => CXCursor_AsmLabelAttr, - 408 => CXCursor_PackedAttr, - 409 => CXCursor_PureAttr, - 410 => CXCursor_ConstAttr, - 411 => CXCursor_NoDuplicateAttr, - 412 => CXCursor_CUDAConstantAttr, - 413 => CXCursor_CUDADeviceAttr, - 414 => CXCursor_CUDAGlobalAttr, - 415 => CXCursor_CUDAHostAttr, - 416 => CXCursor_CUDASharedAttr, - 417 => CXCursor_VisibilityAttr, - 418 => CXCursor_DLLExport, - 419 => CXCursor_DLLImport, - 420 => CXCursor_NSReturnsRetained, - 421 => CXCursor_NSReturnsNotRetained, - 422 => CXCursor_NSReturnsAutoreleased, - 423 => CXCursor_NSConsumesSelf, - 424 => CXCursor_NSConsumed, - 425 => CXCursor_ObjCException, - 426 => CXCursor_ObjCNSObject, - 427 => CXCursor_ObjCIndependentClass, - 428 => CXCursor_ObjCPreciseLifetime, - 429 => CXCursor_ObjCReturnsInnerPointer, - 430 => CXCursor_ObjCRequiresSuper, - 431 => CXCursor_ObjCRootClass, - 432 => CXCursor_ObjCSubclassingRestricted, - 433 => CXCursor_ObjCExplicitProtocolImpl, - 434 => CXCursor_ObjCDesignatedInitializer, - 435 => CXCursor_ObjCRuntimeVisible, - 436 => CXCursor_ObjCBoxable, - 437 => CXCursor_FlagEnum, - 438 => CXCursor_ConvergentAttr, - 439 => CXCursor_WarnUnusedAttr, - 440 => CXCursor_WarnUnusedResultAttr, - 441 => CXCursor_AlignedAttr, - 500 => CXCursor_PreprocessingDirective, - 501 => CXCursor_MacroDefinition, - 502 => CXCursor_MacroExpansion, - 503 => CXCursor_InclusionDirective, - 600 => CXCursor_ModuleImportDecl, - 601 => CXCursor_TypeAliasTemplateDecl, - 602 => CXCursor_StaticAssert, - 603 => CXCursor_FriendDecl, - 700 => CXCursor_OverloadCandidate, - _ => throw ArgumentError('Unknown value for CXCursorKind: $value'), - }; + /// OpenMP barrier directive. + CXCursor_OMPBarrierDirective(244), + + /// OpenMP taskwait directive. + CXCursor_OMPTaskwaitDirective(245), - @override - String toString() { - if (this == CXCursor_UnexposedDecl) - return "CXCursorKind.CXCursor_UnexposedDecl, CXCursorKind.CXCursor_FirstDecl"; - if (this == CXCursor_CXXAccessSpecifier) - return "CXCursorKind.CXCursor_CXXAccessSpecifier, CXCursorKind.CXCursor_LastDecl"; - if (this == CXCursor_FirstRef) - return "CXCursorKind.CXCursor_FirstRef, CXCursorKind.CXCursor_ObjCSuperClassRef"; - if (this == CXCursor_VariableRef) - return "CXCursorKind.CXCursor_VariableRef, CXCursorKind.CXCursor_LastRef"; - if (this == CXCursor_FirstInvalid) - return "CXCursorKind.CXCursor_FirstInvalid, CXCursorKind.CXCursor_InvalidFile"; - if (this == CXCursor_InvalidCode) - return "CXCursorKind.CXCursor_InvalidCode, CXCursorKind.CXCursor_LastInvalid"; - if (this == CXCursor_FirstExpr) - return "CXCursorKind.CXCursor_FirstExpr, CXCursorKind.CXCursor_UnexposedExpr"; - if (this == CXCursor_FixedPointLiteral) - return "CXCursorKind.CXCursor_FixedPointLiteral, CXCursorKind.CXCursor_LastExpr"; - if (this == CXCursor_FirstStmt) - return "CXCursorKind.CXCursor_FirstStmt, CXCursorKind.CXCursor_UnexposedStmt"; - if (this == CXCursor_GCCAsmStmt) - return "CXCursorKind.CXCursor_GCCAsmStmt, CXCursorKind.CXCursor_AsmStmt"; - if (this == CXCursor_OMPParallelMasterDirective) - return "CXCursorKind.CXCursor_OMPParallelMasterDirective, CXCursorKind.CXCursor_LastStmt"; - if (this == CXCursor_FirstAttr) - return "CXCursorKind.CXCursor_FirstAttr, CXCursorKind.CXCursor_UnexposedAttr"; - if (this == CXCursor_AlignedAttr) - return "CXCursorKind.CXCursor_AlignedAttr, CXCursorKind.CXCursor_LastAttr"; - if (this == CXCursor_PreprocessingDirective) - return "CXCursorKind.CXCursor_PreprocessingDirective, CXCursorKind.CXCursor_FirstPreprocessing"; - if (this == CXCursor_MacroExpansion) - return "CXCursorKind.CXCursor_MacroExpansion, CXCursorKind.CXCursor_MacroInstantiation"; - if (this == CXCursor_InclusionDirective) - return "CXCursorKind.CXCursor_InclusionDirective, CXCursorKind.CXCursor_LastPreprocessing"; - if (this == CXCursor_ModuleImportDecl) - return "CXCursorKind.CXCursor_ModuleImportDecl, CXCursorKind.CXCursor_FirstExtraDecl"; - if (this == CXCursor_FriendDecl) - return "CXCursorKind.CXCursor_FriendDecl, CXCursorKind.CXCursor_LastExtraDecl"; - return super.toString(); - } -} + /// OpenMP flush directive. + CXCursor_OMPFlushDirective(246), -/// A cursor representing some element in the abstract syntax tree for -/// a translation unit. -/// -/// The cursor abstraction unifies the different kinds of entities in a -/// program--declaration, statements, expressions, references to declarations, -/// etc.--under a single "cursor" abstraction with a common set of operations. -/// Common operation for a cursor include: getting the physical location in -/// a source file where the cursor points, getting the name associated with a -/// cursor, and retrieving cursors for any child nodes of a particular cursor. -/// -/// Cursors can be produced in two specific ways. -/// clang_getTranslationUnitCursor() produces a cursor for a translation unit, -/// from which one can use clang_visitChildren() to explore the rest of the -/// translation unit. clang_getCursor() maps from a physical source location -/// to the entity that resides at that location, allowing one to map from the -/// source code into the AST. -final class CXCursor extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; + /// Windows Structured Exception Handling's leave statement. + CXCursor_SEHLeaveStmt(247), - CXCursorKind get kind => CXCursorKind.fromValue(kindAsInt); - set kind(CXCursorKind value) => kindAsInt = value.value; + /// OpenMP ordered directive. + CXCursor_OMPOrderedDirective(248), - @ffi.Int() - external int xdata; + /// OpenMP atomic directive. + CXCursor_OMPAtomicDirective(249), - @ffi.Array.multi([3]) - external ffi.Array> data; -} + /// OpenMP for SIMD directive. + CXCursor_OMPForSimdDirective(250), -typedef NativeClang_getNullCursor = CXCursor Function(); -typedef DartClang_getNullCursor = CXCursor Function(); -typedef NativeClang_getTranslationUnitCursor = - CXCursor Function(CXTranslationUnit); -typedef DartClang_getTranslationUnitCursor = - CXCursor Function(CXTranslationUnit); -typedef NativeClang_equalCursors = ffi.UnsignedInt Function(CXCursor, CXCursor); -typedef DartClang_equalCursors = int Function(CXCursor, CXCursor); -typedef NativeClang_Cursor_isNull = ffi.Int Function(CXCursor cursor); -typedef DartClang_Cursor_isNull = int Function(CXCursor cursor); -typedef NativeClang_hashCursor = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_hashCursor = int Function(CXCursor); -typedef NativeClang_getCursorKind = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_getCursorKind = int Function(CXCursor); -typedef NativeClang_isDeclaration = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isDeclaration = int Function(int); -typedef NativeClang_isInvalidDeclaration = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_isInvalidDeclaration = int Function(CXCursor); -typedef NativeClang_isReference = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isReference = int Function(int); -typedef NativeClang_isExpression = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isExpression = int Function(int); -typedef NativeClang_isStatement = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isStatement = int Function(int); -typedef NativeClang_isAttribute = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isAttribute = int Function(int); -typedef NativeClang_Cursor_hasAttrs = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_hasAttrs = int Function(CXCursor C); -typedef NativeClang_isInvalid = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isInvalid = int Function(int); -typedef NativeClang_isTranslationUnit = - ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isTranslationUnit = int Function(int); -typedef NativeClang_isPreprocessing = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isPreprocessing = int Function(int); -typedef NativeClang_isUnexposed = ffi.UnsignedInt Function(ffi.UnsignedInt); -typedef DartClang_isUnexposed = int Function(int); + /// OpenMP parallel for SIMD directive. + CXCursor_OMPParallelForSimdDirective(251), -/// Describe the linkage of the entity referred to by a cursor. -enum CXLinkageKind { - /// This value indicates that no linkage information is available - /// for a provided CXCursor. - CXLinkage_Invalid(0), + /// OpenMP target directive. + CXCursor_OMPTargetDirective(252), - /// This is the linkage for variables, parameters, and so on that - /// have automatic storage. This covers normal (non-extern) local variables. - CXLinkage_NoLinkage(1), + /// OpenMP teams directive. + CXCursor_OMPTeamsDirective(253), - /// This is the linkage for static variables and static functions. - CXLinkage_Internal(2), + /// OpenMP taskgroup directive. + CXCursor_OMPTaskgroupDirective(254), - /// This is the linkage for entities with external linkage that live - /// in C++ anonymous namespaces. - CXLinkage_UniqueExternal(3), + /// OpenMP cancellation point directive. + CXCursor_OMPCancellationPointDirective(255), - /// This is the linkage for entities with true, external linkage. - CXLinkage_External(4); + /// OpenMP cancel directive. + CXCursor_OMPCancelDirective(256), - final int value; - const CXLinkageKind(this.value); + /// OpenMP target data directive. + CXCursor_OMPTargetDataDirective(257), - static CXLinkageKind fromValue(int value) => switch (value) { - 0 => CXLinkage_Invalid, - 1 => CXLinkage_NoLinkage, - 2 => CXLinkage_Internal, - 3 => CXLinkage_UniqueExternal, - 4 => CXLinkage_External, - _ => throw ArgumentError('Unknown value for CXLinkageKind: $value'), - }; -} + /// OpenMP taskloop directive. + CXCursor_OMPTaskLoopDirective(258), -typedef NativeClang_getCursorLinkage = - ffi.UnsignedInt Function(CXCursor cursor); -typedef DartClang_getCursorLinkage = int Function(CXCursor cursor); + /// OpenMP taskloop simd directive. + CXCursor_OMPTaskLoopSimdDirective(259), -enum CXVisibilityKind { - /// This value indicates that no visibility information is available - /// for a provided CXCursor. - CXVisibility_Invalid(0), + /// OpenMP distribute directive. + CXCursor_OMPDistributeDirective(260), - /// Symbol not seen by the linker. - CXVisibility_Hidden(1), + /// OpenMP target enter data directive. + CXCursor_OMPTargetEnterDataDirective(261), - /// Symbol seen by the linker but resolves to a symbol inside this object. - CXVisibility_Protected(2), + /// OpenMP target exit data directive. + CXCursor_OMPTargetExitDataDirective(262), - /// Symbol seen by the linker and acts like a normal symbol. - CXVisibility_Default(3); + /// OpenMP target parallel directive. + CXCursor_OMPTargetParallelDirective(263), - final int value; - const CXVisibilityKind(this.value); + /// OpenMP target parallel for directive. + CXCursor_OMPTargetParallelForDirective(264), - static CXVisibilityKind fromValue(int value) => switch (value) { - 0 => CXVisibility_Invalid, - 1 => CXVisibility_Hidden, - 2 => CXVisibility_Protected, - 3 => CXVisibility_Default, - _ => throw ArgumentError('Unknown value for CXVisibilityKind: $value'), - }; -} + /// OpenMP target update directive. + CXCursor_OMPTargetUpdateDirective(265), -typedef NativeClang_getCursorVisibility = - ffi.UnsignedInt Function(CXCursor cursor); -typedef DartClang_getCursorVisibility = int Function(CXCursor cursor); -typedef NativeClang_getCursorAvailability = - ffi.UnsignedInt Function(CXCursor cursor); -typedef DartClang_getCursorAvailability = int Function(CXCursor cursor); + /// OpenMP distribute parallel for directive. + CXCursor_OMPDistributeParallelForDirective(266), -/// Describes the availability of a given entity on a particular platform, e.g., -/// a particular class might only be available on Mac OS 10.7 or newer. -final class CXPlatformAvailability extends ffi.Struct { - /// A string that describes the platform for which this structure - /// provides availability information. - /// - /// Possible values are "ios" or "macos". - external CXString Platform; + /// OpenMP distribute parallel for simd directive. + CXCursor_OMPDistributeParallelForSimdDirective(267), - /// The version number in which this entity was introduced. - external CXVersion Introduced; + /// OpenMP distribute simd directive. + CXCursor_OMPDistributeSimdDirective(268), - /// The version number in which this entity was deprecated (but is - /// still available). - external CXVersion Deprecated; + /// OpenMP target parallel for simd directive. + CXCursor_OMPTargetParallelForSimdDirective(269), - /// The version number in which this entity was obsoleted, and therefore - /// is no longer available. - external CXVersion Obsoleted; + /// OpenMP target simd directive. + CXCursor_OMPTargetSimdDirective(270), - /// Whether the entity is unconditionally unavailable on this platform. - @ffi.Int() - external int Unavailable; + /// OpenMP teams distribute directive. + CXCursor_OMPTeamsDistributeDirective(271), - /// An optional message to provide to a user of this API, e.g., to - /// suggest replacement APIs. - external CXString Message; -} + /// OpenMP teams distribute simd directive. + CXCursor_OMPTeamsDistributeSimdDirective(272), + + /// OpenMP teams distribute parallel for simd directive. + CXCursor_OMPTeamsDistributeParallelForSimdDirective(273), + + /// OpenMP teams distribute parallel for directive. + CXCursor_OMPTeamsDistributeParallelForDirective(274), + + /// OpenMP target teams directive. + CXCursor_OMPTargetTeamsDirective(275), + + /// OpenMP target teams distribute directive. + CXCursor_OMPTargetTeamsDistributeDirective(276), + + /// OpenMP target teams distribute parallel for directive. + CXCursor_OMPTargetTeamsDistributeParallelForDirective(277), + + /// OpenMP target teams distribute parallel for simd directive. + CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective(278), + + /// OpenMP target teams distribute simd directive. + CXCursor_OMPTargetTeamsDistributeSimdDirective(279), -typedef NativeClang_getCursorPlatformAvailability = - ffi.Int Function( - CXCursor cursor, - ffi.Pointer always_deprecated, - ffi.Pointer deprecated_message, - ffi.Pointer always_unavailable, - ffi.Pointer unavailable_message, - ffi.Pointer availability, - ffi.Int availability_size, - ); -typedef DartClang_getCursorPlatformAvailability = - int Function( - CXCursor cursor, - ffi.Pointer always_deprecated, - ffi.Pointer deprecated_message, - ffi.Pointer always_unavailable, - ffi.Pointer unavailable_message, - ffi.Pointer availability, - int availability_size, - ); -typedef NativeClang_disposeCXPlatformAvailability = - ffi.Void Function(ffi.Pointer availability); -typedef DartClang_disposeCXPlatformAvailability = - void Function(ffi.Pointer availability); + /// C++2a std::bit_cast expression. + CXCursor_BuiltinBitCastExpr(280), -/// Describe the "language" of the entity referred to by a cursor. -enum CXLanguageKind { - CXLanguage_Invalid(0), - CXLanguage_C(1), - CXLanguage_ObjC(2), - CXLanguage_CPlusPlus(3); + /// OpenMP master taskloop directive. + CXCursor_OMPMasterTaskLoopDirective(281), - final int value; - const CXLanguageKind(this.value); + /// OpenMP parallel master taskloop directive. + CXCursor_OMPParallelMasterTaskLoopDirective(282), - static CXLanguageKind fromValue(int value) => switch (value) { - 0 => CXLanguage_Invalid, - 1 => CXLanguage_C, - 2 => CXLanguage_ObjC, - 3 => CXLanguage_CPlusPlus, - _ => throw ArgumentError('Unknown value for CXLanguageKind: $value'), - }; -} + /// OpenMP master taskloop simd directive. + CXCursor_OMPMasterTaskLoopSimdDirective(283), -typedef NativeClang_getCursorLanguage = - ffi.UnsignedInt Function(CXCursor cursor); -typedef DartClang_getCursorLanguage = int Function(CXCursor cursor); + /// OpenMP parallel master taskloop simd directive. + CXCursor_OMPParallelMasterTaskLoopSimdDirective(284), -/// Describe the "thread-local storage (TLS) kind" of the declaration -/// referred to by a cursor. -enum CXTLSKind { - CXTLS_None(0), - CXTLS_Dynamic(1), - CXTLS_Static(2); + /// OpenMP parallel master directive. + CXCursor_OMPParallelMasterDirective(285), - final int value; - const CXTLSKind(this.value); + /// Cursor that represents the translation unit itself. + /// + /// The translation unit cursor exists primarily to act as the root + /// cursor for traversing the contents of a translation unit. + CXCursor_TranslationUnit(300), + CXCursor_FirstAttr(400), + CXCursor_IBActionAttr(401), + CXCursor_IBOutletAttr(402), + CXCursor_IBOutletCollectionAttr(403), + CXCursor_CXXFinalAttr(404), + CXCursor_CXXOverrideAttr(405), + CXCursor_AnnotateAttr(406), + CXCursor_AsmLabelAttr(407), + CXCursor_PackedAttr(408), + CXCursor_PureAttr(409), + CXCursor_ConstAttr(410), + CXCursor_NoDuplicateAttr(411), + CXCursor_CUDAConstantAttr(412), + CXCursor_CUDADeviceAttr(413), + CXCursor_CUDAGlobalAttr(414), + CXCursor_CUDAHostAttr(415), + CXCursor_CUDASharedAttr(416), + CXCursor_VisibilityAttr(417), + CXCursor_DLLExport(418), + CXCursor_DLLImport(419), + CXCursor_NSReturnsRetained(420), + CXCursor_NSReturnsNotRetained(421), + CXCursor_NSReturnsAutoreleased(422), + CXCursor_NSConsumesSelf(423), + CXCursor_NSConsumed(424), + CXCursor_ObjCException(425), + CXCursor_ObjCNSObject(426), + CXCursor_ObjCIndependentClass(427), + CXCursor_ObjCPreciseLifetime(428), + CXCursor_ObjCReturnsInnerPointer(429), + CXCursor_ObjCRequiresSuper(430), + CXCursor_ObjCRootClass(431), + CXCursor_ObjCSubclassingRestricted(432), + CXCursor_ObjCExplicitProtocolImpl(433), + CXCursor_ObjCDesignatedInitializer(434), + CXCursor_ObjCRuntimeVisible(435), + CXCursor_ObjCBoxable(436), + CXCursor_FlagEnum(437), + CXCursor_ConvergentAttr(438), + CXCursor_WarnUnusedAttr(439), + CXCursor_WarnUnusedResultAttr(440), + CXCursor_AlignedAttr(441), + CXCursor_PreprocessingDirective(500), + CXCursor_MacroDefinition(501), + CXCursor_MacroExpansion(502), + CXCursor_InclusionDirective(503), - static CXTLSKind fromValue(int value) => switch (value) { - 0 => CXTLS_None, - 1 => CXTLS_Dynamic, - 2 => CXTLS_Static, - _ => throw ArgumentError('Unknown value for CXTLSKind: $value'), - }; -} + /// A module import declaration. + CXCursor_ModuleImportDecl(600), + CXCursor_TypeAliasTemplateDecl(601), -typedef NativeClang_getCursorTLSKind = - ffi.UnsignedInt Function(CXCursor cursor); -typedef DartClang_getCursorTLSKind = int Function(CXCursor cursor); -typedef NativeClang_Cursor_getTranslationUnit = - CXTranslationUnit Function(CXCursor); -typedef DartClang_Cursor_getTranslationUnit = - CXTranslationUnit Function(CXCursor); + /// A static_assert or _Static_assert node + CXCursor_StaticAssert(602), -/// A fast container representing a set of CXCursors. -typedef CXCursorSet = ffi.Pointer; -typedef NativeClang_createCXCursorSet = CXCursorSet Function(); -typedef DartClang_createCXCursorSet = CXCursorSet Function(); -typedef NativeClang_disposeCXCursorSet = ffi.Void Function(CXCursorSet cset); -typedef DartClang_disposeCXCursorSet = void Function(CXCursorSet cset); -typedef NativeClang_CXCursorSet_contains = - ffi.UnsignedInt Function(CXCursorSet cset, CXCursor cursor); -typedef DartClang_CXCursorSet_contains = - int Function(CXCursorSet cset, CXCursor cursor); -typedef NativeClang_CXCursorSet_insert = - ffi.UnsignedInt Function(CXCursorSet cset, CXCursor cursor); -typedef DartClang_CXCursorSet_insert = - int Function(CXCursorSet cset, CXCursor cursor); -typedef NativeClang_getCursorSemanticParent = - CXCursor Function(CXCursor cursor); -typedef DartClang_getCursorSemanticParent = CXCursor Function(CXCursor cursor); -typedef NativeClang_getCursorLexicalParent = CXCursor Function(CXCursor cursor); -typedef DartClang_getCursorLexicalParent = CXCursor Function(CXCursor cursor); -typedef NativeClang_getOverriddenCursors = - ffi.Void Function( - CXCursor cursor, - ffi.Pointer> overridden, - ffi.Pointer num_overridden, - ); -typedef DartClang_getOverriddenCursors = - void Function( - CXCursor cursor, - ffi.Pointer> overridden, - ffi.Pointer num_overridden, - ); -typedef NativeClang_disposeOverriddenCursors = - ffi.Void Function(ffi.Pointer overridden); -typedef DartClang_disposeOverriddenCursors = - void Function(ffi.Pointer overridden); -typedef NativeClang_getIncludedFile = CXFile Function(CXCursor cursor); -typedef DartClang_getIncludedFile = CXFile Function(CXCursor cursor); -typedef NativeClang_getCursor = - CXCursor Function(CXTranslationUnit, CXSourceLocation); -typedef DartClang_getCursor = - CXCursor Function(CXTranslationUnit, CXSourceLocation); -typedef NativeClang_getCursorLocation = CXSourceLocation Function(CXCursor); -typedef DartClang_getCursorLocation = CXSourceLocation Function(CXCursor); -typedef NativeClang_getCursorExtent = CXSourceRange Function(CXCursor); -typedef DartClang_getCursorExtent = CXSourceRange Function(CXCursor); + /// a friend declaration. + CXCursor_FriendDecl(603), -/// Describes the kind of type -enum CXTypeKind { - /// Represents an invalid type (e.g., where no type is available). - CXType_Invalid(0), + /// A code completion overload candidate. + CXCursor_OverloadCandidate(700); - /// A type whose specific kind is not exposed via this + static const CXCursor_FirstDecl = CXCursor_UnexposedDecl; + static const CXCursor_LastDecl = CXCursor_CXXAccessSpecifier; + static const CXCursor_ObjCSuperClassRef = CXCursor_FirstRef; + static const CXCursor_LastRef = CXCursor_VariableRef; + static const CXCursor_InvalidFile = CXCursor_FirstInvalid; + static const CXCursor_LastInvalid = CXCursor_InvalidCode; + + /// An expression whose specific kind is not exposed via this /// interface. - CXType_Unexposed(1), - CXType_Void(2), - CXType_Bool(3), - CXType_Char_U(4), - CXType_UChar(5), - CXType_Char16(6), - CXType_Char32(7), - CXType_UShort(8), - CXType_UInt(9), - CXType_ULong(10), - CXType_ULongLong(11), - CXType_UInt128(12), - CXType_Char_S(13), - CXType_SChar(14), - CXType_WChar(15), - CXType_Short(16), - CXType_Int(17), - CXType_Long(18), - CXType_LongLong(19), - CXType_Int128(20), - CXType_Float(21), - CXType_Double(22), - CXType_LongDouble(23), - CXType_NullPtr(24), - CXType_Overload(25), - CXType_Dependent(26), - CXType_ObjCId(27), - CXType_ObjCClass(28), - CXType_ObjCSel(29), - CXType_Float128(30), - CXType_Half(31), - CXType_Float16(32), - CXType_ShortAccum(33), - CXType_Accum(34), - CXType_LongAccum(35), - CXType_UShortAccum(36), - CXType_UAccum(37), - CXType_ULongAccum(38), - CXType_Complex(100), - CXType_Pointer(101), - CXType_BlockPointer(102), - CXType_LValueReference(103), - CXType_RValueReference(104), - CXType_Record(105), - CXType_Enum(106), - CXType_Typedef(107), - CXType_ObjCInterface(108), - CXType_ObjCObjectPointer(109), - CXType_FunctionNoProto(110), - CXType_FunctionProto(111), - CXType_ConstantArray(112), - CXType_Vector(113), - CXType_IncompleteArray(114), - CXType_VariableArray(115), - CXType_DependentSizedArray(116), - CXType_MemberPointer(117), - CXType_Auto(118), + /// + /// Unexposed expressions have the same operations as any other kind + /// of expression; one can extract their location information, + /// spelling, children, etc. However, the specific kind of the + /// expression is not reported. + static const CXCursor_UnexposedExpr = CXCursor_FirstExpr; + static const CXCursor_LastExpr = CXCursor_FixedPointLiteral; - /// Represents a type that was referred to using an elaborated type keyword. + /// A statement whose specific kind is not exposed via this + /// interface. /// - /// E.g., struct S, or via a qualified name, e.g., N::M::type, or both. - CXType_Elaborated(119), - CXType_Pipe(120), - CXType_OCLImage1dRO(121), - CXType_OCLImage1dArrayRO(122), - CXType_OCLImage1dBufferRO(123), - CXType_OCLImage2dRO(124), - CXType_OCLImage2dArrayRO(125), - CXType_OCLImage2dDepthRO(126), - CXType_OCLImage2dArrayDepthRO(127), - CXType_OCLImage2dMSAARO(128), - CXType_OCLImage2dArrayMSAARO(129), - CXType_OCLImage2dMSAADepthRO(130), - CXType_OCLImage2dArrayMSAADepthRO(131), - CXType_OCLImage3dRO(132), - CXType_OCLImage1dWO(133), - CXType_OCLImage1dArrayWO(134), - CXType_OCLImage1dBufferWO(135), - CXType_OCLImage2dWO(136), - CXType_OCLImage2dArrayWO(137), - CXType_OCLImage2dDepthWO(138), - CXType_OCLImage2dArrayDepthWO(139), - CXType_OCLImage2dMSAAWO(140), - CXType_OCLImage2dArrayMSAAWO(141), - CXType_OCLImage2dMSAADepthWO(142), - CXType_OCLImage2dArrayMSAADepthWO(143), - CXType_OCLImage3dWO(144), - CXType_OCLImage1dRW(145), - CXType_OCLImage1dArrayRW(146), - CXType_OCLImage1dBufferRW(147), - CXType_OCLImage2dRW(148), - CXType_OCLImage2dArrayRW(149), - CXType_OCLImage2dDepthRW(150), - CXType_OCLImage2dArrayDepthRW(151), - CXType_OCLImage2dMSAARW(152), - CXType_OCLImage2dArrayMSAARW(153), - CXType_OCLImage2dMSAADepthRW(154), - CXType_OCLImage2dArrayMSAADepthRW(155), - CXType_OCLImage3dRW(156), - CXType_OCLSampler(157), - CXType_OCLEvent(158), - CXType_OCLQueue(159), - CXType_OCLReserveID(160), - CXType_ObjCObject(161), - CXType_ObjCTypeParam(162), - CXType_Attributed(163), - CXType_OCLIntelSubgroupAVCMcePayload(164), - CXType_OCLIntelSubgroupAVCImePayload(165), - CXType_OCLIntelSubgroupAVCRefPayload(166), - CXType_OCLIntelSubgroupAVCSicPayload(167), - CXType_OCLIntelSubgroupAVCMceResult(168), - CXType_OCLIntelSubgroupAVCImeResult(169), - CXType_OCLIntelSubgroupAVCRefResult(170), - CXType_OCLIntelSubgroupAVCSicResult(171), - CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout(172), - CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout(173), - CXType_OCLIntelSubgroupAVCImeSingleRefStreamin(174), - CXType_OCLIntelSubgroupAVCImeDualRefStreamin(175), - CXType_ExtVector(176); + /// Unexposed statements have the same operations as any other kind of + /// statement; one can extract their location information, spelling, + /// children, etc. However, the specific kind of the statement is not + /// reported. + static const CXCursor_UnexposedStmt = CXCursor_FirstStmt; + static const CXCursor_AsmStmt = CXCursor_GCCAsmStmt; + static const CXCursor_LastStmt = CXCursor_OMPParallelMasterDirective; - static const CXType_FirstBuiltin = CXType_Void; - static const CXType_LastBuiltin = CXType_ULongAccum; + /// An attribute whose specific kind is not exposed via this + /// interface. + static const CXCursor_UnexposedAttr = CXCursor_FirstAttr; + static const CXCursor_LastAttr = CXCursor_AlignedAttr; + static const CXCursor_MacroInstantiation = CXCursor_MacroExpansion; + static const CXCursor_FirstPreprocessing = CXCursor_PreprocessingDirective; + static const CXCursor_LastPreprocessing = CXCursor_InclusionDirective; + static const CXCursor_FirstExtraDecl = CXCursor_ModuleImportDecl; + static const CXCursor_LastExtraDecl = CXCursor_FriendDecl; final int value; - const CXTypeKind(this.value); + const CXCursorKind(this.value); - static CXTypeKind fromValue(int value) => switch (value) { - 0 => CXType_Invalid, - 1 => CXType_Unexposed, - 2 => CXType_Void, - 3 => CXType_Bool, - 4 => CXType_Char_U, - 5 => CXType_UChar, - 6 => CXType_Char16, - 7 => CXType_Char32, - 8 => CXType_UShort, - 9 => CXType_UInt, - 10 => CXType_ULong, - 11 => CXType_ULongLong, - 12 => CXType_UInt128, - 13 => CXType_Char_S, - 14 => CXType_SChar, - 15 => CXType_WChar, - 16 => CXType_Short, - 17 => CXType_Int, - 18 => CXType_Long, - 19 => CXType_LongLong, - 20 => CXType_Int128, - 21 => CXType_Float, - 22 => CXType_Double, - 23 => CXType_LongDouble, - 24 => CXType_NullPtr, - 25 => CXType_Overload, - 26 => CXType_Dependent, - 27 => CXType_ObjCId, - 28 => CXType_ObjCClass, - 29 => CXType_ObjCSel, - 30 => CXType_Float128, - 31 => CXType_Half, - 32 => CXType_Float16, - 33 => CXType_ShortAccum, - 34 => CXType_Accum, - 35 => CXType_LongAccum, - 36 => CXType_UShortAccum, - 37 => CXType_UAccum, - 38 => CXType_ULongAccum, - 100 => CXType_Complex, - 101 => CXType_Pointer, - 102 => CXType_BlockPointer, - 103 => CXType_LValueReference, - 104 => CXType_RValueReference, - 105 => CXType_Record, - 106 => CXType_Enum, - 107 => CXType_Typedef, - 108 => CXType_ObjCInterface, - 109 => CXType_ObjCObjectPointer, - 110 => CXType_FunctionNoProto, - 111 => CXType_FunctionProto, - 112 => CXType_ConstantArray, - 113 => CXType_Vector, - 114 => CXType_IncompleteArray, - 115 => CXType_VariableArray, - 116 => CXType_DependentSizedArray, - 117 => CXType_MemberPointer, - 118 => CXType_Auto, - 119 => CXType_Elaborated, - 120 => CXType_Pipe, - 121 => CXType_OCLImage1dRO, - 122 => CXType_OCLImage1dArrayRO, - 123 => CXType_OCLImage1dBufferRO, - 124 => CXType_OCLImage2dRO, - 125 => CXType_OCLImage2dArrayRO, - 126 => CXType_OCLImage2dDepthRO, - 127 => CXType_OCLImage2dArrayDepthRO, - 128 => CXType_OCLImage2dMSAARO, - 129 => CXType_OCLImage2dArrayMSAARO, - 130 => CXType_OCLImage2dMSAADepthRO, - 131 => CXType_OCLImage2dArrayMSAADepthRO, - 132 => CXType_OCLImage3dRO, - 133 => CXType_OCLImage1dWO, - 134 => CXType_OCLImage1dArrayWO, - 135 => CXType_OCLImage1dBufferWO, - 136 => CXType_OCLImage2dWO, - 137 => CXType_OCLImage2dArrayWO, - 138 => CXType_OCLImage2dDepthWO, - 139 => CXType_OCLImage2dArrayDepthWO, - 140 => CXType_OCLImage2dMSAAWO, - 141 => CXType_OCLImage2dArrayMSAAWO, - 142 => CXType_OCLImage2dMSAADepthWO, - 143 => CXType_OCLImage2dArrayMSAADepthWO, - 144 => CXType_OCLImage3dWO, - 145 => CXType_OCLImage1dRW, - 146 => CXType_OCLImage1dArrayRW, - 147 => CXType_OCLImage1dBufferRW, - 148 => CXType_OCLImage2dRW, - 149 => CXType_OCLImage2dArrayRW, - 150 => CXType_OCLImage2dDepthRW, - 151 => CXType_OCLImage2dArrayDepthRW, - 152 => CXType_OCLImage2dMSAARW, - 153 => CXType_OCLImage2dArrayMSAARW, - 154 => CXType_OCLImage2dMSAADepthRW, - 155 => CXType_OCLImage2dArrayMSAADepthRW, - 156 => CXType_OCLImage3dRW, - 157 => CXType_OCLSampler, - 158 => CXType_OCLEvent, - 159 => CXType_OCLQueue, - 160 => CXType_OCLReserveID, - 161 => CXType_ObjCObject, - 162 => CXType_ObjCTypeParam, - 163 => CXType_Attributed, - 164 => CXType_OCLIntelSubgroupAVCMcePayload, - 165 => CXType_OCLIntelSubgroupAVCImePayload, - 166 => CXType_OCLIntelSubgroupAVCRefPayload, - 167 => CXType_OCLIntelSubgroupAVCSicPayload, - 168 => CXType_OCLIntelSubgroupAVCMceResult, - 169 => CXType_OCLIntelSubgroupAVCImeResult, - 170 => CXType_OCLIntelSubgroupAVCRefResult, - 171 => CXType_OCLIntelSubgroupAVCSicResult, - 172 => CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout, - 173 => CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout, - 174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin, - 175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin, - 176 => CXType_ExtVector, - _ => throw ArgumentError('Unknown value for CXTypeKind: $value'), + static CXCursorKind fromValue(int value) => switch (value) { + 1 => CXCursor_UnexposedDecl, + 2 => CXCursor_StructDecl, + 3 => CXCursor_UnionDecl, + 4 => CXCursor_ClassDecl, + 5 => CXCursor_EnumDecl, + 6 => CXCursor_FieldDecl, + 7 => CXCursor_EnumConstantDecl, + 8 => CXCursor_FunctionDecl, + 9 => CXCursor_VarDecl, + 10 => CXCursor_ParmDecl, + 11 => CXCursor_ObjCInterfaceDecl, + 12 => CXCursor_ObjCCategoryDecl, + 13 => CXCursor_ObjCProtocolDecl, + 14 => CXCursor_ObjCPropertyDecl, + 15 => CXCursor_ObjCIvarDecl, + 16 => CXCursor_ObjCInstanceMethodDecl, + 17 => CXCursor_ObjCClassMethodDecl, + 18 => CXCursor_ObjCImplementationDecl, + 19 => CXCursor_ObjCCategoryImplDecl, + 20 => CXCursor_TypedefDecl, + 21 => CXCursor_CXXMethod, + 22 => CXCursor_Namespace, + 23 => CXCursor_LinkageSpec, + 24 => CXCursor_Constructor, + 25 => CXCursor_Destructor, + 26 => CXCursor_ConversionFunction, + 27 => CXCursor_TemplateTypeParameter, + 28 => CXCursor_NonTypeTemplateParameter, + 29 => CXCursor_TemplateTemplateParameter, + 30 => CXCursor_FunctionTemplate, + 31 => CXCursor_ClassTemplate, + 32 => CXCursor_ClassTemplatePartialSpecialization, + 33 => CXCursor_NamespaceAlias, + 34 => CXCursor_UsingDirective, + 35 => CXCursor_UsingDeclaration, + 36 => CXCursor_TypeAliasDecl, + 37 => CXCursor_ObjCSynthesizeDecl, + 38 => CXCursor_ObjCDynamicDecl, + 39 => CXCursor_CXXAccessSpecifier, + 40 => CXCursor_FirstRef, + 41 => CXCursor_ObjCProtocolRef, + 42 => CXCursor_ObjCClassRef, + 43 => CXCursor_TypeRef, + 44 => CXCursor_CXXBaseSpecifier, + 45 => CXCursor_TemplateRef, + 46 => CXCursor_NamespaceRef, + 47 => CXCursor_MemberRef, + 48 => CXCursor_LabelRef, + 49 => CXCursor_OverloadedDeclRef, + 50 => CXCursor_VariableRef, + 70 => CXCursor_FirstInvalid, + 71 => CXCursor_NoDeclFound, + 72 => CXCursor_NotImplemented, + 73 => CXCursor_InvalidCode, + 100 => CXCursor_FirstExpr, + 101 => CXCursor_DeclRefExpr, + 102 => CXCursor_MemberRefExpr, + 103 => CXCursor_CallExpr, + 104 => CXCursor_ObjCMessageExpr, + 105 => CXCursor_BlockExpr, + 106 => CXCursor_IntegerLiteral, + 107 => CXCursor_FloatingLiteral, + 108 => CXCursor_ImaginaryLiteral, + 109 => CXCursor_StringLiteral, + 110 => CXCursor_CharacterLiteral, + 111 => CXCursor_ParenExpr, + 112 => CXCursor_UnaryOperator, + 113 => CXCursor_ArraySubscriptExpr, + 114 => CXCursor_BinaryOperator, + 115 => CXCursor_CompoundAssignOperator, + 116 => CXCursor_ConditionalOperator, + 117 => CXCursor_CStyleCastExpr, + 118 => CXCursor_CompoundLiteralExpr, + 119 => CXCursor_InitListExpr, + 120 => CXCursor_AddrLabelExpr, + 121 => CXCursor_StmtExpr, + 122 => CXCursor_GenericSelectionExpr, + 123 => CXCursor_GNUNullExpr, + 124 => CXCursor_CXXStaticCastExpr, + 125 => CXCursor_CXXDynamicCastExpr, + 126 => CXCursor_CXXReinterpretCastExpr, + 127 => CXCursor_CXXConstCastExpr, + 128 => CXCursor_CXXFunctionalCastExpr, + 129 => CXCursor_CXXTypeidExpr, + 130 => CXCursor_CXXBoolLiteralExpr, + 131 => CXCursor_CXXNullPtrLiteralExpr, + 132 => CXCursor_CXXThisExpr, + 133 => CXCursor_CXXThrowExpr, + 134 => CXCursor_CXXNewExpr, + 135 => CXCursor_CXXDeleteExpr, + 136 => CXCursor_UnaryExpr, + 137 => CXCursor_ObjCStringLiteral, + 138 => CXCursor_ObjCEncodeExpr, + 139 => CXCursor_ObjCSelectorExpr, + 140 => CXCursor_ObjCProtocolExpr, + 141 => CXCursor_ObjCBridgedCastExpr, + 142 => CXCursor_PackExpansionExpr, + 143 => CXCursor_SizeOfPackExpr, + 144 => CXCursor_LambdaExpr, + 145 => CXCursor_ObjCBoolLiteralExpr, + 146 => CXCursor_ObjCSelfExpr, + 147 => CXCursor_OMPArraySectionExpr, + 148 => CXCursor_ObjCAvailabilityCheckExpr, + 149 => CXCursor_FixedPointLiteral, + 200 => CXCursor_FirstStmt, + 201 => CXCursor_LabelStmt, + 202 => CXCursor_CompoundStmt, + 203 => CXCursor_CaseStmt, + 204 => CXCursor_DefaultStmt, + 205 => CXCursor_IfStmt, + 206 => CXCursor_SwitchStmt, + 207 => CXCursor_WhileStmt, + 208 => CXCursor_DoStmt, + 209 => CXCursor_ForStmt, + 210 => CXCursor_GotoStmt, + 211 => CXCursor_IndirectGotoStmt, + 212 => CXCursor_ContinueStmt, + 213 => CXCursor_BreakStmt, + 214 => CXCursor_ReturnStmt, + 215 => CXCursor_GCCAsmStmt, + 216 => CXCursor_ObjCAtTryStmt, + 217 => CXCursor_ObjCAtCatchStmt, + 218 => CXCursor_ObjCAtFinallyStmt, + 219 => CXCursor_ObjCAtThrowStmt, + 220 => CXCursor_ObjCAtSynchronizedStmt, + 221 => CXCursor_ObjCAutoreleasePoolStmt, + 222 => CXCursor_ObjCForCollectionStmt, + 223 => CXCursor_CXXCatchStmt, + 224 => CXCursor_CXXTryStmt, + 225 => CXCursor_CXXForRangeStmt, + 226 => CXCursor_SEHTryStmt, + 227 => CXCursor_SEHExceptStmt, + 228 => CXCursor_SEHFinallyStmt, + 229 => CXCursor_MSAsmStmt, + 230 => CXCursor_NullStmt, + 231 => CXCursor_DeclStmt, + 232 => CXCursor_OMPParallelDirective, + 233 => CXCursor_OMPSimdDirective, + 234 => CXCursor_OMPForDirective, + 235 => CXCursor_OMPSectionsDirective, + 236 => CXCursor_OMPSectionDirective, + 237 => CXCursor_OMPSingleDirective, + 238 => CXCursor_OMPParallelForDirective, + 239 => CXCursor_OMPParallelSectionsDirective, + 240 => CXCursor_OMPTaskDirective, + 241 => CXCursor_OMPMasterDirective, + 242 => CXCursor_OMPCriticalDirective, + 243 => CXCursor_OMPTaskyieldDirective, + 244 => CXCursor_OMPBarrierDirective, + 245 => CXCursor_OMPTaskwaitDirective, + 246 => CXCursor_OMPFlushDirective, + 247 => CXCursor_SEHLeaveStmt, + 248 => CXCursor_OMPOrderedDirective, + 249 => CXCursor_OMPAtomicDirective, + 250 => CXCursor_OMPForSimdDirective, + 251 => CXCursor_OMPParallelForSimdDirective, + 252 => CXCursor_OMPTargetDirective, + 253 => CXCursor_OMPTeamsDirective, + 254 => CXCursor_OMPTaskgroupDirective, + 255 => CXCursor_OMPCancellationPointDirective, + 256 => CXCursor_OMPCancelDirective, + 257 => CXCursor_OMPTargetDataDirective, + 258 => CXCursor_OMPTaskLoopDirective, + 259 => CXCursor_OMPTaskLoopSimdDirective, + 260 => CXCursor_OMPDistributeDirective, + 261 => CXCursor_OMPTargetEnterDataDirective, + 262 => CXCursor_OMPTargetExitDataDirective, + 263 => CXCursor_OMPTargetParallelDirective, + 264 => CXCursor_OMPTargetParallelForDirective, + 265 => CXCursor_OMPTargetUpdateDirective, + 266 => CXCursor_OMPDistributeParallelForDirective, + 267 => CXCursor_OMPDistributeParallelForSimdDirective, + 268 => CXCursor_OMPDistributeSimdDirective, + 269 => CXCursor_OMPTargetParallelForSimdDirective, + 270 => CXCursor_OMPTargetSimdDirective, + 271 => CXCursor_OMPTeamsDistributeDirective, + 272 => CXCursor_OMPTeamsDistributeSimdDirective, + 273 => CXCursor_OMPTeamsDistributeParallelForSimdDirective, + 274 => CXCursor_OMPTeamsDistributeParallelForDirective, + 275 => CXCursor_OMPTargetTeamsDirective, + 276 => CXCursor_OMPTargetTeamsDistributeDirective, + 277 => CXCursor_OMPTargetTeamsDistributeParallelForDirective, + 278 => CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective, + 279 => CXCursor_OMPTargetTeamsDistributeSimdDirective, + 280 => CXCursor_BuiltinBitCastExpr, + 281 => CXCursor_OMPMasterTaskLoopDirective, + 282 => CXCursor_OMPParallelMasterTaskLoopDirective, + 283 => CXCursor_OMPMasterTaskLoopSimdDirective, + 284 => CXCursor_OMPParallelMasterTaskLoopSimdDirective, + 285 => CXCursor_OMPParallelMasterDirective, + 300 => CXCursor_TranslationUnit, + 400 => CXCursor_FirstAttr, + 401 => CXCursor_IBActionAttr, + 402 => CXCursor_IBOutletAttr, + 403 => CXCursor_IBOutletCollectionAttr, + 404 => CXCursor_CXXFinalAttr, + 405 => CXCursor_CXXOverrideAttr, + 406 => CXCursor_AnnotateAttr, + 407 => CXCursor_AsmLabelAttr, + 408 => CXCursor_PackedAttr, + 409 => CXCursor_PureAttr, + 410 => CXCursor_ConstAttr, + 411 => CXCursor_NoDuplicateAttr, + 412 => CXCursor_CUDAConstantAttr, + 413 => CXCursor_CUDADeviceAttr, + 414 => CXCursor_CUDAGlobalAttr, + 415 => CXCursor_CUDAHostAttr, + 416 => CXCursor_CUDASharedAttr, + 417 => CXCursor_VisibilityAttr, + 418 => CXCursor_DLLExport, + 419 => CXCursor_DLLImport, + 420 => CXCursor_NSReturnsRetained, + 421 => CXCursor_NSReturnsNotRetained, + 422 => CXCursor_NSReturnsAutoreleased, + 423 => CXCursor_NSConsumesSelf, + 424 => CXCursor_NSConsumed, + 425 => CXCursor_ObjCException, + 426 => CXCursor_ObjCNSObject, + 427 => CXCursor_ObjCIndependentClass, + 428 => CXCursor_ObjCPreciseLifetime, + 429 => CXCursor_ObjCReturnsInnerPointer, + 430 => CXCursor_ObjCRequiresSuper, + 431 => CXCursor_ObjCRootClass, + 432 => CXCursor_ObjCSubclassingRestricted, + 433 => CXCursor_ObjCExplicitProtocolImpl, + 434 => CXCursor_ObjCDesignatedInitializer, + 435 => CXCursor_ObjCRuntimeVisible, + 436 => CXCursor_ObjCBoxable, + 437 => CXCursor_FlagEnum, + 438 => CXCursor_ConvergentAttr, + 439 => CXCursor_WarnUnusedAttr, + 440 => CXCursor_WarnUnusedResultAttr, + 441 => CXCursor_AlignedAttr, + 500 => CXCursor_PreprocessingDirective, + 501 => CXCursor_MacroDefinition, + 502 => CXCursor_MacroExpansion, + 503 => CXCursor_InclusionDirective, + 600 => CXCursor_ModuleImportDecl, + 601 => CXCursor_TypeAliasTemplateDecl, + 602 => CXCursor_StaticAssert, + 603 => CXCursor_FriendDecl, + 700 => CXCursor_OverloadCandidate, + _ => throw ArgumentError('Unknown value for CXCursorKind: $value'), }; @override String toString() { - if (this == CXType_Void) - return "CXTypeKind.CXType_Void, CXTypeKind.CXType_FirstBuiltin"; - if (this == CXType_ULongAccum) - return "CXTypeKind.CXType_ULongAccum, CXTypeKind.CXType_LastBuiltin"; - return super.toString(); - } -} - -/// Describes the calling convention of a function type -enum CXCallingConv { - CXCallingConv_Default(0), - CXCallingConv_C(1), - CXCallingConv_X86StdCall(2), - CXCallingConv_X86FastCall(3), - CXCallingConv_X86ThisCall(4), - CXCallingConv_X86Pascal(5), - CXCallingConv_AAPCS(6), - CXCallingConv_AAPCS_VFP(7), - CXCallingConv_X86RegCall(8), - CXCallingConv_IntelOclBicc(9), - CXCallingConv_Win64(10), - CXCallingConv_X86_64SysV(11), - CXCallingConv_X86VectorCall(12), - CXCallingConv_Swift(13), - CXCallingConv_PreserveMost(14), - CXCallingConv_PreserveAll(15), - CXCallingConv_AArch64VectorCall(16), - CXCallingConv_Invalid(100), - CXCallingConv_Unexposed(200); + if (this == CXCursor_UnexposedDecl) + return "CXCursorKind.CXCursor_UnexposedDecl, CXCursorKind.CXCursor_FirstDecl"; + if (this == CXCursor_CXXAccessSpecifier) + return "CXCursorKind.CXCursor_CXXAccessSpecifier, CXCursorKind.CXCursor_LastDecl"; + if (this == CXCursor_FirstRef) + return "CXCursorKind.CXCursor_FirstRef, CXCursorKind.CXCursor_ObjCSuperClassRef"; + if (this == CXCursor_VariableRef) + return "CXCursorKind.CXCursor_VariableRef, CXCursorKind.CXCursor_LastRef"; + if (this == CXCursor_FirstInvalid) + return "CXCursorKind.CXCursor_FirstInvalid, CXCursorKind.CXCursor_InvalidFile"; + if (this == CXCursor_InvalidCode) + return "CXCursorKind.CXCursor_InvalidCode, CXCursorKind.CXCursor_LastInvalid"; + if (this == CXCursor_FirstExpr) + return "CXCursorKind.CXCursor_FirstExpr, CXCursorKind.CXCursor_UnexposedExpr"; + if (this == CXCursor_FixedPointLiteral) + return "CXCursorKind.CXCursor_FixedPointLiteral, CXCursorKind.CXCursor_LastExpr"; + if (this == CXCursor_FirstStmt) + return "CXCursorKind.CXCursor_FirstStmt, CXCursorKind.CXCursor_UnexposedStmt"; + if (this == CXCursor_GCCAsmStmt) + return "CXCursorKind.CXCursor_GCCAsmStmt, CXCursorKind.CXCursor_AsmStmt"; + if (this == CXCursor_OMPParallelMasterDirective) + return "CXCursorKind.CXCursor_OMPParallelMasterDirective, CXCursorKind.CXCursor_LastStmt"; + if (this == CXCursor_FirstAttr) + return "CXCursorKind.CXCursor_FirstAttr, CXCursorKind.CXCursor_UnexposedAttr"; + if (this == CXCursor_AlignedAttr) + return "CXCursorKind.CXCursor_AlignedAttr, CXCursorKind.CXCursor_LastAttr"; + if (this == CXCursor_PreprocessingDirective) + return "CXCursorKind.CXCursor_PreprocessingDirective, CXCursorKind.CXCursor_FirstPreprocessing"; + if (this == CXCursor_MacroExpansion) + return "CXCursorKind.CXCursor_MacroExpansion, CXCursorKind.CXCursor_MacroInstantiation"; + if (this == CXCursor_InclusionDirective) + return "CXCursorKind.CXCursor_InclusionDirective, CXCursorKind.CXCursor_LastPreprocessing"; + if (this == CXCursor_ModuleImportDecl) + return "CXCursorKind.CXCursor_ModuleImportDecl, CXCursorKind.CXCursor_FirstExtraDecl"; + if (this == CXCursor_FriendDecl) + return "CXCursorKind.CXCursor_FriendDecl, CXCursorKind.CXCursor_LastExtraDecl"; + return super.toString(); + } +} - static const CXCallingConv_X86_64Win64 = CXCallingConv_Win64; +/// A fast container representing a set of CXCursors. +typedef CXCursorSet = ffi.Pointer; - final int value; - const CXCallingConv(this.value); +/// Visitor invoked for each cursor found by a traversal. +/// +/// This visitor function will be invoked for each cursor found by +/// clang_visitCursorChildren(). Its first argument is the cursor being +/// visited, its second argument is the parent visitor for that cursor, +/// and its third argument is the client data provided to +/// clang_visitCursorChildren(). +/// +/// The visitor should return one of the \c CXChildVisitResult values +/// to direct clang_visitCursorChildren(). +typedef CXCursorVisitor = + ffi.Pointer>; +typedef CXCursorVisitorFunction = + ffi.UnsignedInt Function( + CXCursor cursor, + CXCursor parent, + CXClientData client_data, + ); +typedef DartCXCursorVisitorFunction = + CXChildVisitResult Function( + CXCursor cursor, + CXCursor parent, + CXClientData client_data, + ); - static CXCallingConv fromValue(int value) => switch (value) { - 0 => CXCallingConv_Default, - 1 => CXCallingConv_C, - 2 => CXCallingConv_X86StdCall, - 3 => CXCallingConv_X86FastCall, - 4 => CXCallingConv_X86ThisCall, - 5 => CXCallingConv_X86Pascal, - 6 => CXCallingConv_AAPCS, - 7 => CXCallingConv_AAPCS_VFP, - 8 => CXCallingConv_X86RegCall, - 9 => CXCallingConv_IntelOclBicc, - 10 => CXCallingConv_Win64, - 11 => CXCallingConv_X86_64SysV, - 12 => CXCallingConv_X86VectorCall, - 13 => CXCallingConv_Swift, - 14 => CXCallingConv_PreserveMost, - 15 => CXCallingConv_PreserveAll, - 16 => CXCallingConv_AArch64VectorCall, - 100 => CXCallingConv_Invalid, - 200 => CXCallingConv_Unexposed, - _ => throw ArgumentError('Unknown value for CXCallingConv: $value'), - }; +/// A single diagnostic, containing the diagnostic's severity, +/// location, text, source ranges, and fix-it hints. +typedef CXDiagnostic = ffi.Pointer; - @override - String toString() { - if (this == CXCallingConv_Win64) - return "CXCallingConv.CXCallingConv_Win64, CXCallingConv.CXCallingConv_X86_64Win64"; - return super.toString(); - } -} +/// A group of CXDiagnostics. +typedef CXDiagnosticSet = ffi.Pointer; -/// The type of an element in the abstract syntax tree. -final class CXType extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; +/// Describes the severity of a particular diagnostic. +enum CXDiagnosticSeverity { + /// A diagnostic that has been suppressed, e.g., by a command-line + /// option. + CXDiagnostic_Ignored(0), - CXTypeKind get kind => CXTypeKind.fromValue(kindAsInt); - set kind(CXTypeKind value) => kindAsInt = value.value; + /// This diagnostic is a note that should be attached to the + /// previous (non-note) diagnostic. + CXDiagnostic_Note(1), - @ffi.Array.multi([2]) - external ffi.Array> data; -} + /// This diagnostic indicates suspicious code that may not be + /// wrong. + CXDiagnostic_Warning(2), -typedef NativeClang_getCursorType = CXType Function(CXCursor C); -typedef DartClang_getCursorType = CXType Function(CXCursor C); -typedef NativeClang_getTypeSpelling = CXString Function(CXType CT); -typedef DartClang_getTypeSpelling = CXString Function(CXType CT); -typedef NativeClang_getTypedefDeclUnderlyingType = CXType Function(CXCursor C); -typedef DartClang_getTypedefDeclUnderlyingType = CXType Function(CXCursor C); -typedef NativeClang_getEnumDeclIntegerType = CXType Function(CXCursor C); -typedef DartClang_getEnumDeclIntegerType = CXType Function(CXCursor C); -typedef NativeClang_getEnumConstantDeclValue = - ffi.LongLong Function(CXCursor C); -typedef DartClang_getEnumConstantDeclValue = int Function(CXCursor C); -typedef NativeClang_getEnumConstantDeclUnsignedValue = - ffi.UnsignedLongLong Function(CXCursor C); -typedef DartClang_getEnumConstantDeclUnsignedValue = int Function(CXCursor C); -typedef NativeClang_getFieldDeclBitWidth = ffi.Int Function(CXCursor C); -typedef DartClang_getFieldDeclBitWidth = int Function(CXCursor C); -typedef NativeClang_Cursor_getNumArguments = ffi.Int Function(CXCursor C); -typedef DartClang_Cursor_getNumArguments = int Function(CXCursor C); -typedef NativeClang_Cursor_getArgument = - CXCursor Function(CXCursor C, ffi.UnsignedInt i); -typedef DartClang_Cursor_getArgument = CXCursor Function(CXCursor C, int i); + /// This diagnostic indicates that the code is ill-formed. + CXDiagnostic_Error(3), -/// Describes the kind of a template argument. -/// -/// See the definition of llvm::clang::TemplateArgument::ArgKind for full -/// element descriptions. -enum CXTemplateArgumentKind { - CXTemplateArgumentKind_Null(0), - CXTemplateArgumentKind_Type(1), - CXTemplateArgumentKind_Declaration(2), - CXTemplateArgumentKind_NullPtr(3), - CXTemplateArgumentKind_Integral(4), - CXTemplateArgumentKind_Template(5), - CXTemplateArgumentKind_TemplateExpansion(6), - CXTemplateArgumentKind_Expression(7), - CXTemplateArgumentKind_Pack(8), - CXTemplateArgumentKind_Invalid(9); + /// This diagnostic indicates that the code is ill-formed such + /// that future parser recovery is unlikely to produce useful + /// results. + CXDiagnostic_Fatal(4); final int value; - const CXTemplateArgumentKind(this.value); - - static CXTemplateArgumentKind fromValue(int value) => switch (value) { - 0 => CXTemplateArgumentKind_Null, - 1 => CXTemplateArgumentKind_Type, - 2 => CXTemplateArgumentKind_Declaration, - 3 => CXTemplateArgumentKind_NullPtr, - 4 => CXTemplateArgumentKind_Integral, - 5 => CXTemplateArgumentKind_Template, - 6 => CXTemplateArgumentKind_TemplateExpansion, - 7 => CXTemplateArgumentKind_Expression, - 8 => CXTemplateArgumentKind_Pack, - 9 => CXTemplateArgumentKind_Invalid, - _ => throw ArgumentError( - 'Unknown value for CXTemplateArgumentKind: $value', - ), - }; -} + const CXDiagnosticSeverity(this.value); -typedef NativeClang_Cursor_getNumTemplateArguments = - ffi.Int Function(CXCursor C); -typedef DartClang_Cursor_getNumTemplateArguments = int Function(CXCursor C); -typedef NativeClang_Cursor_getTemplateArgumentKind = - ffi.UnsignedInt Function(CXCursor C, ffi.UnsignedInt I); -typedef DartClang_Cursor_getTemplateArgumentKind = - int Function(CXCursor C, int I); -typedef NativeClang_Cursor_getTemplateArgumentType = - CXType Function(CXCursor C, ffi.UnsignedInt I); -typedef DartClang_Cursor_getTemplateArgumentType = - CXType Function(CXCursor C, int I); -typedef NativeClang_Cursor_getTemplateArgumentValue = - ffi.LongLong Function(CXCursor C, ffi.UnsignedInt I); -typedef DartClang_Cursor_getTemplateArgumentValue = - int Function(CXCursor C, int I); -typedef NativeClang_Cursor_getTemplateArgumentUnsignedValue = - ffi.UnsignedLongLong Function(CXCursor C, ffi.UnsignedInt I); -typedef DartClang_Cursor_getTemplateArgumentUnsignedValue = - int Function(CXCursor C, int I); -typedef NativeClang_equalTypes = ffi.UnsignedInt Function(CXType A, CXType B); -typedef DartClang_equalTypes = int Function(CXType A, CXType B); -typedef NativeClang_getCanonicalType = CXType Function(CXType T); -typedef DartClang_getCanonicalType = CXType Function(CXType T); -typedef NativeClang_isConstQualifiedType = ffi.UnsignedInt Function(CXType T); -typedef DartClang_isConstQualifiedType = int Function(CXType T); -typedef NativeClang_Cursor_isMacroFunctionLike = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isMacroFunctionLike = int Function(CXCursor C); -typedef NativeClang_Cursor_isMacroBuiltin = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isMacroBuiltin = int Function(CXCursor C); -typedef NativeClang_Cursor_isFunctionInlined = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isFunctionInlined = int Function(CXCursor C); -typedef NativeClang_isVolatileQualifiedType = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_isVolatileQualifiedType = int Function(CXType T); -typedef NativeClang_isRestrictQualifiedType = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_isRestrictQualifiedType = int Function(CXType T); -typedef NativeClang_getAddressSpace = ffi.UnsignedInt Function(CXType T); -typedef DartClang_getAddressSpace = int Function(CXType T); -typedef NativeClang_getTypedefName = CXString Function(CXType CT); -typedef DartClang_getTypedefName = CXString Function(CXType CT); -typedef NativeClang_getPointeeType = CXType Function(CXType T); -typedef DartClang_getPointeeType = CXType Function(CXType T); -typedef NativeClang_getTypeDeclaration = CXCursor Function(CXType T); -typedef DartClang_getTypeDeclaration = CXCursor Function(CXType T); -typedef NativeClang_getDeclObjCTypeEncoding = CXString Function(CXCursor C); -typedef DartClang_getDeclObjCTypeEncoding = CXString Function(CXCursor C); -typedef NativeClang_Type_getObjCEncoding = CXString Function(CXType type); -typedef DartClang_Type_getObjCEncoding = CXString Function(CXType type); -typedef NativeClang_getTypeKindSpelling = CXString Function(ffi.UnsignedInt K); -typedef DartClang_getTypeKindSpelling = CXString Function(int K); -typedef NativeClang_getFunctionTypeCallingConv = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_getFunctionTypeCallingConv = int Function(CXType T); -typedef NativeClang_getResultType = CXType Function(CXType T); -typedef DartClang_getResultType = CXType Function(CXType T); -typedef NativeClang_getExceptionSpecificationType = ffi.Int Function(CXType T); -typedef DartClang_getExceptionSpecificationType = int Function(CXType T); -typedef NativeClang_getNumArgTypes = ffi.Int Function(CXType T); -typedef DartClang_getNumArgTypes = int Function(CXType T); -typedef NativeClang_getArgType = CXType Function(CXType T, ffi.UnsignedInt i); -typedef DartClang_getArgType = CXType Function(CXType T, int i); -typedef NativeClang_Type_getObjCObjectBaseType = CXType Function(CXType T); -typedef DartClang_Type_getObjCObjectBaseType = CXType Function(CXType T); -typedef NativeClang_Type_getNumObjCProtocolRefs = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_Type_getNumObjCProtocolRefs = int Function(CXType T); -typedef NativeClang_Type_getObjCProtocolDecl = - CXCursor Function(CXType T, ffi.UnsignedInt i); -typedef DartClang_Type_getObjCProtocolDecl = CXCursor Function(CXType T, int i); -typedef NativeClang_Type_getNumObjCTypeArgs = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_Type_getNumObjCTypeArgs = int Function(CXType T); -typedef NativeClang_Type_getObjCTypeArg = - CXType Function(CXType T, ffi.UnsignedInt i); -typedef DartClang_Type_getObjCTypeArg = CXType Function(CXType T, int i); -typedef NativeClang_isFunctionTypeVariadic = ffi.UnsignedInt Function(CXType T); -typedef DartClang_isFunctionTypeVariadic = int Function(CXType T); -typedef NativeClang_getCursorResultType = CXType Function(CXCursor C); -typedef DartClang_getCursorResultType = CXType Function(CXCursor C); -typedef NativeClang_getCursorExceptionSpecificationType = - ffi.Int Function(CXCursor C); -typedef DartClang_getCursorExceptionSpecificationType = - int Function(CXCursor C); -typedef NativeClang_isPODType = ffi.UnsignedInt Function(CXType T); -typedef DartClang_isPODType = int Function(CXType T); -typedef NativeClang_getElementType = CXType Function(CXType T); -typedef DartClang_getElementType = CXType Function(CXType T); -typedef NativeClang_getNumElements = ffi.LongLong Function(CXType T); -typedef DartClang_getNumElements = int Function(CXType T); -typedef NativeClang_getArrayElementType = CXType Function(CXType T); -typedef DartClang_getArrayElementType = CXType Function(CXType T); -typedef NativeClang_getArraySize = ffi.LongLong Function(CXType T); -typedef DartClang_getArraySize = int Function(CXType T); -typedef NativeClang_Type_getNamedType = CXType Function(CXType T); -typedef DartClang_Type_getNamedType = CXType Function(CXType T); -typedef NativeClang_Type_isTransparentTagTypedef = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_Type_isTransparentTagTypedef = int Function(CXType T); + static CXDiagnosticSeverity fromValue(int value) => switch (value) { + 0 => CXDiagnostic_Ignored, + 1 => CXDiagnostic_Note, + 2 => CXDiagnostic_Warning, + 3 => CXDiagnostic_Error, + 4 => CXDiagnostic_Fatal, + _ => throw ArgumentError('Unknown value for CXDiagnosticSeverity: $value'), + }; +} -enum CXTypeNullabilityKind { - /// Values of this type can never be null. - CXTypeNullability_NonNull(0), +/// Error codes returned by libclang routines. +/// +/// Zero (\c CXError_Success) is the only error code indicating success. Other +/// error codes, including not yet assigned non-zero values, indicate errors. +enum CXErrorCode { + /// No error. + CXError_Success(0), - /// Values of this type can be null. - CXTypeNullability_Nullable(1), + /// A generic error code, no further details are available. + /// + /// Errors of this kind can get their own specific error codes in future + /// libclang versions. + CXError_Failure(1), - /// Whether values of this type can be null is (explicitly) - /// unspecified. This captures a (fairly rare) case where we - /// can't conclude anything about the nullability of the type even - /// though it has been considered. - CXTypeNullability_Unspecified(2), + /// libclang crashed while performing the requested operation. + CXError_Crashed(2), - /// Nullability is not applicable to this type. - CXTypeNullability_Invalid(3); + /// The function detected that the arguments violate the function + /// contract. + CXError_InvalidArguments(3), + + /// An AST deserialization error has occurred. + CXError_ASTReadError(4); final int value; - const CXTypeNullabilityKind(this.value); + const CXErrorCode(this.value); - static CXTypeNullabilityKind fromValue(int value) => switch (value) { - 0 => CXTypeNullability_NonNull, - 1 => CXTypeNullability_Nullable, - 2 => CXTypeNullability_Unspecified, - 3 => CXTypeNullability_Invalid, - _ => throw ArgumentError('Unknown value for CXTypeNullabilityKind: $value'), + static CXErrorCode fromValue(int value) => switch (value) { + 0 => CXError_Success, + 1 => CXError_Failure, + 2 => CXError_Crashed, + 3 => CXError_InvalidArguments, + 4 => CXError_ASTReadError, + _ => throw ArgumentError('Unknown value for CXErrorCode: $value'), }; } -typedef NativeClang_Type_getNullability = ffi.UnsignedInt Function(CXType T); -typedef DartClang_Type_getNullability = int Function(CXType T); -typedef NativeClang_Type_getAlignOf = ffi.LongLong Function(CXType T); -typedef DartClang_Type_getAlignOf = int Function(CXType T); -typedef NativeClang_Type_getClassType = CXType Function(CXType T); -typedef DartClang_Type_getClassType = CXType Function(CXType T); -typedef NativeClang_Type_getSizeOf = ffi.LongLong Function(CXType T); -typedef DartClang_Type_getSizeOf = int Function(CXType T); -typedef NativeClang_Type_getOffsetOf = - ffi.LongLong Function(CXType T, ffi.Pointer S); -typedef DartClang_Type_getOffsetOf = - int Function(CXType T, ffi.Pointer S); -typedef NativeClang_Type_getModifiedType = CXType Function(CXType T); -typedef DartClang_Type_getModifiedType = CXType Function(CXType T); -typedef NativeClang_Cursor_getOffsetOfField = ffi.LongLong Function(CXCursor C); -typedef DartClang_Cursor_getOffsetOfField = int Function(CXCursor C); -typedef NativeClang_Cursor_isAnonymous = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isAnonymous = int Function(CXCursor C); -typedef NativeClang_Cursor_isAnonymousRecordDecl = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isAnonymousRecordDecl = int Function(CXCursor C); -typedef NativeClang_Cursor_isInlineNamespace = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isInlineNamespace = int Function(CXCursor C); +/// Evaluation result of a cursor +typedef CXEvalResult = ffi.Pointer; -enum CXRefQualifierKind { - /// No ref-qualifier was provided. - CXRefQualifier_None(0), +enum CXEvalResultKind { + CXEval_Int(1), + CXEval_Float(2), + CXEval_ObjCStrLiteral(3), + CXEval_StrLiteral(4), + CXEval_CFStr(5), + CXEval_Other(6), + CXEval_UnExposed(0); - /// An lvalue ref-qualifier was provided (\c &). - CXRefQualifier_LValue(1), + final int value; + const CXEvalResultKind(this.value); - /// An rvalue ref-qualifier was provided (\c &&). - CXRefQualifier_RValue(2); + static CXEvalResultKind fromValue(int value) => switch (value) { + 1 => CXEval_Int, + 2 => CXEval_Float, + 3 => CXEval_ObjCStrLiteral, + 4 => CXEval_StrLiteral, + 5 => CXEval_CFStr, + 6 => CXEval_Other, + 0 => CXEval_UnExposed, + _ => throw ArgumentError('Unknown value for CXEvalResultKind: $value'), + }; +} + +/// Visitor invoked for each field found by a traversal. +/// +/// This visitor function will be invoked for each field found by +/// \c clang_Type_visitFields. Its first argument is the cursor being +/// visited, its second argument is the client data provided to +/// \c clang_Type_visitFields. +/// +/// The visitor should return one of the \c CXVisitorResult values +/// to direct \c clang_Type_visitFields. +typedef CXFieldVisitor = + ffi.Pointer>; +typedef CXFieldVisitorFunction = + ffi.UnsignedInt Function(CXCursor C, CXClientData client_data); +typedef DartCXFieldVisitorFunction = + CXVisitorResult Function(CXCursor C, CXClientData client_data); + +/// A particular source file that is part of a translation unit. +typedef CXFile = ffi.Pointer; + +/// Uniquely identifies a CXFile, that refers to the same underlying file, +/// across an indexing session. +final class CXFileUniqueID extends ffi.Struct { + @ffi.Array.multi([3]) + external ffi.Array data; +} + +enum CXGlobalOptFlags { + /// Used to indicate that no special CXIndex options are needed. + CXGlobalOpt_None(0), + + /// Used to indicate that threads that libclang creates for indexing + /// purposes should use background priority. + /// + /// Affects #clang_indexSourceFile, #clang_indexTranslationUnit, + /// #clang_parseTranslationUnit, #clang_saveTranslationUnit. + CXGlobalOpt_ThreadBackgroundPriorityForIndexing(1), + + /// Used to indicate that threads that libclang creates for editing + /// purposes should use background priority. + /// + /// Affects #clang_reparseTranslationUnit, #clang_codeCompleteAt, + /// #clang_annotateTokens + CXGlobalOpt_ThreadBackgroundPriorityForEditing(2), + + /// Used to indicate that all threads that libclang creates should use + /// background priority. + CXGlobalOpt_ThreadBackgroundPriorityForAll(3); final int value; - const CXRefQualifierKind(this.value); + const CXGlobalOptFlags(this.value); - static CXRefQualifierKind fromValue(int value) => switch (value) { - 0 => CXRefQualifier_None, - 1 => CXRefQualifier_LValue, - 2 => CXRefQualifier_RValue, - _ => throw ArgumentError('Unknown value for CXRefQualifierKind: $value'), + static CXGlobalOptFlags fromValue(int value) => switch (value) { + 0 => CXGlobalOpt_None, + 1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing, + 2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing, + 3 => CXGlobalOpt_ThreadBackgroundPriorityForAll, + _ => throw ArgumentError('Unknown value for CXGlobalOptFlags: $value'), }; } -typedef NativeClang_Type_getNumTemplateArguments = ffi.Int Function(CXType T); -typedef DartClang_Type_getNumTemplateArguments = int Function(CXType T); -typedef NativeClang_Type_getTemplateArgumentAsType = - CXType Function(CXType T, ffi.UnsignedInt i); -typedef DartClang_Type_getTemplateArgumentAsType = - CXType Function(CXType T, int i); -typedef NativeClang_Type_getCXXRefQualifier = - ffi.UnsignedInt Function(CXType T); -typedef DartClang_Type_getCXXRefQualifier = int Function(CXType T); -typedef NativeClang_Cursor_isBitField = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isBitField = int Function(CXCursor C); -typedef NativeClang_isVirtualBase = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_isVirtualBase = int Function(CXCursor); +final class CXIdxAttrInfo extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; -/// Represents the C++ access control level to a base class for a -/// cursor with kind CX_CXXBaseSpecifier. -enum CX_CXXAccessSpecifier { - CX_CXXInvalidAccessSpecifier(0), - CX_CXXPublic(1), - CX_CXXProtected(2), - CX_CXXPrivate(3); + CXIdxAttrKind get kind => CXIdxAttrKind.fromValue(kindAsInt); + set kind(CXIdxAttrKind value) => kindAsInt = value.value; + + external CXCursor cursor; + + external CXIdxLoc loc; +} + +enum CXIdxAttrKind { + CXIdxAttr_Unexposed(0), + CXIdxAttr_IBAction(1), + CXIdxAttr_IBOutlet(2), + CXIdxAttr_IBOutletCollection(3); final int value; - const CX_CXXAccessSpecifier(this.value); + const CXIdxAttrKind(this.value); - static CX_CXXAccessSpecifier fromValue(int value) => switch (value) { - 0 => CX_CXXInvalidAccessSpecifier, - 1 => CX_CXXPublic, - 2 => CX_CXXProtected, - 3 => CX_CXXPrivate, - _ => throw ArgumentError('Unknown value for CX_CXXAccessSpecifier: $value'), + static CXIdxAttrKind fromValue(int value) => switch (value) { + 0 => CXIdxAttr_Unexposed, + 1 => CXIdxAttr_IBAction, + 2 => CXIdxAttr_IBOutlet, + 3 => CXIdxAttr_IBOutletCollection, + _ => throw ArgumentError('Unknown value for CXIdxAttrKind: $value'), }; } -typedef NativeClang_getCXXAccessSpecifier = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_getCXXAccessSpecifier = int Function(CXCursor); +final class CXIdxBaseClassInfo extends ffi.Struct { + external ffi.Pointer base; -/// Represents the storage classes as declared in the source. CX_SC_Invalid -/// was added for the case that the passed cursor in not a declaration. -enum CX_StorageClass { - CX_SC_Invalid(0), - CX_SC_None(1), - CX_SC_Extern(2), - CX_SC_Static(3), - CX_SC_PrivateExtern(4), - CX_SC_OpenCLWorkGroupLocal(5), - CX_SC_Auto(6), - CX_SC_Register(7); + external CXCursor cursor; - final int value; - const CX_StorageClass(this.value); + external CXIdxLoc loc; +} + +final class CXIdxCXXClassDeclInfo extends ffi.Struct { + external ffi.Pointer declInfo; + + external ffi.Pointer> bases; + + @ffi.UnsignedInt() + external int numBases; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer declInfo, + required ffi.Pointer> bases, + required int numBases, + }) => $allocator() + ..ref.declInfo = declInfo + ..ref.bases = bases + ..ref.numBases = numBases; +} + +/// The client's data object that is associated with an AST file (PCH +/// or module). +typedef CXIdxClientASTFile = ffi.Pointer; + +/// The client's data object that is associated with a semantic container +/// of entities. +typedef CXIdxClientContainer = ffi.Pointer; + +/// The client's data object that is associated with a semantic entity. +typedef CXIdxClientEntity = ffi.Pointer; - static CX_StorageClass fromValue(int value) => switch (value) { - 0 => CX_SC_Invalid, - 1 => CX_SC_None, - 2 => CX_SC_Extern, - 3 => CX_SC_Static, - 4 => CX_SC_PrivateExtern, - 5 => CX_SC_OpenCLWorkGroupLocal, - 6 => CX_SC_Auto, - 7 => CX_SC_Register, - _ => throw ArgumentError('Unknown value for CX_StorageClass: $value'), - }; +/// The client's data object that is associated with a CXFile. +typedef CXIdxClientFile = ffi.Pointer; + +final class CXIdxContainerInfo extends ffi.Struct { + external CXCursor cursor; } -typedef NativeClang_Cursor_getStorageClass = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_Cursor_getStorageClass = int Function(CXCursor); -typedef NativeClang_getNumOverloadedDecls = - ffi.UnsignedInt Function(CXCursor cursor); -typedef DartClang_getNumOverloadedDecls = int Function(CXCursor cursor); -typedef NativeClang_getOverloadedDecl = - CXCursor Function(CXCursor cursor, ffi.UnsignedInt index); -typedef DartClang_getOverloadedDecl = - CXCursor Function(CXCursor cursor, int index); -typedef NativeClang_getIBOutletCollectionType = CXType Function(CXCursor); -typedef DartClang_getIBOutletCollectionType = CXType Function(CXCursor); +final class CXIdxDeclInfo extends ffi.Struct { + external ffi.Pointer entityInfo; -/// Describes how the traversal of the children of a particular -/// cursor should proceed after visiting a particular child cursor. -/// -/// A value of this enumeration type should be returned by each -/// \c CXCursorVisitor to indicate how clang_visitChildren() proceed. -enum CXChildVisitResult { - /// Terminates the cursor traversal. - CXChildVisit_Break(0), + external CXCursor cursor; - /// Continues the cursor traversal with the next sibling of - /// the cursor just visited, without visiting its children. - CXChildVisit_Continue(1), + external CXIdxLoc loc; - /// Recursively traverse the children of this cursor, using - /// the same visitor and client data. - CXChildVisit_Recurse(2); + external ffi.Pointer semanticContainer; - final int value; - const CXChildVisitResult(this.value); + /// Generally same as #semanticContainer but can be different in + /// cases like out-of-line C++ member functions. + external ffi.Pointer lexicalContainer; - static CXChildVisitResult fromValue(int value) => switch (value) { - 0 => CXChildVisit_Break, - 1 => CXChildVisit_Continue, - 2 => CXChildVisit_Recurse, - _ => throw ArgumentError('Unknown value for CXChildVisitResult: $value'), - }; -} + @ffi.Int() + external int isRedeclaration; -typedef CXCursorVisitorFunction = - ffi.UnsignedInt Function( - CXCursor cursor, - CXCursor parent, - CXClientData client_data, - ); -typedef DartCXCursorVisitorFunction = - CXChildVisitResult Function( - CXCursor cursor, - CXCursor parent, - CXClientData client_data, - ); + @ffi.Int() + external int isDefinition; -/// Visitor invoked for each cursor found by a traversal. -/// -/// This visitor function will be invoked for each cursor found by -/// clang_visitCursorChildren(). Its first argument is the cursor being -/// visited, its second argument is the parent visitor for that cursor, -/// and its third argument is the client data provided to -/// clang_visitCursorChildren(). -/// -/// The visitor should return one of the \c CXChildVisitResult values -/// to direct clang_visitCursorChildren(). -typedef CXCursorVisitor = - ffi.Pointer>; -typedef NativeClang_visitChildren = - ffi.UnsignedInt Function( - CXCursor parent, - CXCursorVisitor visitor, - CXClientData client_data, - ); -typedef DartClang_visitChildren = - int Function( - CXCursor parent, - CXCursorVisitor visitor, - CXClientData client_data, - ); -typedef NativeClang_getCursorUSR = CXString Function(CXCursor); -typedef DartClang_getCursorUSR = CXString Function(CXCursor); -typedef NativeClang_constructUSR_ObjCClass = - CXString Function(ffi.Pointer class_name); -typedef DartClang_constructUSR_ObjCClass = - CXString Function(ffi.Pointer class_name); -typedef NativeClang_constructUSR_ObjCCategory = - CXString Function( - ffi.Pointer class_name, - ffi.Pointer category_name, - ); -typedef DartClang_constructUSR_ObjCCategory = - CXString Function( - ffi.Pointer class_name, - ffi.Pointer category_name, - ); -typedef NativeClang_constructUSR_ObjCProtocol = - CXString Function(ffi.Pointer protocol_name); -typedef DartClang_constructUSR_ObjCProtocol = - CXString Function(ffi.Pointer protocol_name); -typedef NativeClang_constructUSR_ObjCIvar = - CXString Function(ffi.Pointer name, CXString classUSR); -typedef DartClang_constructUSR_ObjCIvar = - CXString Function(ffi.Pointer name, CXString classUSR); -typedef NativeClang_constructUSR_ObjCMethod = - CXString Function( - ffi.Pointer name, - ffi.UnsignedInt isInstanceMethod, - CXString classUSR, - ); -typedef DartClang_constructUSR_ObjCMethod = - CXString Function( - ffi.Pointer name, - int isInstanceMethod, - CXString classUSR, - ); -typedef NativeClang_constructUSR_ObjCProperty = - CXString Function(ffi.Pointer property, CXString classUSR); -typedef DartClang_constructUSR_ObjCProperty = - CXString Function(ffi.Pointer property, CXString classUSR); -typedef NativeClang_getCursorSpelling = CXString Function(CXCursor); -typedef DartClang_getCursorSpelling = CXString Function(CXCursor); -typedef NativeClang_Cursor_getSpellingNameRange = - CXSourceRange Function( - CXCursor, - ffi.UnsignedInt pieceIndex, - ffi.UnsignedInt options, - ); -typedef DartClang_Cursor_getSpellingNameRange = - CXSourceRange Function(CXCursor, int pieceIndex, int options); + @ffi.Int() + external int isContainer; -/// Opaque pointer representing a policy that controls pretty printing -/// for \c clang_getCursorPrettyPrinted. -typedef CXPrintingPolicy = ffi.Pointer; + external ffi.Pointer declAsContainer; -/// Properties for the printing policy. -/// -/// See \c clang::PrintingPolicy for more information. -enum CXPrintingPolicyProperty { - CXPrintingPolicy_Indentation(0), - CXPrintingPolicy_SuppressSpecifiers(1), - CXPrintingPolicy_SuppressTagKeyword(2), - CXPrintingPolicy_IncludeTagDefinition(3), - CXPrintingPolicy_SuppressScope(4), - CXPrintingPolicy_SuppressUnwrittenScope(5), - CXPrintingPolicy_SuppressInitializers(6), - CXPrintingPolicy_ConstantArraySizeAsWritten(7), - CXPrintingPolicy_AnonymousTagLocations(8), - CXPrintingPolicy_SuppressStrongLifetime(9), - CXPrintingPolicy_SuppressLifetimeQualifiers(10), - CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors(11), - CXPrintingPolicy_Bool(12), - CXPrintingPolicy_Restrict(13), - CXPrintingPolicy_Alignof(14), - CXPrintingPolicy_UnderscoreAlignof(15), - CXPrintingPolicy_UseVoidForZeroParams(16), - CXPrintingPolicy_TerseOutput(17), - CXPrintingPolicy_PolishForDeclaration(18), - CXPrintingPolicy_Half(19), - CXPrintingPolicy_MSWChar(20), - CXPrintingPolicy_IncludeNewlines(21), - CXPrintingPolicy_MSVCFormatting(22), - CXPrintingPolicy_ConstantsAsWritten(23), - CXPrintingPolicy_SuppressImplicitBase(24), - CXPrintingPolicy_FullyQualifiedName(25); + /// Whether the declaration exists in code or was created implicitly + /// by the compiler, e.g. implicit Objective-C methods for properties. + @ffi.Int() + external int isImplicit; - static const CXPrintingPolicy_LastProperty = - CXPrintingPolicy_FullyQualifiedName; + external ffi.Pointer> attributes; - final int value; - const CXPrintingPolicyProperty(this.value); + @ffi.UnsignedInt() + external int numAttributes; - static CXPrintingPolicyProperty fromValue(int value) => switch (value) { - 0 => CXPrintingPolicy_Indentation, - 1 => CXPrintingPolicy_SuppressSpecifiers, - 2 => CXPrintingPolicy_SuppressTagKeyword, - 3 => CXPrintingPolicy_IncludeTagDefinition, - 4 => CXPrintingPolicy_SuppressScope, - 5 => CXPrintingPolicy_SuppressUnwrittenScope, - 6 => CXPrintingPolicy_SuppressInitializers, - 7 => CXPrintingPolicy_ConstantArraySizeAsWritten, - 8 => CXPrintingPolicy_AnonymousTagLocations, - 9 => CXPrintingPolicy_SuppressStrongLifetime, - 10 => CXPrintingPolicy_SuppressLifetimeQualifiers, - 11 => CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, - 12 => CXPrintingPolicy_Bool, - 13 => CXPrintingPolicy_Restrict, - 14 => CXPrintingPolicy_Alignof, - 15 => CXPrintingPolicy_UnderscoreAlignof, - 16 => CXPrintingPolicy_UseVoidForZeroParams, - 17 => CXPrintingPolicy_TerseOutput, - 18 => CXPrintingPolicy_PolishForDeclaration, - 19 => CXPrintingPolicy_Half, - 20 => CXPrintingPolicy_MSWChar, - 21 => CXPrintingPolicy_IncludeNewlines, - 22 => CXPrintingPolicy_MSVCFormatting, - 23 => CXPrintingPolicy_ConstantsAsWritten, - 24 => CXPrintingPolicy_SuppressImplicitBase, - 25 => CXPrintingPolicy_FullyQualifiedName, - _ => throw ArgumentError( - 'Unknown value for CXPrintingPolicyProperty: $value', - ), - }; + @ffi.UnsignedInt() + external int flags; +} - @override - String toString() { - if (this == CXPrintingPolicy_FullyQualifiedName) - return "CXPrintingPolicyProperty.CXPrintingPolicy_FullyQualifiedName, CXPrintingPolicyProperty.CXPrintingPolicy_LastProperty"; - return super.toString(); - } +/// Extra C++ template information for an entity. This can apply to: +/// CXIdxEntity_Function +/// CXIdxEntity_CXXClass +/// CXIdxEntity_CXXStaticMethod +/// CXIdxEntity_CXXInstanceMethod +/// CXIdxEntity_CXXConstructor +/// CXIdxEntity_CXXConversionFunction +/// CXIdxEntity_CXXTypeAlias +enum CXIdxEntityCXXTemplateKind { + CXIdxEntity_NonTemplate(0), + CXIdxEntity_Template(1), + CXIdxEntity_TemplatePartialSpecialization(2), + CXIdxEntity_TemplateSpecialization(3); + + final int value; + const CXIdxEntityCXXTemplateKind(this.value); + + static CXIdxEntityCXXTemplateKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_NonTemplate, + 1 => CXIdxEntity_Template, + 2 => CXIdxEntity_TemplatePartialSpecialization, + 3 => CXIdxEntity_TemplateSpecialization, + _ => throw ArgumentError( + 'Unknown value for CXIdxEntityCXXTemplateKind: $value', + ), + }; } -typedef NativeClang_PrintingPolicy_getProperty = - ffi.UnsignedInt Function(CXPrintingPolicy Policy, ffi.UnsignedInt Property); -typedef DartClang_PrintingPolicy_getProperty = - int Function(CXPrintingPolicy Policy, int Property); -typedef NativeClang_PrintingPolicy_setProperty = - ffi.Void Function( - CXPrintingPolicy Policy, - ffi.UnsignedInt Property, - ffi.UnsignedInt Value, - ); -typedef DartClang_PrintingPolicy_setProperty = - void Function(CXPrintingPolicy Policy, int Property, int Value); -typedef NativeClang_getCursorPrintingPolicy = - CXPrintingPolicy Function(CXCursor); -typedef DartClang_getCursorPrintingPolicy = CXPrintingPolicy Function(CXCursor); -typedef NativeClang_PrintingPolicy_dispose = - ffi.Void Function(CXPrintingPolicy Policy); -typedef DartClang_PrintingPolicy_dispose = - void Function(CXPrintingPolicy Policy); -typedef NativeClang_getCursorPrettyPrinted = - CXString Function(CXCursor Cursor, CXPrintingPolicy Policy); -typedef DartClang_getCursorPrettyPrinted = - CXString Function(CXCursor Cursor, CXPrintingPolicy Policy); -typedef NativeClang_getCursorDisplayName = CXString Function(CXCursor); -typedef DartClang_getCursorDisplayName = CXString Function(CXCursor); -typedef NativeClang_getCursorReferenced = CXCursor Function(CXCursor); -typedef DartClang_getCursorReferenced = CXCursor Function(CXCursor); -typedef NativeClang_getCursorDefinition = CXCursor Function(CXCursor); -typedef DartClang_getCursorDefinition = CXCursor Function(CXCursor); -typedef NativeClang_isCursorDefinition = ffi.UnsignedInt Function(CXCursor); -typedef DartClang_isCursorDefinition = int Function(CXCursor); -typedef NativeClang_getCanonicalCursor = CXCursor Function(CXCursor); -typedef DartClang_getCanonicalCursor = CXCursor Function(CXCursor); -typedef NativeClang_Cursor_getObjCSelectorIndex = ffi.Int Function(CXCursor); -typedef DartClang_Cursor_getObjCSelectorIndex = int Function(CXCursor); -typedef NativeClang_Cursor_isDynamicCall = ffi.Int Function(CXCursor C); -typedef DartClang_Cursor_isDynamicCall = int Function(CXCursor C); -typedef NativeClang_Cursor_getReceiverType = CXType Function(CXCursor C); -typedef DartClang_Cursor_getReceiverType = CXType Function(CXCursor C); -typedef NativeClang_Cursor_getObjCPropertyAttributes = - ffi.UnsignedInt Function(CXCursor C, ffi.UnsignedInt reserved); -typedef DartClang_Cursor_getObjCPropertyAttributes = - int Function(CXCursor C, int reserved); -typedef NativeClang_Cursor_getObjCPropertyGetterName = - CXString Function(CXCursor C); -typedef DartClang_Cursor_getObjCPropertyGetterName = - CXString Function(CXCursor C); -typedef NativeClang_Cursor_getObjCPropertySetterName = - CXString Function(CXCursor C); -typedef DartClang_Cursor_getObjCPropertySetterName = - CXString Function(CXCursor C); -typedef NativeClang_Cursor_getObjCDeclQualifiers = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_getObjCDeclQualifiers = int Function(CXCursor C); -typedef NativeClang_Cursor_isObjCOptional = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isObjCOptional = int Function(CXCursor C); -typedef NativeClang_Cursor_isVariadic = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_Cursor_isVariadic = int Function(CXCursor C); -typedef NativeClang_Cursor_isExternalSymbol = - ffi.UnsignedInt Function( - CXCursor C, - ffi.Pointer language, - ffi.Pointer definedIn, - ffi.Pointer isGenerated, - ); -typedef DartClang_Cursor_isExternalSymbol = - int Function( - CXCursor C, - ffi.Pointer language, - ffi.Pointer definedIn, - ffi.Pointer isGenerated, - ); -typedef NativeClang_Cursor_getCommentRange = CXSourceRange Function(CXCursor C); -typedef DartClang_Cursor_getCommentRange = CXSourceRange Function(CXCursor C); -typedef NativeClang_Cursor_getRawCommentText = CXString Function(CXCursor C); -typedef DartClang_Cursor_getRawCommentText = CXString Function(CXCursor C); -typedef NativeClang_Cursor_getBriefCommentText = CXString Function(CXCursor C); -typedef DartClang_Cursor_getBriefCommentText = CXString Function(CXCursor C); -typedef NativeClang_Cursor_getMangling = CXString Function(CXCursor); -typedef DartClang_Cursor_getMangling = CXString Function(CXCursor); -typedef NativeClang_Cursor_getCXXManglings = - ffi.Pointer Function(CXCursor); -typedef DartClang_Cursor_getCXXManglings = - ffi.Pointer Function(CXCursor); -typedef NativeClang_Cursor_getObjCManglings = - ffi.Pointer Function(CXCursor); -typedef DartClang_Cursor_getObjCManglings = - ffi.Pointer Function(CXCursor); +final class CXIdxEntityInfo extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; -/// \defgroup CINDEX_MODULE Module introspection -/// -/// The functions in this group provide access to information about modules. -/// -/// @{ -typedef CXModule = ffi.Pointer; -typedef NativeClang_Cursor_getModule = CXModule Function(CXCursor C); -typedef DartClang_Cursor_getModule = CXModule Function(CXCursor C); -typedef NativeClang_getModuleForFile = - CXModule Function(CXTranslationUnit, CXFile); -typedef DartClang_getModuleForFile = - CXModule Function(CXTranslationUnit, CXFile); -typedef NativeClang_Module_getASTFile = CXFile Function(CXModule Module); -typedef DartClang_Module_getASTFile = CXFile Function(CXModule Module); -typedef NativeClang_Module_getParent = CXModule Function(CXModule Module); -typedef DartClang_Module_getParent = CXModule Function(CXModule Module); -typedef NativeClang_Module_getName = CXString Function(CXModule Module); -typedef DartClang_Module_getName = CXString Function(CXModule Module); -typedef NativeClang_Module_getFullName = CXString Function(CXModule Module); -typedef DartClang_Module_getFullName = CXString Function(CXModule Module); -typedef NativeClang_Module_isSystem = ffi.Int Function(CXModule Module); -typedef DartClang_Module_isSystem = int Function(CXModule Module); -typedef NativeClang_Module_getNumTopLevelHeaders = - ffi.UnsignedInt Function(CXTranslationUnit, CXModule Module); -typedef DartClang_Module_getNumTopLevelHeaders = - int Function(CXTranslationUnit, CXModule Module); -typedef NativeClang_Module_getTopLevelHeader = - CXFile Function(CXTranslationUnit, CXModule Module, ffi.UnsignedInt Index); -typedef DartClang_Module_getTopLevelHeader = - CXFile Function(CXTranslationUnit, CXModule Module, int Index); -typedef NativeClang_CXXConstructor_isConvertingConstructor = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXConstructor_isConvertingConstructor = - int Function(CXCursor C); -typedef NativeClang_CXXConstructor_isCopyConstructor = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXConstructor_isCopyConstructor = int Function(CXCursor C); -typedef NativeClang_CXXConstructor_isDefaultConstructor = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXConstructor_isDefaultConstructor = - int Function(CXCursor C); -typedef NativeClang_CXXConstructor_isMoveConstructor = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXConstructor_isMoveConstructor = int Function(CXCursor C); -typedef NativeClang_CXXField_isMutable = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXField_isMutable = int Function(CXCursor C); -typedef NativeClang_CXXMethod_isDefaulted = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXMethod_isDefaulted = int Function(CXCursor C); -typedef NativeClang_CXXMethod_isPureVirtual = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXMethod_isPureVirtual = int Function(CXCursor C); -typedef NativeClang_CXXMethod_isStatic = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXMethod_isStatic = int Function(CXCursor C); -typedef NativeClang_CXXMethod_isVirtual = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXMethod_isVirtual = int Function(CXCursor C); -typedef NativeClang_CXXRecord_isAbstract = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXRecord_isAbstract = int Function(CXCursor C); -typedef NativeClang_EnumDecl_isScoped = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_EnumDecl_isScoped = int Function(CXCursor C); -typedef NativeClang_CXXMethod_isConst = ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_CXXMethod_isConst = int Function(CXCursor C); -typedef NativeClang_getTemplateCursorKind = - ffi.UnsignedInt Function(CXCursor C); -typedef DartClang_getTemplateCursorKind = int Function(CXCursor C); -typedef NativeClang_getSpecializedCursorTemplate = - CXCursor Function(CXCursor C); -typedef DartClang_getSpecializedCursorTemplate = CXCursor Function(CXCursor C); -typedef NativeClang_getCursorReferenceNameRange = - CXSourceRange Function( - CXCursor C, - ffi.UnsignedInt NameFlags, - ffi.UnsignedInt PieceIndex, - ); -typedef DartClang_getCursorReferenceNameRange = - CXSourceRange Function(CXCursor C, int NameFlags, int PieceIndex); + CXIdxEntityKind get kind => CXIdxEntityKind.fromValue(kindAsInt); + set kind(CXIdxEntityKind value) => kindAsInt = value.value; -/// Describes a kind of token. -enum CXTokenKind { - /// A token that contains some kind of punctuation. - CXToken_Punctuation(0), + @ffi.UnsignedInt() + external int templateKindAsInt; - /// A language keyword. - CXToken_Keyword(1), + CXIdxEntityCXXTemplateKind get templateKind => + CXIdxEntityCXXTemplateKind.fromValue(templateKindAsInt); + set templateKind(CXIdxEntityCXXTemplateKind value) => + templateKindAsInt = value.value; - /// An identifier (that is not a keyword). - CXToken_Identifier(2), + @ffi.UnsignedInt() + external int langAsInt; - /// A numeric, string, or character literal. - CXToken_Literal(3), + CXIdxEntityLanguage get lang => CXIdxEntityLanguage.fromValue(langAsInt); + set lang(CXIdxEntityLanguage value) => langAsInt = value.value; + + external ffi.Pointer name; + + external ffi.Pointer USR; + + external CXCursor cursor; + + external ffi.Pointer> attributes; + + @ffi.UnsignedInt() + external int numAttributes; +} + +enum CXIdxEntityKind { + CXIdxEntity_Unexposed(0), + CXIdxEntity_Typedef(1), + CXIdxEntity_Function(2), + CXIdxEntity_Variable(3), + CXIdxEntity_Field(4), + CXIdxEntity_EnumConstant(5), + CXIdxEntity_ObjCClass(6), + CXIdxEntity_ObjCProtocol(7), + CXIdxEntity_ObjCCategory(8), + CXIdxEntity_ObjCInstanceMethod(9), + CXIdxEntity_ObjCClassMethod(10), + CXIdxEntity_ObjCProperty(11), + CXIdxEntity_ObjCIvar(12), + CXIdxEntity_Enum(13), + CXIdxEntity_Struct(14), + CXIdxEntity_Union(15), + CXIdxEntity_CXXClass(16), + CXIdxEntity_CXXNamespace(17), + CXIdxEntity_CXXNamespaceAlias(18), + CXIdxEntity_CXXStaticVariable(19), + CXIdxEntity_CXXStaticMethod(20), + CXIdxEntity_CXXInstanceMethod(21), + CXIdxEntity_CXXConstructor(22), + CXIdxEntity_CXXDestructor(23), + CXIdxEntity_CXXConversionFunction(24), + CXIdxEntity_CXXTypeAlias(25), + CXIdxEntity_CXXInterface(26); + + final int value; + const CXIdxEntityKind(this.value); + + static CXIdxEntityKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_Unexposed, + 1 => CXIdxEntity_Typedef, + 2 => CXIdxEntity_Function, + 3 => CXIdxEntity_Variable, + 4 => CXIdxEntity_Field, + 5 => CXIdxEntity_EnumConstant, + 6 => CXIdxEntity_ObjCClass, + 7 => CXIdxEntity_ObjCProtocol, + 8 => CXIdxEntity_ObjCCategory, + 9 => CXIdxEntity_ObjCInstanceMethod, + 10 => CXIdxEntity_ObjCClassMethod, + 11 => CXIdxEntity_ObjCProperty, + 12 => CXIdxEntity_ObjCIvar, + 13 => CXIdxEntity_Enum, + 14 => CXIdxEntity_Struct, + 15 => CXIdxEntity_Union, + 16 => CXIdxEntity_CXXClass, + 17 => CXIdxEntity_CXXNamespace, + 18 => CXIdxEntity_CXXNamespaceAlias, + 19 => CXIdxEntity_CXXStaticVariable, + 20 => CXIdxEntity_CXXStaticMethod, + 21 => CXIdxEntity_CXXInstanceMethod, + 22 => CXIdxEntity_CXXConstructor, + 23 => CXIdxEntity_CXXDestructor, + 24 => CXIdxEntity_CXXConversionFunction, + 25 => CXIdxEntity_CXXTypeAlias, + 26 => CXIdxEntity_CXXInterface, + _ => throw ArgumentError('Unknown value for CXIdxEntityKind: $value'), + }; +} - /// A comment. - CXToken_Comment(4); +enum CXIdxEntityLanguage { + CXIdxEntityLang_None(0), + CXIdxEntityLang_C(1), + CXIdxEntityLang_ObjC(2), + CXIdxEntityLang_CXX(3), + CXIdxEntityLang_Swift(4); final int value; - const CXTokenKind(this.value); + const CXIdxEntityLanguage(this.value); - static CXTokenKind fromValue(int value) => switch (value) { - 0 => CXToken_Punctuation, - 1 => CXToken_Keyword, - 2 => CXToken_Identifier, - 3 => CXToken_Literal, - 4 => CXToken_Comment, - _ => throw ArgumentError('Unknown value for CXTokenKind: $value'), + static CXIdxEntityLanguage fromValue(int value) => switch (value) { + 0 => CXIdxEntityLang_None, + 1 => CXIdxEntityLang_C, + 2 => CXIdxEntityLang_ObjC, + 3 => CXIdxEntityLang_CXX, + 4 => CXIdxEntityLang_Swift, + _ => throw ArgumentError('Unknown value for CXIdxEntityLanguage: $value'), }; } -/// Describes a single preprocessing token. -final class CXToken extends ffi.Struct { - @ffi.Array.multi([4]) - external ffi.Array int_data; +/// Data for IndexerCallbacks#indexEntityReference. +final class CXIdxEntityRefInfo extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; - external ffi.Pointer ptr_data; -} + CXIdxEntityRefKind get kind => CXIdxEntityRefKind.fromValue(kindAsInt); + set kind(CXIdxEntityRefKind value) => kindAsInt = value.value; -typedef NativeClang_getToken = - ffi.Pointer Function( - CXTranslationUnit TU, - CXSourceLocation Location, - ); -typedef DartClang_getToken = - ffi.Pointer Function( - CXTranslationUnit TU, - CXSourceLocation Location, - ); -typedef NativeClang_getTokenKind = ffi.UnsignedInt Function(CXToken); -typedef DartClang_getTokenKind = int Function(CXToken); -typedef NativeClang_getTokenSpelling = - CXString Function(CXTranslationUnit, CXToken); -typedef DartClang_getTokenSpelling = - CXString Function(CXTranslationUnit, CXToken); -typedef NativeClang_getTokenLocation = - CXSourceLocation Function(CXTranslationUnit, CXToken); -typedef DartClang_getTokenLocation = - CXSourceLocation Function(CXTranslationUnit, CXToken); -typedef NativeClang_getTokenExtent = - CXSourceRange Function(CXTranslationUnit, CXToken); -typedef DartClang_getTokenExtent = - CXSourceRange Function(CXTranslationUnit, CXToken); -typedef NativeClang_tokenize = - ffi.Void Function( - CXTranslationUnit TU, - CXSourceRange Range, - ffi.Pointer> Tokens, - ffi.Pointer NumTokens, - ); -typedef DartClang_tokenize = - void Function( - CXTranslationUnit TU, - CXSourceRange Range, - ffi.Pointer> Tokens, - ffi.Pointer NumTokens, - ); -typedef NativeClang_annotateTokens = - ffi.Void Function( - CXTranslationUnit TU, - ffi.Pointer Tokens, - ffi.UnsignedInt NumTokens, - ffi.Pointer Cursors, - ); -typedef DartClang_annotateTokens = - void Function( - CXTranslationUnit TU, - ffi.Pointer Tokens, - int NumTokens, - ffi.Pointer Cursors, - ); -typedef NativeClang_disposeTokens = - ffi.Void Function( - CXTranslationUnit TU, - ffi.Pointer Tokens, - ffi.UnsignedInt NumTokens, - ); -typedef DartClang_disposeTokens = - void Function( - CXTranslationUnit TU, - ffi.Pointer Tokens, - int NumTokens, - ); -typedef NativeClang_getCursorKindSpelling = - CXString Function(ffi.UnsignedInt Kind); -typedef DartClang_getCursorKindSpelling = CXString Function(int Kind); -typedef NativeClang_getDefinitionSpellingAndExtent = - ffi.Void Function( - CXCursor, - ffi.Pointer> startBuf, - ffi.Pointer> endBuf, - ffi.Pointer startLine, - ffi.Pointer startColumn, - ffi.Pointer endLine, - ffi.Pointer endColumn, - ); -typedef DartClang_getDefinitionSpellingAndExtent = - void Function( - CXCursor, - ffi.Pointer> startBuf, - ffi.Pointer> endBuf, - ffi.Pointer startLine, - ffi.Pointer startColumn, - ffi.Pointer endLine, - ffi.Pointer endColumn, - ); -typedef NativeClang_enableStackTraces = ffi.Void Function(); -typedef DartClang_enableStackTraces = void Function(); -typedef NativeClang_executeOnThread = - ffi.Void Function( - ffi.Pointer)>> - fn, - ffi.Pointer user_data, - ffi.UnsignedInt stack_size, - ); -typedef DartClang_executeOnThread = - void Function( - ffi.Pointer)>> - fn, - ffi.Pointer user_data, - int stack_size, - ); + /// Reference cursor. + external CXCursor cursor; -/// A semantic string that describes a code-completion result. -/// -/// A semantic string that describes the formatting of a code-completion -/// result as a single "template" of text that should be inserted into the -/// source buffer when a particular code-completion result is selected. -/// Each semantic string is made up of some number of "chunks", each of which -/// contains some text along with a description of what that text means, e.g., -/// the name of the entity being referenced, whether the text chunk is part of -/// the template, or whether it is a "placeholder" that the user should replace -/// with actual code,of a specific kind. See \c CXCompletionChunkKind for a -/// description of the different kinds of chunks. -typedef CXCompletionString = ffi.Pointer; + external CXIdxLoc loc; -/// A single result of code completion. -final class CXCompletionResult extends ffi.Struct { - /// The kind of entity that this completion refers to. + /// The entity that gets referenced. + external ffi.Pointer referencedEntity; + + /// Immediate "parent" of the reference. For example: /// - /// The cursor kind will be a macro, keyword, or a declaration (one of the - /// *Decl cursor kinds), describing the entity that the completion is - /// referring to. + /// \code + /// Foo *var; + /// \endcode /// - /// \todo In the future, we would like to provide a full cursor, to allow - /// the client to extract additional information from declaration. - @ffi.UnsignedInt() - external int CursorKindAsInt; + /// The parent of reference of type 'Foo' is the variable 'var'. + /// For references inside statement bodies of functions/methods, + /// the parentEntity will be the function/method. + external ffi.Pointer parentEntity; - CXCursorKind get CursorKind => CXCursorKind.fromValue(CursorKindAsInt); - set CursorKind(CXCursorKind value) => CursorKindAsInt = value.value; + /// Lexical container context of the reference. + external ffi.Pointer container; - /// The code-completion string that describes how to insert this - /// code-completion result into the editing buffer. - external CXCompletionString CompletionString; + /// Sets of symbol roles of the reference. + @ffi.UnsignedInt() + external int roleAsInt; + + CXSymbolRole get role => CXSymbolRole.fromValue(roleAsInt); + set role(CXSymbolRole value) => roleAsInt = value.value; } -/// Describes a single piece of text within a code-completion string. +/// Data for IndexerCallbacks#indexEntityReference. /// -/// Each "chunk" within a code-completion string (\c CXCompletionString) is -/// either a piece of text with a specific "kind" that describes how that text -/// should be interpreted by the client or is another completion string. -enum CXCompletionChunkKind { - /// A code-completion string that describes "optional" text that - /// could be a part of the template (but is not required). - /// - /// The Optional chunk is the only kind of chunk that has a code-completion - /// string for its representation, which is accessible via - /// \c clang_getCompletionChunkCompletionString(). The code-completion string - /// describes an additional part of the template that is completely optional. - /// For example, optional chunks can be used to describe the placeholders for - /// arguments that match up with defaulted function parameters, e.g. given: - /// - /// \code - /// void f(int x, float y = 3.14, double z = 2.71828); - /// \endcode - /// - /// The code-completion string for this function would contain: - /// - a TypedText chunk for "f". - /// - a LeftParen chunk for "(". - /// - a Placeholder chunk for "int x" - /// - an Optional chunk containing the remaining defaulted arguments, e.g., - /// - a Comma chunk for "," - /// - a Placeholder chunk for "float y" - /// - an Optional chunk containing the last defaulted argument: - /// - a Comma chunk for "," - /// - a Placeholder chunk for "double z" - /// - a RightParen chunk for ")" - /// - /// There are many ways to handle Optional chunks. Two simple approaches are: - /// - Completely ignore optional chunks, in which case the template for the - /// function "f" would only include the first parameter ("int x"). - /// - Fully expand all optional chunks, in which case the template for the - /// function "f" would have all of the parameters. - CXCompletionChunk_Optional(0), +/// This may be deprecated in a future version as this duplicates +/// the \c CXSymbolRole_Implicit bit in \c CXSymbolRole. +enum CXIdxEntityRefKind { + /// The entity is referenced directly in user's code. + CXIdxEntityRef_Direct(1), + + /// An implicit reference, e.g. a reference of an Objective-C method + /// via the dot syntax. + CXIdxEntityRef_Implicit(2); + + final int value; + const CXIdxEntityRefKind(this.value); + + static CXIdxEntityRefKind fromValue(int value) => switch (value) { + 1 => CXIdxEntityRef_Direct, + 2 => CXIdxEntityRef_Implicit, + _ => throw ArgumentError('Unknown value for CXIdxEntityRefKind: $value'), + }; +} - /// Text that a user would be expected to type to get this - /// code-completion result. - /// - /// There will be exactly one "typed text" chunk in a semantic string, which - /// will typically provide the spelling of a keyword or the name of a - /// declaration that could be used at the current code point. Clients are - /// expected to filter the code-completion results based on the text in this - /// chunk. - CXCompletionChunk_TypedText(1), +final class CXIdxIBOutletCollectionAttrInfo extends ffi.Struct { + external ffi.Pointer attrInfo; - /// Text that should be inserted as part of a code-completion result. - /// - /// A "text" chunk represents text that is part of the template to be - /// inserted into user code should this particular code-completion result - /// be selected. - CXCompletionChunk_Text(2), + external ffi.Pointer objcClass; - /// Placeholder text that should be replaced by the user. - /// - /// A "placeholder" chunk marks a place where the user should insert text - /// into the code-completion template. For example, placeholders might mark - /// the function parameters for a function declaration, to indicate that the - /// user should provide arguments for each of those parameters. The actual - /// text in a placeholder is a suggestion for the text to display before - /// the user replaces the placeholder with real code. - CXCompletionChunk_Placeholder(3), + external CXCursor classCursor; - /// Informative text that should be displayed but never inserted as - /// part of the template. - /// - /// An "informative" chunk contains annotations that can be displayed to - /// help the user decide whether a particular code-completion result is the - /// right option, but which is not part of the actual template to be inserted - /// by code completion. - CXCompletionChunk_Informative(4), + external CXIdxLoc classLoc; +} - /// Text that describes the current parameter when code-completion is - /// referring to function call, message send, or template specialization. - /// - /// A "current parameter" chunk occurs when code-completion is providing - /// information about a parameter corresponding to the argument at the - /// code-completion point. For example, given a function - /// - /// \code - /// int add(int x, int y); - /// \endcode - /// - /// and the source code \c add(, where the code-completion point is after the - /// "(", the code-completion string will contain a "current parameter" chunk - /// for "int x", indicating that the current argument will initialize that - /// parameter. After typing further, to \c add(17, (where the code-completion - /// point is after the ","), the code-completion string will contain a - /// "current parameter" chunk to "int y". - CXCompletionChunk_CurrentParameter(5), +/// Data for IndexerCallbacks#importedASTFile. +final class CXIdxImportedASTFileInfo extends ffi.Struct { + /// Top level AST file containing the imported PCH, module or submodule. + external CXFile file; - /// A left parenthesis ('('), used to initiate a function call or - /// signal the beginning of a function parameter list. - CXCompletionChunk_LeftParen(6), + /// The imported module or NULL if the AST file is a PCH. + external CXModule module; - /// A right parenthesis (')'), used to finish a function call or - /// signal the end of a function parameter list. - CXCompletionChunk_RightParen(7), + /// Location where the file is imported. Applicable only for modules. + external CXIdxLoc loc; - /// A left bracket ('['). - CXCompletionChunk_LeftBracket(8), + /// Non-zero if an inclusion directive was automatically turned into + /// a module import. Applicable only for modules. + @ffi.Int() + external int isImplicit; +} - /// A right bracket (']'). - CXCompletionChunk_RightBracket(9), +/// Data for ppIncludedFile callback. +final class CXIdxIncludedFileInfo extends ffi.Struct { + /// Location of '#' in the \#include/\#import directive. + external CXIdxLoc hashLoc; - /// A left brace ('{'). - CXCompletionChunk_LeftBrace(10), + /// Filename as written in the \#include/\#import directive. + external ffi.Pointer filename; - /// A right brace ('}'). - CXCompletionChunk_RightBrace(11), + /// The actual file that the \#include/\#import directive resolved to. + external CXFile file; - /// A left angle bracket ('<'). - CXCompletionChunk_LeftAngle(12), + @ffi.Int() + external int isImport; - /// A right angle bracket ('>'). - CXCompletionChunk_RightAngle(13), + @ffi.Int() + external int isAngled; - /// A comma separator (','). - CXCompletionChunk_Comma(14), + /// Non-zero if the directive was automatically turned into a module + /// import. + @ffi.Int() + external int isModuleImport; +} - /// Text that specifies the result type of a given result. - /// - /// This special kind of informative chunk is not meant to be inserted into - /// the text buffer. Rather, it is meant to illustrate the type that an - /// expression using the given completion string would have. - CXCompletionChunk_ResultType(15), +/// Source location passed to index callbacks. +final class CXIdxLoc extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array> ptr_data; - /// A colon (':'). - CXCompletionChunk_Colon(16), + @ffi.UnsignedInt() + external int int_data; +} - /// A semicolon (';'). - CXCompletionChunk_SemiColon(17), +final class CXIdxObjCCategoryDeclInfo extends ffi.Struct { + external ffi.Pointer containerInfo; - /// An '=' sign. - CXCompletionChunk_Equal(18), + external ffi.Pointer objcClass; - /// Horizontal space (' '). - CXCompletionChunk_HorizontalSpace(19), + external CXCursor classCursor; - /// Vertical space ('\\n'), after which it is generally a good idea to - /// perform indentation. - CXCompletionChunk_VerticalSpace(20); + external CXIdxLoc classLoc; - final int value; - const CXCompletionChunkKind(this.value); + external ffi.Pointer protocols; +} - static CXCompletionChunkKind fromValue(int value) => switch (value) { - 0 => CXCompletionChunk_Optional, - 1 => CXCompletionChunk_TypedText, - 2 => CXCompletionChunk_Text, - 3 => CXCompletionChunk_Placeholder, - 4 => CXCompletionChunk_Informative, - 5 => CXCompletionChunk_CurrentParameter, - 6 => CXCompletionChunk_LeftParen, - 7 => CXCompletionChunk_RightParen, - 8 => CXCompletionChunk_LeftBracket, - 9 => CXCompletionChunk_RightBracket, - 10 => CXCompletionChunk_LeftBrace, - 11 => CXCompletionChunk_RightBrace, - 12 => CXCompletionChunk_LeftAngle, - 13 => CXCompletionChunk_RightAngle, - 14 => CXCompletionChunk_Comma, - 15 => CXCompletionChunk_ResultType, - 16 => CXCompletionChunk_Colon, - 17 => CXCompletionChunk_SemiColon, - 18 => CXCompletionChunk_Equal, - 19 => CXCompletionChunk_HorizontalSpace, - 20 => CXCompletionChunk_VerticalSpace, - _ => throw ArgumentError('Unknown value for CXCompletionChunkKind: $value'), - }; +final class CXIdxObjCContainerDeclInfo extends ffi.Struct { + external ffi.Pointer declInfo; + + @ffi.UnsignedInt() + external int kindAsInt; + + CXIdxObjCContainerKind get kind => + CXIdxObjCContainerKind.fromValue(kindAsInt); + set kind(CXIdxObjCContainerKind value) => kindAsInt = value.value; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer declInfo, + required CXIdxObjCContainerKind kind, + }) => $allocator() + ..ref.declInfo = declInfo + ..ref.kind = kind; } -typedef NativeClang_getCompletionChunkKind = - ffi.UnsignedInt Function( - CXCompletionString completion_string, - ffi.UnsignedInt chunk_number, - ); -typedef DartClang_getCompletionChunkKind = - int Function(CXCompletionString completion_string, int chunk_number); -typedef NativeClang_getCompletionChunkText = - CXString Function( - CXCompletionString completion_string, - ffi.UnsignedInt chunk_number, - ); -typedef DartClang_getCompletionChunkText = - CXString Function(CXCompletionString completion_string, int chunk_number); -typedef NativeClang_getCompletionChunkCompletionString = - CXCompletionString Function( - CXCompletionString completion_string, - ffi.UnsignedInt chunk_number, - ); -typedef DartClang_getCompletionChunkCompletionString = - CXCompletionString Function( - CXCompletionString completion_string, - int chunk_number, - ); -typedef NativeClang_getNumCompletionChunks = - ffi.UnsignedInt Function(CXCompletionString completion_string); -typedef DartClang_getNumCompletionChunks = - int Function(CXCompletionString completion_string); -typedef NativeClang_getCompletionPriority = - ffi.UnsignedInt Function(CXCompletionString completion_string); -typedef DartClang_getCompletionPriority = - int Function(CXCompletionString completion_string); -typedef NativeClang_getCompletionAvailability = - ffi.UnsignedInt Function(CXCompletionString completion_string); -typedef DartClang_getCompletionAvailability = - int Function(CXCompletionString completion_string); -typedef NativeClang_getCompletionNumAnnotations = - ffi.UnsignedInt Function(CXCompletionString completion_string); -typedef DartClang_getCompletionNumAnnotations = - int Function(CXCompletionString completion_string); -typedef NativeClang_getCompletionAnnotation = - CXString Function( - CXCompletionString completion_string, - ffi.UnsignedInt annotation_number, - ); -typedef DartClang_getCompletionAnnotation = - CXString Function( - CXCompletionString completion_string, - int annotation_number, - ); -typedef NativeClang_getCompletionParent = - CXString Function( - CXCompletionString completion_string, - ffi.Pointer kind, - ); -typedef DartClang_getCompletionParent = - CXString Function( - CXCompletionString completion_string, - ffi.Pointer kind, - ); -typedef NativeClang_getCompletionBriefComment = - CXString Function(CXCompletionString completion_string); -typedef DartClang_getCompletionBriefComment = - CXString Function(CXCompletionString completion_string); -typedef NativeClang_getCursorCompletionString = - CXCompletionString Function(CXCursor cursor); -typedef DartClang_getCursorCompletionString = - CXCompletionString Function(CXCursor cursor); +enum CXIdxObjCContainerKind { + CXIdxObjCContainer_ForwardRef(0), + CXIdxObjCContainer_Interface(1), + CXIdxObjCContainer_Implementation(2); + + final int value; + const CXIdxObjCContainerKind(this.value); + + static CXIdxObjCContainerKind fromValue(int value) => switch (value) { + 0 => CXIdxObjCContainer_ForwardRef, + 1 => CXIdxObjCContainer_Interface, + 2 => CXIdxObjCContainer_Implementation, + _ => throw ArgumentError( + 'Unknown value for CXIdxObjCContainerKind: $value', + ), + }; +} -/// Contains the results of code-completion. -/// -/// This data structure contains the results of code completion, as -/// produced by \c clang_codeCompleteAt(). Its contents must be freed by -/// \c clang_disposeCodeCompleteResults. -final class CXCodeCompleteResults extends ffi.Struct { - /// The code-completion results. - external ffi.Pointer Results; +final class CXIdxObjCInterfaceDeclInfo extends ffi.Struct { + external ffi.Pointer containerInfo; - /// The number of code-completion results stored in the - /// \c Results array. - @ffi.UnsignedInt() - external int NumResults; + external ffi.Pointer superInfo; + + external ffi.Pointer protocols; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer containerInfo, + required ffi.Pointer superInfo, + required ffi.Pointer protocols, + }) => $allocator() + ..ref.containerInfo = containerInfo + ..ref.superInfo = superInfo + ..ref.protocols = protocols; } -typedef NativeClang_getCompletionNumFixIts = - ffi.UnsignedInt Function( - ffi.Pointer results, - ffi.UnsignedInt completion_index, - ); -typedef DartClang_getCompletionNumFixIts = - int Function( - ffi.Pointer results, - int completion_index, - ); -typedef NativeClang_getCompletionFixIt = - CXString Function( - ffi.Pointer results, - ffi.UnsignedInt completion_index, - ffi.UnsignedInt fixit_index, - ffi.Pointer replacement_range, - ); -typedef DartClang_getCompletionFixIt = - CXString Function( - ffi.Pointer results, - int completion_index, - int fixit_index, - ffi.Pointer replacement_range, - ); -typedef NativeClang_defaultCodeCompleteOptions = ffi.UnsignedInt Function(); -typedef DartClang_defaultCodeCompleteOptions = int Function(); -typedef NativeClang_codeCompleteAt = - ffi.Pointer Function( - CXTranslationUnit TU, - ffi.Pointer complete_filename, - ffi.UnsignedInt complete_line, - ffi.UnsignedInt complete_column, - ffi.Pointer unsaved_files, - ffi.UnsignedInt num_unsaved_files, - ffi.UnsignedInt options, - ); -typedef DartClang_codeCompleteAt = - ffi.Pointer Function( - CXTranslationUnit TU, - ffi.Pointer complete_filename, - int complete_line, - int complete_column, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ); -typedef NativeClang_sortCodeCompletionResults = - ffi.Void Function( - ffi.Pointer Results, - ffi.UnsignedInt NumResults, - ); -typedef DartClang_sortCodeCompletionResults = - void Function(ffi.Pointer Results, int NumResults); -typedef NativeClang_disposeCodeCompleteResults = - ffi.Void Function(ffi.Pointer Results); -typedef DartClang_disposeCodeCompleteResults = - void Function(ffi.Pointer Results); -typedef NativeClang_codeCompleteGetNumDiagnostics = - ffi.UnsignedInt Function(ffi.Pointer Results); -typedef DartClang_codeCompleteGetNumDiagnostics = - int Function(ffi.Pointer Results); -typedef NativeClang_codeCompleteGetDiagnostic = - CXDiagnostic Function( - ffi.Pointer Results, - ffi.UnsignedInt Index, - ); -typedef DartClang_codeCompleteGetDiagnostic = - CXDiagnostic Function( - ffi.Pointer Results, - int Index, - ); -typedef NativeClang_codeCompleteGetContexts = - ffi.UnsignedLongLong Function(ffi.Pointer Results); -typedef DartClang_codeCompleteGetContexts = - int Function(ffi.Pointer Results); -typedef NativeClang_codeCompleteGetContainerKind = - ffi.UnsignedInt Function( - ffi.Pointer Results, - ffi.Pointer IsIncomplete, - ); -typedef DartClang_codeCompleteGetContainerKind = - int Function( - ffi.Pointer Results, - ffi.Pointer IsIncomplete, - ); -typedef NativeClang_codeCompleteGetContainerUSR = - CXString Function(ffi.Pointer Results); -typedef DartClang_codeCompleteGetContainerUSR = - CXString Function(ffi.Pointer Results); -typedef NativeClang_codeCompleteGetObjCSelector = - CXString Function(ffi.Pointer Results); -typedef DartClang_codeCompleteGetObjCSelector = - CXString Function(ffi.Pointer Results); -typedef NativeClang_getClangVersion = CXString Function(); -typedef DartClang_getClangVersion = CXString Function(); -typedef NativeClang_toggleCrashRecovery = - ffi.Void Function(ffi.UnsignedInt isEnabled); -typedef DartClang_toggleCrashRecovery = void Function(int isEnabled); -typedef CXInclusionVisitorFunction = - ffi.Void Function( - CXFile included_file, - ffi.Pointer inclusion_stack, - ffi.UnsignedInt include_len, - CXClientData client_data, - ); -typedef DartCXInclusionVisitorFunction = - void Function( - CXFile included_file, - ffi.Pointer inclusion_stack, - int include_len, - CXClientData client_data, - ); +final class CXIdxObjCPropertyDeclInfo extends ffi.Struct { + external ffi.Pointer declInfo; + + external ffi.Pointer getter; + + external ffi.Pointer setter; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer declInfo, + required ffi.Pointer getter, + required ffi.Pointer setter, + }) => $allocator() + ..ref.declInfo = declInfo + ..ref.getter = getter + ..ref.setter = setter; +} + +final class CXIdxObjCProtocolRefInfo extends ffi.Struct { + external ffi.Pointer protocol; + + external CXCursor cursor; + + external CXIdxLoc loc; +} + +final class CXIdxObjCProtocolRefListInfo extends ffi.Struct { + external ffi.Pointer> protocols; + + @ffi.UnsignedInt() + external int numProtocols; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer> protocols, + required int numProtocols, + }) => $allocator() + ..ref.protocols = protocols + ..ref.numProtocols = numProtocols; +} /// Visitor invoked for each file in a translation unit /// (used with clang_getInclusions()). @@ -10502,193 +8905,280 @@ typedef DartCXInclusionVisitorFunction = /// the first element refers to the location that included 'included_file'. typedef CXInclusionVisitor = ffi.Pointer>; -typedef NativeClang_getInclusions = +typedef CXInclusionVisitorFunction = ffi.Void Function( - CXTranslationUnit tu, - CXInclusionVisitor visitor, + CXFile included_file, + ffi.Pointer inclusion_stack, + ffi.UnsignedInt include_len, CXClientData client_data, ); -typedef DartClang_getInclusions = +typedef DartCXInclusionVisitorFunction = void Function( - CXTranslationUnit tu, - CXInclusionVisitor visitor, + CXFile included_file, + ffi.Pointer inclusion_stack, + int include_len, CXClientData client_data, ); -enum CXEvalResultKind { - CXEval_Int(1), - CXEval_Float(2), - CXEval_ObjCStrLiteral(3), - CXEval_StrLiteral(4), - CXEval_CFStr(5), - CXEval_Other(6), - CXEval_UnExposed(0); +/// An "index" that consists of a set of translation units that would +/// typically be linked together into an executable or library. +typedef CXIndex = ffi.Pointer; + +/// An indexing action/session, to be applied to one or multiple +/// translation units. +typedef CXIndexAction = ffi.Pointer; + +/// Describe the "language" of the entity referred to by a cursor. +enum CXLanguageKind { + CXLanguage_Invalid(0), + CXLanguage_C(1), + CXLanguage_ObjC(2), + CXLanguage_CPlusPlus(3); + + final int value; + const CXLanguageKind(this.value); + + static CXLanguageKind fromValue(int value) => switch (value) { + 0 => CXLanguage_Invalid, + 1 => CXLanguage_C, + 2 => CXLanguage_ObjC, + 3 => CXLanguage_CPlusPlus, + _ => throw ArgumentError('Unknown value for CXLanguageKind: $value'), + }; +} + +/// Describe the linkage of the entity referred to by a cursor. +enum CXLinkageKind { + /// This value indicates that no linkage information is available + /// for a provided CXCursor. + CXLinkage_Invalid(0), + + /// This is the linkage for variables, parameters, and so on that + /// have automatic storage. This covers normal (non-extern) local variables. + CXLinkage_NoLinkage(1), + + /// This is the linkage for static variables and static functions. + CXLinkage_Internal(2), + + /// This is the linkage for entities with external linkage that live + /// in C++ anonymous namespaces. + CXLinkage_UniqueExternal(3), + + /// This is the linkage for entities with true, external linkage. + CXLinkage_External(4); + + final int value; + const CXLinkageKind(this.value); + + static CXLinkageKind fromValue(int value) => switch (value) { + 0 => CXLinkage_Invalid, + 1 => CXLinkage_NoLinkage, + 2 => CXLinkage_Internal, + 3 => CXLinkage_UniqueExternal, + 4 => CXLinkage_External, + _ => throw ArgumentError('Unknown value for CXLinkageKind: $value'), + }; +} + +/// Describes the kind of error that occurred (if any) in a call to +/// \c clang_loadDiagnostics. +enum CXLoadDiag_Error { + /// Indicates that no error occurred. + CXLoadDiag_None(0), + + /// Indicates that an unknown error occurred while attempting to + /// deserialize diagnostics. + CXLoadDiag_Unknown(1), + + /// Indicates that the file containing the serialized diagnostics + /// could not be opened. + CXLoadDiag_CannotLoad(2), + + /// Indicates that the serialized diagnostics file is invalid or + /// corrupt. + CXLoadDiag_InvalidFile(3); final int value; - const CXEvalResultKind(this.value); + const CXLoadDiag_Error(this.value); - static CXEvalResultKind fromValue(int value) => switch (value) { - 1 => CXEval_Int, - 2 => CXEval_Float, - 3 => CXEval_ObjCStrLiteral, - 4 => CXEval_StrLiteral, - 5 => CXEval_CFStr, - 6 => CXEval_Other, - 0 => CXEval_UnExposed, - _ => throw ArgumentError('Unknown value for CXEvalResultKind: $value'), + static CXLoadDiag_Error fromValue(int value) => switch (value) { + 0 => CXLoadDiag_None, + 1 => CXLoadDiag_Unknown, + 2 => CXLoadDiag_CannotLoad, + 3 => CXLoadDiag_InvalidFile, + _ => throw ArgumentError('Unknown value for CXLoadDiag_Error: $value'), }; } -/// Evaluation result of a cursor -typedef CXEvalResult = ffi.Pointer; -typedef NativeClang_Cursor_Evaluate = CXEvalResult Function(CXCursor C); -typedef DartClang_Cursor_Evaluate = CXEvalResult Function(CXCursor C); -typedef NativeClang_EvalResult_getKind = - ffi.UnsignedInt Function(CXEvalResult E); -typedef DartClang_EvalResult_getKind = int Function(CXEvalResult E); -typedef NativeClang_EvalResult_getAsInt = ffi.Int Function(CXEvalResult E); -typedef DartClang_EvalResult_getAsInt = int Function(CXEvalResult E); -typedef NativeClang_EvalResult_getAsLongLong = - ffi.LongLong Function(CXEvalResult E); -typedef DartClang_EvalResult_getAsLongLong = int Function(CXEvalResult E); -typedef NativeClang_EvalResult_isUnsignedInt = - ffi.UnsignedInt Function(CXEvalResult E); -typedef DartClang_EvalResult_isUnsignedInt = int Function(CXEvalResult E); -typedef NativeClang_EvalResult_getAsUnsigned = - ffi.UnsignedLongLong Function(CXEvalResult E); -typedef DartClang_EvalResult_getAsUnsigned = int Function(CXEvalResult E); -typedef NativeClang_EvalResult_getAsDouble = - ffi.Double Function(CXEvalResult E); -typedef DartClang_EvalResult_getAsDouble = double Function(CXEvalResult E); -typedef NativeClang_EvalResult_getAsStr = - ffi.Pointer Function(CXEvalResult E); -typedef DartClang_EvalResult_getAsStr = - ffi.Pointer Function(CXEvalResult E); -typedef NativeClang_EvalResult_dispose = ffi.Void Function(CXEvalResult E); -typedef DartClang_EvalResult_dispose = void Function(CXEvalResult E); +/// \defgroup CINDEX_MODULE Module introspection +/// +/// The functions in this group provide access to information about modules. +/// +/// @{ +typedef CXModule = ffi.Pointer; -/// A remapping of original source files and their translated files. -typedef CXRemapping = ffi.Pointer; -typedef NativeClang_getRemappings = - CXRemapping Function(ffi.Pointer path); -typedef DartClang_getRemappings = - CXRemapping Function(ffi.Pointer path); -typedef NativeClang_getRemappingsFromFileList = - CXRemapping Function( - ffi.Pointer> filePaths, - ffi.UnsignedInt numFiles, - ); -typedef DartClang_getRemappingsFromFileList = - CXRemapping Function( - ffi.Pointer> filePaths, - int numFiles, - ); -typedef NativeClang_remap_getNumFiles = ffi.UnsignedInt Function(CXRemapping); -typedef DartClang_remap_getNumFiles = int Function(CXRemapping); -typedef NativeClang_remap_getFilenames = - ffi.Void Function( - CXRemapping, - ffi.UnsignedInt index, - ffi.Pointer original, - ffi.Pointer transformed, - ); -typedef DartClang_remap_getFilenames = - void Function( - CXRemapping, - int index, - ffi.Pointer original, - ffi.Pointer transformed, - ); -typedef NativeClang_remap_dispose = ffi.Void Function(CXRemapping); -typedef DartClang_remap_dispose = void Function(CXRemapping); +/// Describes the availability of a given entity on a particular platform, e.g., +/// a particular class might only be available on Mac OS 10.7 or newer. +final class CXPlatformAvailability extends ffi.Struct { + /// A string that describes the platform for which this structure + /// provides availability information. + /// + /// Possible values are "ios" or "macos". + external CXString Platform; -/// \defgroup CINDEX_HIGH Higher level API functions + /// The version number in which this entity was introduced. + external CXVersion Introduced; + + /// The version number in which this entity was deprecated (but is + /// still available). + external CXVersion Deprecated; + + /// The version number in which this entity was obsoleted, and therefore + /// is no longer available. + external CXVersion Obsoleted; + + /// Whether the entity is unconditionally unavailable on this platform. + @ffi.Int() + external int Unavailable; + + /// An optional message to provide to a user of this API, e.g., to + /// suggest replacement APIs. + external CXString Message; +} + +/// Opaque pointer representing a policy that controls pretty printing +/// for \c clang_getCursorPrettyPrinted. +typedef CXPrintingPolicy = ffi.Pointer; + +/// Properties for the printing policy. /// -/// @{ -enum CXVisitorResult { - CXVisit_Break(0), - CXVisit_Continue(1); +/// See \c clang::PrintingPolicy for more information. +enum CXPrintingPolicyProperty { + CXPrintingPolicy_Indentation(0), + CXPrintingPolicy_SuppressSpecifiers(1), + CXPrintingPolicy_SuppressTagKeyword(2), + CXPrintingPolicy_IncludeTagDefinition(3), + CXPrintingPolicy_SuppressScope(4), + CXPrintingPolicy_SuppressUnwrittenScope(5), + CXPrintingPolicy_SuppressInitializers(6), + CXPrintingPolicy_ConstantArraySizeAsWritten(7), + CXPrintingPolicy_AnonymousTagLocations(8), + CXPrintingPolicy_SuppressStrongLifetime(9), + CXPrintingPolicy_SuppressLifetimeQualifiers(10), + CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors(11), + CXPrintingPolicy_Bool(12), + CXPrintingPolicy_Restrict(13), + CXPrintingPolicy_Alignof(14), + CXPrintingPolicy_UnderscoreAlignof(15), + CXPrintingPolicy_UseVoidForZeroParams(16), + CXPrintingPolicy_TerseOutput(17), + CXPrintingPolicy_PolishForDeclaration(18), + CXPrintingPolicy_Half(19), + CXPrintingPolicy_MSWChar(20), + CXPrintingPolicy_IncludeNewlines(21), + CXPrintingPolicy_MSVCFormatting(22), + CXPrintingPolicy_ConstantsAsWritten(23), + CXPrintingPolicy_SuppressImplicitBase(24), + CXPrintingPolicy_FullyQualifiedName(25); + + static const CXPrintingPolicy_LastProperty = + CXPrintingPolicy_FullyQualifiedName; final int value; - const CXVisitorResult(this.value); + const CXPrintingPolicyProperty(this.value); - static CXVisitorResult fromValue(int value) => switch (value) { - 0 => CXVisit_Break, - 1 => CXVisit_Continue, - _ => throw ArgumentError('Unknown value for CXVisitorResult: $value'), + static CXPrintingPolicyProperty fromValue(int value) => switch (value) { + 0 => CXPrintingPolicy_Indentation, + 1 => CXPrintingPolicy_SuppressSpecifiers, + 2 => CXPrintingPolicy_SuppressTagKeyword, + 3 => CXPrintingPolicy_IncludeTagDefinition, + 4 => CXPrintingPolicy_SuppressScope, + 5 => CXPrintingPolicy_SuppressUnwrittenScope, + 6 => CXPrintingPolicy_SuppressInitializers, + 7 => CXPrintingPolicy_ConstantArraySizeAsWritten, + 8 => CXPrintingPolicy_AnonymousTagLocations, + 9 => CXPrintingPolicy_SuppressStrongLifetime, + 10 => CXPrintingPolicy_SuppressLifetimeQualifiers, + 11 => CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + 12 => CXPrintingPolicy_Bool, + 13 => CXPrintingPolicy_Restrict, + 14 => CXPrintingPolicy_Alignof, + 15 => CXPrintingPolicy_UnderscoreAlignof, + 16 => CXPrintingPolicy_UseVoidForZeroParams, + 17 => CXPrintingPolicy_TerseOutput, + 18 => CXPrintingPolicy_PolishForDeclaration, + 19 => CXPrintingPolicy_Half, + 20 => CXPrintingPolicy_MSWChar, + 21 => CXPrintingPolicy_IncludeNewlines, + 22 => CXPrintingPolicy_MSVCFormatting, + 23 => CXPrintingPolicy_ConstantsAsWritten, + 24 => CXPrintingPolicy_SuppressImplicitBase, + 25 => CXPrintingPolicy_FullyQualifiedName, + _ => throw ArgumentError( + 'Unknown value for CXPrintingPolicyProperty: $value', + ), }; -} - -final class CXCursorAndRangeVisitor extends ffi.Struct { - external ffi.Pointer context; - external ffi.Pointer< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer, CXCursor, CXSourceRange) - > - > - visit; + @override + String toString() { + if (this == CXPrintingPolicy_FullyQualifiedName) + return "CXPrintingPolicyProperty.CXPrintingPolicy_FullyQualifiedName, CXPrintingPolicyProperty.CXPrintingPolicy_LastProperty"; + return super.toString(); + } } -enum CXResult { - /// Function returned successfully. - CXResult_Success(0), +enum CXRefQualifierKind { + /// No ref-qualifier was provided. + CXRefQualifier_None(0), - /// One of the parameters was invalid for the function. - CXResult_Invalid(1), + /// An lvalue ref-qualifier was provided (\c &). + CXRefQualifier_LValue(1), - /// The function was terminated by a callback (e.g. it returned - /// CXVisit_Break) - CXResult_VisitBreak(2); + /// An rvalue ref-qualifier was provided (\c &&). + CXRefQualifier_RValue(2); final int value; - const CXResult(this.value); + const CXRefQualifierKind(this.value); - static CXResult fromValue(int value) => switch (value) { - 0 => CXResult_Success, - 1 => CXResult_Invalid, - 2 => CXResult_VisitBreak, - _ => throw ArgumentError('Unknown value for CXResult: $value'), + static CXRefQualifierKind fromValue(int value) => switch (value) { + 0 => CXRefQualifier_None, + 1 => CXRefQualifier_LValue, + 2 => CXRefQualifier_RValue, + _ => throw ArgumentError('Unknown value for CXRefQualifierKind: $value'), }; } -typedef NativeClang_findReferencesInFile = - ffi.UnsignedInt Function( - CXCursor cursor, - CXFile file, - CXCursorAndRangeVisitor visitor, - ); -typedef DartClang_findReferencesInFile = - int Function(CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor); -typedef NativeClang_findIncludesInFile = - ffi.UnsignedInt Function( - CXTranslationUnit TU, - CXFile file, - CXCursorAndRangeVisitor visitor, - ); -typedef DartClang_findIncludesInFile = - int Function( - CXTranslationUnit TU, - CXFile file, - CXCursorAndRangeVisitor visitor, - ); +/// A remapping of original source files and their translated files. +typedef CXRemapping = ffi.Pointer; -/// The client's data object that is associated with a CXFile. -typedef CXIdxClientFile = ffi.Pointer; +enum CXResult { + /// Function returned successfully. + CXResult_Success(0), -/// The client's data object that is associated with a semantic entity. -typedef CXIdxClientEntity = ffi.Pointer; + /// One of the parameters was invalid for the function. + CXResult_Invalid(1), -/// The client's data object that is associated with a semantic container -/// of entities. -typedef CXIdxClientContainer = ffi.Pointer; + /// The function was terminated by a callback (e.g. it returned + /// CXVisit_Break) + CXResult_VisitBreak(2); -/// The client's data object that is associated with an AST file (PCH -/// or module). -typedef CXIdxClientASTFile = ffi.Pointer; + final int value; + const CXResult(this.value); -/// Source location passed to index callbacks. -final class CXIdxLoc extends ffi.Struct { + static CXResult fromValue(int value) => switch (value) { + 0 => CXResult_Success, + 1 => CXResult_Invalid, + 2 => CXResult_VisitBreak, + _ => throw ArgumentError('Unknown value for CXResult: $value'), + }; +} + +/// Identifies a specific source location within a translation +/// unit. +/// +/// Use clang_getExpansionLocation() or clang_getSpellingLocation() +/// to map a source location to a particular file, line, and column. +final class CXSourceLocation extends ffi.Struct { @ffi.Array.multi([2]) external ffi.Array> ptr_data; @@ -10696,454 +9186,757 @@ final class CXIdxLoc extends ffi.Struct { external int int_data; } -/// Data for ppIncludedFile callback. -final class CXIdxIncludedFileInfo extends ffi.Struct { - /// Location of '#' in the \#include/\#import directive. - external CXIdxLoc hashLoc; - - /// Filename as written in the \#include/\#import directive. - external ffi.Pointer filename; - - /// The actual file that the \#include/\#import directive resolved to. - external CXFile file; - - @ffi.Int() - external int isImport; +/// Identifies a half-open character range in the source code. +/// +/// Use clang_getRangeStart() and clang_getRangeEnd() to retrieve the +/// starting and end locations from a source range, respectively. +final class CXSourceRange extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array> ptr_data; - @ffi.Int() - external int isAngled; + @ffi.UnsignedInt() + external int begin_int_data; - /// Non-zero if the directive was automatically turned into a module - /// import. - @ffi.Int() - external int isModuleImport; + @ffi.UnsignedInt() + external int end_int_data; } -/// Data for IndexerCallbacks#importedASTFile. -final class CXIdxImportedASTFileInfo extends ffi.Struct { - /// Top level AST file containing the imported PCH, module or submodule. - external CXFile file; - - /// The imported module or NULL if the AST file is a PCH. - external CXModule module; +/// Identifies an array of ranges. +final class CXSourceRangeList extends ffi.Struct { + /// The number of ranges in the \c ranges array. + @ffi.UnsignedInt() + external int count; - /// Location where the file is imported. Applicable only for modules. - external CXIdxLoc loc; + /// An array of \c CXSourceRanges. + external ffi.Pointer ranges; - /// Non-zero if an inclusion directive was automatically turned into - /// a module import. Applicable only for modules. - @ffi.Int() - external int isImplicit; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int count, + required ffi.Pointer ranges, + }) => $allocator() + ..ref.count = count + ..ref.ranges = ranges; } -enum CXIdxEntityKind { - CXIdxEntity_Unexposed(0), - CXIdxEntity_Typedef(1), - CXIdxEntity_Function(2), - CXIdxEntity_Variable(3), - CXIdxEntity_Field(4), - CXIdxEntity_EnumConstant(5), - CXIdxEntity_ObjCClass(6), - CXIdxEntity_ObjCProtocol(7), - CXIdxEntity_ObjCCategory(8), - CXIdxEntity_ObjCInstanceMethod(9), - CXIdxEntity_ObjCClassMethod(10), - CXIdxEntity_ObjCProperty(11), - CXIdxEntity_ObjCIvar(12), - CXIdxEntity_Enum(13), - CXIdxEntity_Struct(14), - CXIdxEntity_Union(15), - CXIdxEntity_CXXClass(16), - CXIdxEntity_CXXNamespace(17), - CXIdxEntity_CXXNamespaceAlias(18), - CXIdxEntity_CXXStaticVariable(19), - CXIdxEntity_CXXStaticMethod(20), - CXIdxEntity_CXXInstanceMethod(21), - CXIdxEntity_CXXConstructor(22), - CXIdxEntity_CXXDestructor(23), - CXIdxEntity_CXXConversionFunction(24), - CXIdxEntity_CXXTypeAlias(25), - CXIdxEntity_CXXInterface(26); +/// A character string. +/// +/// The \c CXString type is used to return strings from the interface when +/// the ownership of that string might differ from one call to the next. +/// Use \c clang_getCString() to retrieve the string data and, once finished +/// with the string data, call \c clang_disposeString() to free the string. +final class CXString extends ffi.Struct { + external ffi.Pointer data; - final int value; - const CXIdxEntityKind(this.value); + @ffi.UnsignedInt() + external int private_flags; - static CXIdxEntityKind fromValue(int value) => switch (value) { - 0 => CXIdxEntity_Unexposed, - 1 => CXIdxEntity_Typedef, - 2 => CXIdxEntity_Function, - 3 => CXIdxEntity_Variable, - 4 => CXIdxEntity_Field, - 5 => CXIdxEntity_EnumConstant, - 6 => CXIdxEntity_ObjCClass, - 7 => CXIdxEntity_ObjCProtocol, - 8 => CXIdxEntity_ObjCCategory, - 9 => CXIdxEntity_ObjCInstanceMethod, - 10 => CXIdxEntity_ObjCClassMethod, - 11 => CXIdxEntity_ObjCProperty, - 12 => CXIdxEntity_ObjCIvar, - 13 => CXIdxEntity_Enum, - 14 => CXIdxEntity_Struct, - 15 => CXIdxEntity_Union, - 16 => CXIdxEntity_CXXClass, - 17 => CXIdxEntity_CXXNamespace, - 18 => CXIdxEntity_CXXNamespaceAlias, - 19 => CXIdxEntity_CXXStaticVariable, - 20 => CXIdxEntity_CXXStaticMethod, - 21 => CXIdxEntity_CXXInstanceMethod, - 22 => CXIdxEntity_CXXConstructor, - 23 => CXIdxEntity_CXXDestructor, - 24 => CXIdxEntity_CXXConversionFunction, - 25 => CXIdxEntity_CXXTypeAlias, - 26 => CXIdxEntity_CXXInterface, - _ => throw ArgumentError('Unknown value for CXIdxEntityKind: $value'), - }; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer data, + required int private_flags, + }) => $allocator() + ..ref.data = data + ..ref.private_flags = private_flags; } -enum CXIdxEntityLanguage { - CXIdxEntityLang_None(0), - CXIdxEntityLang_C(1), - CXIdxEntityLang_ObjC(2), - CXIdxEntityLang_CXX(3), - CXIdxEntityLang_Swift(4); +final class CXStringSet extends ffi.Struct { + external ffi.Pointer Strings; - final int value; - const CXIdxEntityLanguage(this.value); + @ffi.UnsignedInt() + external int Count; - static CXIdxEntityLanguage fromValue(int value) => switch (value) { - 0 => CXIdxEntityLang_None, - 1 => CXIdxEntityLang_C, - 2 => CXIdxEntityLang_ObjC, - 3 => CXIdxEntityLang_CXX, - 4 => CXIdxEntityLang_Swift, - _ => throw ArgumentError('Unknown value for CXIdxEntityLanguage: $value'), - }; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer Strings, + required int Count, + }) => $allocator() + ..ref.Strings = Strings + ..ref.Count = Count; } -/// Extra C++ template information for an entity. This can apply to: -/// CXIdxEntity_Function -/// CXIdxEntity_CXXClass -/// CXIdxEntity_CXXStaticMethod -/// CXIdxEntity_CXXInstanceMethod -/// CXIdxEntity_CXXConstructor -/// CXIdxEntity_CXXConversionFunction -/// CXIdxEntity_CXXTypeAlias -enum CXIdxEntityCXXTemplateKind { - CXIdxEntity_NonTemplate(0), - CXIdxEntity_Template(1), - CXIdxEntity_TemplatePartialSpecialization(2), - CXIdxEntity_TemplateSpecialization(3); +/// Roles that are attributed to symbol occurrences. +/// +/// Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with +/// higher bits zeroed. These high bits may be exposed in the future. +enum CXSymbolRole { + CXSymbolRole_None(0), + CXSymbolRole_Declaration(1), + CXSymbolRole_Definition(2), + CXSymbolRole_Reference(4), + CXSymbolRole_Read(8), + CXSymbolRole_Write(16), + CXSymbolRole_Call(32), + CXSymbolRole_Dynamic(64), + CXSymbolRole_AddressOf(128), + CXSymbolRole_Implicit(256); final int value; - const CXIdxEntityCXXTemplateKind(this.value); + const CXSymbolRole(this.value); - static CXIdxEntityCXXTemplateKind fromValue(int value) => switch (value) { - 0 => CXIdxEntity_NonTemplate, - 1 => CXIdxEntity_Template, - 2 => CXIdxEntity_TemplatePartialSpecialization, - 3 => CXIdxEntity_TemplateSpecialization, - _ => throw ArgumentError( - 'Unknown value for CXIdxEntityCXXTemplateKind: $value', - ), + static CXSymbolRole fromValue(int value) => switch (value) { + 0 => CXSymbolRole_None, + 1 => CXSymbolRole_Declaration, + 2 => CXSymbolRole_Definition, + 4 => CXSymbolRole_Reference, + 8 => CXSymbolRole_Read, + 16 => CXSymbolRole_Write, + 32 => CXSymbolRole_Call, + 64 => CXSymbolRole_Dynamic, + 128 => CXSymbolRole_AddressOf, + 256 => CXSymbolRole_Implicit, + _ => throw ArgumentError('Unknown value for CXSymbolRole: $value'), }; } -enum CXIdxAttrKind { - CXIdxAttr_Unexposed(0), - CXIdxAttr_IBAction(1), - CXIdxAttr_IBOutlet(2), - CXIdxAttr_IBOutletCollection(3); +/// Describe the "thread-local storage (TLS) kind" of the declaration +/// referred to by a cursor. +enum CXTLSKind { + CXTLS_None(0), + CXTLS_Dynamic(1), + CXTLS_Static(2); final int value; - const CXIdxAttrKind(this.value); + const CXTLSKind(this.value); - static CXIdxAttrKind fromValue(int value) => switch (value) { - 0 => CXIdxAttr_Unexposed, - 1 => CXIdxAttr_IBAction, - 2 => CXIdxAttr_IBOutlet, - 3 => CXIdxAttr_IBOutletCollection, - _ => throw ArgumentError('Unknown value for CXIdxAttrKind: $value'), + static CXTLSKind fromValue(int value) => switch (value) { + 0 => CXTLS_None, + 1 => CXTLS_Dynamic, + 2 => CXTLS_Static, + _ => throw ArgumentError('Unknown value for CXTLSKind: $value'), }; } -final class CXIdxAttrInfo extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; +/// The memory usage of a CXTranslationUnit, broken into categories. +final class CXTUResourceUsage extends ffi.Struct { + external ffi.Pointer data; - CXIdxAttrKind get kind => CXIdxAttrKind.fromValue(kindAsInt); - set kind(CXIdxAttrKind value) => kindAsInt = value.value; + @ffi.UnsignedInt() + external int numEntries; - external CXCursor cursor; + external ffi.Pointer entries; - external CXIdxLoc loc; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer data, + required int numEntries, + required ffi.Pointer entries, + }) => $allocator() + ..ref.data = data + ..ref.numEntries = numEntries + ..ref.entries = entries; } -final class CXIdxEntityInfo extends ffi.Struct { +final class CXTUResourceUsageEntry extends ffi.Struct { @ffi.UnsignedInt() external int kindAsInt; - CXIdxEntityKind get kind => CXIdxEntityKind.fromValue(kindAsInt); - set kind(CXIdxEntityKind value) => kindAsInt = value.value; - - @ffi.UnsignedInt() - external int templateKindAsInt; - - CXIdxEntityCXXTemplateKind get templateKind => - CXIdxEntityCXXTemplateKind.fromValue(templateKindAsInt); - set templateKind(CXIdxEntityCXXTemplateKind value) => - templateKindAsInt = value.value; + CXTUResourceUsageKind get kind => CXTUResourceUsageKind.fromValue(kindAsInt); + set kind(CXTUResourceUsageKind value) => kindAsInt = value.value; - @ffi.UnsignedInt() - external int langAsInt; + @ffi.UnsignedLong() + external int amount; - CXIdxEntityLanguage get lang => CXIdxEntityLanguage.fromValue(langAsInt); - set lang(CXIdxEntityLanguage value) => langAsInt = value.value; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required CXTUResourceUsageKind kind, + required int amount, + }) => $allocator() + ..ref.kind = kind + ..ref.amount = amount; +} - external ffi.Pointer name; +/// Categorizes how memory is being used by a translation unit. +enum CXTUResourceUsageKind { + CXTUResourceUsage_AST(1), + CXTUResourceUsage_Identifiers(2), + CXTUResourceUsage_Selectors(3), + CXTUResourceUsage_GlobalCompletionResults(4), + CXTUResourceUsage_SourceManagerContentCache(5), + CXTUResourceUsage_AST_SideTables(6), + CXTUResourceUsage_SourceManager_Membuffer_Malloc(7), + CXTUResourceUsage_SourceManager_Membuffer_MMap(8), + CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc(9), + CXTUResourceUsage_ExternalASTSource_Membuffer_MMap(10), + CXTUResourceUsage_Preprocessor(11), + CXTUResourceUsage_PreprocessingRecord(12), + CXTUResourceUsage_SourceManager_DataStructures(13), + CXTUResourceUsage_Preprocessor_HeaderSearch(14); - external ffi.Pointer USR; + static const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST; + static const CXTUResourceUsage_MEMORY_IN_BYTES_END = + CXTUResourceUsage_Preprocessor_HeaderSearch; + static const CXTUResourceUsage_First = CXTUResourceUsage_AST; + static const CXTUResourceUsage_Last = + CXTUResourceUsage_Preprocessor_HeaderSearch; - external CXCursor cursor; + final int value; + const CXTUResourceUsageKind(this.value); - external ffi.Pointer> attributes; + static CXTUResourceUsageKind fromValue(int value) => switch (value) { + 1 => CXTUResourceUsage_AST, + 2 => CXTUResourceUsage_Identifiers, + 3 => CXTUResourceUsage_Selectors, + 4 => CXTUResourceUsage_GlobalCompletionResults, + 5 => CXTUResourceUsage_SourceManagerContentCache, + 6 => CXTUResourceUsage_AST_SideTables, + 7 => CXTUResourceUsage_SourceManager_Membuffer_Malloc, + 8 => CXTUResourceUsage_SourceManager_Membuffer_MMap, + 9 => CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc, + 10 => CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, + 11 => CXTUResourceUsage_Preprocessor, + 12 => CXTUResourceUsage_PreprocessingRecord, + 13 => CXTUResourceUsage_SourceManager_DataStructures, + 14 => CXTUResourceUsage_Preprocessor_HeaderSearch, + _ => throw ArgumentError('Unknown value for CXTUResourceUsageKind: $value'), + }; - @ffi.UnsignedInt() - external int numAttributes; + @override + String toString() { + if (this == CXTUResourceUsage_AST) + return "CXTUResourceUsageKind.CXTUResourceUsage_AST, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN, CXTUResourceUsageKind.CXTUResourceUsage_First"; + if (this == CXTUResourceUsage_Preprocessor_HeaderSearch) + return "CXTUResourceUsageKind.CXTUResourceUsage_Preprocessor_HeaderSearch, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_END, CXTUResourceUsageKind.CXTUResourceUsage_Last"; + return super.toString(); + } } -final class CXIdxContainerInfo extends ffi.Struct { - external CXCursor cursor; -} +/// An opaque type representing target information for a given translation +/// unit. +typedef CXTargetInfo = ffi.Pointer; -final class CXIdxIBOutletCollectionAttrInfo extends ffi.Struct { - external ffi.Pointer attrInfo; +final class CXTargetInfoImpl extends ffi.Opaque {} - external ffi.Pointer objcClass; +/// Describes the kind of a template argument. +/// +/// See the definition of llvm::clang::TemplateArgument::ArgKind for full +/// element descriptions. +enum CXTemplateArgumentKind { + CXTemplateArgumentKind_Null(0), + CXTemplateArgumentKind_Type(1), + CXTemplateArgumentKind_Declaration(2), + CXTemplateArgumentKind_NullPtr(3), + CXTemplateArgumentKind_Integral(4), + CXTemplateArgumentKind_Template(5), + CXTemplateArgumentKind_TemplateExpansion(6), + CXTemplateArgumentKind_Expression(7), + CXTemplateArgumentKind_Pack(8), + CXTemplateArgumentKind_Invalid(9); - external CXCursor classCursor; + final int value; + const CXTemplateArgumentKind(this.value); - external CXIdxLoc classLoc; + static CXTemplateArgumentKind fromValue(int value) => switch (value) { + 0 => CXTemplateArgumentKind_Null, + 1 => CXTemplateArgumentKind_Type, + 2 => CXTemplateArgumentKind_Declaration, + 3 => CXTemplateArgumentKind_NullPtr, + 4 => CXTemplateArgumentKind_Integral, + 5 => CXTemplateArgumentKind_Template, + 6 => CXTemplateArgumentKind_TemplateExpansion, + 7 => CXTemplateArgumentKind_Expression, + 8 => CXTemplateArgumentKind_Pack, + 9 => CXTemplateArgumentKind_Invalid, + _ => throw ArgumentError( + 'Unknown value for CXTemplateArgumentKind: $value', + ), + }; } -final class CXIdxDeclInfo extends ffi.Struct { - external ffi.Pointer entityInfo; +/// Describes a single preprocessing token. +final class CXToken extends ffi.Struct { + @ffi.Array.multi([4]) + external ffi.Array int_data; - external CXCursor cursor; + external ffi.Pointer ptr_data; +} - external CXIdxLoc loc; +/// Describes a kind of token. +enum CXTokenKind { + /// A token that contains some kind of punctuation. + CXToken_Punctuation(0), - external ffi.Pointer semanticContainer; + /// A language keyword. + CXToken_Keyword(1), - /// Generally same as #semanticContainer but can be different in - /// cases like out-of-line C++ member functions. - external ffi.Pointer lexicalContainer; + /// An identifier (that is not a keyword). + CXToken_Identifier(2), - @ffi.Int() - external int isRedeclaration; + /// A numeric, string, or character literal. + CXToken_Literal(3), - @ffi.Int() - external int isDefinition; + /// A comment. + CXToken_Comment(4); - @ffi.Int() - external int isContainer; + final int value; + const CXTokenKind(this.value); - external ffi.Pointer declAsContainer; + static CXTokenKind fromValue(int value) => switch (value) { + 0 => CXToken_Punctuation, + 1 => CXToken_Keyword, + 2 => CXToken_Identifier, + 3 => CXToken_Literal, + 4 => CXToken_Comment, + _ => throw ArgumentError('Unknown value for CXTokenKind: $value'), + }; +} - /// Whether the declaration exists in code or was created implicitly - /// by the compiler, e.g. implicit Objective-C methods for properties. - @ffi.Int() - external int isImplicit; +/// A single translation unit, which resides in an index. +typedef CXTranslationUnit = ffi.Pointer; - external ffi.Pointer> attributes; +final class CXTranslationUnitImpl extends ffi.Opaque {} +/// The type of an element in the abstract syntax tree. +final class CXType extends ffi.Struct { @ffi.UnsignedInt() - external int numAttributes; + external int kindAsInt; - @ffi.UnsignedInt() - external int flags; + CXTypeKind get kind => CXTypeKind.fromValue(kindAsInt); + set kind(CXTypeKind value) => kindAsInt = value.value; + + @ffi.Array.multi([2]) + external ffi.Array> data; } -enum CXIdxObjCContainerKind { - CXIdxObjCContainer_ForwardRef(0), - CXIdxObjCContainer_Interface(1), - CXIdxObjCContainer_Implementation(2); +/// Describes the kind of type +enum CXTypeKind { + /// Represents an invalid type (e.g., where no type is available). + CXType_Invalid(0), + + /// A type whose specific kind is not exposed via this + /// interface. + CXType_Unexposed(1), + CXType_Void(2), + CXType_Bool(3), + CXType_Char_U(4), + CXType_UChar(5), + CXType_Char16(6), + CXType_Char32(7), + CXType_UShort(8), + CXType_UInt(9), + CXType_ULong(10), + CXType_ULongLong(11), + CXType_UInt128(12), + CXType_Char_S(13), + CXType_SChar(14), + CXType_WChar(15), + CXType_Short(16), + CXType_Int(17), + CXType_Long(18), + CXType_LongLong(19), + CXType_Int128(20), + CXType_Float(21), + CXType_Double(22), + CXType_LongDouble(23), + CXType_NullPtr(24), + CXType_Overload(25), + CXType_Dependent(26), + CXType_ObjCId(27), + CXType_ObjCClass(28), + CXType_ObjCSel(29), + CXType_Float128(30), + CXType_Half(31), + CXType_Float16(32), + CXType_ShortAccum(33), + CXType_Accum(34), + CXType_LongAccum(35), + CXType_UShortAccum(36), + CXType_UAccum(37), + CXType_ULongAccum(38), + CXType_Complex(100), + CXType_Pointer(101), + CXType_BlockPointer(102), + CXType_LValueReference(103), + CXType_RValueReference(104), + CXType_Record(105), + CXType_Enum(106), + CXType_Typedef(107), + CXType_ObjCInterface(108), + CXType_ObjCObjectPointer(109), + CXType_FunctionNoProto(110), + CXType_FunctionProto(111), + CXType_ConstantArray(112), + CXType_Vector(113), + CXType_IncompleteArray(114), + CXType_VariableArray(115), + CXType_DependentSizedArray(116), + CXType_MemberPointer(117), + CXType_Auto(118), + + /// Represents a type that was referred to using an elaborated type keyword. + /// + /// E.g., struct S, or via a qualified name, e.g., N::M::type, or both. + CXType_Elaborated(119), + CXType_Pipe(120), + CXType_OCLImage1dRO(121), + CXType_OCLImage1dArrayRO(122), + CXType_OCLImage1dBufferRO(123), + CXType_OCLImage2dRO(124), + CXType_OCLImage2dArrayRO(125), + CXType_OCLImage2dDepthRO(126), + CXType_OCLImage2dArrayDepthRO(127), + CXType_OCLImage2dMSAARO(128), + CXType_OCLImage2dArrayMSAARO(129), + CXType_OCLImage2dMSAADepthRO(130), + CXType_OCLImage2dArrayMSAADepthRO(131), + CXType_OCLImage3dRO(132), + CXType_OCLImage1dWO(133), + CXType_OCLImage1dArrayWO(134), + CXType_OCLImage1dBufferWO(135), + CXType_OCLImage2dWO(136), + CXType_OCLImage2dArrayWO(137), + CXType_OCLImage2dDepthWO(138), + CXType_OCLImage2dArrayDepthWO(139), + CXType_OCLImage2dMSAAWO(140), + CXType_OCLImage2dArrayMSAAWO(141), + CXType_OCLImage2dMSAADepthWO(142), + CXType_OCLImage2dArrayMSAADepthWO(143), + CXType_OCLImage3dWO(144), + CXType_OCLImage1dRW(145), + CXType_OCLImage1dArrayRW(146), + CXType_OCLImage1dBufferRW(147), + CXType_OCLImage2dRW(148), + CXType_OCLImage2dArrayRW(149), + CXType_OCLImage2dDepthRW(150), + CXType_OCLImage2dArrayDepthRW(151), + CXType_OCLImage2dMSAARW(152), + CXType_OCLImage2dArrayMSAARW(153), + CXType_OCLImage2dMSAADepthRW(154), + CXType_OCLImage2dArrayMSAADepthRW(155), + CXType_OCLImage3dRW(156), + CXType_OCLSampler(157), + CXType_OCLEvent(158), + CXType_OCLQueue(159), + CXType_OCLReserveID(160), + CXType_ObjCObject(161), + CXType_ObjCTypeParam(162), + CXType_Attributed(163), + CXType_OCLIntelSubgroupAVCMcePayload(164), + CXType_OCLIntelSubgroupAVCImePayload(165), + CXType_OCLIntelSubgroupAVCRefPayload(166), + CXType_OCLIntelSubgroupAVCSicPayload(167), + CXType_OCLIntelSubgroupAVCMceResult(168), + CXType_OCLIntelSubgroupAVCImeResult(169), + CXType_OCLIntelSubgroupAVCRefResult(170), + CXType_OCLIntelSubgroupAVCSicResult(171), + CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout(172), + CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout(173), + CXType_OCLIntelSubgroupAVCImeSingleRefStreamin(174), + CXType_OCLIntelSubgroupAVCImeDualRefStreamin(175), + CXType_ExtVector(176); + + static const CXType_FirstBuiltin = CXType_Void; + static const CXType_LastBuiltin = CXType_ULongAccum; final int value; - const CXIdxObjCContainerKind(this.value); + const CXTypeKind(this.value); - static CXIdxObjCContainerKind fromValue(int value) => switch (value) { - 0 => CXIdxObjCContainer_ForwardRef, - 1 => CXIdxObjCContainer_Interface, - 2 => CXIdxObjCContainer_Implementation, - _ => throw ArgumentError( - 'Unknown value for CXIdxObjCContainerKind: $value', - ), + static CXTypeKind fromValue(int value) => switch (value) { + 0 => CXType_Invalid, + 1 => CXType_Unexposed, + 2 => CXType_Void, + 3 => CXType_Bool, + 4 => CXType_Char_U, + 5 => CXType_UChar, + 6 => CXType_Char16, + 7 => CXType_Char32, + 8 => CXType_UShort, + 9 => CXType_UInt, + 10 => CXType_ULong, + 11 => CXType_ULongLong, + 12 => CXType_UInt128, + 13 => CXType_Char_S, + 14 => CXType_SChar, + 15 => CXType_WChar, + 16 => CXType_Short, + 17 => CXType_Int, + 18 => CXType_Long, + 19 => CXType_LongLong, + 20 => CXType_Int128, + 21 => CXType_Float, + 22 => CXType_Double, + 23 => CXType_LongDouble, + 24 => CXType_NullPtr, + 25 => CXType_Overload, + 26 => CXType_Dependent, + 27 => CXType_ObjCId, + 28 => CXType_ObjCClass, + 29 => CXType_ObjCSel, + 30 => CXType_Float128, + 31 => CXType_Half, + 32 => CXType_Float16, + 33 => CXType_ShortAccum, + 34 => CXType_Accum, + 35 => CXType_LongAccum, + 36 => CXType_UShortAccum, + 37 => CXType_UAccum, + 38 => CXType_ULongAccum, + 100 => CXType_Complex, + 101 => CXType_Pointer, + 102 => CXType_BlockPointer, + 103 => CXType_LValueReference, + 104 => CXType_RValueReference, + 105 => CXType_Record, + 106 => CXType_Enum, + 107 => CXType_Typedef, + 108 => CXType_ObjCInterface, + 109 => CXType_ObjCObjectPointer, + 110 => CXType_FunctionNoProto, + 111 => CXType_FunctionProto, + 112 => CXType_ConstantArray, + 113 => CXType_Vector, + 114 => CXType_IncompleteArray, + 115 => CXType_VariableArray, + 116 => CXType_DependentSizedArray, + 117 => CXType_MemberPointer, + 118 => CXType_Auto, + 119 => CXType_Elaborated, + 120 => CXType_Pipe, + 121 => CXType_OCLImage1dRO, + 122 => CXType_OCLImage1dArrayRO, + 123 => CXType_OCLImage1dBufferRO, + 124 => CXType_OCLImage2dRO, + 125 => CXType_OCLImage2dArrayRO, + 126 => CXType_OCLImage2dDepthRO, + 127 => CXType_OCLImage2dArrayDepthRO, + 128 => CXType_OCLImage2dMSAARO, + 129 => CXType_OCLImage2dArrayMSAARO, + 130 => CXType_OCLImage2dMSAADepthRO, + 131 => CXType_OCLImage2dArrayMSAADepthRO, + 132 => CXType_OCLImage3dRO, + 133 => CXType_OCLImage1dWO, + 134 => CXType_OCLImage1dArrayWO, + 135 => CXType_OCLImage1dBufferWO, + 136 => CXType_OCLImage2dWO, + 137 => CXType_OCLImage2dArrayWO, + 138 => CXType_OCLImage2dDepthWO, + 139 => CXType_OCLImage2dArrayDepthWO, + 140 => CXType_OCLImage2dMSAAWO, + 141 => CXType_OCLImage2dArrayMSAAWO, + 142 => CXType_OCLImage2dMSAADepthWO, + 143 => CXType_OCLImage2dArrayMSAADepthWO, + 144 => CXType_OCLImage3dWO, + 145 => CXType_OCLImage1dRW, + 146 => CXType_OCLImage1dArrayRW, + 147 => CXType_OCLImage1dBufferRW, + 148 => CXType_OCLImage2dRW, + 149 => CXType_OCLImage2dArrayRW, + 150 => CXType_OCLImage2dDepthRW, + 151 => CXType_OCLImage2dArrayDepthRW, + 152 => CXType_OCLImage2dMSAARW, + 153 => CXType_OCLImage2dArrayMSAARW, + 154 => CXType_OCLImage2dMSAADepthRW, + 155 => CXType_OCLImage2dArrayMSAADepthRW, + 156 => CXType_OCLImage3dRW, + 157 => CXType_OCLSampler, + 158 => CXType_OCLEvent, + 159 => CXType_OCLQueue, + 160 => CXType_OCLReserveID, + 161 => CXType_ObjCObject, + 162 => CXType_ObjCTypeParam, + 163 => CXType_Attributed, + 164 => CXType_OCLIntelSubgroupAVCMcePayload, + 165 => CXType_OCLIntelSubgroupAVCImePayload, + 166 => CXType_OCLIntelSubgroupAVCRefPayload, + 167 => CXType_OCLIntelSubgroupAVCSicPayload, + 168 => CXType_OCLIntelSubgroupAVCMceResult, + 169 => CXType_OCLIntelSubgroupAVCImeResult, + 170 => CXType_OCLIntelSubgroupAVCRefResult, + 171 => CXType_OCLIntelSubgroupAVCSicResult, + 172 => CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout, + 173 => CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout, + 174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin, + 175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin, + 176 => CXType_ExtVector, + _ => throw ArgumentError('Unknown value for CXTypeKind: $value'), }; -} - -final class CXIdxObjCContainerDeclInfo extends ffi.Struct { - external ffi.Pointer declInfo; - - @ffi.UnsignedInt() - external int kindAsInt; - CXIdxObjCContainerKind get kind => - CXIdxObjCContainerKind.fromValue(kindAsInt); - set kind(CXIdxObjCContainerKind value) => kindAsInt = value.value; + @override + String toString() { + if (this == CXType_Void) + return "CXTypeKind.CXType_Void, CXTypeKind.CXType_FirstBuiltin"; + if (this == CXType_ULongAccum) + return "CXTypeKind.CXType_ULongAccum, CXTypeKind.CXType_LastBuiltin"; + return super.toString(); + } } -final class CXIdxBaseClassInfo extends ffi.Struct { - external ffi.Pointer base; +enum CXTypeNullabilityKind { + /// Values of this type can never be null. + CXTypeNullability_NonNull(0), - external CXCursor cursor; + /// Values of this type can be null. + CXTypeNullability_Nullable(1), - external CXIdxLoc loc; -} + /// Whether values of this type can be null is (explicitly) + /// unspecified. This captures a (fairly rare) case where we + /// can't conclude anything about the nullability of the type even + /// though it has been considered. + CXTypeNullability_Unspecified(2), -final class CXIdxObjCProtocolRefInfo extends ffi.Struct { - external ffi.Pointer protocol; + /// Nullability is not applicable to this type. + CXTypeNullability_Invalid(3); - external CXCursor cursor; + final int value; + const CXTypeNullabilityKind(this.value); - external CXIdxLoc loc; + static CXTypeNullabilityKind fromValue(int value) => switch (value) { + 0 => CXTypeNullability_NonNull, + 1 => CXTypeNullability_Nullable, + 2 => CXTypeNullability_Unspecified, + 3 => CXTypeNullability_Invalid, + _ => throw ArgumentError('Unknown value for CXTypeNullabilityKind: $value'), + }; } -final class CXIdxObjCProtocolRefListInfo extends ffi.Struct { - external ffi.Pointer> protocols; - - @ffi.UnsignedInt() - external int numProtocols; -} +/// Provides the contents of a file that has not yet been saved to disk. +/// +/// Each CXUnsavedFile instance provides the name of a file on the +/// system along with the current contents of that file that have not +/// yet been saved to disk. +final class CXUnsavedFile extends ffi.Struct { + /// The file whose contents have not yet been saved. + /// + /// This file must already exist in the file system. + external ffi.Pointer Filename; -final class CXIdxObjCInterfaceDeclInfo extends ffi.Struct { - external ffi.Pointer containerInfo; + /// A buffer containing the unsaved contents of this file. + external ffi.Pointer Contents; - external ffi.Pointer superInfo; + /// The length of the unsaved contents of this buffer. + @ffi.UnsignedLong() + external int Length; - external ffi.Pointer protocols; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer Filename, + required ffi.Pointer Contents, + required int Length, + }) => $allocator() + ..ref.Filename = Filename + ..ref.Contents = Contents + ..ref.Length = Length; } -final class CXIdxObjCCategoryDeclInfo extends ffi.Struct { - external ffi.Pointer containerInfo; - - external ffi.Pointer objcClass; +/// Describes a version number of the form major.minor.subminor. +final class CXVersion extends ffi.Struct { + /// The major version number, e.g., the '10' in '10.7.3'. A negative + /// value indicates that there is no version number at all. + @ffi.Int() + external int Major; - external CXCursor classCursor; + /// The minor version number, e.g., the '7' in '10.7.3'. This value + /// will be negative if no minor version number was provided, e.g., for + /// version '10'. + @ffi.Int() + external int Minor; - external CXIdxLoc classLoc; + /// The subminor version number, e.g., the '3' in '10.7.3'. This value + /// will be negative if no minor or subminor version number was provided, + /// e.g., in version '10' or '10.7'. + @ffi.Int() + external int Subminor; - external ffi.Pointer protocols; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int Major, + required int Minor, + required int Subminor, + }) => $allocator() + ..ref.Major = Major + ..ref.Minor = Minor + ..ref.Subminor = Subminor; } -final class CXIdxObjCPropertyDeclInfo extends ffi.Struct { - external ffi.Pointer declInfo; +enum CXVisibilityKind { + /// This value indicates that no visibility information is available + /// for a provided CXCursor. + CXVisibility_Invalid(0), - external ffi.Pointer getter; + /// Symbol not seen by the linker. + CXVisibility_Hidden(1), - external ffi.Pointer setter; -} + /// Symbol seen by the linker but resolves to a symbol inside this object. + CXVisibility_Protected(2), -final class CXIdxCXXClassDeclInfo extends ffi.Struct { - external ffi.Pointer declInfo; + /// Symbol seen by the linker and acts like a normal symbol. + CXVisibility_Default(3); - external ffi.Pointer> bases; + final int value; + const CXVisibilityKind(this.value); - @ffi.UnsignedInt() - external int numBases; + static CXVisibilityKind fromValue(int value) => switch (value) { + 0 => CXVisibility_Invalid, + 1 => CXVisibility_Hidden, + 2 => CXVisibility_Protected, + 3 => CXVisibility_Default, + _ => throw ArgumentError('Unknown value for CXVisibilityKind: $value'), + }; } -/// Data for IndexerCallbacks#indexEntityReference. +/// \defgroup CINDEX_HIGH Higher level API functions /// -/// This may be deprecated in a future version as this duplicates -/// the \c CXSymbolRole_Implicit bit in \c CXSymbolRole. -enum CXIdxEntityRefKind { - /// The entity is referenced directly in user's code. - CXIdxEntityRef_Direct(1), - - /// An implicit reference, e.g. a reference of an Objective-C method - /// via the dot syntax. - CXIdxEntityRef_Implicit(2); +/// @{ +enum CXVisitorResult { + CXVisit_Break(0), + CXVisit_Continue(1); final int value; - const CXIdxEntityRefKind(this.value); + const CXVisitorResult(this.value); - static CXIdxEntityRefKind fromValue(int value) => switch (value) { - 1 => CXIdxEntityRef_Direct, - 2 => CXIdxEntityRef_Implicit, - _ => throw ArgumentError('Unknown value for CXIdxEntityRefKind: $value'), + static CXVisitorResult fromValue(int value) => switch (value) { + 0 => CXVisit_Break, + 1 => CXVisit_Continue, + _ => throw ArgumentError('Unknown value for CXVisitorResult: $value'), }; } -/// Roles that are attributed to symbol occurrences. -/// -/// Internal: this currently mirrors low 9 bits of clang::index::SymbolRole with -/// higher bits zeroed. These high bits may be exposed in the future. -enum CXSymbolRole { - CXSymbolRole_None(0), - CXSymbolRole_Declaration(1), - CXSymbolRole_Definition(2), - CXSymbolRole_Reference(4), - CXSymbolRole_Read(8), - CXSymbolRole_Write(16), - CXSymbolRole_Call(32), - CXSymbolRole_Dynamic(64), - CXSymbolRole_AddressOf(128), - CXSymbolRole_Implicit(256); +/// Represents the C++ access control level to a base class for a +/// cursor with kind CX_CXXBaseSpecifier. +enum CX_CXXAccessSpecifier { + CX_CXXInvalidAccessSpecifier(0), + CX_CXXPublic(1), + CX_CXXProtected(2), + CX_CXXPrivate(3); final int value; - const CXSymbolRole(this.value); + const CX_CXXAccessSpecifier(this.value); - static CXSymbolRole fromValue(int value) => switch (value) { - 0 => CXSymbolRole_None, - 1 => CXSymbolRole_Declaration, - 2 => CXSymbolRole_Definition, - 4 => CXSymbolRole_Reference, - 8 => CXSymbolRole_Read, - 16 => CXSymbolRole_Write, - 32 => CXSymbolRole_Call, - 64 => CXSymbolRole_Dynamic, - 128 => CXSymbolRole_AddressOf, - 256 => CXSymbolRole_Implicit, - _ => throw ArgumentError('Unknown value for CXSymbolRole: $value'), + static CX_CXXAccessSpecifier fromValue(int value) => switch (value) { + 0 => CX_CXXInvalidAccessSpecifier, + 1 => CX_CXXPublic, + 2 => CX_CXXProtected, + 3 => CX_CXXPrivate, + _ => throw ArgumentError('Unknown value for CX_CXXAccessSpecifier: $value'), }; } -/// Data for IndexerCallbacks#indexEntityReference. -final class CXIdxEntityRefInfo extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; - - CXIdxEntityRefKind get kind => CXIdxEntityRefKind.fromValue(kindAsInt); - set kind(CXIdxEntityRefKind value) => kindAsInt = value.value; - - /// Reference cursor. - external CXCursor cursor; - - external CXIdxLoc loc; - - /// The entity that gets referenced. - external ffi.Pointer referencedEntity; - - /// Immediate "parent" of the reference. For example: - /// - /// \code - /// Foo *var; - /// \endcode - /// - /// The parent of reference of type 'Foo' is the variable 'var'. - /// For references inside statement bodies of functions/methods, - /// the parentEntity will be the function/method. - external ffi.Pointer parentEntity; - - /// Lexical container context of the reference. - external ffi.Pointer container; +/// Represents the storage classes as declared in the source. CX_SC_Invalid +/// was added for the case that the passed cursor in not a declaration. +enum CX_StorageClass { + CX_SC_Invalid(0), + CX_SC_None(1), + CX_SC_Extern(2), + CX_SC_Static(3), + CX_SC_PrivateExtern(4), + CX_SC_OpenCLWorkGroupLocal(5), + CX_SC_Auto(6), + CX_SC_Register(7); - /// Sets of symbol roles of the reference. - @ffi.UnsignedInt() - external int roleAsInt; + final int value; + const CX_StorageClass(this.value); - CXSymbolRole get role => CXSymbolRole.fromValue(roleAsInt); - set role(CXSymbolRole value) => roleAsInt = value.value; + static CX_StorageClass fromValue(int value) => switch (value) { + 0 => CX_SC_Invalid, + 1 => CX_SC_None, + 2 => CX_SC_Extern, + 3 => CX_SC_Static, + 4 => CX_SC_PrivateExtern, + 5 => CX_SC_OpenCLWorkGroupLocal, + 6 => CX_SC_Auto, + 7 => CX_SC_Register, + _ => throw ArgumentError('Unknown value for CX_StorageClass: $value'), + }; } /// A group of callbacks used by #clang_indexSourceFile and @@ -11226,11 +10019,1364 @@ final class IndexerCallbacks extends ffi.Struct { > > indexEntityReference; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + CXClientData client_data, + ffi.Pointer reserved, + ) + > + > + abortQuery, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(CXClientData, CXDiagnosticSet, ffi.Pointer) + > + > + diagnostic, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientFile Function( + CXClientData client_data, + CXFile mainFile, + ffi.Pointer reserved, + ) + > + > + enteredMainFile, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientFile Function( + CXClientData, + ffi.Pointer, + ) + > + > + ppIncludedFile, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientASTFile Function( + CXClientData, + ffi.Pointer, + ) + > + > + importedASTFile, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientContainer Function( + CXClientData client_data, + ffi.Pointer reserved, + ) + > + > + startedTranslationUnit, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(CXClientData, ffi.Pointer) + > + > + indexDeclaration, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(CXClientData, ffi.Pointer) + > + > + indexEntityReference, + }) => $allocator() + ..ref.abortQuery = abortQuery + ..ref.diagnostic = diagnostic + ..ref.enteredMainFile = enteredMainFile + ..ref.ppIncludedFile = ppIncludedFile + ..ref.importedASTFile = importedASTFile + ..ref.startedTranslationUnit = startedTranslationUnit + ..ref.indexDeclaration = indexDeclaration + ..ref.indexEntityReference = indexEntityReference; } -typedef NativeClang_index_isEntityObjCContainerKind = - ffi.Int Function(ffi.UnsignedInt); -typedef DartClang_index_isEntityObjCContainerKind = int Function(int); +typedef NativeClang_CXCursorSet_contains = + ffi.UnsignedInt Function(CXCursorSet cset, CXCursor cursor); +typedef DartClang_CXCursorSet_contains = + int Function(CXCursorSet cset, CXCursor cursor); +typedef NativeClang_CXCursorSet_insert = + ffi.UnsignedInt Function(CXCursorSet cset, CXCursor cursor); +typedef DartClang_CXCursorSet_insert = + int Function(CXCursorSet cset, CXCursor cursor); +typedef NativeClang_CXIndex_getGlobalOptions = + ffi.UnsignedInt Function(CXIndex); +typedef DartClang_CXIndex_getGlobalOptions = int Function(CXIndex); +typedef NativeClang_CXIndex_setGlobalOptions = + ffi.Void Function(CXIndex, ffi.UnsignedInt options); +typedef DartClang_CXIndex_setGlobalOptions = + void Function(CXIndex, int options); +typedef NativeClang_CXIndex_setInvocationEmissionPathOption = + ffi.Void Function(CXIndex, ffi.Pointer Path); +typedef DartClang_CXIndex_setInvocationEmissionPathOption = + void Function(CXIndex, ffi.Pointer Path); +typedef NativeClang_CXXConstructor_isConvertingConstructor = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXConstructor_isConvertingConstructor = + int Function(CXCursor C); +typedef NativeClang_CXXConstructor_isCopyConstructor = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXConstructor_isCopyConstructor = int Function(CXCursor C); +typedef NativeClang_CXXConstructor_isDefaultConstructor = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXConstructor_isDefaultConstructor = + int Function(CXCursor C); +typedef NativeClang_CXXConstructor_isMoveConstructor = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXConstructor_isMoveConstructor = int Function(CXCursor C); +typedef NativeClang_CXXField_isMutable = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXField_isMutable = int Function(CXCursor C); +typedef NativeClang_CXXMethod_isConst = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXMethod_isConst = int Function(CXCursor C); +typedef NativeClang_CXXMethod_isDefaulted = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXMethod_isDefaulted = int Function(CXCursor C); +typedef NativeClang_CXXMethod_isPureVirtual = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXMethod_isPureVirtual = int Function(CXCursor C); +typedef NativeClang_CXXMethod_isStatic = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXMethod_isStatic = int Function(CXCursor C); +typedef NativeClang_CXXMethod_isVirtual = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXMethod_isVirtual = int Function(CXCursor C); +typedef NativeClang_CXXRecord_isAbstract = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_CXXRecord_isAbstract = int Function(CXCursor C); +typedef NativeClang_Cursor_Evaluate = CXEvalResult Function(CXCursor C); +typedef DartClang_Cursor_Evaluate = CXEvalResult Function(CXCursor C); +typedef NativeClang_Cursor_getArgument = + CXCursor Function(CXCursor C, ffi.UnsignedInt i); +typedef DartClang_Cursor_getArgument = CXCursor Function(CXCursor C, int i); +typedef NativeClang_Cursor_getBriefCommentText = CXString Function(CXCursor C); +typedef DartClang_Cursor_getBriefCommentText = CXString Function(CXCursor C); +typedef NativeClang_Cursor_getCXXManglings = + ffi.Pointer Function(CXCursor); +typedef DartClang_Cursor_getCXXManglings = + ffi.Pointer Function(CXCursor); +typedef NativeClang_Cursor_getCommentRange = CXSourceRange Function(CXCursor C); +typedef DartClang_Cursor_getCommentRange = CXSourceRange Function(CXCursor C); +typedef NativeClang_Cursor_getMangling = CXString Function(CXCursor); +typedef DartClang_Cursor_getMangling = CXString Function(CXCursor); +typedef NativeClang_Cursor_getModule = CXModule Function(CXCursor C); +typedef DartClang_Cursor_getModule = CXModule Function(CXCursor C); +typedef NativeClang_Cursor_getNumArguments = ffi.Int Function(CXCursor C); +typedef DartClang_Cursor_getNumArguments = int Function(CXCursor C); +typedef NativeClang_Cursor_getNumTemplateArguments = + ffi.Int Function(CXCursor C); +typedef DartClang_Cursor_getNumTemplateArguments = int Function(CXCursor C); +typedef NativeClang_Cursor_getObjCDeclQualifiers = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_getObjCDeclQualifiers = int Function(CXCursor C); +typedef NativeClang_Cursor_getObjCManglings = + ffi.Pointer Function(CXCursor); +typedef DartClang_Cursor_getObjCManglings = + ffi.Pointer Function(CXCursor); +typedef NativeClang_Cursor_getObjCPropertyAttributes = + ffi.UnsignedInt Function(CXCursor C, ffi.UnsignedInt reserved); +typedef DartClang_Cursor_getObjCPropertyAttributes = + int Function(CXCursor C, int reserved); +typedef NativeClang_Cursor_getObjCPropertyGetterName = + CXString Function(CXCursor C); +typedef DartClang_Cursor_getObjCPropertyGetterName = + CXString Function(CXCursor C); +typedef NativeClang_Cursor_getObjCPropertySetterName = + CXString Function(CXCursor C); +typedef DartClang_Cursor_getObjCPropertySetterName = + CXString Function(CXCursor C); +typedef NativeClang_Cursor_getObjCSelectorIndex = ffi.Int Function(CXCursor); +typedef DartClang_Cursor_getObjCSelectorIndex = int Function(CXCursor); +typedef NativeClang_Cursor_getOffsetOfField = ffi.LongLong Function(CXCursor C); +typedef DartClang_Cursor_getOffsetOfField = int Function(CXCursor C); +typedef NativeClang_Cursor_getRawCommentText = CXString Function(CXCursor C); +typedef DartClang_Cursor_getRawCommentText = CXString Function(CXCursor C); +typedef NativeClang_Cursor_getReceiverType = CXType Function(CXCursor C); +typedef DartClang_Cursor_getReceiverType = CXType Function(CXCursor C); +typedef NativeClang_Cursor_getSpellingNameRange = + CXSourceRange Function( + CXCursor, + ffi.UnsignedInt pieceIndex, + ffi.UnsignedInt options, + ); +typedef DartClang_Cursor_getSpellingNameRange = + CXSourceRange Function(CXCursor, int pieceIndex, int options); +typedef NativeClang_Cursor_getStorageClass = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_Cursor_getStorageClass = int Function(CXCursor); +typedef NativeClang_Cursor_getTemplateArgumentKind = + ffi.UnsignedInt Function(CXCursor C, ffi.UnsignedInt I); +typedef DartClang_Cursor_getTemplateArgumentKind = + int Function(CXCursor C, int I); +typedef NativeClang_Cursor_getTemplateArgumentType = + CXType Function(CXCursor C, ffi.UnsignedInt I); +typedef DartClang_Cursor_getTemplateArgumentType = + CXType Function(CXCursor C, int I); +typedef NativeClang_Cursor_getTemplateArgumentUnsignedValue = + ffi.UnsignedLongLong Function(CXCursor C, ffi.UnsignedInt I); +typedef DartClang_Cursor_getTemplateArgumentUnsignedValue = + int Function(CXCursor C, int I); +typedef NativeClang_Cursor_getTemplateArgumentValue = + ffi.LongLong Function(CXCursor C, ffi.UnsignedInt I); +typedef DartClang_Cursor_getTemplateArgumentValue = + int Function(CXCursor C, int I); +typedef NativeClang_Cursor_getTranslationUnit = + CXTranslationUnit Function(CXCursor); +typedef DartClang_Cursor_getTranslationUnit = + CXTranslationUnit Function(CXCursor); +typedef NativeClang_Cursor_hasAttrs = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_hasAttrs = int Function(CXCursor C); +typedef NativeClang_Cursor_isAnonymous = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isAnonymous = int Function(CXCursor C); +typedef NativeClang_Cursor_isAnonymousRecordDecl = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isAnonymousRecordDecl = int Function(CXCursor C); +typedef NativeClang_Cursor_isBitField = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isBitField = int Function(CXCursor C); +typedef NativeClang_Cursor_isDynamicCall = ffi.Int Function(CXCursor C); +typedef DartClang_Cursor_isDynamicCall = int Function(CXCursor C); +typedef NativeClang_Cursor_isExternalSymbol = + ffi.UnsignedInt Function( + CXCursor C, + ffi.Pointer language, + ffi.Pointer definedIn, + ffi.Pointer isGenerated, + ); +typedef DartClang_Cursor_isExternalSymbol = + int Function( + CXCursor C, + ffi.Pointer language, + ffi.Pointer definedIn, + ffi.Pointer isGenerated, + ); +typedef NativeClang_Cursor_isFunctionInlined = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isFunctionInlined = int Function(CXCursor C); +typedef NativeClang_Cursor_isInlineNamespace = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isInlineNamespace = int Function(CXCursor C); +typedef NativeClang_Cursor_isMacroBuiltin = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isMacroBuiltin = int Function(CXCursor C); +typedef NativeClang_Cursor_isMacroFunctionLike = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isMacroFunctionLike = int Function(CXCursor C); +typedef NativeClang_Cursor_isNull = ffi.Int Function(CXCursor cursor); +typedef DartClang_Cursor_isNull = int Function(CXCursor cursor); +typedef NativeClang_Cursor_isObjCOptional = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isObjCOptional = int Function(CXCursor C); +typedef NativeClang_Cursor_isVariadic = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_Cursor_isVariadic = int Function(CXCursor C); +typedef NativeClang_EnumDecl_isScoped = ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_EnumDecl_isScoped = int Function(CXCursor C); +typedef NativeClang_EvalResult_dispose = ffi.Void Function(CXEvalResult E); +typedef DartClang_EvalResult_dispose = void Function(CXEvalResult E); +typedef NativeClang_EvalResult_getAsDouble = + ffi.Double Function(CXEvalResult E); +typedef DartClang_EvalResult_getAsDouble = double Function(CXEvalResult E); +typedef NativeClang_EvalResult_getAsInt = ffi.Int Function(CXEvalResult E); +typedef DartClang_EvalResult_getAsInt = int Function(CXEvalResult E); +typedef NativeClang_EvalResult_getAsLongLong = + ffi.LongLong Function(CXEvalResult E); +typedef DartClang_EvalResult_getAsLongLong = int Function(CXEvalResult E); +typedef NativeClang_EvalResult_getAsStr = + ffi.Pointer Function(CXEvalResult E); +typedef DartClang_EvalResult_getAsStr = + ffi.Pointer Function(CXEvalResult E); +typedef NativeClang_EvalResult_getAsUnsigned = + ffi.UnsignedLongLong Function(CXEvalResult E); +typedef DartClang_EvalResult_getAsUnsigned = int Function(CXEvalResult E); +typedef NativeClang_EvalResult_getKind = + ffi.UnsignedInt Function(CXEvalResult E); +typedef DartClang_EvalResult_getKind = int Function(CXEvalResult E); +typedef NativeClang_EvalResult_isUnsignedInt = + ffi.UnsignedInt Function(CXEvalResult E); +typedef DartClang_EvalResult_isUnsignedInt = int Function(CXEvalResult E); +typedef NativeClang_File_isEqual = ffi.Int Function(CXFile file1, CXFile file2); +typedef DartClang_File_isEqual = int Function(CXFile file1, CXFile file2); +typedef NativeClang_File_tryGetRealPathName = CXString Function(CXFile file); +typedef DartClang_File_tryGetRealPathName = CXString Function(CXFile file); +typedef NativeClang_IndexAction_create = CXIndexAction Function(CXIndex CIdx); +typedef DartClang_IndexAction_create = CXIndexAction Function(CXIndex CIdx); +typedef NativeClang_IndexAction_dispose = ffi.Void Function(CXIndexAction); +typedef DartClang_IndexAction_dispose = void Function(CXIndexAction); +typedef NativeClang_Location_isFromMainFile = + ffi.Int Function(CXSourceLocation location); +typedef DartClang_Location_isFromMainFile = + int Function(CXSourceLocation location); +typedef NativeClang_Location_isInSystemHeader = + ffi.Int Function(CXSourceLocation location); +typedef DartClang_Location_isInSystemHeader = + int Function(CXSourceLocation location); +typedef NativeClang_Module_getASTFile = CXFile Function(CXModule Module); +typedef DartClang_Module_getASTFile = CXFile Function(CXModule Module); +typedef NativeClang_Module_getFullName = CXString Function(CXModule Module); +typedef DartClang_Module_getFullName = CXString Function(CXModule Module); +typedef NativeClang_Module_getName = CXString Function(CXModule Module); +typedef DartClang_Module_getName = CXString Function(CXModule Module); +typedef NativeClang_Module_getNumTopLevelHeaders = + ffi.UnsignedInt Function(CXTranslationUnit, CXModule Module); +typedef DartClang_Module_getNumTopLevelHeaders = + int Function(CXTranslationUnit, CXModule Module); +typedef NativeClang_Module_getParent = CXModule Function(CXModule Module); +typedef DartClang_Module_getParent = CXModule Function(CXModule Module); +typedef NativeClang_Module_getTopLevelHeader = + CXFile Function(CXTranslationUnit, CXModule Module, ffi.UnsignedInt Index); +typedef DartClang_Module_getTopLevelHeader = + CXFile Function(CXTranslationUnit, CXModule Module, int Index); +typedef NativeClang_Module_isSystem = ffi.Int Function(CXModule Module); +typedef DartClang_Module_isSystem = int Function(CXModule Module); +typedef NativeClang_PrintingPolicy_dispose = + ffi.Void Function(CXPrintingPolicy Policy); +typedef DartClang_PrintingPolicy_dispose = + void Function(CXPrintingPolicy Policy); +typedef NativeClang_PrintingPolicy_getProperty = + ffi.UnsignedInt Function(CXPrintingPolicy Policy, ffi.UnsignedInt Property); +typedef DartClang_PrintingPolicy_getProperty = + int Function(CXPrintingPolicy Policy, int Property); +typedef NativeClang_PrintingPolicy_setProperty = + ffi.Void Function( + CXPrintingPolicy Policy, + ffi.UnsignedInt Property, + ffi.UnsignedInt Value, + ); +typedef DartClang_PrintingPolicy_setProperty = + void Function(CXPrintingPolicy Policy, int Property, int Value); +typedef NativeClang_Range_isNull = ffi.Int Function(CXSourceRange range); +typedef DartClang_Range_isNull = int Function(CXSourceRange range); +typedef NativeClang_TargetInfo_dispose = ffi.Void Function(CXTargetInfo Info); +typedef DartClang_TargetInfo_dispose = void Function(CXTargetInfo Info); +typedef NativeClang_TargetInfo_getPointerWidth = + ffi.Int Function(CXTargetInfo Info); +typedef DartClang_TargetInfo_getPointerWidth = int Function(CXTargetInfo Info); +typedef NativeClang_TargetInfo_getTriple = CXString Function(CXTargetInfo Info); +typedef DartClang_TargetInfo_getTriple = CXString Function(CXTargetInfo Info); +typedef NativeClang_Type_getAlignOf = ffi.LongLong Function(CXType T); +typedef DartClang_Type_getAlignOf = int Function(CXType T); +typedef NativeClang_Type_getCXXRefQualifier = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_Type_getCXXRefQualifier = int Function(CXType T); +typedef NativeClang_Type_getClassType = CXType Function(CXType T); +typedef DartClang_Type_getClassType = CXType Function(CXType T); +typedef NativeClang_Type_getModifiedType = CXType Function(CXType T); +typedef DartClang_Type_getModifiedType = CXType Function(CXType T); +typedef NativeClang_Type_getNamedType = CXType Function(CXType T); +typedef DartClang_Type_getNamedType = CXType Function(CXType T); +typedef NativeClang_Type_getNullability = ffi.UnsignedInt Function(CXType T); +typedef DartClang_Type_getNullability = int Function(CXType T); +typedef NativeClang_Type_getNumObjCProtocolRefs = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_Type_getNumObjCProtocolRefs = int Function(CXType T); +typedef NativeClang_Type_getNumObjCTypeArgs = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_Type_getNumObjCTypeArgs = int Function(CXType T); +typedef NativeClang_Type_getNumTemplateArguments = ffi.Int Function(CXType T); +typedef DartClang_Type_getNumTemplateArguments = int Function(CXType T); +typedef NativeClang_Type_getObjCEncoding = CXString Function(CXType type); +typedef DartClang_Type_getObjCEncoding = CXString Function(CXType type); +typedef NativeClang_Type_getObjCObjectBaseType = CXType Function(CXType T); +typedef DartClang_Type_getObjCObjectBaseType = CXType Function(CXType T); +typedef NativeClang_Type_getObjCProtocolDecl = + CXCursor Function(CXType T, ffi.UnsignedInt i); +typedef DartClang_Type_getObjCProtocolDecl = CXCursor Function(CXType T, int i); +typedef NativeClang_Type_getObjCTypeArg = + CXType Function(CXType T, ffi.UnsignedInt i); +typedef DartClang_Type_getObjCTypeArg = CXType Function(CXType T, int i); +typedef NativeClang_Type_getOffsetOf = + ffi.LongLong Function(CXType T, ffi.Pointer S); +typedef DartClang_Type_getOffsetOf = + int Function(CXType T, ffi.Pointer S); +typedef NativeClang_Type_getSizeOf = ffi.LongLong Function(CXType T); +typedef DartClang_Type_getSizeOf = int Function(CXType T); +typedef NativeClang_Type_getTemplateArgumentAsType = + CXType Function(CXType T, ffi.UnsignedInt i); +typedef DartClang_Type_getTemplateArgumentAsType = + CXType Function(CXType T, int i); +typedef NativeClang_Type_isTransparentTagTypedef = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_Type_isTransparentTagTypedef = int Function(CXType T); +typedef NativeClang_Type_visitFields = + ffi.UnsignedInt Function( + CXType T, + CXFieldVisitor visitor, + CXClientData client_data, + ); +typedef DartClang_Type_visitFields = + int Function(CXType T, CXFieldVisitor visitor, CXClientData client_data); +typedef NativeClang_annotateTokens = + ffi.Void Function( + CXTranslationUnit TU, + ffi.Pointer Tokens, + ffi.UnsignedInt NumTokens, + ffi.Pointer Cursors, + ); +typedef DartClang_annotateTokens = + void Function( + CXTranslationUnit TU, + ffi.Pointer Tokens, + int NumTokens, + ffi.Pointer Cursors, + ); +typedef NativeClang_codeCompleteAt = + ffi.Pointer Function( + CXTranslationUnit TU, + ffi.Pointer complete_filename, + ffi.UnsignedInt complete_line, + ffi.UnsignedInt complete_column, + ffi.Pointer unsaved_files, + ffi.UnsignedInt num_unsaved_files, + ffi.UnsignedInt options, + ); +typedef DartClang_codeCompleteAt = + ffi.Pointer Function( + CXTranslationUnit TU, + ffi.Pointer complete_filename, + int complete_line, + int complete_column, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ); +typedef NativeClang_codeCompleteGetContainerKind = + ffi.UnsignedInt Function( + ffi.Pointer Results, + ffi.Pointer IsIncomplete, + ); +typedef DartClang_codeCompleteGetContainerKind = + int Function( + ffi.Pointer Results, + ffi.Pointer IsIncomplete, + ); +typedef NativeClang_codeCompleteGetContainerUSR = + CXString Function(ffi.Pointer Results); +typedef DartClang_codeCompleteGetContainerUSR = + CXString Function(ffi.Pointer Results); +typedef NativeClang_codeCompleteGetContexts = + ffi.UnsignedLongLong Function(ffi.Pointer Results); +typedef DartClang_codeCompleteGetContexts = + int Function(ffi.Pointer Results); +typedef NativeClang_codeCompleteGetDiagnostic = + CXDiagnostic Function( + ffi.Pointer Results, + ffi.UnsignedInt Index, + ); +typedef DartClang_codeCompleteGetDiagnostic = + CXDiagnostic Function( + ffi.Pointer Results, + int Index, + ); +typedef NativeClang_codeCompleteGetNumDiagnostics = + ffi.UnsignedInt Function(ffi.Pointer Results); +typedef DartClang_codeCompleteGetNumDiagnostics = + int Function(ffi.Pointer Results); +typedef NativeClang_codeCompleteGetObjCSelector = + CXString Function(ffi.Pointer Results); +typedef DartClang_codeCompleteGetObjCSelector = + CXString Function(ffi.Pointer Results); +typedef NativeClang_constructUSR_ObjCCategory = + CXString Function( + ffi.Pointer class_name, + ffi.Pointer category_name, + ); +typedef DartClang_constructUSR_ObjCCategory = + CXString Function( + ffi.Pointer class_name, + ffi.Pointer category_name, + ); +typedef NativeClang_constructUSR_ObjCClass = + CXString Function(ffi.Pointer class_name); +typedef DartClang_constructUSR_ObjCClass = + CXString Function(ffi.Pointer class_name); +typedef NativeClang_constructUSR_ObjCIvar = + CXString Function(ffi.Pointer name, CXString classUSR); +typedef DartClang_constructUSR_ObjCIvar = + CXString Function(ffi.Pointer name, CXString classUSR); +typedef NativeClang_constructUSR_ObjCMethod = + CXString Function( + ffi.Pointer name, + ffi.UnsignedInt isInstanceMethod, + CXString classUSR, + ); +typedef DartClang_constructUSR_ObjCMethod = + CXString Function( + ffi.Pointer name, + int isInstanceMethod, + CXString classUSR, + ); +typedef NativeClang_constructUSR_ObjCProperty = + CXString Function(ffi.Pointer property, CXString classUSR); +typedef DartClang_constructUSR_ObjCProperty = + CXString Function(ffi.Pointer property, CXString classUSR); +typedef NativeClang_constructUSR_ObjCProtocol = + CXString Function(ffi.Pointer protocol_name); +typedef DartClang_constructUSR_ObjCProtocol = + CXString Function(ffi.Pointer protocol_name); +typedef NativeClang_createCXCursorSet = CXCursorSet Function(); +typedef DartClang_createCXCursorSet = CXCursorSet Function(); +typedef NativeClang_createIndex = + CXIndex Function( + ffi.Int excludeDeclarationsFromPCH, + ffi.Int displayDiagnostics, + ); +typedef DartClang_createIndex = + CXIndex Function(int excludeDeclarationsFromPCH, int displayDiagnostics); +typedef NativeClang_createTranslationUnit = + CXTranslationUnit Function( + CXIndex CIdx, + ffi.Pointer ast_filename, + ); +typedef DartClang_createTranslationUnit = + CXTranslationUnit Function( + CXIndex CIdx, + ffi.Pointer ast_filename, + ); +typedef NativeClang_createTranslationUnit2 = + ffi.UnsignedInt Function( + CXIndex CIdx, + ffi.Pointer ast_filename, + ffi.Pointer out_TU, + ); +typedef DartClang_createTranslationUnit2 = + int Function( + CXIndex CIdx, + ffi.Pointer ast_filename, + ffi.Pointer out_TU, + ); +typedef NativeClang_createTranslationUnitFromSourceFile = + CXTranslationUnit Function( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Int num_clang_command_line_args, + ffi.Pointer> clang_command_line_args, + ffi.UnsignedInt num_unsaved_files, + ffi.Pointer unsaved_files, + ); +typedef DartClang_createTranslationUnitFromSourceFile = + CXTranslationUnit Function( + CXIndex CIdx, + ffi.Pointer source_filename, + int num_clang_command_line_args, + ffi.Pointer> clang_command_line_args, + int num_unsaved_files, + ffi.Pointer unsaved_files, + ); +typedef NativeClang_defaultCodeCompleteOptions = ffi.UnsignedInt Function(); +typedef DartClang_defaultCodeCompleteOptions = int Function(); +typedef NativeClang_defaultDiagnosticDisplayOptions = + ffi.UnsignedInt Function(); +typedef DartClang_defaultDiagnosticDisplayOptions = int Function(); +typedef NativeClang_defaultEditingTranslationUnitOptions = + ffi.UnsignedInt Function(); +typedef DartClang_defaultEditingTranslationUnitOptions = int Function(); +typedef NativeClang_defaultReparseOptions = + ffi.UnsignedInt Function(CXTranslationUnit TU); +typedef DartClang_defaultReparseOptions = int Function(CXTranslationUnit TU); +typedef NativeClang_defaultSaveOptions = + ffi.UnsignedInt Function(CXTranslationUnit TU); +typedef DartClang_defaultSaveOptions = int Function(CXTranslationUnit TU); +typedef NativeClang_disposeCXCursorSet = ffi.Void Function(CXCursorSet cset); +typedef DartClang_disposeCXCursorSet = void Function(CXCursorSet cset); +typedef NativeClang_disposeCXPlatformAvailability = + ffi.Void Function(ffi.Pointer availability); +typedef DartClang_disposeCXPlatformAvailability = + void Function(ffi.Pointer availability); +typedef NativeClang_disposeCXTUResourceUsage = + ffi.Void Function(CXTUResourceUsage usage); +typedef DartClang_disposeCXTUResourceUsage = + void Function(CXTUResourceUsage usage); +typedef NativeClang_disposeCodeCompleteResults = + ffi.Void Function(ffi.Pointer Results); +typedef DartClang_disposeCodeCompleteResults = + void Function(ffi.Pointer Results); +typedef NativeClang_disposeDiagnostic = + ffi.Void Function(CXDiagnostic Diagnostic); +typedef DartClang_disposeDiagnostic = void Function(CXDiagnostic Diagnostic); +typedef NativeClang_disposeDiagnosticSet = + ffi.Void Function(CXDiagnosticSet Diags); +typedef DartClang_disposeDiagnosticSet = void Function(CXDiagnosticSet Diags); +typedef NativeClang_disposeIndex = ffi.Void Function(CXIndex index); +typedef DartClang_disposeIndex = void Function(CXIndex index); +typedef NativeClang_disposeOverriddenCursors = + ffi.Void Function(ffi.Pointer overridden); +typedef DartClang_disposeOverriddenCursors = + void Function(ffi.Pointer overridden); +typedef NativeClang_disposeSourceRangeList = + ffi.Void Function(ffi.Pointer ranges); +typedef DartClang_disposeSourceRangeList = + void Function(ffi.Pointer ranges); +typedef NativeClang_disposeString = ffi.Void Function(CXString string); +typedef DartClang_disposeString = void Function(CXString string); +typedef NativeClang_disposeStringSet = + ffi.Void Function(ffi.Pointer set); +typedef DartClang_disposeStringSet = + void Function(ffi.Pointer set); +typedef NativeClang_disposeTokens = + ffi.Void Function( + CXTranslationUnit TU, + ffi.Pointer Tokens, + ffi.UnsignedInt NumTokens, + ); +typedef DartClang_disposeTokens = + void Function( + CXTranslationUnit TU, + ffi.Pointer Tokens, + int NumTokens, + ); +typedef NativeClang_disposeTranslationUnit = + ffi.Void Function(CXTranslationUnit); +typedef DartClang_disposeTranslationUnit = void Function(CXTranslationUnit); +typedef NativeClang_enableStackTraces = ffi.Void Function(); +typedef DartClang_enableStackTraces = void Function(); +typedef NativeClang_equalCursors = ffi.UnsignedInt Function(CXCursor, CXCursor); +typedef DartClang_equalCursors = int Function(CXCursor, CXCursor); +typedef NativeClang_equalLocations = + ffi.UnsignedInt Function(CXSourceLocation loc1, CXSourceLocation loc2); +typedef DartClang_equalLocations = + int Function(CXSourceLocation loc1, CXSourceLocation loc2); +typedef NativeClang_equalRanges = + ffi.UnsignedInt Function(CXSourceRange range1, CXSourceRange range2); +typedef DartClang_equalRanges = + int Function(CXSourceRange range1, CXSourceRange range2); +typedef NativeClang_equalTypes = ffi.UnsignedInt Function(CXType A, CXType B); +typedef DartClang_equalTypes = int Function(CXType A, CXType B); +typedef NativeClang_executeOnThread = + ffi.Void Function( + ffi.Pointer)>> + fn, + ffi.Pointer user_data, + ffi.UnsignedInt stack_size, + ); +typedef DartClang_executeOnThread = + void Function( + ffi.Pointer)>> + fn, + ffi.Pointer user_data, + int stack_size, + ); +typedef NativeClang_findIncludesInFile = + ffi.UnsignedInt Function( + CXTranslationUnit TU, + CXFile file, + CXCursorAndRangeVisitor visitor, + ); +typedef DartClang_findIncludesInFile = + int Function( + CXTranslationUnit TU, + CXFile file, + CXCursorAndRangeVisitor visitor, + ); +typedef NativeClang_findReferencesInFile = + ffi.UnsignedInt Function( + CXCursor cursor, + CXFile file, + CXCursorAndRangeVisitor visitor, + ); +typedef DartClang_findReferencesInFile = + int Function(CXCursor cursor, CXFile file, CXCursorAndRangeVisitor visitor); +typedef NativeClang_formatDiagnostic = + CXString Function(CXDiagnostic Diagnostic, ffi.UnsignedInt Options); +typedef DartClang_formatDiagnostic = + CXString Function(CXDiagnostic Diagnostic, int Options); +typedef NativeClang_getAddressSpace = ffi.UnsignedInt Function(CXType T); +typedef DartClang_getAddressSpace = int Function(CXType T); +typedef NativeClang_getAllSkippedRanges = + ffi.Pointer Function(CXTranslationUnit tu); +typedef DartClang_getAllSkippedRanges = + ffi.Pointer Function(CXTranslationUnit tu); +typedef NativeClang_getArgType = CXType Function(CXType T, ffi.UnsignedInt i); +typedef DartClang_getArgType = CXType Function(CXType T, int i); +typedef NativeClang_getArrayElementType = CXType Function(CXType T); +typedef DartClang_getArrayElementType = CXType Function(CXType T); +typedef NativeClang_getArraySize = ffi.LongLong Function(CXType T); +typedef DartClang_getArraySize = int Function(CXType T); +typedef NativeClang_getCString = + ffi.Pointer Function(CXString string); +typedef DartClang_getCString = ffi.Pointer Function(CXString string); +typedef NativeClang_getCXTUResourceUsage = + CXTUResourceUsage Function(CXTranslationUnit TU); +typedef DartClang_getCXTUResourceUsage = + CXTUResourceUsage Function(CXTranslationUnit TU); +typedef NativeClang_getCXXAccessSpecifier = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_getCXXAccessSpecifier = int Function(CXCursor); +typedef NativeClang_getCanonicalCursor = CXCursor Function(CXCursor); +typedef DartClang_getCanonicalCursor = CXCursor Function(CXCursor); +typedef NativeClang_getCanonicalType = CXType Function(CXType T); +typedef DartClang_getCanonicalType = CXType Function(CXType T); +typedef NativeClang_getChildDiagnostics = + CXDiagnosticSet Function(CXDiagnostic D); +typedef DartClang_getChildDiagnostics = + CXDiagnosticSet Function(CXDiagnostic D); +typedef NativeClang_getClangVersion = CXString Function(); +typedef DartClang_getClangVersion = CXString Function(); +typedef NativeClang_getCompletionAnnotation = + CXString Function( + CXCompletionString completion_string, + ffi.UnsignedInt annotation_number, + ); +typedef DartClang_getCompletionAnnotation = + CXString Function( + CXCompletionString completion_string, + int annotation_number, + ); +typedef NativeClang_getCompletionAvailability = + ffi.UnsignedInt Function(CXCompletionString completion_string); +typedef DartClang_getCompletionAvailability = + int Function(CXCompletionString completion_string); +typedef NativeClang_getCompletionBriefComment = + CXString Function(CXCompletionString completion_string); +typedef DartClang_getCompletionBriefComment = + CXString Function(CXCompletionString completion_string); +typedef NativeClang_getCompletionChunkCompletionString = + CXCompletionString Function( + CXCompletionString completion_string, + ffi.UnsignedInt chunk_number, + ); +typedef DartClang_getCompletionChunkCompletionString = + CXCompletionString Function( + CXCompletionString completion_string, + int chunk_number, + ); +typedef NativeClang_getCompletionChunkKind = + ffi.UnsignedInt Function( + CXCompletionString completion_string, + ffi.UnsignedInt chunk_number, + ); +typedef DartClang_getCompletionChunkKind = + int Function(CXCompletionString completion_string, int chunk_number); +typedef NativeClang_getCompletionChunkText = + CXString Function( + CXCompletionString completion_string, + ffi.UnsignedInt chunk_number, + ); +typedef DartClang_getCompletionChunkText = + CXString Function(CXCompletionString completion_string, int chunk_number); +typedef NativeClang_getCompletionFixIt = + CXString Function( + ffi.Pointer results, + ffi.UnsignedInt completion_index, + ffi.UnsignedInt fixit_index, + ffi.Pointer replacement_range, + ); +typedef DartClang_getCompletionFixIt = + CXString Function( + ffi.Pointer results, + int completion_index, + int fixit_index, + ffi.Pointer replacement_range, + ); +typedef NativeClang_getCompletionNumAnnotations = + ffi.UnsignedInt Function(CXCompletionString completion_string); +typedef DartClang_getCompletionNumAnnotations = + int Function(CXCompletionString completion_string); +typedef NativeClang_getCompletionNumFixIts = + ffi.UnsignedInt Function( + ffi.Pointer results, + ffi.UnsignedInt completion_index, + ); +typedef DartClang_getCompletionNumFixIts = + int Function( + ffi.Pointer results, + int completion_index, + ); +typedef NativeClang_getCompletionParent = + CXString Function( + CXCompletionString completion_string, + ffi.Pointer kind, + ); +typedef DartClang_getCompletionParent = + CXString Function( + CXCompletionString completion_string, + ffi.Pointer kind, + ); +typedef NativeClang_getCompletionPriority = + ffi.UnsignedInt Function(CXCompletionString completion_string); +typedef DartClang_getCompletionPriority = + int Function(CXCompletionString completion_string); +typedef NativeClang_getCursor = + CXCursor Function(CXTranslationUnit, CXSourceLocation); +typedef DartClang_getCursor = + CXCursor Function(CXTranslationUnit, CXSourceLocation); +typedef NativeClang_getCursorAvailability = + ffi.UnsignedInt Function(CXCursor cursor); +typedef DartClang_getCursorAvailability = int Function(CXCursor cursor); +typedef NativeClang_getCursorCompletionString = + CXCompletionString Function(CXCursor cursor); +typedef DartClang_getCursorCompletionString = + CXCompletionString Function(CXCursor cursor); +typedef NativeClang_getCursorDefinition = CXCursor Function(CXCursor); +typedef DartClang_getCursorDefinition = CXCursor Function(CXCursor); +typedef NativeClang_getCursorDisplayName = CXString Function(CXCursor); +typedef DartClang_getCursorDisplayName = CXString Function(CXCursor); +typedef NativeClang_getCursorExceptionSpecificationType = + ffi.Int Function(CXCursor C); +typedef DartClang_getCursorExceptionSpecificationType = + int Function(CXCursor C); +typedef NativeClang_getCursorExtent = CXSourceRange Function(CXCursor); +typedef DartClang_getCursorExtent = CXSourceRange Function(CXCursor); +typedef NativeClang_getCursorKind = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_getCursorKind = int Function(CXCursor); +typedef NativeClang_getCursorKindSpelling = + CXString Function(ffi.UnsignedInt Kind); +typedef DartClang_getCursorKindSpelling = CXString Function(int Kind); +typedef NativeClang_getCursorLanguage = + ffi.UnsignedInt Function(CXCursor cursor); +typedef DartClang_getCursorLanguage = int Function(CXCursor cursor); +typedef NativeClang_getCursorLexicalParent = CXCursor Function(CXCursor cursor); +typedef DartClang_getCursorLexicalParent = CXCursor Function(CXCursor cursor); +typedef NativeClang_getCursorLinkage = + ffi.UnsignedInt Function(CXCursor cursor); +typedef DartClang_getCursorLinkage = int Function(CXCursor cursor); +typedef NativeClang_getCursorLocation = CXSourceLocation Function(CXCursor); +typedef DartClang_getCursorLocation = CXSourceLocation Function(CXCursor); +typedef NativeClang_getCursorPlatformAvailability = + ffi.Int Function( + CXCursor cursor, + ffi.Pointer always_deprecated, + ffi.Pointer deprecated_message, + ffi.Pointer always_unavailable, + ffi.Pointer unavailable_message, + ffi.Pointer availability, + ffi.Int availability_size, + ); +typedef DartClang_getCursorPlatformAvailability = + int Function( + CXCursor cursor, + ffi.Pointer always_deprecated, + ffi.Pointer deprecated_message, + ffi.Pointer always_unavailable, + ffi.Pointer unavailable_message, + ffi.Pointer availability, + int availability_size, + ); +typedef NativeClang_getCursorPrettyPrinted = + CXString Function(CXCursor Cursor, CXPrintingPolicy Policy); +typedef DartClang_getCursorPrettyPrinted = + CXString Function(CXCursor Cursor, CXPrintingPolicy Policy); +typedef NativeClang_getCursorPrintingPolicy = + CXPrintingPolicy Function(CXCursor); +typedef DartClang_getCursorPrintingPolicy = CXPrintingPolicy Function(CXCursor); +typedef NativeClang_getCursorReferenceNameRange = + CXSourceRange Function( + CXCursor C, + ffi.UnsignedInt NameFlags, + ffi.UnsignedInt PieceIndex, + ); +typedef DartClang_getCursorReferenceNameRange = + CXSourceRange Function(CXCursor C, int NameFlags, int PieceIndex); +typedef NativeClang_getCursorReferenced = CXCursor Function(CXCursor); +typedef DartClang_getCursorReferenced = CXCursor Function(CXCursor); +typedef NativeClang_getCursorResultType = CXType Function(CXCursor C); +typedef DartClang_getCursorResultType = CXType Function(CXCursor C); +typedef NativeClang_getCursorSemanticParent = + CXCursor Function(CXCursor cursor); +typedef DartClang_getCursorSemanticParent = CXCursor Function(CXCursor cursor); +typedef NativeClang_getCursorSpelling = CXString Function(CXCursor); +typedef DartClang_getCursorSpelling = CXString Function(CXCursor); +typedef NativeClang_getCursorTLSKind = + ffi.UnsignedInt Function(CXCursor cursor); +typedef DartClang_getCursorTLSKind = int Function(CXCursor cursor); +typedef NativeClang_getCursorType = CXType Function(CXCursor C); +typedef DartClang_getCursorType = CXType Function(CXCursor C); +typedef NativeClang_getCursorUSR = CXString Function(CXCursor); +typedef DartClang_getCursorUSR = CXString Function(CXCursor); +typedef NativeClang_getCursorVisibility = + ffi.UnsignedInt Function(CXCursor cursor); +typedef DartClang_getCursorVisibility = int Function(CXCursor cursor); +typedef NativeClang_getDeclObjCTypeEncoding = CXString Function(CXCursor C); +typedef DartClang_getDeclObjCTypeEncoding = CXString Function(CXCursor C); +typedef NativeClang_getDefinitionSpellingAndExtent = + ffi.Void Function( + CXCursor, + ffi.Pointer> startBuf, + ffi.Pointer> endBuf, + ffi.Pointer startLine, + ffi.Pointer startColumn, + ffi.Pointer endLine, + ffi.Pointer endColumn, + ); +typedef DartClang_getDefinitionSpellingAndExtent = + void Function( + CXCursor, + ffi.Pointer> startBuf, + ffi.Pointer> endBuf, + ffi.Pointer startLine, + ffi.Pointer startColumn, + ffi.Pointer endLine, + ffi.Pointer endColumn, + ); +typedef NativeClang_getDiagnostic = + CXDiagnostic Function(CXTranslationUnit Unit, ffi.UnsignedInt Index); +typedef DartClang_getDiagnostic = + CXDiagnostic Function(CXTranslationUnit Unit, int Index); +typedef NativeClang_getDiagnosticCategory = + ffi.UnsignedInt Function(CXDiagnostic); +typedef DartClang_getDiagnosticCategory = int Function(CXDiagnostic); +typedef NativeClang_getDiagnosticCategoryName = + CXString Function(ffi.UnsignedInt Category); +typedef DartClang_getDiagnosticCategoryName = CXString Function(int Category); +typedef NativeClang_getDiagnosticCategoryText = CXString Function(CXDiagnostic); +typedef DartClang_getDiagnosticCategoryText = CXString Function(CXDiagnostic); +typedef NativeClang_getDiagnosticFixIt = + CXString Function( + CXDiagnostic Diagnostic, + ffi.UnsignedInt FixIt, + ffi.Pointer ReplacementRange, + ); +typedef DartClang_getDiagnosticFixIt = + CXString Function( + CXDiagnostic Diagnostic, + int FixIt, + ffi.Pointer ReplacementRange, + ); +typedef NativeClang_getDiagnosticInSet = + CXDiagnostic Function(CXDiagnosticSet Diags, ffi.UnsignedInt Index); +typedef DartClang_getDiagnosticInSet = + CXDiagnostic Function(CXDiagnosticSet Diags, int Index); +typedef NativeClang_getDiagnosticLocation = + CXSourceLocation Function(CXDiagnostic); +typedef DartClang_getDiagnosticLocation = + CXSourceLocation Function(CXDiagnostic); +typedef NativeClang_getDiagnosticNumFixIts = + ffi.UnsignedInt Function(CXDiagnostic Diagnostic); +typedef DartClang_getDiagnosticNumFixIts = + int Function(CXDiagnostic Diagnostic); +typedef NativeClang_getDiagnosticNumRanges = + ffi.UnsignedInt Function(CXDiagnostic); +typedef DartClang_getDiagnosticNumRanges = int Function(CXDiagnostic); +typedef NativeClang_getDiagnosticOption = + CXString Function(CXDiagnostic Diag, ffi.Pointer Disable); +typedef DartClang_getDiagnosticOption = + CXString Function(CXDiagnostic Diag, ffi.Pointer Disable); +typedef NativeClang_getDiagnosticRange = + CXSourceRange Function(CXDiagnostic Diagnostic, ffi.UnsignedInt Range); +typedef DartClang_getDiagnosticRange = + CXSourceRange Function(CXDiagnostic Diagnostic, int Range); +typedef NativeClang_getDiagnosticSetFromTU = + CXDiagnosticSet Function(CXTranslationUnit Unit); +typedef DartClang_getDiagnosticSetFromTU = + CXDiagnosticSet Function(CXTranslationUnit Unit); +typedef NativeClang_getDiagnosticSeverity = + ffi.UnsignedInt Function(CXDiagnostic); +typedef DartClang_getDiagnosticSeverity = int Function(CXDiagnostic); +typedef NativeClang_getDiagnosticSpelling = CXString Function(CXDiagnostic); +typedef DartClang_getDiagnosticSpelling = CXString Function(CXDiagnostic); +typedef NativeClang_getElementType = CXType Function(CXType T); +typedef DartClang_getElementType = CXType Function(CXType T); +typedef NativeClang_getEnumConstantDeclUnsignedValue = + ffi.UnsignedLongLong Function(CXCursor C); +typedef DartClang_getEnumConstantDeclUnsignedValue = int Function(CXCursor C); +typedef NativeClang_getEnumConstantDeclValue = + ffi.LongLong Function(CXCursor C); +typedef DartClang_getEnumConstantDeclValue = int Function(CXCursor C); +typedef NativeClang_getEnumDeclIntegerType = CXType Function(CXCursor C); +typedef DartClang_getEnumDeclIntegerType = CXType Function(CXCursor C); +typedef NativeClang_getExceptionSpecificationType = ffi.Int Function(CXType T); +typedef DartClang_getExceptionSpecificationType = int Function(CXType T); +typedef NativeClang_getExpansionLocation = + ffi.Void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef DartClang_getExpansionLocation = + void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef NativeClang_getFieldDeclBitWidth = ffi.Int Function(CXCursor C); +typedef DartClang_getFieldDeclBitWidth = int Function(CXCursor C); +typedef NativeClang_getFile = + CXFile Function(CXTranslationUnit tu, ffi.Pointer file_name); +typedef DartClang_getFile = + CXFile Function(CXTranslationUnit tu, ffi.Pointer file_name); +typedef NativeClang_getFileContents = + ffi.Pointer Function( + CXTranslationUnit tu, + CXFile file, + ffi.Pointer size, + ); +typedef DartClang_getFileContents = + ffi.Pointer Function( + CXTranslationUnit tu, + CXFile file, + ffi.Pointer size, + ); +typedef NativeClang_getFileLocation = + ffi.Void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef DartClang_getFileLocation = + void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef NativeClang_getFileName = CXString Function(CXFile SFile); +typedef DartClang_getFileName = CXString Function(CXFile SFile); +typedef NativeClang_getFileTime = ffi.Int64 Function(CXFile SFile); +typedef DartClang_getFileTime = int Function(CXFile SFile); +typedef NativeClang_getFileUniqueID = + ffi.Int Function(CXFile file, ffi.Pointer outID); +typedef DartClang_getFileUniqueID = + int Function(CXFile file, ffi.Pointer outID); +typedef NativeClang_getFunctionTypeCallingConv = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_getFunctionTypeCallingConv = int Function(CXType T); +typedef NativeClang_getIBOutletCollectionType = CXType Function(CXCursor); +typedef DartClang_getIBOutletCollectionType = CXType Function(CXCursor); +typedef NativeClang_getIncludedFile = CXFile Function(CXCursor cursor); +typedef DartClang_getIncludedFile = CXFile Function(CXCursor cursor); +typedef NativeClang_getInclusions = + ffi.Void Function( + CXTranslationUnit tu, + CXInclusionVisitor visitor, + CXClientData client_data, + ); +typedef DartClang_getInclusions = + void Function( + CXTranslationUnit tu, + CXInclusionVisitor visitor, + CXClientData client_data, + ); +typedef NativeClang_getInstantiationLocation = + ffi.Void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef DartClang_getInstantiationLocation = + void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef NativeClang_getLocation = + CXSourceLocation Function( + CXTranslationUnit tu, + CXFile file, + ffi.UnsignedInt line, + ffi.UnsignedInt column, + ); +typedef DartClang_getLocation = + CXSourceLocation Function( + CXTranslationUnit tu, + CXFile file, + int line, + int column, + ); +typedef NativeClang_getLocationForOffset = + CXSourceLocation Function( + CXTranslationUnit tu, + CXFile file, + ffi.UnsignedInt offset, + ); +typedef DartClang_getLocationForOffset = + CXSourceLocation Function(CXTranslationUnit tu, CXFile file, int offset); +typedef NativeClang_getModuleForFile = + CXModule Function(CXTranslationUnit, CXFile); +typedef DartClang_getModuleForFile = + CXModule Function(CXTranslationUnit, CXFile); +typedef NativeClang_getNullCursor = CXCursor Function(); +typedef DartClang_getNullCursor = CXCursor Function(); +typedef NativeClang_getNullLocation = CXSourceLocation Function(); +typedef DartClang_getNullLocation = CXSourceLocation Function(); +typedef NativeClang_getNullRange = CXSourceRange Function(); +typedef DartClang_getNullRange = CXSourceRange Function(); +typedef NativeClang_getNumArgTypes = ffi.Int Function(CXType T); +typedef DartClang_getNumArgTypes = int Function(CXType T); +typedef NativeClang_getNumCompletionChunks = + ffi.UnsignedInt Function(CXCompletionString completion_string); +typedef DartClang_getNumCompletionChunks = + int Function(CXCompletionString completion_string); +typedef NativeClang_getNumDiagnostics = + ffi.UnsignedInt Function(CXTranslationUnit Unit); +typedef DartClang_getNumDiagnostics = int Function(CXTranslationUnit Unit); +typedef NativeClang_getNumDiagnosticsInSet = + ffi.UnsignedInt Function(CXDiagnosticSet Diags); +typedef DartClang_getNumDiagnosticsInSet = int Function(CXDiagnosticSet Diags); +typedef NativeClang_getNumElements = ffi.LongLong Function(CXType T); +typedef DartClang_getNumElements = int Function(CXType T); +typedef NativeClang_getNumOverloadedDecls = + ffi.UnsignedInt Function(CXCursor cursor); +typedef DartClang_getNumOverloadedDecls = int Function(CXCursor cursor); +typedef NativeClang_getOverloadedDecl = + CXCursor Function(CXCursor cursor, ffi.UnsignedInt index); +typedef DartClang_getOverloadedDecl = + CXCursor Function(CXCursor cursor, int index); +typedef NativeClang_getOverriddenCursors = + ffi.Void Function( + CXCursor cursor, + ffi.Pointer> overridden, + ffi.Pointer num_overridden, + ); +typedef DartClang_getOverriddenCursors = + void Function( + CXCursor cursor, + ffi.Pointer> overridden, + ffi.Pointer num_overridden, + ); +typedef NativeClang_getPointeeType = CXType Function(CXType T); +typedef DartClang_getPointeeType = CXType Function(CXType T); +typedef NativeClang_getPresumedLocation = + ffi.Void Function( + CXSourceLocation location, + ffi.Pointer filename, + ffi.Pointer line, + ffi.Pointer column, + ); +typedef DartClang_getPresumedLocation = + void Function( + CXSourceLocation location, + ffi.Pointer filename, + ffi.Pointer line, + ffi.Pointer column, + ); +typedef NativeClang_getRange = + CXSourceRange Function(CXSourceLocation begin, CXSourceLocation end); +typedef DartClang_getRange = + CXSourceRange Function(CXSourceLocation begin, CXSourceLocation end); +typedef NativeClang_getRangeEnd = + CXSourceLocation Function(CXSourceRange range); +typedef DartClang_getRangeEnd = CXSourceLocation Function(CXSourceRange range); +typedef NativeClang_getRangeStart = + CXSourceLocation Function(CXSourceRange range); +typedef DartClang_getRangeStart = + CXSourceLocation Function(CXSourceRange range); +typedef NativeClang_getRemappings = + CXRemapping Function(ffi.Pointer path); +typedef DartClang_getRemappings = + CXRemapping Function(ffi.Pointer path); +typedef NativeClang_getRemappingsFromFileList = + CXRemapping Function( + ffi.Pointer> filePaths, + ffi.UnsignedInt numFiles, + ); +typedef DartClang_getRemappingsFromFileList = + CXRemapping Function( + ffi.Pointer> filePaths, + int numFiles, + ); +typedef NativeClang_getResultType = CXType Function(CXType T); +typedef DartClang_getResultType = CXType Function(CXType T); +typedef NativeClang_getSkippedRanges = + ffi.Pointer Function(CXTranslationUnit tu, CXFile file); +typedef DartClang_getSkippedRanges = + ffi.Pointer Function(CXTranslationUnit tu, CXFile file); +typedef NativeClang_getSpecializedCursorTemplate = + CXCursor Function(CXCursor C); +typedef DartClang_getSpecializedCursorTemplate = CXCursor Function(CXCursor C); +typedef NativeClang_getSpellingLocation = + ffi.Void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef DartClang_getSpellingLocation = + void Function( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef NativeClang_getTUResourceUsageName = + ffi.Pointer Function(ffi.UnsignedInt kind); +typedef DartClang_getTUResourceUsageName = + ffi.Pointer Function(int kind); +typedef NativeClang_getTemplateCursorKind = + ffi.UnsignedInt Function(CXCursor C); +typedef DartClang_getTemplateCursorKind = int Function(CXCursor C); +typedef NativeClang_getToken = + ffi.Pointer Function( + CXTranslationUnit TU, + CXSourceLocation Location, + ); +typedef DartClang_getToken = + ffi.Pointer Function( + CXTranslationUnit TU, + CXSourceLocation Location, + ); +typedef NativeClang_getTokenExtent = + CXSourceRange Function(CXTranslationUnit, CXToken); +typedef DartClang_getTokenExtent = + CXSourceRange Function(CXTranslationUnit, CXToken); +typedef NativeClang_getTokenKind = ffi.UnsignedInt Function(CXToken); +typedef DartClang_getTokenKind = int Function(CXToken); +typedef NativeClang_getTokenLocation = + CXSourceLocation Function(CXTranslationUnit, CXToken); +typedef DartClang_getTokenLocation = + CXSourceLocation Function(CXTranslationUnit, CXToken); +typedef NativeClang_getTokenSpelling = + CXString Function(CXTranslationUnit, CXToken); +typedef DartClang_getTokenSpelling = + CXString Function(CXTranslationUnit, CXToken); +typedef NativeClang_getTranslationUnitCursor = + CXCursor Function(CXTranslationUnit); +typedef DartClang_getTranslationUnitCursor = + CXCursor Function(CXTranslationUnit); +typedef NativeClang_getTranslationUnitSpelling = + CXString Function(CXTranslationUnit CTUnit); +typedef DartClang_getTranslationUnitSpelling = + CXString Function(CXTranslationUnit CTUnit); +typedef NativeClang_getTranslationUnitTargetInfo = + CXTargetInfo Function(CXTranslationUnit CTUnit); +typedef DartClang_getTranslationUnitTargetInfo = + CXTargetInfo Function(CXTranslationUnit CTUnit); +typedef NativeClang_getTypeDeclaration = CXCursor Function(CXType T); +typedef DartClang_getTypeDeclaration = CXCursor Function(CXType T); +typedef NativeClang_getTypeKindSpelling = CXString Function(ffi.UnsignedInt K); +typedef DartClang_getTypeKindSpelling = CXString Function(int K); +typedef NativeClang_getTypeSpelling = CXString Function(CXType CT); +typedef DartClang_getTypeSpelling = CXString Function(CXType CT); +typedef NativeClang_getTypedefDeclUnderlyingType = CXType Function(CXCursor C); +typedef DartClang_getTypedefDeclUnderlyingType = CXType Function(CXCursor C); +typedef NativeClang_getTypedefName = CXString Function(CXType CT); +typedef DartClang_getTypedefName = CXString Function(CXType CT); +typedef NativeClang_hashCursor = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_hashCursor = int Function(CXCursor); +typedef NativeClang_indexLoc_getCXSourceLocation = + CXSourceLocation Function(CXIdxLoc loc); +typedef DartClang_indexLoc_getCXSourceLocation = + CXSourceLocation Function(CXIdxLoc loc); +typedef NativeClang_indexLoc_getFileLocation = + ffi.Void Function( + CXIdxLoc loc, + ffi.Pointer indexFile, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef DartClang_indexLoc_getFileLocation = + void Function( + CXIdxLoc loc, + ffi.Pointer indexFile, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ); +typedef NativeClang_indexSourceFile = + ffi.Int Function( + CXIndexAction, + CXClientData client_data, + ffi.Pointer index_callbacks, + ffi.UnsignedInt index_callbacks_size, + ffi.UnsignedInt index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + ffi.Int num_command_line_args, + ffi.Pointer unsaved_files, + ffi.UnsignedInt num_unsaved_files, + ffi.Pointer out_TU, + ffi.UnsignedInt TU_options, + ); +typedef DartClang_indexSourceFile = + int Function( + CXIndexAction, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + ffi.Pointer out_TU, + int TU_options, + ); +typedef NativeClang_indexSourceFileFullArgv = + ffi.Int Function( + CXIndexAction, + CXClientData client_data, + ffi.Pointer index_callbacks, + ffi.UnsignedInt index_callbacks_size, + ffi.UnsignedInt index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + ffi.Int num_command_line_args, + ffi.Pointer unsaved_files, + ffi.UnsignedInt num_unsaved_files, + ffi.Pointer out_TU, + ffi.UnsignedInt TU_options, + ); +typedef DartClang_indexSourceFileFullArgv = + int Function( + CXIndexAction, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + ffi.Pointer out_TU, + int TU_options, + ); +typedef NativeClang_indexTranslationUnit = + ffi.Int Function( + CXIndexAction, + CXClientData client_data, + ffi.Pointer index_callbacks, + ffi.UnsignedInt index_callbacks_size, + ffi.UnsignedInt index_options, + CXTranslationUnit, + ); +typedef DartClang_indexTranslationUnit = + int Function( + CXIndexAction, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + CXTranslationUnit, + ); +typedef NativeClang_index_getCXXClassDeclInfo = + ffi.Pointer Function(ffi.Pointer); +typedef DartClang_index_getCXXClassDeclInfo = + ffi.Pointer Function(ffi.Pointer); +typedef NativeClang_index_getClientContainer = + CXIdxClientContainer Function(ffi.Pointer); +typedef DartClang_index_getClientContainer = + CXIdxClientContainer Function(ffi.Pointer); +typedef NativeClang_index_getClientEntity = + CXIdxClientEntity Function(ffi.Pointer); +typedef DartClang_index_getClientEntity = + CXIdxClientEntity Function(ffi.Pointer); +typedef NativeClang_index_getIBOutletCollectionAttrInfo = + ffi.Pointer Function( + ffi.Pointer, + ); +typedef DartClang_index_getIBOutletCollectionAttrInfo = + ffi.Pointer Function( + ffi.Pointer, + ); +typedef NativeClang_index_getObjCCategoryDeclInfo = + ffi.Pointer Function(ffi.Pointer); +typedef DartClang_index_getObjCCategoryDeclInfo = + ffi.Pointer Function(ffi.Pointer); typedef NativeClang_index_getObjCContainerDeclInfo = ffi.Pointer Function( ffi.Pointer, @@ -11247,187 +11393,226 @@ typedef DartClang_index_getObjCInterfaceDeclInfo = ffi.Pointer Function( ffi.Pointer, ); -typedef NativeClang_index_getObjCCategoryDeclInfo = - ffi.Pointer Function(ffi.Pointer); -typedef DartClang_index_getObjCCategoryDeclInfo = - ffi.Pointer Function(ffi.Pointer); +typedef NativeClang_index_getObjCPropertyDeclInfo = + ffi.Pointer Function(ffi.Pointer); +typedef DartClang_index_getObjCPropertyDeclInfo = + ffi.Pointer Function(ffi.Pointer); typedef NativeClang_index_getObjCProtocolRefListInfo = ffi.Pointer Function( ffi.Pointer, ); -typedef DartClang_index_getObjCProtocolRefListInfo = - ffi.Pointer Function( - ffi.Pointer, +typedef DartClang_index_getObjCProtocolRefListInfo = + ffi.Pointer Function( + ffi.Pointer, + ); +typedef NativeClang_index_isEntityObjCContainerKind = + ffi.Int Function(ffi.UnsignedInt); +typedef DartClang_index_isEntityObjCContainerKind = int Function(int); +typedef NativeClang_index_setClientContainer = + ffi.Void Function(ffi.Pointer, CXIdxClientContainer); +typedef DartClang_index_setClientContainer = + void Function(ffi.Pointer, CXIdxClientContainer); +typedef NativeClang_index_setClientEntity = + ffi.Void Function(ffi.Pointer, CXIdxClientEntity); +typedef DartClang_index_setClientEntity = + void Function(ffi.Pointer, CXIdxClientEntity); +typedef NativeClang_isAttribute = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isAttribute = int Function(int); +typedef NativeClang_isConstQualifiedType = ffi.UnsignedInt Function(CXType T); +typedef DartClang_isConstQualifiedType = int Function(CXType T); +typedef NativeClang_isCursorDefinition = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_isCursorDefinition = int Function(CXCursor); +typedef NativeClang_isDeclaration = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isDeclaration = int Function(int); +typedef NativeClang_isExpression = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isExpression = int Function(int); +typedef NativeClang_isFileMultipleIncludeGuarded = + ffi.UnsignedInt Function(CXTranslationUnit tu, CXFile file); +typedef DartClang_isFileMultipleIncludeGuarded = + int Function(CXTranslationUnit tu, CXFile file); +typedef NativeClang_isFunctionTypeVariadic = ffi.UnsignedInt Function(CXType T); +typedef DartClang_isFunctionTypeVariadic = int Function(CXType T); +typedef NativeClang_isInvalid = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isInvalid = int Function(int); +typedef NativeClang_isInvalidDeclaration = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_isInvalidDeclaration = int Function(CXCursor); +typedef NativeClang_isPODType = ffi.UnsignedInt Function(CXType T); +typedef DartClang_isPODType = int Function(CXType T); +typedef NativeClang_isPreprocessing = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isPreprocessing = int Function(int); +typedef NativeClang_isReference = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isReference = int Function(int); +typedef NativeClang_isRestrictQualifiedType = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_isRestrictQualifiedType = int Function(CXType T); +typedef NativeClang_isStatement = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isStatement = int Function(int); +typedef NativeClang_isTranslationUnit = + ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isTranslationUnit = int Function(int); +typedef NativeClang_isUnexposed = ffi.UnsignedInt Function(ffi.UnsignedInt); +typedef DartClang_isUnexposed = int Function(int); +typedef NativeClang_isVirtualBase = ffi.UnsignedInt Function(CXCursor); +typedef DartClang_isVirtualBase = int Function(CXCursor); +typedef NativeClang_isVolatileQualifiedType = + ffi.UnsignedInt Function(CXType T); +typedef DartClang_isVolatileQualifiedType = int Function(CXType T); +typedef NativeClang_loadDiagnostics = + CXDiagnosticSet Function( + ffi.Pointer file, + ffi.Pointer error, + ffi.Pointer errorString, + ); +typedef DartClang_loadDiagnostics = + CXDiagnosticSet Function( + ffi.Pointer file, + ffi.Pointer error, + ffi.Pointer errorString, ); -typedef NativeClang_index_getObjCPropertyDeclInfo = - ffi.Pointer Function(ffi.Pointer); -typedef DartClang_index_getObjCPropertyDeclInfo = - ffi.Pointer Function(ffi.Pointer); -typedef NativeClang_index_getIBOutletCollectionAttrInfo = - ffi.Pointer Function( - ffi.Pointer, +typedef NativeClang_parseTranslationUnit = + CXTranslationUnit Function( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + ffi.Int num_command_line_args, + ffi.Pointer unsaved_files, + ffi.UnsignedInt num_unsaved_files, + ffi.UnsignedInt options, ); -typedef DartClang_index_getIBOutletCollectionAttrInfo = - ffi.Pointer Function( - ffi.Pointer, +typedef DartClang_parseTranslationUnit = + CXTranslationUnit Function( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, ); -typedef NativeClang_index_getCXXClassDeclInfo = - ffi.Pointer Function(ffi.Pointer); -typedef DartClang_index_getCXXClassDeclInfo = - ffi.Pointer Function(ffi.Pointer); -typedef NativeClang_index_getClientContainer = - CXIdxClientContainer Function(ffi.Pointer); -typedef DartClang_index_getClientContainer = - CXIdxClientContainer Function(ffi.Pointer); -typedef NativeClang_index_setClientContainer = - ffi.Void Function(ffi.Pointer, CXIdxClientContainer); -typedef DartClang_index_setClientContainer = - void Function(ffi.Pointer, CXIdxClientContainer); -typedef NativeClang_index_getClientEntity = - CXIdxClientEntity Function(ffi.Pointer); -typedef DartClang_index_getClientEntity = - CXIdxClientEntity Function(ffi.Pointer); -typedef NativeClang_index_setClientEntity = - ffi.Void Function(ffi.Pointer, CXIdxClientEntity); -typedef DartClang_index_setClientEntity = - void Function(ffi.Pointer, CXIdxClientEntity); - -/// An indexing action/session, to be applied to one or multiple -/// translation units. -typedef CXIndexAction = ffi.Pointer; -typedef NativeClang_IndexAction_create = CXIndexAction Function(CXIndex CIdx); -typedef DartClang_IndexAction_create = CXIndexAction Function(CXIndex CIdx); -typedef NativeClang_IndexAction_dispose = ffi.Void Function(CXIndexAction); -typedef DartClang_IndexAction_dispose = void Function(CXIndexAction); -typedef NativeClang_indexSourceFile = - ffi.Int Function( - CXIndexAction, - CXClientData client_data, - ffi.Pointer index_callbacks, - ffi.UnsignedInt index_callbacks_size, - ffi.UnsignedInt index_options, +typedef NativeClang_parseTranslationUnit2 = + ffi.UnsignedInt Function( + CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, ffi.Int num_command_line_args, ffi.Pointer unsaved_files, ffi.UnsignedInt num_unsaved_files, + ffi.UnsignedInt options, ffi.Pointer out_TU, - ffi.UnsignedInt TU_options, ); -typedef DartClang_indexSourceFile = +typedef DartClang_parseTranslationUnit2 = int Function( - CXIndexAction, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, + CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, int num_command_line_args, ffi.Pointer unsaved_files, int num_unsaved_files, + int options, ffi.Pointer out_TU, - int TU_options, ); -typedef NativeClang_indexSourceFileFullArgv = - ffi.Int Function( - CXIndexAction, - CXClientData client_data, - ffi.Pointer index_callbacks, - ffi.UnsignedInt index_callbacks_size, - ffi.UnsignedInt index_options, +typedef NativeClang_parseTranslationUnit2FullArgv = + ffi.UnsignedInt Function( + CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, ffi.Int num_command_line_args, ffi.Pointer unsaved_files, ffi.UnsignedInt num_unsaved_files, + ffi.UnsignedInt options, ffi.Pointer out_TU, - ffi.UnsignedInt TU_options, ); -typedef DartClang_indexSourceFileFullArgv = +typedef DartClang_parseTranslationUnit2FullArgv = int Function( - CXIndexAction, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, + CXIndex CIdx, ffi.Pointer source_filename, ffi.Pointer> command_line_args, int num_command_line_args, ffi.Pointer unsaved_files, int num_unsaved_files, + int options, ffi.Pointer out_TU, - int TU_options, ); -typedef NativeClang_indexTranslationUnit = +typedef NativeClang_remap_dispose = ffi.Void Function(CXRemapping); +typedef DartClang_remap_dispose = void Function(CXRemapping); +typedef NativeClang_remap_getFilenames = + ffi.Void Function( + CXRemapping, + ffi.UnsignedInt index, + ffi.Pointer original, + ffi.Pointer transformed, + ); +typedef DartClang_remap_getFilenames = + void Function( + CXRemapping, + int index, + ffi.Pointer original, + ffi.Pointer transformed, + ); +typedef NativeClang_remap_getNumFiles = ffi.UnsignedInt Function(CXRemapping); +typedef DartClang_remap_getNumFiles = int Function(CXRemapping); +typedef NativeClang_reparseTranslationUnit = ffi.Int Function( - CXIndexAction, - CXClientData client_data, - ffi.Pointer index_callbacks, - ffi.UnsignedInt index_callbacks_size, - ffi.UnsignedInt index_options, - CXTranslationUnit, + CXTranslationUnit TU, + ffi.UnsignedInt num_unsaved_files, + ffi.Pointer unsaved_files, + ffi.UnsignedInt options, ); -typedef DartClang_indexTranslationUnit = +typedef DartClang_reparseTranslationUnit = int Function( - CXIndexAction, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - CXTranslationUnit, + CXTranslationUnit TU, + int num_unsaved_files, + ffi.Pointer unsaved_files, + int options, ); -typedef NativeClang_indexLoc_getFileLocation = +typedef NativeClang_saveTranslationUnit = + ffi.Int Function( + CXTranslationUnit TU, + ffi.Pointer FileName, + ffi.UnsignedInt options, + ); +typedef DartClang_saveTranslationUnit = + int Function( + CXTranslationUnit TU, + ffi.Pointer FileName, + int options, + ); +typedef NativeClang_sortCodeCompletionResults = ffi.Void Function( - CXIdxLoc loc, - ffi.Pointer indexFile, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, + ffi.Pointer Results, + ffi.UnsignedInt NumResults, ); -typedef DartClang_indexLoc_getFileLocation = +typedef DartClang_sortCodeCompletionResults = + void Function(ffi.Pointer Results, int NumResults); +typedef NativeClang_suspendTranslationUnit = + ffi.UnsignedInt Function(CXTranslationUnit); +typedef DartClang_suspendTranslationUnit = int Function(CXTranslationUnit); +typedef NativeClang_toggleCrashRecovery = + ffi.Void Function(ffi.UnsignedInt isEnabled); +typedef DartClang_toggleCrashRecovery = void Function(int isEnabled); +typedef NativeClang_tokenize = + ffi.Void Function( + CXTranslationUnit TU, + CXSourceRange Range, + ffi.Pointer> Tokens, + ffi.Pointer NumTokens, + ); +typedef DartClang_tokenize = void Function( - CXIdxLoc loc, - ffi.Pointer indexFile, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, + CXTranslationUnit TU, + CXSourceRange Range, + ffi.Pointer> Tokens, + ffi.Pointer NumTokens, ); -typedef NativeClang_indexLoc_getCXSourceLocation = - CXSourceLocation Function(CXIdxLoc loc); -typedef DartClang_indexLoc_getCXSourceLocation = - CXSourceLocation Function(CXIdxLoc loc); -typedef CXFieldVisitorFunction = - ffi.UnsignedInt Function(CXCursor C, CXClientData client_data); -typedef DartCXFieldVisitorFunction = - CXVisitorResult Function(CXCursor C, CXClientData client_data); - -/// Visitor invoked for each field found by a traversal. -/// -/// This visitor function will be invoked for each field found by -/// \c clang_Type_visitFields. Its first argument is the cursor being -/// visited, its second argument is the client data provided to -/// \c clang_Type_visitFields. -/// -/// The visitor should return one of the \c CXVisitorResult values -/// to direct \c clang_Type_visitFields. -typedef CXFieldVisitor = - ffi.Pointer>; -typedef NativeClang_Type_visitFields = +typedef NativeClang_visitChildren = ffi.UnsignedInt Function( - CXType T, - CXFieldVisitor visitor, + CXCursor parent, + CXCursorVisitor visitor, + CXClientData client_data, + ); +typedef DartClang_visitChildren = + int Function( + CXCursor parent, + CXCursorVisitor visitor, CXClientData client_data, ); -typedef DartClang_Type_visitFields = - int Function(CXType T, CXFieldVisitor visitor, CXClientData client_data); - -const int CINDEX_VERSION_MAJOR = 0; - -const int CINDEX_VERSION_MINOR = 59; - -const int CINDEX_VERSION = 59; - -const String CINDEX_VERSION_STRING = '0.59'; diff --git a/pkgs/ffigen/example/objective_c/avf_audio_bindings.dart b/pkgs/ffigen/example/objective_c/avf_audio_bindings.dart index 18187787e8..0d97511df9 100644 --- a/pkgs/ffigen/example/objective_c/avf_audio_bindings.dart +++ b/pkgs/ffigen/example/objective_c/avf_audio_bindings.dart @@ -563,11 +563,13 @@ extension type AVAudioPlayer._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [AVAudioPlayer]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_AVAudioPlayer, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_AVAudioPlayer, + ); /// alloc static AVAudioPlayer alloc() { diff --git a/pkgs/ffigen/example/objective_c/pubspec.yaml b/pkgs/ffigen/example/objective_c/pubspec.yaml index bced920489..f8b72c2749 100644 --- a/pkgs/ffigen/example/objective_c/pubspec.yaml +++ b/pkgs/ffigen/example/objective_c/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: args: ^2.6.0 ffi: ^2.0.1 logging: ^1.3.0 - objective_c: ^0.0.1 + objective_c: ^9.2.3 dev_dependencies: dart_flutter_team_lints: ^3.5.2 diff --git a/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart b/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart index ab040e92ee..ae51c6f678 100644 --- a/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart +++ b/pkgs/ffigen/example/shared_bindings/lib/generated/a_shared_b_gen.dart @@ -82,16 +82,6 @@ class NativeLibraryASharedB { .asFunction(); } -final class A_Struct1 extends ffi.Struct { - @ffi.Int() - external int a; -} - -final class A_Union1 extends ffi.Union { - @ffi.Int() - external int a; -} - enum A_Enum { A_ENUM_1(0), A_ENUM_2(1); @@ -106,6 +96,21 @@ enum A_Enum { }; } -const int BASE_MACRO_1 = 1; - const int A_MACRO_1 = 1; + +final class A_Struct1 extends ffi.Struct { + @ffi.Int() + external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; +} + +final class A_Union1 extends ffi.Union { + @ffi.Int() + external int a; +} + +const int BASE_MACRO_1 = 1; diff --git a/pkgs/ffigen/example/simple/generated_bindings.dart b/pkgs/ffigen/example/simple/generated_bindings.dart index 0efbfae62c..a6b8f9f3ca 100644 --- a/pkgs/ffigen/example/simple/generated_bindings.dart +++ b/pkgs/ffigen/example/simple/generated_bindings.dart @@ -19,39 +19,6 @@ class NativeLibrary { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - /// Adds 2 integers. - int sum(int a, int b) { - return _sum(a, b); - } - - late final _sumPtr = - _lookup>('sum'); - late final _sum = _sumPtr.asFunction(); - - /// Subtracts 2 integers. - int subtract(ffi.Pointer a, int b) { - return _subtract(a, b); - } - - late final _subtractPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('subtract'); - late final _subtract = _subtractPtr - .asFunction, int)>(); - - /// Multiplies 2 integers, returns pointer to an integer,. - ffi.Pointer multiply(int a, int b) { - return _multiply(a, b); - } - - late final _multiplyPtr = - _lookup< - ffi.NativeFunction Function(ffi.Int, ffi.Int)> - >('multiply'); - late final _multiply = _multiplyPtr - .asFunction Function(int, int)>(); - /// Divides 2 integers, returns pointer to a float. ffi.Pointer divide(int a, int b) { return _divide(a, b); @@ -88,4 +55,37 @@ class NativeLibrary { ffi.Pointer, ) >(); + + /// Multiplies 2 integers, returns pointer to an integer,. + ffi.Pointer multiply(int a, int b) { + return _multiply(a, b); + } + + late final _multiplyPtr = + _lookup< + ffi.NativeFunction Function(ffi.Int, ffi.Int)> + >('multiply'); + late final _multiply = _multiplyPtr + .asFunction Function(int, int)>(); + + /// Subtracts 2 integers. + int subtract(ffi.Pointer a, int b) { + return _subtract(a, b); + } + + late final _subtractPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('subtract'); + late final _subtract = _subtractPtr + .asFunction, int)>(); + + /// Adds 2 integers. + int sum(int a, int b) { + return _sum(a, b); + } + + late final _sumPtr = + _lookup>('sum'); + late final _sum = _sumPtr.asFunction(); } diff --git a/pkgs/ffigen/example/swift/pubspec.yaml b/pkgs/ffigen/example/swift/pubspec.yaml index 6465873724..2ad0d9b7e0 100644 --- a/pkgs/ffigen/example/swift/pubspec.yaml +++ b/pkgs/ffigen/example/swift/pubspec.yaml @@ -10,7 +10,7 @@ environment: dependencies: args: ^2.6.0 ffi: ^2.0.1 - objective_c: ^0.0.1 + objective_c: ^9.2.3 dev_dependencies: dart_flutter_team_lints: ^3.5.2 diff --git a/pkgs/ffigen/example/swift/swift_api_bindings.dart b/pkgs/ffigen/example/swift/swift_api_bindings.dart index a2c3a2496d..d349d8dc79 100644 --- a/pkgs/ffigen/example/swift/swift_api_bindings.dart +++ b/pkgs/ffigen/example/swift/swift_api_bindings.dart @@ -30,77 +30,13 @@ final _objc_msgSend_19nvye5 = objc.msgSendPointer ) >(); late final _sel_sayHello = objc.registerName("sayHello"); -final _objc_msgSend_151sglz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); late final _sel_someField = objc.registerName("someField"); -final _objc_msgSend_1hz7y9r = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Long Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); late final _sel_setSomeField_ = objc.registerName("setSomeField:"); -final _objc_msgSend_4sp4xj = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); typedef instancetype = ffi.Pointer; typedef Dartinstancetype = objc.ObjCObject; late final _sel_init = objc.registerName("init"); late final _sel_new = objc.registerName("new"); late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); -final _objc_msgSend_1cwp428 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); late final _sel_alloc = objc.registerName("alloc"); /// SwiftClass @@ -121,11 +57,13 @@ extension type SwiftClass._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [SwiftClass]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_SwiftClass, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_SwiftClass, + ); /// alloc static SwiftClass alloc() { @@ -184,3 +122,68 @@ extension SwiftClass$Methods on SwiftClass { return _objc_msgSend_1hz7y9r(object$.ref.pointer, _sel_someField); } } + +final _objc_msgSend_151sglz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1hz7y9r = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_4sp4xj = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +final _objc_msgSend_1cwp428 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); diff --git a/pkgs/ffigen/example/swift/third_party/swift_api.h b/pkgs/ffigen/example/swift/third_party/swift_api.h index 1185516e67..41849f3214 100644 --- a/pkgs/ffigen/example/swift/third_party/swift_api.h +++ b/pkgs/ffigen/example/swift/third_party/swift_api.h @@ -1,4 +1,4 @@ -// Generated by Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.19.9 clang-1700.3.19.1) +// Generated by Apple Swift version 6.0.2 effective-5.10 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) #ifndef SWIFT_MODULE_SWIFT_H #define SWIFT_MODULE_SWIFT_H #pragma clang diagnostic push @@ -63,7 +63,6 @@ # if __has_include() # include # elif !defined(__cplusplus) -typedef unsigned char char8_t; typedef uint_least16_t char16_t; typedef uint_least32_t char32_t; # endif @@ -301,8 +300,8 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4))); #endif #if defined(__OBJC__) - @class NSString; + SWIFT_CLASS("_TtC12swift_module10SwiftClass") @interface SwiftClass : NSObject - (NSString * _Nonnull)sayHello SWIFT_WARN_UNUSED_RESULT; diff --git a/pkgs/ffigen/lib/src/code_generator/compound.dart b/pkgs/ffigen/lib/src/code_generator/compound.dart index 55bc5691a3..0fe40f275e 100644 --- a/pkgs/ffigen/lib/src/code_generator/compound.dart +++ b/pkgs/ffigen/lib/src/code_generator/compound.dart @@ -58,6 +58,88 @@ abstract class Compound extends BindingType with HasLocalScope { return type.getCType(context); } + bool _shouldGenerateAllocate() { + if (this is! Struct || isOpaque || name.startsWith('_')) { + return false; + } + for (final m in members) { + final memberType = m.type.typealiasType; + if (memberType is ConstantArray) { + return false; + } + if (memberType is Struct || memberType is Union) { + return false; + } + } + return true; + } + + bool _isEnumDartStyleMember(CompoundMember member) { + final type = member.type; + return type is EnumClass && type.style == EnumStyle.dartEnum; + } + + String _memberStorageName(CompoundMember member) { + if (_isEnumDartStyleMember(member)) { + return member.name; + } + return member.type.sameDartAndFfiDartType + ? member.name + : '${member.name}AsInt'; + } + + String _memberParameterType(CompoundMember member) { + if (_isEnumDartStyleMember(member)) { + return member.type.getDartType(context); + } + return member.type.getFfiDartType(context); + } + + String _generateAllocateMethod(String enclosingClassName, String ffiPrefix) { + final usedParamNames = {}; + final params = <({String type, String name, String assignment})>[]; + for (final m in members) { + params.add(( + type: _memberParameterType(m), + name: _allocateParamName(m.name, usedParamNames), + assignment: _memberStorageName(m), + )); + } + + final b = StringBuffer(); + b.write( + ' static $ffiPrefix.Pointer<$enclosingClassName> \$allocate(\n' + ' $ffiPrefix.Allocator \$allocator, {\n', + ); + for (final p in params) { + b.write(' required ${p.type} ${p.name},\n'); + } + b.write(' }) => \$allocator<$enclosingClassName>()'); + for (final p in params) { + b.write('\n ..ref.${p.assignment} = ${p.name}'); + } + b.write(';\n\n'); + return b.toString(); + } + + String _allocateParamName(String memberName, Set usedNames) { + var name = memberName; + if (name.startsWith('_')) { + final withoutLeadingUnderscores = name.replaceFirst(RegExp(r'^_+'), ''); + final core = withoutLeadingUnderscores.isEmpty + ? 'unnamed' + : withoutLeadingUnderscores; + name = '\$$core'; + } + + var unique = name; + for (var i = 1; usedNames.contains(unique); ++i) { + unique = '$name\$$i'; + } + usedNames.add(unique); + return unique; + } + @override bool get isObjCImport => context.objCBuiltInFunctions.getBuiltInCompoundName(originalName) != null; @@ -118,6 +200,9 @@ abstract class Compound extends BindingType with HasLocalScope { ); } } + if (_shouldGenerateAllocate()) { + s.write(_generateAllocateMethod(enclosingClassName, ffiPrefix)); + } s.write('}\n\n'); final bindingType = this is Struct diff --git a/pkgs/ffigen/lib/src/code_generator/func_type.dart b/pkgs/ffigen/lib/src/code_generator/func_type.dart index 58b2b0e6e8..1f818965bd 100644 --- a/pkgs/ffigen/lib/src/code_generator/func_type.dart +++ b/pkgs/ffigen/lib/src/code_generator/func_type.dart @@ -54,12 +54,7 @@ class FunctionType extends Type with HasLocalScope { // Write Function. sb.write(' Function('); - sb.write( - [ - ...params.map(paramToString), - if (varArgPack != null) varArgPack, - ].join(', '), - ); + sb.write([...params.map(paramToString), ?varArgPack].join(', ')); sb.write(')'); return sb.toString(); diff --git a/pkgs/ffigen/lib/src/code_generator/objc_block.dart b/pkgs/ffigen/lib/src/code_generator/objc_block.dart index 53697c3013..da7d4b3940 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_block.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_block.dart @@ -41,15 +41,30 @@ class ObjCBlock extends BindingType with HasLocalScope { final usr = _getBlockUsr(returnType, renamedParams, returnsRetained); + final newBlockName = _getBlockName( + returnType, + renamedParams.map((a) => a.type), + reduced: false, + ); final oldBlock = context.bindingsIndex.getSeenObjCBlock(usr); if (oldBlock != null) { + if (oldBlock.symbol.oldName != newBlockName) { + // Block with matching signature, but a different name. This is usually + // due to type aliases. Replace the name with the reduced name, so that + // it makes sense as a name for all blocks sharing this signature. + oldBlock.symbol.oldName = _getBlockName( + returnType, + renamedParams.map((a) => a.type), + reduced: true, + ); + } return oldBlock; } final block = ObjCBlock._( context, usr: usr, - name: _getBlockName(returnType, renamedParams.map((a) => a.type)), + name: newBlockName, returnType: returnType, params: renamedParams, returnsRetained: returnsRetained, @@ -96,11 +111,26 @@ class ObjCBlock extends BindingType with HasLocalScope { // type. These names will be pretty verbose and unweildy, but they're at least // sensible and stable. Users can always add their own typedef with a simpler // name if necessary. - static String _getBlockName(Type returnType, Iterable argTypes) => - 'ObjCBlock_${[returnType, ...argTypes].map(_typeName).join('_')}'; - static String _typeName(Type type) => - type.toString().replaceAll(_illegalNameChar, ''); + static String _getBlockName( + Type returnType, + Iterable argTypes, { + required bool reduced, + }) { + final types = [returnType, ...argTypes].map((t) => _typeName(t, reduced)); + return 'ObjCBlock_${types.join('_')}'; + } + + static String _typeName(Type type, bool reduced) => + (reduced ? _reducedType(type) : type).toString().replaceAll( + _illegalNameChar, + '', + ); static final _illegalNameChar = RegExp(r'[^0-9a-zA-Z]'); + static Type _reducedType(Type type) { + if (type.baseType != type) return _reducedType(type.baseType); + if (type.typealiasType != type) return _reducedType(type.typealiasType); + return type; + } static String _getBlockUsr( Type returnType, @@ -536,6 +566,9 @@ $ret $fnName(id target, $argRecv) { _blockingHelper.visitChildren(visitor); } + @override + void visit(Visitation visitation) => visitation.visitObjCBlock(this); + @override bool isSupertypeOf(Type other) { other = other.typealiasType; diff --git a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart index 9b63a89f2b..a2179c9afc 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_built_in_functions.dart @@ -242,6 +242,10 @@ class ObjCBlockWrapperFuncs extends AstNode { visitor.visit(blockingWrapper); visitor.visit(objcPkgImport); } + + @override + void visit(Visitation visitation) => + visitation.visitObjCBlockWrapperFuncs(this); } /// A native trampoline function for a protocol method. @@ -341,6 +345,10 @@ final $name = $pointer.cast<$cType>().asFunction<$dartType>(); visitor.visit(type); visitor.visit(objcPkgImport); } + + @override + void visit(Visitation visitation) => + visitation.visitObjCMsgSendVariantFunc(this); } /// A wrapper around the objc_msgSend function, or the stret or fpret variants. @@ -452,7 +460,7 @@ class ObjCMsgSendFunc extends AstNode with HasLocalScope { Iterable params, { String? structRetPtr, }) { - return '''$name(${[if (structRetPtr != null) structRetPtr, target, sel, ...params].join(', ')})'''; + return '''$name(${[?structRetPtr, target, sel, ...params].join(', ')})'''; } @override diff --git a/pkgs/ffigen/lib/src/code_generator/objc_interface.dart b/pkgs/ffigen/lib/src/code_generator/objc_interface.dart index 9fec93b2d5..32bb152fac 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_interface.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_interface.dart @@ -152,7 +152,9 @@ ${generateInstanceMethodBindings(w, this)} s.write(''' /// Returns whether [obj] is an instance of [$name]. - static bool isA($wrapObjType obj) => $isKindOfClass; + static bool isA($wrapObjType? obj) => obj == null + ? false + : $isKindOfClass; '''); s.write(generateStaticMethodBindings(w, this)); diff --git a/pkgs/ffigen/lib/src/code_generator/objc_methods.dart b/pkgs/ffigen/lib/src/code_generator/objc_methods.dart index 31cb46f9b1..7629b53e4c 100644 --- a/pkgs/ffigen/lib/src/code_generator/objc_methods.dart +++ b/pkgs/ffigen/lib/src/code_generator/objc_methods.dart @@ -310,15 +310,18 @@ class ObjCMethod extends AstNode with HasLocalScope { bool get isRequired => !isOptional; bool get isInstanceMethod => !isClassMethod; - void fillMsgSend() { - msgSend ??= context.objCBuiltInFunctions.getMsgSendFunc( + ObjCMsgSendFunc fillMsgSend() { + return msgSend ??= context.objCBuiltInFunctions.getMsgSendFunc( returnType, _params, ); } - void fillProtocolBlock() { - protocolBlock ??= ObjCBlock( + ObjCBlock fillProtocolBlock() { + protocolMethodName ??= symbol.oldName == originalProtocolMethodName + ? symbol + : Symbol(originalProtocolMethodName, SymbolKind.method); + return protocolBlock ??= ObjCBlock( context, returnType: returnType, params: [ @@ -328,9 +331,6 @@ class ObjCMethod extends AstNode with HasLocalScope { ], returnsRetained: returnsRetained, )..fillProtocolTrampoline(); - protocolMethodName ??= symbol.oldName == originalProtocolMethodName - ? symbol - : Symbol(originalProtocolMethodName, SymbolKind.method); } bool sameAs(ObjCMethod other) { diff --git a/pkgs/ffigen/lib/src/code_generator/scope.dart b/pkgs/ffigen/lib/src/code_generator/scope.dart index 864dc0aac1..21993e552f 100644 --- a/pkgs/ffigen/lib/src/code_generator/scope.dart +++ b/pkgs/ffigen/lib/src/code_generator/scope.dart @@ -161,15 +161,23 @@ class Namer { /// Add the [Symbol] to a [Scope], and it will be assigned a name during the /// transformation phase. class Symbol extends AstNode { - final String oldName; + String _oldName; final SymbolKind kind; bool isImported = false; String? _name; + String get oldName => _oldName; + + /// Only valid if [Scope.fillNames] has not been called yet. + set oldName(String n) { + assert(!isFilled); + _oldName = n; + } + /// Only valid if [Scope.fillNames] has been called already. String get name => _name!; - Symbol(this.oldName, this.kind); + Symbol(this._oldName, this.kind); bool get isFilled => _name != null; diff --git a/pkgs/ffigen/lib/src/code_generator/writer.dart b/pkgs/ffigen/lib/src/code_generator/writer.dart index 646726cadf..56595933ab 100644 --- a/pkgs/ffigen/lib/src/code_generator/writer.dart +++ b/pkgs/ffigen/lib/src/code_generator/writer.dart @@ -250,10 +250,7 @@ class Writer { Map _makeSymbolMapValue(Binding b) { final dartName = b is Typealias ? getTypedefDartAliasName(b) : null; - return { - strings.name: b.name, - if (dartName != null) strings.dartName: dartName, - }; + return {strings.name: b.name, strings.dartName: ?dartName}; } String? getTypedefDartAliasName(Type b) { diff --git a/pkgs/ffigen/lib/src/config_provider/config.dart b/pkgs/ffigen/lib/src/config_provider/config.dart index 138f0280d0..94b6642c65 100644 --- a/pkgs/ffigen/lib/src/config_provider/config.dart +++ b/pkgs/ffigen/lib/src/config_provider/config.dart @@ -652,9 +652,6 @@ final class Output { /// The config for the symbol file. final SymbolFile? symbolFile; - /// Whether to sort the generated bindings alphabetically. - final bool sort; - /// The type of comments to generate. final CommentType commentType; @@ -671,7 +668,6 @@ final class Output { required this.dartFile, this.objectiveCFile, this.symbolFile, - this.sort = false, this.commentType = const CommentType.def(), this.preamble, this.format = true, diff --git a/pkgs/ffigen/lib/src/config_provider/config_spec.dart b/pkgs/ffigen/lib/src/config_provider/config_spec.dart index ee342d20be..c97961e35a 100644 --- a/pkgs/ffigen/lib/src/config_provider/config_spec.dart +++ b/pkgs/ffigen/lib/src/config_provider/config_spec.dart @@ -386,7 +386,7 @@ class HeterogeneousMapConfigSpec 'type': 'object', if (additionalProperties != AdditionalProperties.allow) 'additionalProperties': false, - if (schemaDescription != null) 'description': schemaDescription!, + 'description': ?schemaDescription, if (entries.isNotEmpty) 'properties': { for (final kv in entries) @@ -515,7 +515,7 @@ class MapConfigSpec Map _generateJsonSchemaNode(Map defs) { return { 'type': 'object', - if (schemaDescription != null) 'description': schemaDescription!, + 'description': ?schemaDescription, if (keyValueConfigSpecs.isNotEmpty) 'patternProperties': { for (final (keyRegexp: keyRegexp, valueConfigSpec: valueConfigSpec) @@ -596,7 +596,7 @@ class ListConfigSpec Map _generateJsonSchemaNode(Map defs) { return { 'type': 'array', - if (schemaDescription != null) 'description': schemaDescription!, + 'description': ?schemaDescription, 'items': childConfigSpec._getJsonRefOrSchemaNode(defs), }; } @@ -650,7 +650,7 @@ class StringConfigSpec extends ConfigSpec { Map _generateJsonSchemaNode(Map defs) { return { 'type': 'string', - if (schemaDescription != null) 'description': schemaDescription!, + 'description': ?schemaDescription, if (pattern != null) 'pattern': pattern, }; } @@ -691,10 +691,7 @@ class IntConfigSpec extends ConfigSpec { @override Map _generateJsonSchemaNode(Map defs) { - return { - 'type': 'integer', - if (schemaDescription != null) 'description': schemaDescription!, - }; + return {'type': 'integer', 'description': ?schemaDescription}; } } @@ -741,10 +738,7 @@ class EnumConfigSpec @override Map _generateJsonSchemaNode(Map defs) { - return { - 'enum': allowedValues.toList(), - if (schemaDescription != null) 'description': schemaDescription!, - }; + return {'enum': allowedValues.toList(), 'description': ?schemaDescription}; } } @@ -783,10 +777,7 @@ class BoolConfigSpec extends ConfigSpec { @override Map _generateJsonSchemaNode(Map defs) { - return { - 'type': 'boolean', - if (schemaDescription != null) 'description': schemaDescription!, - }; + return {'type': 'boolean', 'description': ?schemaDescription}; } } @@ -848,7 +839,7 @@ class OneOfConfigSpec @override Map _generateJsonSchemaNode(Map defs) { return { - if (schemaDescription != null) 'description': schemaDescription!, + 'description': ?schemaDescription, r'$oneOf': childConfigSpecs .map((child) => child._getJsonRefOrSchemaNode(defs)) .toList(), diff --git a/pkgs/ffigen/lib/src/config_provider/path_finder.dart b/pkgs/ffigen/lib/src/config_provider/path_finder.dart index cdda5c1eaa..15ea8b0e5c 100644 --- a/pkgs/ffigen/lib/src/config_provider/path_finder.dart +++ b/pkgs/ffigen/lib/src/config_provider/path_finder.dart @@ -10,13 +10,14 @@ import 'dart:io'; import 'package:logging/logging.dart'; import 'package:path/path.dart' as p; +import 'utils.dart' show macSdkPath, xcodePath; + /// This will return include path from either LLVM, XCode or CommandLineTools. List getCStandardLibraryHeadersForMac(Logger logger) { final includePaths = []; /// Add system headers. - const systemHeaders = - '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include'; + final systemHeaders = p.join(macSdkPath, 'usr', 'include'); if (Directory(systemHeaders).existsSync()) { logger.fine('Added $systemHeaders to compiler-opts.'); includePaths.add('-I$systemHeaders'); @@ -24,9 +25,15 @@ List getCStandardLibraryHeadersForMac(Logger logger) { /// Find headers from XCode or LLVM installed via brew. const brewLlvmPath = '/usr/local/opt/llvm/lib/clang'; - const xcodeClangPath = - '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/'; - const searchPaths = [brewLlvmPath, xcodeClangPath]; + final xcodeClangPath = p.join( + xcodePath, + 'Toolchains', + 'XcodeDefault.xctoolchain', + 'usr', + 'lib', + 'clang', + ); + final searchPaths = [brewLlvmPath, xcodeClangPath]; for (final searchPath in searchPaths) { if (!Directory(searchPath).existsSync()) continue; diff --git a/pkgs/ffigen/lib/src/config_provider/yaml_config.dart b/pkgs/ffigen/lib/src/config_provider/yaml_config.dart index 4cbaec8d51..f63ee2ff22 100644 --- a/pkgs/ffigen/lib/src/config_provider/yaml_config.dart +++ b/pkgs/ffigen/lib/src/config_provider/yaml_config.dart @@ -1237,7 +1237,6 @@ final class YamlConfig { dartFile: output, objectiveCFile: outputObjC, symbolFile: symbolFile, - sort: sort, commentType: commentType, preamble: preamble, format: formatOutput, diff --git a/pkgs/ffigen/lib/src/context.dart b/pkgs/ffigen/lib/src/context.dart index 4b2eae002a..241c3a00f5 100644 --- a/pkgs/ffigen/lib/src/context.dart +++ b/pkgs/ffigen/lib/src/context.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:ffi'; +import 'dart:io'; import 'package:logging/logging.dart'; @@ -31,20 +32,30 @@ class Context { final Scope rootScope = Scope.createRoot('root'); final Scope rootObjCScope = Scope.createRoot('objc_root'); late final ExtraSymbols extraSymbols; - - Context(this.logger, FfiGenerator generator, {Uri? libclangDylib}) - : config = Config(generator), - cursorIndex = CursorIndex(logger) { + final String tmpDir; + + Context( + this.logger, + FfiGenerator generator, { + Uri? libclangDylib, + String? tmpDir, + }) : config = Config(generator), + cursorIndex = CursorIndex(logger), + tmpDir = + tmpDir ?? + Directory.systemTemp.createTempSync('ffigen temp dir ').path { objCBuiltInFunctions = ObjCBuiltInFunctions( this, // ignore: deprecated_member_use_from_same_package generator.objectiveC?.generateForPackageObjectiveC ?? false, ); + final libclangDylibPath = // ignore: deprecated_member_use_from_same_package generator.libclangDylib?.toFilePath() ?? libclangDylib?.toFilePath() ?? findDylibAtDefaultLocations(logger); + _clang ??= Clang(DynamicLibrary.open(libclangDylibPath)); } } diff --git a/pkgs/ffigen/lib/src/header_parser/parser.dart b/pkgs/ffigen/lib/src/header_parser/parser.dart index f04c3d01ae..89dee9ee74 100644 --- a/pkgs/ffigen/lib/src/header_parser/parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/parser.dart @@ -164,18 +164,17 @@ List _findObjectiveCSysroot() => [ ]; @visibleForTesting -List transformBindings(List bindings, Context context) { +List transformBindings(List rawBindings, Context context) { final config = context.config; final allBindings = visit( context, FindTransitiveDepsVisitation(), - bindings, + rawBindings, ).transitives; visit(context, CopyMethodsFromSuperTypesVisitation(), allBindings); visit(context, FixOverriddenMethodsVisitation(context), allBindings); - visit(context, FillMethodDependenciesVisitation(), allBindings); final applyConfigFiltersVisitation = ApplyConfigFiltersVisitation(config); visit(context, applyConfigFiltersVisitation, allBindings); @@ -206,26 +205,27 @@ List transformBindings(List bindings, Context context) { included, ).directTransitives; - final finalBindings = visit( + final semiFinalBindings = visit( context, ListBindingsVisitation(config, included, transitives, directTransitives), - bindings, + included, ).bindings; + final finalBindings = visit( + context, + FillMethodDependenciesVisitation(context, semiFinalBindings), + semiFinalBindings, + ).finalBindings; visit(context, MarkBindingsVisitation(finalBindings), allBindings); - visit(context, MarkImportsVisitation(context), finalBindings); _nameAllSymbols(context, finalBindings); /// Sort bindings. - var finalBindingsList = finalBindings.toList(); - if (config.output.sort) { - finalBindingsList = visit( - context, - SorterVisitation(finalBindings, SorterVisitation.nameSortKey), - finalBindings, - ).sorted; - } + final finalBindingsList = visit( + context, + SorterVisitation(finalBindings, SorterVisitation.nameSortKey), + finalBindings, + ).sorted; /// Handle any declaration-declaration name conflicts and emit warnings. for (final b in finalBindingsList) { diff --git a/pkgs/ffigen/lib/src/header_parser/sub_parsers/macro_parser.dart b/pkgs/ffigen/lib/src/header_parser/sub_parsers/macro_parser.dart index 5a681f5236..bc93a75224 100644 --- a/pkgs/ffigen/lib/src/header_parser/sub_parsers/macro_parser.dart +++ b/pkgs/ffigen/lib/src/header_parser/sub_parsers/macro_parser.dart @@ -12,7 +12,6 @@ import 'package:path/path.dart' as p; import '../../code_generator.dart'; import '../../config_provider/config_types.dart'; import '../../context.dart'; -import '../../strings.dart' as strings; import '../clang_bindings/clang_bindings.dart' as clang_types; import '../utils.dart'; @@ -178,7 +177,7 @@ late Set _macroVarNames; /// Creates a temporary file for parsing macros in current directory. File createFileForMacros(Context context) { - final fileNameBase = p.normalize(p.join(strings.tmpDir, 'temp_for_macros')); + final fileNameBase = p.normalize(p.join(context.tmpDir, 'temp_for_macros')); final fileExt = 'hpp'; // Find a filename which doesn't already exist. diff --git a/pkgs/ffigen/lib/src/strings.dart b/pkgs/ffigen/lib/src/strings.dart index 4e5c18cf11..8258f7a1a8 100644 --- a/pkgs/ffigen/lib/src/strings.dart +++ b/pkgs/ffigen/lib/src/strings.dart @@ -280,19 +280,6 @@ const synthUsrChar = '~'; const ffiNative = 'ffi-native'; const ffiNativeAsset = 'asset-id'; -Directory? _tmpDir; - -/// A path to a unique temporary directory that should be used for files meant -/// to be discarded after the current execution is finished. -String get tmpDir { - if (Platform.environment.containsKey('TEST_TMPDIR')) { - return Platform.environment['TEST_TMPDIR']!; - } - - _tmpDir ??= Directory.systemTemp.createTempSync(); - return _tmpDir!.path; -} - const ffigenJsonSchemaIndent = ' '; const ffigenJsonSchemaId = 'https://json.schemastore.org/ffigen'; const ffigenJsonSchemaFileName = 'ffigen.schema.json'; diff --git a/pkgs/ffigen/lib/src/visitor/fill_method_dependencies.dart b/pkgs/ffigen/lib/src/visitor/fill_method_dependencies.dart index 9a961910f5..04b9518d3a 100644 --- a/pkgs/ffigen/lib/src/visitor/fill_method_dependencies.dart +++ b/pkgs/ffigen/lib/src/visitor/fill_method_dependencies.dart @@ -3,35 +3,93 @@ // BSD-style license that can be found in the LICENSE file. import '../code_generator.dart'; - +import '../context.dart'; import 'ast.dart'; class FillMethodDependenciesVisitation extends Visitation { + final Set finalBindings; + late final Visitor _adder; + + FillMethodDependenciesVisitation(Context context, Set bindings) + : finalBindings = bindings.toSet() { + _adder = Visitor(context, _MethodDepAdderVisitation(finalBindings)); + } + + @override + void visitAstNode(AstNode node) { + // Don't visit children by default. + } + @override void visitObjCInterface(ObjCInterface node) { - node.visitChildren(visitor); + if (!finalBindings.contains(node)) return; - for (final method in node.methods) { - method.fillMsgSend(); + if (!node.generateAsStub) { + node.visitChildren(visitor); + for (final method in node.methods) { + _adder.visit(method.fillMsgSend()); + } } } @override void visitObjCCategory(ObjCCategory node) { + if (!finalBindings.contains(node)) return; node.visitChildren(visitor); for (final method in node.methods) { - method.fillMsgSend(); + _adder.visit(method.fillMsgSend()); } } @override void visitObjCProtocol(ObjCProtocol node) { - node.visitChildren(visitor); + if (!finalBindings.contains(node)) return; - for (final method in node.methods) { - method.fillProtocolBlock(); - method.fillMsgSend(); + if (!node.generateAsStub) { + node.visitChildren(visitor); + for (final method in node.methods) { + _adder.visit(method.fillProtocolBlock()); + _adder.visit(method.fillMsgSend()); + } } } } + +// Adding the method deps can introduce some new bindings, so add those to the +// final bindings set. +class _MethodDepAdderVisitation extends Visitation { + final Set finalBindings; + + _MethodDepAdderVisitation(this.finalBindings); + + @override + void visitAstNode(AstNode node) { + // Don't visit children by default. + } + + @override + void visitObjCMsgSendFunc(ObjCMsgSendFunc node) => + node.visitChildren(visitor); + + @override + void visitObjCMsgSendVariantFunc(ObjCMsgSendVariantFunc node) => + finalBindings.add(node); + + @override + void visitObjCBlock(ObjCBlock node) { + node.visitChildren(visitor); + finalBindings.add(node); + } + + @override + void visitFunc(Func node) => finalBindings.add(node); + + @override + void visitObjCProtocolMethodTrampoline(ObjCProtocolMethodTrampoline node) => + node.visitChildren(visitor); + + @override + void visitObjCBlockWrapperFuncs(ObjCBlockWrapperFuncs node) => + node.visitChildren(visitor); +} diff --git a/pkgs/ffigen/lib/src/visitor/list_bindings.dart b/pkgs/ffigen/lib/src/visitor/list_bindings.dart index 5a9c0260ac..0fefb1cd34 100644 --- a/pkgs/ffigen/lib/src/visitor/list_bindings.dart +++ b/pkgs/ffigen/lib/src/visitor/list_bindings.dart @@ -70,9 +70,20 @@ class ListBindingsVisitation extends Visitation { ? _IncludeBehavior.configOrTransitive : _IncludeBehavior.configOnly, ); + if (omit && directTransitives.contains(node)) { node.generateAsStub = true; bindings.add(node); + + // Always visit the supertypes and protocols, even if this is a stub. + visitor.visit(node.superType); + visitor.visitAll(node.protocols); + } + + if (includes.contains(node)) { + // Always visit the categories of explicitly included interfaces, even if + // they're built-in types: https://github.com/dart-lang/native/issues/1820 + visitor.visitAll(node.categories); } } @@ -94,9 +105,13 @@ class ListBindingsVisitation extends Visitation { ? _IncludeBehavior.configOrTransitive : _IncludeBehavior.configOnly, ); + if (omit && directTransitives.contains(node)) { node.generateAsStub = true; bindings.add(node); + + // Always visit the super protocols, even if this is a stub. + visitor.visitAll(node.superProtocols); } } diff --git a/pkgs/ffigen/lib/src/visitor/visitor.dart b/pkgs/ffigen/lib/src/visitor/visitor.dart index cabd54a93b..32741aa4ca 100644 --- a/pkgs/ffigen/lib/src/visitor/visitor.dart +++ b/pkgs/ffigen/lib/src/visitor/visitor.dart @@ -82,6 +82,7 @@ abstract class Visitation { void visitObjCInterface(ObjCInterface node) => visitBindingType(node); void visitObjCProtocol(ObjCProtocol node) => visitNoLookUpBinding(node); void visitObjCCategory(ObjCCategory node) => visitNoLookUpBinding(node); + void visitObjCBlock(ObjCBlock node) => visitBindingType(node); void visitStruct(Struct node) => visitCompound(node); void visitUnion(Union node) => visitCompound(node); void visitCompound(Compound node) => visitBindingType(node); @@ -101,6 +102,10 @@ abstract class Visitation { void visitLibraryImport(LibraryImport node) => visitAstNode(node); void visitSymbol(Symbol node) => visitAstNode(node); void visitObjCMsgSendFunc(ObjCMsgSendFunc node) => visitAstNode(node); + void visitObjCMsgSendVariantFunc(ObjCMsgSendVariantFunc node) => + visitNoLookUpBinding(node); + void visitObjCBlockWrapperFuncs(ObjCBlockWrapperFuncs node) => + visitAstNode(node); void visitObjCMethod(ObjCMethod node) => visitAstNode(node); /// Default behavior for all visit methods. diff --git a/pkgs/ffigen/pubspec.yaml b/pkgs/ffigen/pubspec.yaml index 8b50c2b92d..cb0f7eb992 100644 --- a/pkgs/ffigen/pubspec.yaml +++ b/pkgs/ffigen/pubspec.yaml @@ -39,8 +39,8 @@ dev_dependencies: async: ^2.11.0 dart_flutter_team_lints: ^3.5.2 json_schema: ^5.1.1 - leak_tracker: ^10.0.7 - objective_c: ^9.2.0 + leak_tracker: ^11.0.2 + objective_c: ^9.2.3 test: ^1.26.2 dependency_overrides: diff --git a/pkgs/ffigen/test/code_generator_tests/code_generator_test.dart b/pkgs/ffigen/test/code_generator_tests/code_generator_test.dart index 2a993d1e2d..af37007f67 100644 --- a/pkgs/ffigen/test/code_generator_tests/code_generator_test.dart +++ b/pkgs/ffigen/test/code_generator_tests/code_generator_test.dart @@ -197,6 +197,32 @@ void main() { _matchLib(library, 'struct'); }); + test('Struct allocate helper name collisions', () { + final context = makeContext(); + final library = Library( + context: context, + header: licenseHeader, + bindings: transformBindings([ + Struct( + context: context, + name: 'CollisionStruct', + members: [ + CompoundMember( + name: 'allocator', + type: NativeType(SupportedNativeType.int32), + ), + CompoundMember( + name: 'allocate', + type: NativeType(SupportedNativeType.int32), + ), + ], + ), + ], context), + ); + + _matchLib(library, 'struct_allocate_collision'); + }); + test('Function and Struct Binding (pointer to Struct)', () { final context = makeContext(); final structSome = Struct( @@ -789,10 +815,16 @@ void main() { /// Utility to match expected bindings to the generated bindings. void _matchLib(Library lib, String testName) { - matchLibraryWithExpected(lib, 'code_generator_test_${testName}_output.dart', [ - 'test', - 'code_generator_tests', - 'expected_bindings', - '_expected_${testName}_bindings.dart', - ]); + final context = testContext(); + matchLibraryWithExpected( + context, + lib, + 'code_generator_test_${testName}_output.dart', + [ + 'test', + 'code_generator_tests', + 'expected_bindings', + '_expected_${testName}_bindings.dart', + ], + ); } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_boolean_dartbool_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_boolean_dartbool_bindings.dart index d3db1618cd..46564fd4dd 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_boolean_dartbool_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_boolean_dartbool_bindings.dart @@ -36,4 +36,9 @@ class Bindings { final class Test2 extends ffi.Struct { @ffi.Bool() external bool a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required bool a, + }) => $allocator()..ref.a = a; } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_func_and_struct_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_func_and_struct_bindings.dart index d8a3376fbb..89adaeca76 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_func_and_struct_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_enumclass_func_and_struct_bindings.dart @@ -21,6 +21,17 @@ class Bindings { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; + void funcWithBothEnums(Enum1 value1, int value2) { + return _funcWithBothEnums(value1.value, value2); + } + + late final _funcWithBothEnumsPtr = + _lookup>( + 'funcWithBothEnums', + ); + late final _funcWithBothEnums = _funcWithBothEnumsPtr + .asFunction(); + Enum1 funcWithEnum1(Enum1 value) { return Enum1.fromValue(_funcWithEnum1(value.value)); } @@ -37,17 +48,6 @@ class Bindings { _lookup>('funcWithEnum2'); late final _funcWithEnum2 = _funcWithEnum2Ptr.asFunction(); - void funcWithBothEnums(Enum1 value1, int value2) { - return _funcWithBothEnums(value1.value, value2); - } - - late final _funcWithBothEnumsPtr = - _lookup>( - 'funcWithBothEnums', - ); - late final _funcWithBothEnums = _funcWithBothEnumsPtr - .asFunction(); - StructWithEnums funcWithStruct(StructWithEnums value) { return _funcWithStruct(value); } @@ -91,4 +91,12 @@ final class StructWithEnums extends ffi.Struct { @ffi.Int() external int enum2; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required Enum1 enum1, + required int enum2, + }) => $allocator() + ..ref.enum1 = enum1 + ..ref.enum2 = enum2; } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_bindings.dart index fbd88dd740..2f9fff2d62 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_bindings.dart @@ -21,6 +21,17 @@ class Bindings { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; + /// A function with isLeaf: true + int leafFunc(int a) { + return _leafFunc(a); + } + + late final _leafFuncPtr = + _lookup>('leafFunc'); + late final _leafFunc = _leafFuncPtr.asFunction( + isLeaf: true, + ); + /// Just a test function /// heres another line int noParam() { @@ -32,17 +43,6 @@ class Bindings { ); late final _noParam = _noParamPtr.asFunction(); - int withPrimitiveParam(int a, int b) { - return _withPrimitiveParam(a, b); - } - - late final _withPrimitiveParamPtr = - _lookup>( - 'withPrimitiveParam', - ); - late final _withPrimitiveParam = _withPrimitiveParamPtr - .asFunction(); - ffi.Pointer withPointerParam( ffi.Pointer a, ffi.Pointer> b, @@ -67,14 +67,14 @@ class Bindings { ) >(); - /// A function with isLeaf: true - int leafFunc(int a) { - return _leafFunc(a); + int withPrimitiveParam(int a, int b) { + return _withPrimitiveParam(a, b); } - late final _leafFuncPtr = - _lookup>('leafFunc'); - late final _leafFunc = _leafFuncPtr.asFunction( - isLeaf: true, - ); + late final _withPrimitiveParamPtr = + _lookup>( + 'withPrimitiveParam', + ); + late final _withPrimitiveParam = _withPrimitiveParamPtr + .asFunction(); } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_ffiNative_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_ffiNative_bindings.dart index a412181a38..cf37106820 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_ffiNative_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_ffiNative_bindings.dart @@ -11,14 +11,15 @@ library; import 'dart:ffi' as ffi; +/// A function with isLeaf: true +@ffi.Native(isLeaf: true) +external int leafFunc(int a); + /// Just a test function /// heres another line @ffi.Native() external int noParam(); -@ffi.Native() -external int withPrimitiveParam(int a, int b); - @ffi.Native< ffi.Pointer Function( ffi.Pointer, @@ -30,6 +31,5 @@ external ffi.Pointer withPointerParam( ffi.Pointer> b, ); -/// A function with isLeaf: true -@ffi.Native(isLeaf: true) -external int leafFunc(int a); +@ffi.Native() +external int withPrimitiveParam(int a, int b); diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_n_struct_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_n_struct_bindings.dart index faa7cf9586..e5531b8577 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_n_struct_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_function_n_struct_bindings.dart @@ -46,4 +46,14 @@ final class SomeStruct extends ffi.Struct { @ffi.Uint8() external int c; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + required double b, + required int c, + }) => $allocator() + ..ref.a = a + ..ref.b = b + ..ref.c = c; } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_bindings.dart index 71eca6794f..d4a7f0789b 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_bindings.dart @@ -21,6 +21,12 @@ class Bindings { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; + late final ffi.Pointer _globalStruct = _lookup( + 'globalStruct', + ); + + ffi.Pointer get globalStruct => _globalStruct; + late final ffi.Pointer _test1 = _lookup('test1'); int get test1 => _test1.value; @@ -43,14 +49,8 @@ class Bindings { ffi.Pointer get test5 => _test5.value; set test5(ffi.Pointer value) => _test5.value = value; - - late final ffi.Pointer _globalStruct = _lookup( - 'globalStruct', - ); - - ffi.Pointer get globalStruct => _globalStruct; } -final class Some extends ffi.Opaque {} - final class EmptyStruct extends ffi.Opaque {} + +final class Some extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_native_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_native_bindings.dart index c5bc1c1928..2c0fbd3fdb 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_native_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_global_native_bindings.dart @@ -11,6 +11,9 @@ library; import 'dart:ffi' as ffi; +@ffi.Native() +external EmptyStruct globalStruct; + @ffi.Native() external int test1; @@ -24,9 +27,6 @@ external final ffi.Array test3; @ffi.Native>() external ffi.Pointer test5; -@ffi.Native() -external EmptyStruct globalStruct; +final class EmptyStruct extends ffi.Opaque {} final class Some extends ffi.Opaque {} - -final class EmptyStruct extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_internal_conflict_resolution_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_internal_conflict_resolution_bindings.dart index d145a06d97..125cd6c8f8 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_internal_conflict_resolution_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_internal_conflict_resolution_bindings.dart @@ -24,23 +24,14 @@ class init_dylib$1 { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - void test() { - return _test$1(); - } - - late final _testPtr = _lookup>( - 'test', - ); - late final _test$1 = _testPtr.asFunction(); - - void _test() { - return __test(); + void Test() { + return _Test$1(); } - late final __testPtr = _lookup>( - '_test', + late final _TestPtr = _lookup>( + 'Test', ); - late final __test = __testPtr.asFunction(); + late final _Test$1 = _TestPtr.asFunction(); void _c_test() { return __c_test(); @@ -60,23 +51,32 @@ class init_dylib$1 { ); late final __dart_test = __dart_testPtr.asFunction(); - void Test() { - return _Test$1(); + void _test() { + return __test(); } - late final _TestPtr = _lookup>( - 'Test', + late final __testPtr = _lookup>( + '_test', ); - late final _Test$1 = _TestPtr.asFunction(); + late final __test = __testPtr.asFunction(); + + void test() { + return _test$1(); + } + + late final _testPtr = _lookup>( + 'test', + ); + late final _test$1 = _testPtr.asFunction(); } +final class ArrayHelperPrefixCollisionTest extends ffi.Opaque {} + final class _Test extends ffi.Struct { @ffi.Array.multi([2]) external ffi.Array array; } -final class ArrayHelperPrefixCollisionTest extends ffi.Opaque {} - sealed class _c_Test {} sealed class init_dylib {} diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_packed_structs_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_packed_structs_bindings.dart index 4b4548a874..1d40c83cb3 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_packed_structs_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_packed_structs_bindings.dart @@ -11,34 +11,64 @@ import 'dart:ffi' as ffi; final class NoPacking extends ffi.Struct { @ffi.Uint8() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } @ffi.Packed(1) final class Pack1 extends ffi.Struct { @ffi.Uint8() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; +} + +@ffi.Packed(16) +final class Pack16 extends ffi.Struct { + @ffi.Uint8() + external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } @ffi.Packed(2) final class Pack2 extends ffi.Struct { @ffi.Uint8() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } @ffi.Packed(4) final class Pack4 extends ffi.Struct { @ffi.Uint8() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } @ffi.Packed(8) final class Pack8 extends ffi.Struct { @ffi.Uint8() external int a; -} -@ffi.Packed(16) -final class Pack16 extends ffi.Struct { - @ffi.Uint8() - external int a; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_allocate_collision_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_allocate_collision_bindings.dart new file mode 100644 index 0000000000..bbc6bd9802 --- /dev/null +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_allocate_collision_bindings.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint, unused_import +import 'dart:ffi' as ffi; + +final class CollisionStruct extends ffi.Struct { + @ffi.Int32() + external int allocator; + + @ffi.Int32() + external int allocate; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int allocator, + required int allocate, + }) => $allocator() + ..ref.allocator = allocator + ..ref.allocate = allocate; +} diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_bindings.dart index 45884e455e..0b2931f8ac 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_struct_bindings.dart @@ -12,15 +12,18 @@ import 'dart:ffi' as ffi; /// heres another line final class NoMember extends ffi.Opaque {} -final class WithPrimitiveMember extends ffi.Struct { - @ffi.Int32() - external int a; +final class WithIntPtrUintPtr extends ffi.Struct { + external ffi.Pointer a; - @ffi.Double() - external double b; + external ffi.Pointer> b; - @ffi.Uint8() - external int c; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer a, + required ffi.Pointer> b, + }) => $allocator() + ..ref.a = a + ..ref.b = b; } final class WithPointerMember extends ffi.Struct { @@ -30,10 +33,35 @@ final class WithPointerMember extends ffi.Struct { @ffi.Uint8() external int c; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer a, + required ffi.Pointer> b, + required int c, + }) => $allocator() + ..ref.a = a + ..ref.b = b + ..ref.c = c; } -final class WithIntPtrUintPtr extends ffi.Struct { - external ffi.Pointer a; +final class WithPrimitiveMember extends ffi.Struct { + @ffi.Int32() + external int a; - external ffi.Pointer> b; + @ffi.Double() + external double b; + + @ffi.Uint8() + external int c; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + required double b, + required int c, + }) => $allocator() + ..ref.a = a + ..ref.b = b + ..ref.c = c; } diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_typealias_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_typealias_bindings.dart index dc97d08a23..2cf7dd26ed 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_typealias_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_typealias_bindings.dart @@ -43,21 +43,26 @@ class Bindings { >(); } -final class Struct1 extends ffi.Opaque {} - typedef RawUnused = Struct1; +final class Struct1 extends ffi.Opaque {} + final class Struct2 extends ffi.Struct { @ffi.Double() external double a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required double a, + }) => $allocator()..ref.a = a; } typedef Struct2Typealias = Struct2; -final class WithTypealiasStruct$1 extends ffi.Struct { - external Struct2Typealias t; -} - final class Struct3 extends ffi.Opaque {} typedef Struct3Typealias = Struct3; + +final class WithTypealiasStruct$1 extends ffi.Struct { + external Struct2Typealias t; +} diff --git a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_unions_bindings.dart b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_unions_bindings.dart index bd8445eb8c..fd1c9873e8 100644 --- a/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_unions_bindings.dart +++ b/pkgs/ffigen/test/code_generator_tests/expected_bindings/_expected_unions_bindings.dart @@ -8,16 +8,6 @@ // ignore_for_file: type=lint, unused_import import 'dart:ffi' as ffi; -final class Struct1 extends ffi.Struct { - @ffi.Char() - external int a; -} - -final class Union1 extends ffi.Union { - @ffi.Char() - external int a; -} - final class EmptyUnion extends ffi.Opaque {} final class Primitives extends ffi.Union { @@ -48,6 +38,21 @@ final class PrimitivesWithPointers extends ffi.Union { external ffi.Pointer d$1; } +final class Struct1 extends ffi.Struct { + @ffi.Char() + external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; +} + +final class Union1 extends ffi.Union { + @ffi.Char() + external int a; +} + final class WithArray extends ffi.Union { @ffi.Array.multi([10]) external ffi.Array a; diff --git a/pkgs/ffigen/test/collision_tests/decl_decl_collision_test.dart b/pkgs/ffigen/test/collision_tests/decl_decl_collision_test.dart index 12404a2957..852edbee05 100644 --- a/pkgs/ffigen/test/collision_tests/decl_decl_collision_test.dart +++ b/pkgs/ffigen/test/collision_tests/decl_decl_collision_test.dart @@ -83,6 +83,7 @@ void main() { ], context), ); matchLibraryWithExpected( + context, library, 'decl_decl_collision_test_output.dart', [ diff --git a/pkgs/ffigen/test/collision_tests/decl_symbol_address_collision_test.dart b/pkgs/ffigen/test/collision_tests/decl_symbol_address_collision_test.dart index 40fd097970..fce49fd9c5 100644 --- a/pkgs/ffigen/test/collision_tests/decl_symbol_address_collision_test.dart +++ b/pkgs/ffigen/test/collision_tests/decl_symbol_address_collision_test.dart @@ -49,7 +49,9 @@ void main() { ); }); test('declaration and symbol address conflict', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'collision_test_decl_symbol_address_collision_output.dart', [ diff --git a/pkgs/ffigen/test/collision_tests/decl_type_name_collision_test.dart b/pkgs/ffigen/test/collision_tests/decl_type_name_collision_test.dart index 4c811cbda1..5a9626ee5b 100644 --- a/pkgs/ffigen/test/collision_tests/decl_type_name_collision_test.dart +++ b/pkgs/ffigen/test/collision_tests/decl_type_name_collision_test.dart @@ -28,7 +28,9 @@ ${strings.headers}: }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'decl_type_name_collision_test_output.dart', [ diff --git a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_decl_collision_bindings.dart b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_decl_collision_bindings.dart index 39d69c39d5..6dec7e8a2d 100644 --- a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_decl_collision_bindings.dart +++ b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_decl_collision_bindings.dart @@ -19,6 +19,24 @@ class Bindings { lookup, ) : _lookup = lookup; + void ffi$1() { + return _ffi$1(); + } + + late final _ffi$1Ptr = _lookup>( + 'ffi\$1', + ); + late final _ffi$1 = _ffi$1Ptr.asFunction(); + + void testCrossDecl$1() { + return _testCrossDecl$1(); + } + + late final _testCrossDecl$1Ptr = + _lookup>('testCrossDecl'); + late final _testCrossDecl$1 = _testCrossDecl$1Ptr + .asFunction(); + void testFunc() { return _testFunc(); } @@ -34,50 +52,32 @@ class Bindings { late final _testFunc$1Ptr = _lookup>('testFunc'); late final _testFunc$1 = _testFunc$1Ptr.asFunction(); +} - void testCrossDecl$1() { - return _testCrossDecl$1(); - } - - late final _testCrossDecl$1Ptr = - _lookup>('testCrossDecl'); - late final _testCrossDecl$1 = _testCrossDecl$1Ptr - .asFunction(); - - void ffi$1() { - return _ffi$1(); - } +sealed class TestEnum {} - late final _ffi$1Ptr = _lookup>( - 'ffi\$1', - ); - late final _ffi$1 = _ffi$1Ptr.asFunction(); -} +sealed class TestEnum$1 {} final class TestStruct extends ffi$2.Opaque {} final class TestStruct$1 extends ffi$2.Opaque {} -sealed class TestEnum {} - -sealed class TestEnum$1 {} - const int Test_Macro = 0; const int Test_Macro$1 = 0; +final class ffi extends ffi$2.Opaque {} + typedef testAlias = ffi$2.Void; typedef DarttestAlias = void; typedef testAlias$1 = ffi$2.Void; typedef DarttestAlias$1 = void; -final class testCrossDecl$3 extends ffi$2.Opaque {} +sealed class testCrossDecl {} const int testCrossDecl$2 = 0; -sealed class testCrossDecl {} +final class testCrossDecl$3 extends ffi$2.Opaque {} typedef testCrossDecl$4 = ffi$2.Void; typedef DarttestCrossDecl = void; - -final class ffi extends ffi$2.Opaque {} diff --git a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_symbol_address_collision_bindings.dart b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_symbol_address_collision_bindings.dart index c782b13d74..bc8b6b65a1 100644 --- a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_symbol_address_collision_bindings.dart +++ b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_symbol_address_collision_bindings.dart @@ -20,15 +20,6 @@ class Bindings$1 { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - void _library() { - return __library(); - } - - late final __libraryPtr = _lookup>( - '_library', - ); - late final __library = __libraryPtr.asFunction(); - void _SymbolAddresses_1() { return __SymbolAddresses_1(); } @@ -38,23 +29,32 @@ class Bindings$1 { late final __SymbolAddresses_1 = __SymbolAddresses_1Ptr .asFunction(); + void _library() { + return __library(); + } + + late final __libraryPtr = _lookup>( + '_library', + ); + late final __library = __libraryPtr.asFunction(); + late final addresses$1 = _SymbolAddresses$1(this); } class _SymbolAddresses$1 { final Bindings$1 _library$1; _SymbolAddresses$1(this._library$1); - ffi.Pointer> get _library => - _library$1.__libraryPtr; ffi.Pointer> get _SymbolAddresses_1 => _library$1.__SymbolAddresses_1Ptr; + ffi.Pointer> get _library => + _library$1.__libraryPtr; } -final class addresses extends ffi.Opaque {} - -final class _SymbolAddresses extends ffi.Opaque {} - sealed class Bindings {} typedef Native_library = ffi.Void Function(); typedef Dart_library = void Function(); + +final class _SymbolAddresses extends ffi.Opaque {} + +final class addresses extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_type_name_collision_bindings.dart b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_type_name_collision_bindings.dart index 894c09c4f3..461db6b840 100644 --- a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_type_name_collision_bindings.dart +++ b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_decl_type_name_collision_bindings.dart @@ -7,6 +7,9 @@ import 'dart:ffi' as ffi; final class A extends ffi.Struct { @ffi.Int() external int a; + + static ffi.Pointer $allocate(ffi.Allocator $allocator, {required int a}) => + $allocator()..ref.a = a; } final class B extends ffi.Struct { @@ -15,6 +18,14 @@ final class B extends ffi.Struct { @ffi.Int() external int A$1; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int B$1, + required int A$1, + }) => $allocator() + ..ref.B$1 = B$1 + ..ref.A$1 = A$1; } final class C extends ffi.Struct { diff --git a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_reserved_keyword_collision_bindings.dart b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_reserved_keyword_collision_bindings.dart index 35583b337b..9c7bad11b7 100644 --- a/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_reserved_keyword_collision_bindings.dart +++ b/pkgs/ffigen/test/collision_tests/expected_bindings/_expected_reserved_keyword_collision_bindings.dart @@ -41,6 +41,14 @@ final class Repro2795 extends ffi.Struct { ffi.NativeFunction in$)> > var$1; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction in$)> + > + var$1, + }) => $allocator()..ref.var$1 = var$1; } final class abstract$ extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/collision_tests/reserved_keyword_collision_test.dart b/pkgs/ffigen/test/collision_tests/reserved_keyword_collision_test.dart index bded6ac88a..cc5e3a8195 100644 --- a/pkgs/ffigen/test/collision_tests/reserved_keyword_collision_test.dart +++ b/pkgs/ffigen/test/collision_tests/reserved_keyword_collision_test.dart @@ -12,12 +12,12 @@ import '../test_utils.dart'; void main() { group('reserved_keyword_collision_test', () { test('reserved keyword collision', () { + final context = testContext(); final library = parser.parse( testContext( FfiGenerator( output: Output( dartFile: Uri.file('unused'), - sort: true, style: const DynamicLibraryBindings(), ), @@ -46,6 +46,7 @@ void main() { ), ); matchLibraryWithExpected( + context, library, 'reserved_keyword_collision_test_output.dart', [ diff --git a/pkgs/ffigen/test/example_tests/cjson_example_test.dart b/pkgs/ffigen/test/example_tests/cjson_example_test.dart index 2fc1c43bce..9740c29f40 100644 --- a/pkgs/ffigen/test/example_tests/cjson_example_test.dart +++ b/pkgs/ffigen/test/example_tests/cjson_example_test.dart @@ -14,9 +14,10 @@ void main() { final config = testConfigFromPath( path.join(packagePathForTests, 'example', 'c_json', 'config.yaml'), ); - final library = parse(testContext(config)); + final context = testContext(config); + final library = parse(context); - matchLibraryWithExpected(library, 'example_c_json.dart', [ + matchLibraryWithExpected(context, library, 'example_c_json.dart', [ config.output.dartFile.toFilePath(), ]); }); diff --git a/pkgs/ffigen/test/example_tests/ffinative_example_test.dart b/pkgs/ffigen/test/example_tests/ffinative_example_test.dart index 5e70ca1143..180e601ef5 100644 --- a/pkgs/ffigen/test/example_tests/ffinative_example_test.dart +++ b/pkgs/ffigen/test/example_tests/ffinative_example_test.dart @@ -14,9 +14,10 @@ void main() { final config = testConfigFromPath( path.join(packagePathForTests, 'example', 'ffinative', 'config.yaml'), ); - final library = parse(testContext(config)); + final context = testContext(config); + final library = parse(context); - matchLibraryWithExpected(library, 'example_ffinative.dart', [ + matchLibraryWithExpected(context, library, 'example_ffinative.dart', [ config.output.dartFile.toFilePath(), ]); }); diff --git a/pkgs/ffigen/test/example_tests/libclang_example_test.dart b/pkgs/ffigen/test/example_tests/libclang_example_test.dart index 4435bcd36c..22dd0a0c0e 100644 --- a/pkgs/ffigen/test/example_tests/libclang_example_test.dart +++ b/pkgs/ffigen/test/example_tests/libclang_example_test.dart @@ -35,7 +35,7 @@ void main() { final context = testContext(generator); final library = parse(context); - matchLibraryWithExpected(library, 'example_libclang.dart', [ + matchLibraryWithExpected(context, library, 'example_libclang.dart', [ generator.output.dartFile.toFilePath(), ]); }); diff --git a/pkgs/ffigen/test/example_tests/shared_bindings_example_test.dart b/pkgs/ffigen/test/example_tests/shared_bindings_example_test.dart index f950b9f669..5e2a5d0179 100644 --- a/pkgs/ffigen/test/example_tests/shared_bindings_example_test.dart +++ b/pkgs/ffigen/test/example_tests/shared_bindings_example_test.dart @@ -20,11 +20,14 @@ void main() { 'a_shared_base.yaml', ), ); - final library = parse(testContext(config)); - - matchLibraryWithExpected(library, 'example_shared_bindings.dart', [ - config.output.dartFile.toFilePath(), - ]); + final context = testContext(config); + final library = parse(context); + matchLibraryWithExpected( + context, + library, + 'example_shared_bindings.dart', + [config.output.dartFile.toFilePath()], + ); }); test('base symbol file output', () { @@ -37,8 +40,10 @@ void main() { 'base.yaml', ), ); - final library = parse(testContext(config)); + final context = testContext(config); + final library = parse(context); matchLibrarySymbolFileWithExpected( + context, library, 'example_shared_bindings.yaml', [config.output.symbolFile!.output.toFilePath()], diff --git a/pkgs/ffigen/test/example_tests/simple_example_test.dart b/pkgs/ffigen/test/example_tests/simple_example_test.dart index 4d5fee6394..f449ff85a5 100644 --- a/pkgs/ffigen/test/example_tests/simple_example_test.dart +++ b/pkgs/ffigen/test/example_tests/simple_example_test.dart @@ -14,9 +14,10 @@ void main() { final config = testConfigFromPath( path.join(packagePathForTests, 'example', 'simple', 'config.yaml'), ); - final library = parse(testContext(config)); + final context = testContext(config); + final library = parse(context); - matchLibraryWithExpected(library, 'example_simple.dart', [ + matchLibraryWithExpected(context, library, 'example_simple.dart', [ config.output.dartFile.toFilePath(), ]); }); diff --git a/pkgs/ffigen/test/header_parser_tests/comment_markup_test.dart b/pkgs/ffigen/test/header_parser_tests/comment_markup_test.dart index 80cbd8f37b..7d3488c01d 100644 --- a/pkgs/ffigen/test/header_parser_tests/comment_markup_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/comment_markup_test.dart @@ -31,7 +31,9 @@ ${strings.comments}: }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_comment_markup_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/dart_handle_test.dart b/pkgs/ffigen/test/header_parser_tests/dart_handle_test.dart index 8148c9a41c..226582b709 100644 --- a/pkgs/ffigen/test/header_parser_tests/dart_handle_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/dart_handle_test.dart @@ -34,7 +34,9 @@ ${strings.headers}: ); }); test('Expected Bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_dart_handle_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/enum_int_mimic_test.dart b/pkgs/ffigen/test/header_parser_tests/enum_int_mimic_test.dart index 783427b602..0c52231f48 100644 --- a/pkgs/ffigen/test/header_parser_tests/enum_int_mimic_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/enum_int_mimic_test.dart @@ -31,7 +31,9 @@ ${strings.ignoreSourceErrors}: true }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_enum_int_mimic_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_dart_handle_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_dart_handle_bindings.dart index f26d648a25..ae6c04966a 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_dart_handle_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_dart_handle_bindings.dart @@ -60,12 +60,17 @@ class NativeLibrary { late final _func4 = _func4Ptr.asFunction(); } -typedef Typedef1Function = ffi.Void Function(ffi.Handle); -typedef DartTypedef1Function = void Function(Object); -typedef Typedef1 = ffi.Pointer>; - final class Struct1 extends ffi.Opaque {} final class Struct2 extends ffi.Struct { external ffi.Pointer h; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer h, + }) => $allocator()..ref.h = h; } + +typedef Typedef1 = ffi.Pointer>; +typedef Typedef1Function = ffi.Void Function(ffi.Handle); +typedef DartTypedef1Function = void Function(Object); diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart index 4d5aa7bb82..7eb6bcac99 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_enum_int_mimic_bindings.dart @@ -4,29 +4,39 @@ // ignore_for_file: type=lint, unused_import import 'dart:ffi' as ffi; -enum Simple { - A0(0); +const int ANONYMOUS1 = 0; + +const int ANONYMOUS2 = -1000; + +const int ANONYMOUS3 = 0; + +enum ExplicitType { + E0(0), + E1(1); final int value; - const Simple(this.value); + const ExplicitType(this.value); - static Simple fromValue(int value) => switch (value) { - 0 => A0, - _ => throw ArgumentError('Unknown value for Simple: $value'), + static ExplicitType fromValue(int value) => switch (value) { + 0 => E0, + 1 => E1, + _ => throw ArgumentError('Unknown value for ExplicitType: $value'), }; } -enum SimpleWithNegative { - B0(0), - B1(-1000); +enum ExplicitTypeWithOverflow { + F0(0), + F1(-32727); final int value; - const SimpleWithNegative(this.value); + const ExplicitTypeWithOverflow(this.value); - static SimpleWithNegative fromValue(int value) => switch (value) { - 0 => B0, - -1000 => B1, - _ => throw ArgumentError('Unknown value for SimpleWithNegative: $value'), + static ExplicitTypeWithOverflow fromValue(int value) => switch (value) { + 0 => F0, + -32727 => F1, + _ => throw ArgumentError( + 'Unknown value for ExplicitTypeWithOverflow: $value', + ), }; } @@ -42,33 +52,29 @@ enum PositiveIntOverflow { }; } -enum ExplicitType { - E0(0), - E1(1); +enum Simple { + A0(0); final int value; - const ExplicitType(this.value); + const Simple(this.value); - static ExplicitType fromValue(int value) => switch (value) { - 0 => E0, - 1 => E1, - _ => throw ArgumentError('Unknown value for ExplicitType: $value'), + static Simple fromValue(int value) => switch (value) { + 0 => A0, + _ => throw ArgumentError('Unknown value for Simple: $value'), }; } -enum ExplicitTypeWithOverflow { - F0(0), - F1(-32727); +enum SimpleWithNegative { + B0(0), + B1(-1000); final int value; - const ExplicitTypeWithOverflow(this.value); + const SimpleWithNegative(this.value); - static ExplicitTypeWithOverflow fromValue(int value) => switch (value) { - 0 => F0, - -32727 => F1, - _ => throw ArgumentError( - 'Unknown value for ExplicitTypeWithOverflow: $value', - ), + static SimpleWithNegative fromValue(int value) => switch (value) { + 0 => B0, + -1000 => B1, + _ => throw ArgumentError('Unknown value for SimpleWithNegative: $value'), }; } @@ -109,9 +115,3 @@ final class Test extends ffi.Struct { set explicitTypeWithOverflow(ExplicitTypeWithOverflow value) => explicitTypeWithOverflowAsInt = value.value; } - -const int ANONYMOUS1 = 0; - -const int ANONYMOUS2 = -1000; - -const int ANONYMOUS3 = 0; diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart index 4f18dac1d7..714dda9005 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_forward_decl_bindings.dart @@ -36,6 +36,14 @@ final class A extends ffi.Struct { @ffi.Int() external int b; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + required int b, + }) => $allocator() + ..ref.a = a + ..ref.b = b; } enum B { diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_functions_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_functions_bindings.dart index 2e4fb2ef6a..a9f1ed5a35 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_functions_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_functions_bindings.dart @@ -19,6 +19,27 @@ class NativeLibrary { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; + int diffChars(int a, int b) { + return _diffChars(a, b); + } + + late final _diffCharsPtr = + _lookup< + ffi.NativeFunction + >('diffChars'); + late final _diffChars = _diffCharsPtr.asFunction(); + + void externInlineFunc(int a) { + return _externInlineFunc(a); + } + + late final _externInlineFuncPtr = + _lookup>( + 'externInlineFunc', + ); + late final _externInlineFunc = _externInlineFuncPtr + .asFunction(); + void func1() { return _func1(); } @@ -100,27 +121,6 @@ class NativeLibrary { ) >(); - void externInlineFunc(int a) { - return _externInlineFunc(a); - } - - late final _externInlineFuncPtr = - _lookup>( - 'externInlineFunc', - ); - late final _externInlineFunc = _externInlineFuncPtr - .asFunction(); - - int diffChars(int a, int b) { - return _diffChars(a, b); - } - - late final _diffCharsPtr = - _lookup< - ffi.NativeFunction - >('diffChars'); - late final _diffChars = _diffCharsPtr.asFunction(); - late final addresses = _SymbolAddresses(this); } diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_native_func_typedef_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_native_func_typedef_bindings.dart index f1a5dcaf5f..a63114dc6d 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_native_func_typedef_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_native_func_typedef_bindings.dart @@ -71,6 +71,11 @@ class NativeLibrary { .asFunction(); } +typedef InsideReturnType = + ffi.Pointer>; +typedef InsideReturnTypeFunction = ffi.Void Function(); +typedef DartInsideReturnTypeFunction = void Function(); + final class Struct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< @@ -80,20 +85,33 @@ final class Struct extends ffi.Struct { > > unnamed1; -} -typedef InsideReturnTypeFunction = ffi.Void Function(); -typedef DartInsideReturnTypeFunction = void Function(); -typedef InsideReturnType = - ffi.Pointer>; -typedef WithTypedefReturnTypeFunction = InsideReturnType Function(); -typedef WithTypedefReturnType = - ffi.Pointer>; -typedef VoidFuncPointerFunction = ffi.Void Function(); -typedef DartVoidFuncPointerFunction = void Function(); -typedef VoidFuncPointer = - ffi.Pointer>; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer> unnamed2, + ) + > + > + unnamed1, + }) => $allocator()..ref.unnamed1 = unnamed1; +} final class Struct2 extends ffi.Struct { external VoidFuncPointer constFuncPointer; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required VoidFuncPointer constFuncPointer, + }) => $allocator()..ref.constFuncPointer = constFuncPointer; } + +typedef VoidFuncPointer = + ffi.Pointer>; +typedef VoidFuncPointerFunction = ffi.Void Function(); +typedef DartVoidFuncPointerFunction = void Function(); +typedef WithTypedefReturnType = + ffi.Pointer>; +typedef WithTypedefReturnTypeFunction = InsideReturnType Function(); diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_opaque_dependencies_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_opaque_dependencies_bindings.dart index 9983748696..d7ac599ee5 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_opaque_dependencies_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_opaque_dependencies_bindings.dart @@ -50,13 +50,19 @@ typedef BAlias = B; final class C extends ffi.Opaque {} -final class NoDefinitionStructInD extends ffi.Opaque {} - final class D extends ffi.Struct { @ffi.Int() external int a; external ffi.Pointer nds; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + required ffi.Pointer nds, + }) => $allocator() + ..ref.a = a + ..ref.nds = nds; } final class DArray extends ffi.Struct { @@ -64,6 +70,14 @@ final class DArray extends ffi.Struct { external int a; external ffi.Pointer nds; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + required ffi.Pointer nds, + }) => $allocator() + ..ref.a = a + ..ref.nds = nds; } final class E extends ffi.Struct { @@ -75,6 +89,8 @@ final class E extends ffi.Struct { external ffi.Array dArray; } +final class NoDefinitionStructInD extends ffi.Opaque {} + final class UA extends ffi.Opaque {} final class UB extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_packed_structs_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_packed_structs_bindings.dart index 97a10acb82..3216b48cbe 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_packed_structs_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_packed_structs_bindings.dart @@ -7,27 +7,21 @@ import 'dart:ffi' as ffi; final class NormalStruct1 extends ffi.Struct { @ffi.Char() external int a; -} - -/// Should not be packed. -final class StructWithAttr extends ffi.Struct { - external ffi.Pointer a; - external ffi.Pointer b; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } -/// Should be packed with 1. -@ffi.Packed(1) -final class PackedAttr extends ffi.Struct { - @ffi.Int() +final class NormalStruct2 extends ffi.Struct { + @ffi.Char() external int a; -} -/// Should be packed with 8. -@ffi.Packed(8) -final class PackedAttrAlign8 extends ffi.Struct { - @ffi.Int() - external int a; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } /// Should be packed with 2. @@ -35,6 +29,11 @@ final class PackedAttrAlign8 extends ffi.Struct { final class Pack2WithPragma extends ffi.Struct { @ffi.Int() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } /// Should be packed with 4. @@ -42,9 +41,48 @@ final class Pack2WithPragma extends ffi.Struct { final class Pack4WithPragma extends ffi.Struct { @ffi.LongLong() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } -final class NormalStruct2 extends ffi.Struct { - @ffi.Char() +/// Should be packed with 1. +@ffi.Packed(1) +final class PackedAttr extends ffi.Struct { + @ffi.Int() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; +} + +/// Should be packed with 8. +@ffi.Packed(8) +final class PackedAttrAlign8 extends ffi.Struct { + @ffi.Int() + external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; +} + +/// Should not be packed. +final class StructWithAttr extends ffi.Struct { + external ffi.Pointer a; + + external ffi.Pointer b; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer a, + required ffi.Pointer b, + }) => $allocator() + ..ref.a = a + ..ref.b = b; } diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_struct_fptr_fields_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_struct_fptr_fields_bindings.dart index d1ac40e634..8b29c3a7b5 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_struct_fptr_fields_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_struct_fptr_fields_bindings.dart @@ -4,10 +4,10 @@ // ignore_for_file: type=lint, unused_import import 'dart:ffi' as ffi; -typedef ArithmeticOperationFunction = ffi.Int Function(ffi.Int a, ffi.Int b); -typedef DartArithmeticOperationFunction = int Function(int a, int b); typedef ArithmeticOperation = ffi.Pointer>; +typedef ArithmeticOperationFunction = ffi.Int Function(ffi.Int a, ffi.Int b); +typedef DartArithmeticOperationFunction = int Function(int a, int b); final class S extends ffi.Struct { external ffi.Pointer> func1; diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart index 06552949a9..844df2b522 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_typedef_bindings.dart @@ -77,45 +77,65 @@ class Bindings { .asFunction)>(); } -typedef NamedFunctionProtoFunction = ffi.Void Function(); -typedef DartNamedFunctionProtoFunction = void Function(); +enum AnonymousEnumInTypedef { + a(0); + + final int value; + const AnonymousEnumInTypedef(this.value); + + static AnonymousEnumInTypedef fromValue(int value) => switch (value) { + 0 => a, + _ => throw ArgumentError( + 'Unknown value for AnonymousEnumInTypedef: $value', + ), + }; +} + +final class AnonymousStructInTypedef extends ffi.Opaque {} + +typedef ExcludedStruct = _ExcludedStruct; +typedef IncludedTypedef = ffi.Pointer; +typedef NTyperef1 = ExcludedStruct; typedef NamedFunctionProto = ffi.Pointer>; +typedef NamedFunctionProtoFunction = ffi.Void Function(); +typedef DartNamedFunctionProtoFunction = void Function(); +typedef NamedStructInTypedef = _NamedStructInTypedef; +typedef NestingASpecifiedType = ffi.IntPtr; +typedef DartNestingASpecifiedType = int; final class Struct1 extends ffi.Struct { external NamedFunctionProto named; external ffi.Pointer> unnamed; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required NamedFunctionProto named, + required ffi.Pointer> unnamed, + }) => $allocator() + ..ref.named = named + ..ref.unnamed = unnamed; } -final class AnonymousStructInTypedef extends ffi.Opaque {} +final class Struct2 extends ffi.Opaque {} +typedef Struct3 = Struct2; typedef Typeref1 = AnonymousStructInTypedef; typedef Typeref2 = AnonymousStructInTypedef; -final class _NamedStructInTypedef extends ffi.Opaque {} +final class WithBoolAlias extends ffi.Struct { + @ffi.Bool() + external bool b; -typedef NamedStructInTypedef = _NamedStructInTypedef; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required bool b, + }) => $allocator()..ref.b = b; +} final class _ExcludedStruct extends ffi.Opaque {} -typedef ExcludedStruct = _ExcludedStruct; -typedef NTyperef1 = ExcludedStruct; - -enum AnonymousEnumInTypedef { - a(0); - - final int value; - const AnonymousEnumInTypedef(this.value); - - static AnonymousEnumInTypedef fromValue(int value) => switch (value) { - 0 => a, - _ => throw ArgumentError( - 'Unknown value for AnonymousEnumInTypedef: $value', - ), - }; -} - enum _NamedEnumInTypedef { b(0); @@ -128,16 +148,4 @@ enum _NamedEnumInTypedef { }; } -typedef NestingASpecifiedType = ffi.IntPtr; -typedef DartNestingASpecifiedType = int; - -final class Struct2 extends ffi.Opaque {} - -typedef Struct3 = Struct2; - -final class WithBoolAlias extends ffi.Struct { - @ffi.Bool() - external bool b; -} - -typedef IncludedTypedef = ffi.Pointer; +final class _NamedStructInTypedef extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_unions_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_unions_bindings.dart index 5bbee81ac7..dda9dd891b 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_unions_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_unions_bindings.dart @@ -57,6 +57,14 @@ final class Union4 extends ffi.Opaque {} final class Union5 extends ffi.Opaque {} +final class Union6 extends ffi.Union { + external UnnamedUnion unnamed; + + external UnnamedUnion$1 unnamed$1; +} + +final class Union7 extends ffi.Opaque {} + final class UnnamedUnion extends ffi.Union { @ffi.Float() external double a; @@ -66,11 +74,3 @@ final class UnnamedUnion$1 extends ffi.Union { @ffi.Float() external double b; } - -final class Union6 extends ffi.Union { - external UnnamedUnion unnamed; - - external UnnamedUnion$1 unnamed$1; -} - -final class Union7 extends ffi.Opaque {} diff --git a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_varargs_bindings.dart b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_varargs_bindings.dart index 84c7ba9580..896b4728f3 100644 --- a/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_varargs_bindings.dart +++ b/pkgs/ffigen/test/header_parser_tests/expected_bindings/_expected_varargs_bindings.dart @@ -187,9 +187,19 @@ class NativeLibrary { final class SA extends ffi.Struct { @ffi.Int() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } final class Struct_WithLong_Name_test extends ffi.Struct { @ffi.Int() external int a; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + }) => $allocator()..ref.a = a; } diff --git a/pkgs/ffigen/test/header_parser_tests/forward_decl_test.dart b/pkgs/ffigen/test/header_parser_tests/forward_decl_test.dart index ac4d12d773..d70eb0ac2a 100644 --- a/pkgs/ffigen/test/header_parser_tests/forward_decl_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/forward_decl_test.dart @@ -29,7 +29,9 @@ ${strings.ignoreSourceErrors}: true }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_forward_decl_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/functions_test.dart b/pkgs/ffigen/test/header_parser_tests/functions_test.dart index 664516593c..99d6721778 100644 --- a/pkgs/ffigen/test/header_parser_tests/functions_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/functions_test.dart @@ -40,7 +40,9 @@ ${strings.functions}: ); }); test('Expected Bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_functions_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart b/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart index 4de99982c5..6b1d4fb800 100644 --- a/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/imported_types_test.dart @@ -31,7 +31,9 @@ ${strings.headers}: ); }); test('Expected Bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_imported_types_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/native_func_typedef_test.dart b/pkgs/ffigen/test/header_parser_tests/native_func_typedef_test.dart index 049af1f3cc..39583399cd 100644 --- a/pkgs/ffigen/test/header_parser_tests/native_func_typedef_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/native_func_typedef_test.dart @@ -35,7 +35,9 @@ ${strings.headers}: }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_native_func_typedef_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/opaque_dependencies_test.dart b/pkgs/ffigen/test/header_parser_tests/opaque_dependencies_test.dart index 14955ee0ca..9449aebeba 100644 --- a/pkgs/ffigen/test/header_parser_tests/opaque_dependencies_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/opaque_dependencies_test.dart @@ -35,7 +35,9 @@ ${strings.unions}: ); }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_opaque_dependencies_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/packed_structs_test.dart b/pkgs/ffigen/test/header_parser_tests/packed_structs_test.dart index 188cf5b8e9..bc00429bc7 100644 --- a/pkgs/ffigen/test/header_parser_tests/packed_structs_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/packed_structs_test.dart @@ -28,7 +28,9 @@ ${strings.headers}: }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_packed_structs_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart b/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart index a4aeb7a76e..59177ece5d 100644 --- a/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/regress_384_test.dart @@ -29,7 +29,9 @@ ${strings.headers}: }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_regress_384_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/sort_test.dart b/pkgs/ffigen/test/header_parser_tests/sort_test.dart index 65ff536fc1..92a6c79023 100644 --- a/pkgs/ffigen/test/header_parser_tests/sort_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/sort_test.dart @@ -18,7 +18,7 @@ void main() { actual = parser.parse( testContext( FfiGenerator( - output: Output(dartFile: Uri.file('unused'), sort: true), + output: Output(dartFile: Uri.file('unused')), headers: Headers( entryPoints: [ Uri.file( @@ -42,12 +42,18 @@ void main() { ); }); test('Expected Bindings', () { - matchLibraryWithExpected(actual, 'header_parser_sort_test_output.dart', [ - 'test', - 'header_parser_tests', - 'expected_bindings', - '_expected_sort_bindings.dart', - ]); + final context = testContext(); + matchLibraryWithExpected( + context, + actual, + 'header_parser_sort_test_output.dart', + [ + 'test', + 'header_parser_tests', + 'expected_bindings', + '_expected_sort_bindings.dart', + ], + ); }); }); } diff --git a/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields_test.dart b/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields_test.dart index c19409e9af..c319f1d3b6 100644 --- a/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/struct_fptr_fields_test.dart @@ -34,7 +34,9 @@ ${strings.headers}: }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_struct_fptr_fields_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/typedef_test.dart b/pkgs/ffigen/test/header_parser_tests/typedef_test.dart index 45cbb00c97..ddbb8800a1 100644 --- a/pkgs/ffigen/test/header_parser_tests/typedef_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/typedef_test.dart @@ -48,7 +48,9 @@ ${strings.preamble}: | }); test('Expected Bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_typedef_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/unions_test.dart b/pkgs/ffigen/test/header_parser_tests/unions_test.dart index b9708a2619..af8165e295 100644 --- a/pkgs/ffigen/test/header_parser_tests/unions_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/unions_test.dart @@ -29,7 +29,9 @@ ${strings.ignoreSourceErrors}: true }); test('Expected bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_unions_test_output.dart', [ diff --git a/pkgs/ffigen/test/header_parser_tests/varargs_test.dart b/pkgs/ffigen/test/header_parser_tests/varargs_test.dart index 816ec8894d..b07364235f 100644 --- a/pkgs/ffigen/test/header_parser_tests/varargs_test.dart +++ b/pkgs/ffigen/test/header_parser_tests/varargs_test.dart @@ -49,7 +49,9 @@ ${strings.functions}: ); }); test('Expected Bindings', () { + final context = testContext(); matchLibraryWithExpected( + context, actual, 'header_parser_varargs_test_output.dart', [ diff --git a/pkgs/ffigen/test/large_integration_tests/_expected_cjson_bindings.dart b/pkgs/ffigen/test/large_integration_tests/_expected_cjson_bindings.dart index 3a20aa4cf6..ac6f5b99eb 100644 --- a/pkgs/ffigen/test/large_integration_tests/_expected_cjson_bindings.dart +++ b/pkgs/ffigen/test/large_integration_tests/_expected_cjson_bindings.dart @@ -18,362 +18,427 @@ class CJson { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - ffi.Pointer cJSON_Version() { - return _cJSON_Version(); - } - - late final _cJSON_VersionPtr = - _lookup Function()>>( - 'cJSON_Version', - ); - late final _cJSON_Version = _cJSON_VersionPtr - .asFunction Function()>(); - - void cJSON_InitHooks(ffi.Pointer hooks) { - return _cJSON_InitHooks(hooks); - } - - late final _cJSON_InitHooksPtr = - _lookup)>>( - 'cJSON_InitHooks', - ); - late final _cJSON_InitHooks = _cJSON_InitHooksPtr - .asFunction)>(); - - ffi.Pointer cJSON_Parse(ffi.Pointer value) { - return _cJSON_Parse(value); + ffi.Pointer cJSON_AddArrayToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddArrayToObject(object, name); } - late final _cJSON_ParsePtr = + late final _cJSON_AddArrayToObjectPtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_Parse'); - late final _cJSON_Parse = _cJSON_ParsePtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddArrayToObject'); + late final _cJSON_AddArrayToObject = _cJSON_AddArrayToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - ffi.Pointer cJSON_ParseWithOpts( - ffi.Pointer value, - ffi.Pointer> return_parse_end, - int require_null_terminated, + ffi.Pointer cJSON_AddBoolToObject( + ffi.Pointer object, + ffi.Pointer name, + int boolean, ) { - return _cJSON_ParseWithOpts( - value, - return_parse_end, - require_null_terminated, - ); + return _cJSON_AddBoolToObject(object, name, boolean); } - late final _cJSON_ParseWithOptsPtr = + late final _cJSON_AddBoolToObjectPtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer>, cJSON_bool, ) > - >('cJSON_ParseWithOpts'); - late final _cJSON_ParseWithOpts = _cJSON_ParseWithOptsPtr + >('cJSON_AddBoolToObject'); + late final _cJSON_AddBoolToObject = _cJSON_AddBoolToObjectPtr .asFunction< ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer>, int, ) >(); - ffi.Pointer cJSON_Print(ffi.Pointer item) { - return _cJSON_Print(item); - } - - late final _cJSON_PrintPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_Print'); - late final _cJSON_Print = _cJSON_PrintPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_PrintUnformatted(ffi.Pointer item) { - return _cJSON_PrintUnformatted(item); + ffi.Pointer cJSON_AddFalseToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddFalseToObject(object, name); } - late final _cJSON_PrintUnformattedPtr = + late final _cJSON_AddFalseToObjectPtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_PrintUnformatted'); - late final _cJSON_PrintUnformatted = _cJSON_PrintUnformattedPtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddFalseToObject'); + late final _cJSON_AddFalseToObject = _cJSON_AddFalseToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - ffi.Pointer cJSON_PrintBuffered( + void cJSON_AddItemReferenceToArray( + ffi.Pointer array, ffi.Pointer item, - int prebuffer, - int fmt, ) { - return _cJSON_PrintBuffered(item, prebuffer, fmt); + return _cJSON_AddItemReferenceToArray(array, item); } - late final _cJSON_PrintBufferedPtr = + late final _cJSON_AddItemReferenceToArrayPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, - cJSON_bool, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_PrintBuffered'); - late final _cJSON_PrintBuffered = _cJSON_PrintBufferedPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int, int) - >(); + >('cJSON_AddItemReferenceToArray'); + late final _cJSON_AddItemReferenceToArray = _cJSON_AddItemReferenceToArrayPtr + .asFunction, ffi.Pointer)>(); - int cJSON_PrintPreallocated( + void cJSON_AddItemReferenceToObject( + ffi.Pointer object, + ffi.Pointer string, ffi.Pointer item, - ffi.Pointer buffer, - int length, - int format, ) { - return _cJSON_PrintPreallocated(item, buffer, length, format); + return _cJSON_AddItemReferenceToObject(object, string, item); } - late final _cJSON_PrintPreallocatedPtr = + late final _cJSON_AddItemReferenceToObjectPtr = _lookup< ffi.NativeFunction< - cJSON_bool Function( + ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Int, - cJSON_bool, + ffi.Pointer, ) > - >('cJSON_PrintPreallocated'); - late final _cJSON_PrintPreallocated = _cJSON_PrintPreallocatedPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, int) - >(); - - void cJSON_Delete(ffi.Pointer item) { - return _cJSON_Delete(item); - } - - late final _cJSON_DeletePtr = - _lookup)>>( - 'cJSON_Delete', - ); - late final _cJSON_Delete = _cJSON_DeletePtr - .asFunction)>(); - - int cJSON_GetArraySize(ffi.Pointer array) { - return _cJSON_GetArraySize(array); - } - - late final _cJSON_GetArraySizePtr = - _lookup)>>( - 'cJSON_GetArraySize', - ); - late final _cJSON_GetArraySize = _cJSON_GetArraySizePtr - .asFunction)>(); + >('cJSON_AddItemReferenceToObject'); + late final _cJSON_AddItemReferenceToObject = + _cJSON_AddItemReferenceToObjectPtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - ffi.Pointer cJSON_GetArrayItem(ffi.Pointer array, int index) { - return _cJSON_GetArrayItem(array, index); + void cJSON_AddItemToArray(ffi.Pointer array, ffi.Pointer item) { + return _cJSON_AddItemToArray(array, item); } - late final _cJSON_GetArrayItemPtr = + late final _cJSON_AddItemToArrayPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_GetArrayItem'); - late final _cJSON_GetArrayItem = _cJSON_GetArrayItemPtr - .asFunction Function(ffi.Pointer, int)>(); + >('cJSON_AddItemToArray'); + late final _cJSON_AddItemToArray = _cJSON_AddItemToArrayPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer cJSON_GetObjectItem( + void cJSON_AddItemToObject( ffi.Pointer object, ffi.Pointer string, + ffi.Pointer item, ) { - return _cJSON_GetObjectItem(object, string); + return _cJSON_AddItemToObject(object, string, item); } - late final _cJSON_GetObjectItemPtr = + late final _cJSON_AddItemToObjectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_GetObjectItem'); - late final _cJSON_GetObjectItem = _cJSON_GetObjectItemPtr + >('cJSON_AddItemToObject'); + late final _cJSON_AddItemToObject = _cJSON_AddItemToObjectPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >(); - ffi.Pointer cJSON_GetObjectItemCaseSensitive( + void cJSON_AddItemToObjectCS( ffi.Pointer object, ffi.Pointer string, + ffi.Pointer item, ) { - return _cJSON_GetObjectItemCaseSensitive(object, string); + return _cJSON_AddItemToObjectCS(object, string, item); } - late final _cJSON_GetObjectItemCaseSensitivePtr = + late final _cJSON_AddItemToObjectCSPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_GetObjectItemCaseSensitive'); - late final _cJSON_GetObjectItemCaseSensitive = - _cJSON_GetObjectItemCaseSensitivePtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('cJSON_AddItemToObjectCS'); + late final _cJSON_AddItemToObjectCS = _cJSON_AddItemToObjectCSPtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int cJSON_HasObjectItem( + ffi.Pointer cJSON_AddNullToObject( ffi.Pointer object, - ffi.Pointer string, + ffi.Pointer name, ) { - return _cJSON_HasObjectItem(object, string); + return _cJSON_AddNullToObject(object, name); } - late final _cJSON_HasObjectItemPtr = + late final _cJSON_AddNullToObjectPtr = _lookup< ffi.NativeFunction< - cJSON_bool Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_HasObjectItem'); - late final _cJSON_HasObjectItem = _cJSON_HasObjectItemPtr - .asFunction, ffi.Pointer)>(); + >('cJSON_AddNullToObject'); + late final _cJSON_AddNullToObject = _cJSON_AddNullToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - ffi.Pointer cJSON_GetErrorPtr() { - return _cJSON_GetErrorPtr(); + ffi.Pointer cJSON_AddNumberToObject( + ffi.Pointer object, + ffi.Pointer name, + double number, + ) { + return _cJSON_AddNumberToObject(object, name, number); } - late final _cJSON_GetErrorPtrPtr = - _lookup Function()>>( - 'cJSON_GetErrorPtr', - ); - late final _cJSON_GetErrorPtr = _cJSON_GetErrorPtrPtr - .asFunction Function()>(); + late final _cJSON_AddNumberToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Double, + ) + > + >('cJSON_AddNumberToObject'); + late final _cJSON_AddNumberToObject = _cJSON_AddNumberToObjectPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + double, + ) + >(); - ffi.Pointer cJSON_GetStringValue(ffi.Pointer item) { - return _cJSON_GetStringValue(item); + ffi.Pointer cJSON_AddObjectToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddObjectToObject(object, name); } - late final _cJSON_GetStringValuePtr = + late final _cJSON_AddObjectToObjectPtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_GetStringValue'); - late final _cJSON_GetStringValue = _cJSON_GetStringValuePtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddObjectToObject'); + late final _cJSON_AddObjectToObject = _cJSON_AddObjectToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - int cJSON_IsInvalid(ffi.Pointer item) { - return _cJSON_IsInvalid(item); + ffi.Pointer cJSON_AddRawToObject( + ffi.Pointer object, + ffi.Pointer name, + ffi.Pointer raw, + ) { + return _cJSON_AddRawToObject(object, name, raw); } - late final _cJSON_IsInvalidPtr = - _lookup)>>( - 'cJSON_IsInvalid', - ); - late final _cJSON_IsInvalid = _cJSON_IsInvalidPtr - .asFunction)>(); + late final _cJSON_AddRawToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('cJSON_AddRawToObject'); + late final _cJSON_AddRawToObject = _cJSON_AddRawToObjectPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int cJSON_IsFalse(ffi.Pointer item) { - return _cJSON_IsFalse(item); + ffi.Pointer cJSON_AddStringToObject( + ffi.Pointer object, + ffi.Pointer name, + ffi.Pointer string, + ) { + return _cJSON_AddStringToObject(object, name, string); } - late final _cJSON_IsFalsePtr = - _lookup)>>( - 'cJSON_IsFalse', - ); - late final _cJSON_IsFalse = _cJSON_IsFalsePtr - .asFunction)>(); + late final _cJSON_AddStringToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('cJSON_AddStringToObject'); + late final _cJSON_AddStringToObject = _cJSON_AddStringToObjectPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int cJSON_IsTrue(ffi.Pointer item) { - return _cJSON_IsTrue(item); + ffi.Pointer cJSON_AddTrueToObject( + ffi.Pointer object, + ffi.Pointer name, + ) { + return _cJSON_AddTrueToObject(object, name); } - late final _cJSON_IsTruePtr = - _lookup)>>( - 'cJSON_IsTrue', - ); - late final _cJSON_IsTrue = _cJSON_IsTruePtr - .asFunction)>(); + late final _cJSON_AddTrueToObjectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + > + >('cJSON_AddTrueToObject'); + late final _cJSON_AddTrueToObject = _cJSON_AddTrueToObjectPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - int cJSON_IsBool(ffi.Pointer item) { - return _cJSON_IsBool(item); + int cJSON_Compare( + ffi.Pointer a, + ffi.Pointer b, + int case_sensitive, + ) { + return _cJSON_Compare(a, b, case_sensitive); } - late final _cJSON_IsBoolPtr = - _lookup)>>( - 'cJSON_IsBool', - ); - late final _cJSON_IsBool = _cJSON_IsBoolPtr - .asFunction)>(); + late final _cJSON_ComparePtr = + _lookup< + ffi.NativeFunction< + cJSON_bool Function( + ffi.Pointer, + ffi.Pointer, + cJSON_bool, + ) + > + >('cJSON_Compare'); + late final _cJSON_Compare = _cJSON_ComparePtr + .asFunction, ffi.Pointer, int)>(); - int cJSON_IsNull(ffi.Pointer item) { - return _cJSON_IsNull(item); + ffi.Pointer cJSON_CreateArray() { + return _cJSON_CreateArray(); } - late final _cJSON_IsNullPtr = - _lookup)>>( - 'cJSON_IsNull', + late final _cJSON_CreateArrayPtr = + _lookup Function()>>( + 'cJSON_CreateArray', ); - late final _cJSON_IsNull = _cJSON_IsNullPtr - .asFunction)>(); + late final _cJSON_CreateArray = _cJSON_CreateArrayPtr + .asFunction Function()>(); - int cJSON_IsNumber(ffi.Pointer item) { - return _cJSON_IsNumber(item); + ffi.Pointer cJSON_CreateArrayReference(ffi.Pointer child) { + return _cJSON_CreateArrayReference(child); } - late final _cJSON_IsNumberPtr = - _lookup)>>( - 'cJSON_IsNumber', - ); - late final _cJSON_IsNumber = _cJSON_IsNumberPtr - .asFunction)>(); + late final _cJSON_CreateArrayReferencePtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateArrayReference'); + late final _cJSON_CreateArrayReference = _cJSON_CreateArrayReferencePtr + .asFunction Function(ffi.Pointer)>(); - int cJSON_IsString(ffi.Pointer item) { - return _cJSON_IsString(item); + ffi.Pointer cJSON_CreateBool(int boolean) { + return _cJSON_CreateBool(boolean); } - late final _cJSON_IsStringPtr = - _lookup)>>( - 'cJSON_IsString', + late final _cJSON_CreateBoolPtr = + _lookup Function(cJSON_bool)>>( + 'cJSON_CreateBool', ); - late final _cJSON_IsString = _cJSON_IsStringPtr - .asFunction)>(); + late final _cJSON_CreateBool = _cJSON_CreateBoolPtr + .asFunction Function(int)>(); - int cJSON_IsArray(ffi.Pointer item) { - return _cJSON_IsArray(item); + ffi.Pointer cJSON_CreateDoubleArray( + ffi.Pointer numbers, + int count, + ) { + return _cJSON_CreateDoubleArray(numbers, count); } - late final _cJSON_IsArrayPtr = - _lookup)>>( - 'cJSON_IsArray', - ); - late final _cJSON_IsArray = _cJSON_IsArrayPtr - .asFunction)>(); + late final _cJSON_CreateDoubleArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('cJSON_CreateDoubleArray'); + late final _cJSON_CreateDoubleArray = _cJSON_CreateDoubleArrayPtr + .asFunction Function(ffi.Pointer, int)>(); - int cJSON_IsObject(ffi.Pointer item) { - return _cJSON_IsObject(item); + ffi.Pointer cJSON_CreateFalse() { + return _cJSON_CreateFalse(); } - late final _cJSON_IsObjectPtr = - _lookup)>>( - 'cJSON_IsObject', + late final _cJSON_CreateFalsePtr = + _lookup Function()>>( + 'cJSON_CreateFalse', ); - late final _cJSON_IsObject = _cJSON_IsObjectPtr - .asFunction)>(); + late final _cJSON_CreateFalse = _cJSON_CreateFalsePtr + .asFunction Function()>(); - int cJSON_IsRaw(ffi.Pointer item) { - return _cJSON_IsRaw(item); + ffi.Pointer cJSON_CreateFloatArray( + ffi.Pointer numbers, + int count, + ) { + return _cJSON_CreateFloatArray(numbers, count); } - late final _cJSON_IsRawPtr = - _lookup)>>( - 'cJSON_IsRaw', - ); - late final _cJSON_IsRaw = _cJSON_IsRawPtr - .asFunction)>(); + late final _cJSON_CreateFloatArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('cJSON_CreateFloatArray'); + late final _cJSON_CreateFloatArray = _cJSON_CreateFloatArrayPtr + .asFunction Function(ffi.Pointer, int)>(); + + ffi.Pointer cJSON_CreateIntArray( + ffi.Pointer numbers, + int count, + ) { + return _cJSON_CreateIntArray(numbers, count); + } + + late final _cJSON_CreateIntArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('cJSON_CreateIntArray'); + late final _cJSON_CreateIntArray = _cJSON_CreateIntArrayPtr + .asFunction Function(ffi.Pointer, int)>(); ffi.Pointer cJSON_CreateNull() { return _cJSON_CreateNull(); @@ -386,39 +451,6 @@ class CJson { late final _cJSON_CreateNull = _cJSON_CreateNullPtr .asFunction Function()>(); - ffi.Pointer cJSON_CreateTrue() { - return _cJSON_CreateTrue(); - } - - late final _cJSON_CreateTruePtr = - _lookup Function()>>( - 'cJSON_CreateTrue', - ); - late final _cJSON_CreateTrue = _cJSON_CreateTruePtr - .asFunction Function()>(); - - ffi.Pointer cJSON_CreateFalse() { - return _cJSON_CreateFalse(); - } - - late final _cJSON_CreateFalsePtr = - _lookup Function()>>( - 'cJSON_CreateFalse', - ); - late final _cJSON_CreateFalse = _cJSON_CreateFalsePtr - .asFunction Function()>(); - - ffi.Pointer cJSON_CreateBool(int boolean) { - return _cJSON_CreateBool(boolean); - } - - late final _cJSON_CreateBoolPtr = - _lookup Function(cJSON_bool)>>( - 'cJSON_CreateBool', - ); - late final _cJSON_CreateBool = _cJSON_CreateBoolPtr - .asFunction Function(int)>(); - ffi.Pointer cJSON_CreateNumber(double num) { return _cJSON_CreateNumber(num); } @@ -430,39 +462,6 @@ class CJson { late final _cJSON_CreateNumber = _cJSON_CreateNumberPtr .asFunction Function(double)>(); - ffi.Pointer cJSON_CreateString(ffi.Pointer string) { - return _cJSON_CreateString(string); - } - - late final _cJSON_CreateStringPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateString'); - late final _cJSON_CreateString = _cJSON_CreateStringPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_CreateRaw(ffi.Pointer raw) { - return _cJSON_CreateRaw(raw); - } - - late final _cJSON_CreateRawPtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateRaw'); - late final _cJSON_CreateRaw = _cJSON_CreateRawPtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_CreateArray() { - return _cJSON_CreateArray(); - } - - late final _cJSON_CreateArrayPtr = - _lookup Function()>>( - 'cJSON_CreateArray', - ); - late final _cJSON_CreateArray = _cJSON_CreateArrayPtr - .asFunction Function()>(); - ffi.Pointer cJSON_CreateObject() { return _cJSON_CreateObject(); } @@ -474,17 +473,6 @@ class CJson { late final _cJSON_CreateObject = _cJSON_CreateObjectPtr .asFunction Function()>(); - ffi.Pointer cJSON_CreateStringReference(ffi.Pointer string) { - return _cJSON_CreateStringReference(string); - } - - late final _cJSON_CreateStringReferencePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateStringReference'); - late final _cJSON_CreateStringReference = _cJSON_CreateStringReferencePtr - .asFunction Function(ffi.Pointer)>(); - ffi.Pointer cJSON_CreateObjectReference(ffi.Pointer child) { return _cJSON_CreateObjectReference(child); } @@ -496,64 +484,27 @@ class CJson { late final _cJSON_CreateObjectReference = _cJSON_CreateObjectReferencePtr .asFunction Function(ffi.Pointer)>(); - ffi.Pointer cJSON_CreateArrayReference(ffi.Pointer child) { - return _cJSON_CreateArrayReference(child); - } - - late final _cJSON_CreateArrayReferencePtr = - _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('cJSON_CreateArrayReference'); - late final _cJSON_CreateArrayReference = _cJSON_CreateArrayReferencePtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer cJSON_CreateIntArray( - ffi.Pointer numbers, - int count, - ) { - return _cJSON_CreateIntArray(numbers, count); - } - - late final _cJSON_CreateIntArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('cJSON_CreateIntArray'); - late final _cJSON_CreateIntArray = _cJSON_CreateIntArrayPtr - .asFunction Function(ffi.Pointer, int)>(); - - ffi.Pointer cJSON_CreateFloatArray( - ffi.Pointer numbers, - int count, - ) { - return _cJSON_CreateFloatArray(numbers, count); + ffi.Pointer cJSON_CreateRaw(ffi.Pointer raw) { + return _cJSON_CreateRaw(raw); } - late final _cJSON_CreateFloatArrayPtr = + late final _cJSON_CreateRawPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('cJSON_CreateFloatArray'); - late final _cJSON_CreateFloatArray = _cJSON_CreateFloatArrayPtr - .asFunction Function(ffi.Pointer, int)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateRaw'); + late final _cJSON_CreateRaw = _cJSON_CreateRawPtr + .asFunction Function(ffi.Pointer)>(); - ffi.Pointer cJSON_CreateDoubleArray( - ffi.Pointer numbers, - int count, - ) { - return _cJSON_CreateDoubleArray(numbers, count); + ffi.Pointer cJSON_CreateString(ffi.Pointer string) { + return _cJSON_CreateString(string); } - late final _cJSON_CreateDoubleArrayPtr = + late final _cJSON_CreateStringPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('cJSON_CreateDoubleArray'); - late final _cJSON_CreateDoubleArray = _cJSON_CreateDoubleArrayPtr - .asFunction Function(ffi.Pointer, int)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateString'); + late final _cJSON_CreateString = _cJSON_CreateStringPtr + .asFunction Function(ffi.Pointer)>(); ffi.Pointer cJSON_CreateStringArray( ffi.Pointer> strings, @@ -564,146 +515,96 @@ class CJson { late final _cJSON_CreateStringArrayPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer>, - ffi.Int, - ) - > - >('cJSON_CreateStringArray'); - late final _cJSON_CreateStringArray = _cJSON_CreateStringArrayPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer>, int) - >(); - - void cJSON_AddItemToArray(ffi.Pointer array, ffi.Pointer item) { - return _cJSON_AddItemToArray(array, item); - } - - late final _cJSON_AddItemToArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddItemToArray'); - late final _cJSON_AddItemToArray = _cJSON_AddItemToArrayPtr - .asFunction, ffi.Pointer)>(); - - void cJSON_AddItemToObject( - ffi.Pointer object, - ffi.Pointer string, - ffi.Pointer item, - ) { - return _cJSON_AddItemToObject(object, string, item); - } - - late final _cJSON_AddItemToObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('cJSON_AddItemToObject'); - late final _cJSON_AddItemToObject = _cJSON_AddItemToObjectPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - void cJSON_AddItemToObjectCS( - ffi.Pointer object, - ffi.Pointer string, - ffi.Pointer item, - ) { - return _cJSON_AddItemToObjectCS(object, string, item); - } - - late final _cJSON_AddItemToObjectCSPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer>, + ffi.Int, ) > - >('cJSON_AddItemToObjectCS'); - late final _cJSON_AddItemToObjectCS = _cJSON_AddItemToObjectCSPtr + >('cJSON_CreateStringArray'); + late final _cJSON_CreateStringArray = _cJSON_CreateStringArrayPtr .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer>, int) >(); - void cJSON_AddItemReferenceToArray( - ffi.Pointer array, - ffi.Pointer item, - ) { - return _cJSON_AddItemReferenceToArray(array, item); + ffi.Pointer cJSON_CreateStringReference(ffi.Pointer string) { + return _cJSON_CreateStringReference(string); } - late final _cJSON_AddItemReferenceToArrayPtr = + late final _cJSON_CreateStringReferencePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddItemReferenceToArray'); - late final _cJSON_AddItemReferenceToArray = _cJSON_AddItemReferenceToArrayPtr - .asFunction, ffi.Pointer)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_CreateStringReference'); + late final _cJSON_CreateStringReference = _cJSON_CreateStringReferencePtr + .asFunction Function(ffi.Pointer)>(); - void cJSON_AddItemReferenceToObject( + ffi.Pointer cJSON_CreateTrue() { + return _cJSON_CreateTrue(); + } + + late final _cJSON_CreateTruePtr = + _lookup Function()>>( + 'cJSON_CreateTrue', + ); + late final _cJSON_CreateTrue = _cJSON_CreateTruePtr + .asFunction Function()>(); + + void cJSON_Delete(ffi.Pointer item) { + return _cJSON_Delete(item); + } + + late final _cJSON_DeletePtr = + _lookup)>>( + 'cJSON_Delete', + ); + late final _cJSON_Delete = _cJSON_DeletePtr + .asFunction)>(); + + void cJSON_DeleteItemFromArray(ffi.Pointer array, int which) { + return _cJSON_DeleteItemFromArray(array, which); + } + + late final _cJSON_DeleteItemFromArrayPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('cJSON_DeleteItemFromArray'); + late final _cJSON_DeleteItemFromArray = _cJSON_DeleteItemFromArrayPtr + .asFunction, int)>(); + + void cJSON_DeleteItemFromObject( ffi.Pointer object, ffi.Pointer string, - ffi.Pointer item, ) { - return _cJSON_AddItemReferenceToObject(object, string, item); + return _cJSON_DeleteItemFromObject(object, string); } - late final _cJSON_AddItemReferenceToObjectPtr = + late final _cJSON_DeleteItemFromObjectPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_AddItemReferenceToObject'); - late final _cJSON_AddItemReferenceToObject = - _cJSON_AddItemReferenceToObjectPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('cJSON_DeleteItemFromObject'); + late final _cJSON_DeleteItemFromObject = _cJSON_DeleteItemFromObjectPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer cJSON_DetachItemViaPointer( - ffi.Pointer parent, - ffi.Pointer item, + void cJSON_DeleteItemFromObjectCaseSensitive( + ffi.Pointer object, + ffi.Pointer string, ) { - return _cJSON_DetachItemViaPointer(parent, item); + return _cJSON_DeleteItemFromObjectCaseSensitive(object, string); } - late final _cJSON_DetachItemViaPointerPtr = + late final _cJSON_DeleteItemFromObjectCaseSensitivePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_DetachItemViaPointer'); - late final _cJSON_DetachItemViaPointer = _cJSON_DetachItemViaPointerPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_DeleteItemFromObjectCaseSensitive'); + late final _cJSON_DeleteItemFromObjectCaseSensitive = + _cJSON_DeleteItemFromObjectCaseSensitivePtr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >(); ffi.Pointer cJSON_DetachItemFromArray( ffi.Pointer array, @@ -721,17 +622,6 @@ class CJson { late final _cJSON_DetachItemFromArray = _cJSON_DetachItemFromArrayPtr .asFunction Function(ffi.Pointer, int)>(); - void cJSON_DeleteItemFromArray(ffi.Pointer array, int which) { - return _cJSON_DeleteItemFromArray(array, which); - } - - late final _cJSON_DeleteItemFromArrayPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('cJSON_DeleteItemFromArray'); - late final _cJSON_DeleteItemFromArray = _cJSON_DeleteItemFromArrayPtr - .asFunction, int)>(); - ffi.Pointer cJSON_DetachItemFromObject( ffi.Pointer object, ffi.Pointer string, @@ -772,394 +662,493 @@ class CJson { ) >(); - void cJSON_DeleteItemFromObject( - ffi.Pointer object, - ffi.Pointer string, + ffi.Pointer cJSON_DetachItemViaPointer( + ffi.Pointer parent, + ffi.Pointer item, ) { - return _cJSON_DeleteItemFromObject(object, string); + return _cJSON_DetachItemViaPointer(parent, item); } - late final _cJSON_DeleteItemFromObjectPtr = + late final _cJSON_DetachItemViaPointerPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_DeleteItemFromObject'); - late final _cJSON_DeleteItemFromObject = _cJSON_DeleteItemFromObjectPtr - .asFunction, ffi.Pointer)>(); + >('cJSON_DetachItemViaPointer'); + late final _cJSON_DetachItemViaPointer = _cJSON_DetachItemViaPointerPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + >(); - void cJSON_DeleteItemFromObjectCaseSensitive( - ffi.Pointer object, - ffi.Pointer string, - ) { - return _cJSON_DeleteItemFromObjectCaseSensitive(object, string); + ffi.Pointer cJSON_Duplicate(ffi.Pointer item, int recurse) { + return _cJSON_Duplicate(item, recurse); } - late final _cJSON_DeleteItemFromObjectCaseSensitivePtr = + late final _cJSON_DuplicatePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, cJSON_bool) > - >('cJSON_DeleteItemFromObjectCaseSensitive'); - late final _cJSON_DeleteItemFromObjectCaseSensitive = - _cJSON_DeleteItemFromObjectCaseSensitivePtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_Duplicate'); + late final _cJSON_Duplicate = _cJSON_DuplicatePtr + .asFunction Function(ffi.Pointer, int)>(); - void cJSON_InsertItemInArray( - ffi.Pointer array, - int which, - ffi.Pointer newitem, - ) { - return _cJSON_InsertItemInArray(array, which, newitem); + ffi.Pointer cJSON_GetArrayItem(ffi.Pointer array, int index) { + return _cJSON_GetArrayItem(array, index); } - late final _cJSON_InsertItemInArrayPtr = + late final _cJSON_GetArrayItemPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('cJSON_InsertItemInArray'); - late final _cJSON_InsertItemInArray = _cJSON_InsertItemInArrayPtr - .asFunction, int, ffi.Pointer)>(); + >('cJSON_GetArrayItem'); + late final _cJSON_GetArrayItem = _cJSON_GetArrayItemPtr + .asFunction Function(ffi.Pointer, int)>(); - int cJSON_ReplaceItemViaPointer( - ffi.Pointer parent, - ffi.Pointer item, - ffi.Pointer replacement, - ) { - return _cJSON_ReplaceItemViaPointer(parent, item, replacement); + int cJSON_GetArraySize(ffi.Pointer array) { + return _cJSON_GetArraySize(array); } - late final _cJSON_ReplaceItemViaPointerPtr = - _lookup< - ffi.NativeFunction< - cJSON_bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('cJSON_ReplaceItemViaPointer'); - late final _cJSON_ReplaceItemViaPointer = _cJSON_ReplaceItemViaPointerPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer) - >(); + late final _cJSON_GetArraySizePtr = + _lookup)>>( + 'cJSON_GetArraySize', + ); + late final _cJSON_GetArraySize = _cJSON_GetArraySizePtr + .asFunction)>(); - void cJSON_ReplaceItemInArray( - ffi.Pointer array, - int which, - ffi.Pointer newitem, - ) { - return _cJSON_ReplaceItemInArray(array, which, newitem); + ffi.Pointer cJSON_GetErrorPtr() { + return _cJSON_GetErrorPtr(); } - late final _cJSON_ReplaceItemInArrayPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) - > - >('cJSON_ReplaceItemInArray'); - late final _cJSON_ReplaceItemInArray = _cJSON_ReplaceItemInArrayPtr - .asFunction, int, ffi.Pointer)>(); + late final _cJSON_GetErrorPtrPtr = + _lookup Function()>>( + 'cJSON_GetErrorPtr', + ); + late final _cJSON_GetErrorPtr = _cJSON_GetErrorPtrPtr + .asFunction Function()>(); - void cJSON_ReplaceItemInObject( + ffi.Pointer cJSON_GetObjectItem( ffi.Pointer object, ffi.Pointer string, - ffi.Pointer newitem, ) { - return _cJSON_ReplaceItemInObject(object, string, newitem); + return _cJSON_GetObjectItem(object, string); } - late final _cJSON_ReplaceItemInObjectPtr = + late final _cJSON_GetObjectItemPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_ReplaceItemInObject'); - late final _cJSON_ReplaceItemInObject = _cJSON_ReplaceItemInObjectPtr + >('cJSON_GetObjectItem'); + late final _cJSON_GetObjectItem = _cJSON_GetObjectItemPtr .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) >(); - void cJSON_ReplaceItemInObjectCaseSensitive( + ffi.Pointer cJSON_GetObjectItemCaseSensitive( ffi.Pointer object, ffi.Pointer string, - ffi.Pointer newitem, ) { - return _cJSON_ReplaceItemInObjectCaseSensitive(object, string, newitem); + return _cJSON_GetObjectItemCaseSensitive(object, string); } - late final _cJSON_ReplaceItemInObjectCaseSensitivePtr = + late final _cJSON_GetObjectItemCaseSensitivePtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_ReplaceItemInObjectCaseSensitive'); - late final _cJSON_ReplaceItemInObjectCaseSensitive = - _cJSON_ReplaceItemInObjectCaseSensitivePtr + >('cJSON_GetObjectItemCaseSensitive'); + late final _cJSON_GetObjectItemCaseSensitive = + _cJSON_GetObjectItemCaseSensitivePtr .asFunction< - void Function( + ffi.Pointer Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, ) >(); - ffi.Pointer cJSON_Duplicate(ffi.Pointer item, int recurse) { - return _cJSON_Duplicate(item, recurse); + ffi.Pointer cJSON_GetStringValue(ffi.Pointer item) { + return _cJSON_GetStringValue(item); } - late final _cJSON_DuplicatePtr = + late final _cJSON_GetStringValuePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, cJSON_bool) - > - >('cJSON_Duplicate'); - late final _cJSON_Duplicate = _cJSON_DuplicatePtr - .asFunction Function(ffi.Pointer, int)>(); + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_GetStringValue'); + late final _cJSON_GetStringValue = _cJSON_GetStringValuePtr + .asFunction Function(ffi.Pointer)>(); - int cJSON_Compare( - ffi.Pointer a, - ffi.Pointer b, - int case_sensitive, + int cJSON_HasObjectItem( + ffi.Pointer object, + ffi.Pointer string, ) { - return _cJSON_Compare(a, b, case_sensitive); + return _cJSON_HasObjectItem(object, string); } - late final _cJSON_ComparePtr = + late final _cJSON_HasObjectItemPtr = _lookup< ffi.NativeFunction< - cJSON_bool Function( - ffi.Pointer, - ffi.Pointer, - cJSON_bool, - ) + cJSON_bool Function(ffi.Pointer, ffi.Pointer) > - >('cJSON_Compare'); - late final _cJSON_Compare = _cJSON_ComparePtr - .asFunction, ffi.Pointer, int)>(); + >('cJSON_HasObjectItem'); + late final _cJSON_HasObjectItem = _cJSON_HasObjectItemPtr + .asFunction, ffi.Pointer)>(); - void cJSON_Minify(ffi.Pointer json) { - return _cJSON_Minify(json); + void cJSON_InitHooks(ffi.Pointer hooks) { + return _cJSON_InitHooks(hooks); } - late final _cJSON_MinifyPtr = - _lookup)>>( - 'cJSON_Minify', + late final _cJSON_InitHooksPtr = + _lookup)>>( + 'cJSON_InitHooks', ); - late final _cJSON_Minify = _cJSON_MinifyPtr - .asFunction)>(); + late final _cJSON_InitHooks = _cJSON_InitHooksPtr + .asFunction)>(); - ffi.Pointer cJSON_AddNullToObject( - ffi.Pointer object, - ffi.Pointer name, + void cJSON_InsertItemInArray( + ffi.Pointer array, + int which, + ffi.Pointer newitem, ) { - return _cJSON_AddNullToObject(object, name); + return _cJSON_InsertItemInArray(array, which, newitem); } - late final _cJSON_AddNullToObjectPtr = + late final _cJSON_InsertItemInArrayPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) > - >('cJSON_AddNullToObject'); - late final _cJSON_AddNullToObject = _cJSON_AddNullToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_InsertItemInArray'); + late final _cJSON_InsertItemInArray = _cJSON_InsertItemInArrayPtr + .asFunction, int, ffi.Pointer)>(); - ffi.Pointer cJSON_AddTrueToObject( - ffi.Pointer object, - ffi.Pointer name, - ) { - return _cJSON_AddTrueToObject(object, name); + int cJSON_IsArray(ffi.Pointer item) { + return _cJSON_IsArray(item); } - late final _cJSON_AddTrueToObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddTrueToObject'); - late final _cJSON_AddTrueToObject = _cJSON_AddTrueToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + late final _cJSON_IsArrayPtr = + _lookup)>>( + 'cJSON_IsArray', + ); + late final _cJSON_IsArray = _cJSON_IsArrayPtr + .asFunction)>(); - ffi.Pointer cJSON_AddFalseToObject( - ffi.Pointer object, - ffi.Pointer name, - ) { - return _cJSON_AddFalseToObject(object, name); + int cJSON_IsBool(ffi.Pointer item) { + return _cJSON_IsBool(item); } - late final _cJSON_AddFalseToObjectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - > - >('cJSON_AddFalseToObject'); - late final _cJSON_AddFalseToObject = _cJSON_AddFalseToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + late final _cJSON_IsBoolPtr = + _lookup)>>( + 'cJSON_IsBool', + ); + late final _cJSON_IsBool = _cJSON_IsBoolPtr + .asFunction)>(); - ffi.Pointer cJSON_AddBoolToObject( - ffi.Pointer object, - ffi.Pointer name, - int boolean, + int cJSON_IsFalse(ffi.Pointer item) { + return _cJSON_IsFalse(item); + } + + late final _cJSON_IsFalsePtr = + _lookup)>>( + 'cJSON_IsFalse', + ); + late final _cJSON_IsFalse = _cJSON_IsFalsePtr + .asFunction)>(); + + int cJSON_IsInvalid(ffi.Pointer item) { + return _cJSON_IsInvalid(item); + } + + late final _cJSON_IsInvalidPtr = + _lookup)>>( + 'cJSON_IsInvalid', + ); + late final _cJSON_IsInvalid = _cJSON_IsInvalidPtr + .asFunction)>(); + + int cJSON_IsNull(ffi.Pointer item) { + return _cJSON_IsNull(item); + } + + late final _cJSON_IsNullPtr = + _lookup)>>( + 'cJSON_IsNull', + ); + late final _cJSON_IsNull = _cJSON_IsNullPtr + .asFunction)>(); + + int cJSON_IsNumber(ffi.Pointer item) { + return _cJSON_IsNumber(item); + } + + late final _cJSON_IsNumberPtr = + _lookup)>>( + 'cJSON_IsNumber', + ); + late final _cJSON_IsNumber = _cJSON_IsNumberPtr + .asFunction)>(); + + int cJSON_IsObject(ffi.Pointer item) { + return _cJSON_IsObject(item); + } + + late final _cJSON_IsObjectPtr = + _lookup)>>( + 'cJSON_IsObject', + ); + late final _cJSON_IsObject = _cJSON_IsObjectPtr + .asFunction)>(); + + int cJSON_IsRaw(ffi.Pointer item) { + return _cJSON_IsRaw(item); + } + + late final _cJSON_IsRawPtr = + _lookup)>>( + 'cJSON_IsRaw', + ); + late final _cJSON_IsRaw = _cJSON_IsRawPtr + .asFunction)>(); + + int cJSON_IsString(ffi.Pointer item) { + return _cJSON_IsString(item); + } + + late final _cJSON_IsStringPtr = + _lookup)>>( + 'cJSON_IsString', + ); + late final _cJSON_IsString = _cJSON_IsStringPtr + .asFunction)>(); + + int cJSON_IsTrue(ffi.Pointer item) { + return _cJSON_IsTrue(item); + } + + late final _cJSON_IsTruePtr = + _lookup)>>( + 'cJSON_IsTrue', + ); + late final _cJSON_IsTrue = _cJSON_IsTruePtr + .asFunction)>(); + + void cJSON_Minify(ffi.Pointer json) { + return _cJSON_Minify(json); + } + + late final _cJSON_MinifyPtr = + _lookup)>>( + 'cJSON_Minify', + ); + late final _cJSON_Minify = _cJSON_MinifyPtr + .asFunction)>(); + + ffi.Pointer cJSON_Parse(ffi.Pointer value) { + return _cJSON_Parse(value); + } + + late final _cJSON_ParsePtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_Parse'); + late final _cJSON_Parse = _cJSON_ParsePtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer cJSON_ParseWithOpts( + ffi.Pointer value, + ffi.Pointer> return_parse_end, + int require_null_terminated, ) { - return _cJSON_AddBoolToObject(object, name, boolean); + return _cJSON_ParseWithOpts( + value, + return_parse_end, + require_null_terminated, + ); } - late final _cJSON_AddBoolToObjectPtr = + late final _cJSON_ParseWithOptsPtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( - ffi.Pointer, ffi.Pointer, + ffi.Pointer>, cJSON_bool, ) > - >('cJSON_AddBoolToObject'); - late final _cJSON_AddBoolToObject = _cJSON_AddBoolToObjectPtr + >('cJSON_ParseWithOpts'); + late final _cJSON_ParseWithOpts = _cJSON_ParseWithOptsPtr .asFunction< ffi.Pointer Function( - ffi.Pointer, ffi.Pointer, + ffi.Pointer>, int, ) >(); - ffi.Pointer cJSON_AddNumberToObject( - ffi.Pointer object, - ffi.Pointer name, - double number, + ffi.Pointer cJSON_Print(ffi.Pointer item) { + return _cJSON_Print(item); + } + + late final _cJSON_PrintPtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_Print'); + late final _cJSON_Print = _cJSON_PrintPtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer cJSON_PrintBuffered( + ffi.Pointer item, + int prebuffer, + int fmt, ) { - return _cJSON_AddNumberToObject(object, name, number); + return _cJSON_PrintBuffered(item, prebuffer, fmt); } - late final _cJSON_AddNumberToObjectPtr = + late final _cJSON_PrintBufferedPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, - ffi.Pointer, - ffi.Double, + ffi.Int, + cJSON_bool, ) > - >('cJSON_AddNumberToObject'); - late final _cJSON_AddNumberToObject = _cJSON_AddNumberToObjectPtr + >('cJSON_PrintBuffered'); + late final _cJSON_PrintBuffered = _cJSON_PrintBufferedPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - double, - ) + ffi.Pointer Function(ffi.Pointer, int, int) >(); - ffi.Pointer cJSON_AddStringToObject( - ffi.Pointer object, - ffi.Pointer name, - ffi.Pointer string, + int cJSON_PrintPreallocated( + ffi.Pointer item, + ffi.Pointer buffer, + int length, + int format, ) { - return _cJSON_AddStringToObject(object, name, string); + return _cJSON_PrintPreallocated(item, buffer, length, format); } - late final _cJSON_AddStringToObjectPtr = + late final _cJSON_PrintPreallocatedPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + cJSON_bool Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Int, + cJSON_bool, ) > - >('cJSON_AddStringToObject'); - late final _cJSON_AddStringToObject = _cJSON_AddStringToObjectPtr + >('cJSON_PrintPreallocated'); + late final _cJSON_PrintPreallocated = _cJSON_PrintPreallocatedPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer, int, int) >(); - ffi.Pointer cJSON_AddRawToObject( + ffi.Pointer cJSON_PrintUnformatted(ffi.Pointer item) { + return _cJSON_PrintUnformatted(item); + } + + late final _cJSON_PrintUnformattedPtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('cJSON_PrintUnformatted'); + late final _cJSON_PrintUnformatted = _cJSON_PrintUnformattedPtr + .asFunction Function(ffi.Pointer)>(); + + void cJSON_ReplaceItemInArray( + ffi.Pointer array, + int which, + ffi.Pointer newitem, + ) { + return _cJSON_ReplaceItemInArray(array, which, newitem); + } + + late final _cJSON_ReplaceItemInArrayPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Pointer) + > + >('cJSON_ReplaceItemInArray'); + late final _cJSON_ReplaceItemInArray = _cJSON_ReplaceItemInArrayPtr + .asFunction, int, ffi.Pointer)>(); + + void cJSON_ReplaceItemInObject( ffi.Pointer object, - ffi.Pointer name, - ffi.Pointer raw, + ffi.Pointer string, + ffi.Pointer newitem, ) { - return _cJSON_AddRawToObject(object, name, raw); + return _cJSON_ReplaceItemInObject(object, string, newitem); } - late final _cJSON_AddRawToObjectPtr = + late final _cJSON_ReplaceItemInObjectPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Pointer, ) > - >('cJSON_AddRawToObject'); - late final _cJSON_AddRawToObject = _cJSON_AddRawToObjectPtr + >('cJSON_ReplaceItemInObject'); + late final _cJSON_ReplaceItemInObject = _cJSON_ReplaceItemInObjectPtr .asFunction< - ffi.Pointer Function( + void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.Pointer, ) >(); - ffi.Pointer cJSON_AddObjectToObject( + void cJSON_ReplaceItemInObjectCaseSensitive( ffi.Pointer object, - ffi.Pointer name, + ffi.Pointer string, + ffi.Pointer newitem, ) { - return _cJSON_AddObjectToObject(object, name); + return _cJSON_ReplaceItemInObjectCaseSensitive(object, string, newitem); } - late final _cJSON_AddObjectToObjectPtr = + late final _cJSON_ReplaceItemInObjectCaseSensitivePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_AddObjectToObject'); - late final _cJSON_AddObjectToObject = _cJSON_AddObjectToObjectPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) - >(); + >('cJSON_ReplaceItemInObjectCaseSensitive'); + late final _cJSON_ReplaceItemInObjectCaseSensitive = + _cJSON_ReplaceItemInObjectCaseSensitivePtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - ffi.Pointer cJSON_AddArrayToObject( - ffi.Pointer object, - ffi.Pointer name, + int cJSON_ReplaceItemViaPointer( + ffi.Pointer parent, + ffi.Pointer item, + ffi.Pointer replacement, ) { - return _cJSON_AddArrayToObject(object, name); + return _cJSON_ReplaceItemViaPointer(parent, item, replacement); } - late final _cJSON_AddArrayToObjectPtr = + late final _cJSON_ReplaceItemViaPointerPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + cJSON_bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('cJSON_AddArrayToObject'); - late final _cJSON_AddArrayToObject = _cJSON_AddArrayToObjectPtr + >('cJSON_ReplaceItemViaPointer'); + late final _cJSON_ReplaceItemViaPointer = _cJSON_ReplaceItemViaPointerPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Pointer) + int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer) >(); double cJSON_SetNumberHelper(ffi.Pointer object, double number) { @@ -1173,16 +1162,16 @@ class CJson { late final _cJSON_SetNumberHelper = _cJSON_SetNumberHelperPtr .asFunction, double)>(); - ffi.Pointer cJSON_malloc(int size) { - return _cJSON_malloc(size); + ffi.Pointer cJSON_Version() { + return _cJSON_Version(); } - late final _cJSON_mallocPtr = - _lookup Function(ffi.Size)>>( - 'cJSON_malloc', + late final _cJSON_VersionPtr = + _lookup Function()>>( + 'cJSON_Version', ); - late final _cJSON_malloc = _cJSON_mallocPtr - .asFunction Function(int)>(); + late final _cJSON_Version = _cJSON_VersionPtr + .asFunction Function()>(); void cJSON_free(ffi.Pointer object) { return _cJSON_free(object); @@ -1194,8 +1183,29 @@ class CJson { ); late final _cJSON_free = _cJSON_freePtr .asFunction)>(); + + ffi.Pointer cJSON_malloc(int size) { + return _cJSON_malloc(size); + } + + late final _cJSON_mallocPtr = + _lookup Function(ffi.Size)>>( + 'cJSON_malloc', + ); + late final _cJSON_malloc = _cJSON_mallocPtr + .asFunction Function(int)>(); } +const double CJSON_DOUBLE_PRECISION = 1e-16; + +const int CJSON_NESTING_LIMIT = 1000; + +const int CJSON_VERSION_MAJOR = 1; + +const int CJSON_VERSION_MINOR = 7; + +const int CJSON_VERSION_PATCH = 12; + final class cJSON extends ffi.Struct { external ffi.Pointer next; @@ -1215,8 +1225,32 @@ final class cJSON extends ffi.Struct { external double valuedouble; external ffi.Pointer string; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer next, + required ffi.Pointer prev, + required ffi.Pointer child, + required int type, + required ffi.Pointer valuestring, + required int valueint, + required double valuedouble, + required ffi.Pointer string, + }) => $allocator() + ..ref.next = next + ..ref.prev = prev + ..ref.child = child + ..ref.type = type + ..ref.valuestring = valuestring + ..ref.valueint = valueint + ..ref.valuedouble = valuedouble + ..ref.string = string; } +const int cJSON_Array = 32; + +const int cJSON_False = 1; + final class cJSON_Hooks extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction Function(ffi.Size sz)> @@ -1227,39 +1261,39 @@ final class cJSON_Hooks extends ffi.Struct { ffi.NativeFunction ptr)> > free_fn; -} -typedef cJSON_bool = ffi.Int; -typedef DartcJSON_bool = int; - -const int CJSON_VERSION_MAJOR = 1; - -const int CJSON_VERSION_MINOR = 7; - -const int CJSON_VERSION_PATCH = 12; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction Function(ffi.Size sz)> + > + malloc_fn, + required ffi.Pointer< + ffi.NativeFunction ptr)> + > + free_fn, + }) => $allocator() + ..ref.malloc_fn = malloc_fn + ..ref.free_fn = free_fn; +} const int cJSON_Invalid = 0; -const int cJSON_False = 1; - -const int cJSON_True = 2; +const int cJSON_IsReference = 256; const int cJSON_NULL = 4; const int cJSON_Number = 8; -const int cJSON_String = 16; - -const int cJSON_Array = 32; - const int cJSON_Object = 64; const int cJSON_Raw = 128; -const int cJSON_IsReference = 256; +const int cJSON_String = 16; const int cJSON_StringIsConst = 512; -const int CJSON_NESTING_LIMIT = 1000; +const int cJSON_True = 2; -const double CJSON_DOUBLE_PRECISION = 1e-16; +typedef cJSON_bool = ffi.Int; +typedef DartcJSON_bool = int; diff --git a/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart b/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart index 1573c903db..663943025f 100644 --- a/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart +++ b/pkgs/ffigen/test/large_integration_tests/_expected_libclang_bindings.dart @@ -18,1639 +18,1214 @@ class LibClang { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - /// Retrieve the character data associated with the given string. - ffi.Pointer clang_getCString(CXString string) { - return _clang_getCString(string); + /// Queries a CXCursorSet to see if it contains a specific CXCursor. + int clang_CXCursorSet_contains(CXCursorSet cset, CXCursor cursor) { + return _clang_CXCursorSet_contains(cset, cursor); } - late final _clang_getCStringPtr = - _lookup Function(CXString)>>( - 'clang_getCString', - ); - late final _clang_getCString = _clang_getCStringPtr - .asFunction Function(CXString)>(); + late final _clang_CXCursorSet_containsPtr = + _lookup< + ffi.NativeFunction + >('clang_CXCursorSet_contains'); + late final _clang_CXCursorSet_contains = _clang_CXCursorSet_containsPtr + .asFunction(); - /// Free the given string. - void clang_disposeString(CXString string) { - return _clang_disposeString(string); + /// Inserts a CXCursor into a CXCursorSet. + int clang_CXCursorSet_insert(CXCursorSet cset, CXCursor cursor) { + return _clang_CXCursorSet_insert(cset, cursor); } - late final _clang_disposeStringPtr = - _lookup>( - 'clang_disposeString', - ); - late final _clang_disposeString = _clang_disposeStringPtr - .asFunction(); + late final _clang_CXCursorSet_insertPtr = + _lookup< + ffi.NativeFunction + >('clang_CXCursorSet_insert'); + late final _clang_CXCursorSet_insert = _clang_CXCursorSet_insertPtr + .asFunction(); - /// Free the given string set. - void clang_disposeStringSet(ffi.Pointer set) { - return _clang_disposeStringSet(set); + /// Gets the general options associated with a CXIndex. + int clang_CXIndex_getGlobalOptions(CXIndex arg0) { + return _clang_CXIndex_getGlobalOptions(arg0); } - late final _clang_disposeStringSetPtr = - _lookup)>>( - 'clang_disposeStringSet', + late final _clang_CXIndex_getGlobalOptionsPtr = + _lookup>( + 'clang_CXIndex_getGlobalOptions', ); - late final _clang_disposeStringSet = _clang_disposeStringSetPtr - .asFunction)>(); + late final _clang_CXIndex_getGlobalOptions = + _clang_CXIndex_getGlobalOptionsPtr.asFunction(); - /// Return the timestamp for use with Clang's -fbuild-session-timestamp= - /// option. - int clang_getBuildSessionTimestamp() { - return _clang_getBuildSessionTimestamp(); + /// Sets general options associated with a CXIndex. + void clang_CXIndex_setGlobalOptions(CXIndex arg0, int options) { + return _clang_CXIndex_setGlobalOptions(arg0, options); } - late final _clang_getBuildSessionTimestampPtr = - _lookup>( - 'clang_getBuildSessionTimestamp', + late final _clang_CXIndex_setGlobalOptionsPtr = + _lookup>( + 'clang_CXIndex_setGlobalOptions', ); - late final _clang_getBuildSessionTimestamp = - _clang_getBuildSessionTimestampPtr.asFunction(); + late final _clang_CXIndex_setGlobalOptions = + _clang_CXIndex_setGlobalOptionsPtr + .asFunction(); - /// Create a CXVirtualFileOverlay object. Must be disposed with - /// clang_VirtualFileOverlay_dispose(). - CXVirtualFileOverlay clang_VirtualFileOverlay_create(int options) { - return _clang_VirtualFileOverlay_create(options); + /// Sets the invocation emission path option in a CXIndex. + void clang_CXIndex_setInvocationEmissionPathOption( + CXIndex arg0, + ffi.Pointer Path, + ) { + return _clang_CXIndex_setInvocationEmissionPathOption(arg0, Path); } - late final _clang_VirtualFileOverlay_createPtr = + late final _clang_CXIndex_setInvocationEmissionPathOptionPtr = _lookup< - ffi.NativeFunction - >('clang_VirtualFileOverlay_create'); - late final _clang_VirtualFileOverlay_create = - _clang_VirtualFileOverlay_createPtr - .asFunction(); + ffi.NativeFunction)> + >('clang_CXIndex_setInvocationEmissionPathOption'); + late final _clang_CXIndex_setInvocationEmissionPathOption = + _clang_CXIndex_setInvocationEmissionPathOptionPtr + .asFunction)>(); - /// Map an absolute virtual file path to an absolute real one. The virtual - /// path must be canonicalized (not contain "."/".."). - CXErrorCode clang_VirtualFileOverlay_addFileMapping( - CXVirtualFileOverlay arg0, - ffi.Pointer virtualPath, - ffi.Pointer realPath, - ) { - return CXErrorCode.fromValue( - _clang_VirtualFileOverlay_addFileMapping(arg0, virtualPath, realPath), - ); + /// Determine if a C++ constructor is a converting constructor. + int clang_CXXConstructor_isConvertingConstructor(CXCursor C) { + return _clang_CXXConstructor_isConvertingConstructor(C); } - late final _clang_VirtualFileOverlay_addFileMappingPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - CXVirtualFileOverlay, - ffi.Pointer, - ffi.Pointer, - ) - > - >('clang_VirtualFileOverlay_addFileMapping'); - late final _clang_VirtualFileOverlay_addFileMapping = - _clang_VirtualFileOverlay_addFileMappingPtr - .asFunction< - int Function( - CXVirtualFileOverlay, - ffi.Pointer, - ffi.Pointer, - ) - >(); + late final _clang_CXXConstructor_isConvertingConstructorPtr = + _lookup>( + 'clang_CXXConstructor_isConvertingConstructor', + ); + late final _clang_CXXConstructor_isConvertingConstructor = + _clang_CXXConstructor_isConvertingConstructorPtr + .asFunction(); - /// Set the case sensitivity for the CXVirtualFileOverlay object. The - /// CXVirtualFileOverlay object is case-sensitive by default, this option can - /// be used to override the default. - CXErrorCode clang_VirtualFileOverlay_setCaseSensitivity( - CXVirtualFileOverlay arg0, - int caseSensitive, - ) { - return CXErrorCode.fromValue( - _clang_VirtualFileOverlay_setCaseSensitivity(arg0, caseSensitive), - ); + /// Determine if a C++ constructor is a copy constructor. + int clang_CXXConstructor_isCopyConstructor(CXCursor C) { + return _clang_CXXConstructor_isCopyConstructor(C); } - late final _clang_VirtualFileOverlay_setCaseSensitivityPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXVirtualFileOverlay, ffi.Int) - > - >('clang_VirtualFileOverlay_setCaseSensitivity'); - late final _clang_VirtualFileOverlay_setCaseSensitivity = - _clang_VirtualFileOverlay_setCaseSensitivityPtr - .asFunction(); + late final _clang_CXXConstructor_isCopyConstructorPtr = + _lookup>( + 'clang_CXXConstructor_isCopyConstructor', + ); + late final _clang_CXXConstructor_isCopyConstructor = + _clang_CXXConstructor_isCopyConstructorPtr + .asFunction(); - /// Write out the CXVirtualFileOverlay object to a char buffer. - CXErrorCode clang_VirtualFileOverlay_writeToBuffer( - CXVirtualFileOverlay arg0, - int options, - ffi.Pointer> out_buffer_ptr, - ffi.Pointer out_buffer_size, - ) { - return CXErrorCode.fromValue( - _clang_VirtualFileOverlay_writeToBuffer( - arg0, - options, - out_buffer_ptr, - out_buffer_size, - ), - ); + /// Determine if a C++ constructor is the default constructor. + int clang_CXXConstructor_isDefaultConstructor(CXCursor C) { + return _clang_CXXConstructor_isDefaultConstructor(C); } - late final _clang_VirtualFileOverlay_writeToBufferPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - CXVirtualFileOverlay, - ffi.UnsignedInt, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('clang_VirtualFileOverlay_writeToBuffer'); - late final _clang_VirtualFileOverlay_writeToBuffer = - _clang_VirtualFileOverlay_writeToBufferPtr - .asFunction< - int Function( - CXVirtualFileOverlay, - int, - ffi.Pointer>, - ffi.Pointer, - ) - >(); + late final _clang_CXXConstructor_isDefaultConstructorPtr = + _lookup>( + 'clang_CXXConstructor_isDefaultConstructor', + ); + late final _clang_CXXConstructor_isDefaultConstructor = + _clang_CXXConstructor_isDefaultConstructorPtr + .asFunction(); - /// free memory allocated by libclang, such as the buffer returned by - /// CXVirtualFileOverlay() or clang_ModuleMapDescriptor_writeToBuffer(). - void clang_free(ffi.Pointer buffer) { - return _clang_free(buffer); + /// Determine if a C++ constructor is a move constructor. + int clang_CXXConstructor_isMoveConstructor(CXCursor C) { + return _clang_CXXConstructor_isMoveConstructor(C); } - late final _clang_freePtr = - _lookup)>>( - 'clang_free', + late final _clang_CXXConstructor_isMoveConstructorPtr = + _lookup>( + 'clang_CXXConstructor_isMoveConstructor', ); - late final _clang_free = _clang_freePtr - .asFunction)>(); + late final _clang_CXXConstructor_isMoveConstructor = + _clang_CXXConstructor_isMoveConstructorPtr + .asFunction(); - /// Dispose a CXVirtualFileOverlay object. - void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay arg0) { - return _clang_VirtualFileOverlay_dispose(arg0); + /// Determine if a C++ field is declared 'mutable'. + int clang_CXXField_isMutable(CXCursor C) { + return _clang_CXXField_isMutable(C); } - late final _clang_VirtualFileOverlay_disposePtr = - _lookup>( - 'clang_VirtualFileOverlay_dispose', + late final _clang_CXXField_isMutablePtr = + _lookup>( + 'clang_CXXField_isMutable', ); - late final _clang_VirtualFileOverlay_dispose = - _clang_VirtualFileOverlay_disposePtr - .asFunction(); + late final _clang_CXXField_isMutable = _clang_CXXField_isMutablePtr + .asFunction(); - /// Create a CXModuleMapDescriptor object. Must be disposed with - /// clang_ModuleMapDescriptor_dispose(). - CXModuleMapDescriptor clang_ModuleMapDescriptor_create(int options) { - return _clang_ModuleMapDescriptor_create(options); + /// Determine if a C++ member function or member function template is declared + /// 'const'. + int clang_CXXMethod_isConst(CXCursor C) { + return _clang_CXXMethod_isConst(C); } - late final _clang_ModuleMapDescriptor_createPtr = - _lookup< - ffi.NativeFunction - >('clang_ModuleMapDescriptor_create'); - late final _clang_ModuleMapDescriptor_create = - _clang_ModuleMapDescriptor_createPtr - .asFunction(); + late final _clang_CXXMethod_isConstPtr = + _lookup>( + 'clang_CXXMethod_isConst', + ); + late final _clang_CXXMethod_isConst = _clang_CXXMethod_isConstPtr + .asFunction(); - /// Sets the framework module name that the module.map describes. - CXErrorCode clang_ModuleMapDescriptor_setFrameworkModuleName( - CXModuleMapDescriptor arg0, - ffi.Pointer name, - ) { - return CXErrorCode.fromValue( - _clang_ModuleMapDescriptor_setFrameworkModuleName(arg0, name), - ); + /// Determine if a C++ method is declared '= default'. + int clang_CXXMethod_isDefaulted(CXCursor C) { + return _clang_CXXMethod_isDefaulted(C); } - late final _clang_ModuleMapDescriptor_setFrameworkModuleNamePtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXModuleMapDescriptor, ffi.Pointer) - > - >('clang_ModuleMapDescriptor_setFrameworkModuleName'); - late final _clang_ModuleMapDescriptor_setFrameworkModuleName = - _clang_ModuleMapDescriptor_setFrameworkModuleNamePtr - .asFunction< - int Function(CXModuleMapDescriptor, ffi.Pointer) - >(); + late final _clang_CXXMethod_isDefaultedPtr = + _lookup>( + 'clang_CXXMethod_isDefaulted', + ); + late final _clang_CXXMethod_isDefaulted = _clang_CXXMethod_isDefaultedPtr + .asFunction(); - /// Sets the umbrealla header name that the module.map describes. - CXErrorCode clang_ModuleMapDescriptor_setUmbrellaHeader( - CXModuleMapDescriptor arg0, - ffi.Pointer name, - ) { - return CXErrorCode.fromValue( - _clang_ModuleMapDescriptor_setUmbrellaHeader(arg0, name), - ); + /// Determine if a C++ member function or member function template is pure + /// virtual. + int clang_CXXMethod_isPureVirtual(CXCursor C) { + return _clang_CXXMethod_isPureVirtual(C); } - late final _clang_ModuleMapDescriptor_setUmbrellaHeaderPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXModuleMapDescriptor, ffi.Pointer) - > - >('clang_ModuleMapDescriptor_setUmbrellaHeader'); - late final _clang_ModuleMapDescriptor_setUmbrellaHeader = - _clang_ModuleMapDescriptor_setUmbrellaHeaderPtr - .asFunction< - int Function(CXModuleMapDescriptor, ffi.Pointer) - >(); + late final _clang_CXXMethod_isPureVirtualPtr = + _lookup>( + 'clang_CXXMethod_isPureVirtual', + ); + late final _clang_CXXMethod_isPureVirtual = _clang_CXXMethod_isPureVirtualPtr + .asFunction(); - /// Write out the CXModuleMapDescriptor object to a char buffer. - CXErrorCode clang_ModuleMapDescriptor_writeToBuffer( - CXModuleMapDescriptor arg0, - int options, - ffi.Pointer> out_buffer_ptr, - ffi.Pointer out_buffer_size, - ) { - return CXErrorCode.fromValue( - _clang_ModuleMapDescriptor_writeToBuffer( - arg0, - options, - out_buffer_ptr, - out_buffer_size, - ), - ); + /// Determine if a C++ member function or member function template is declared + /// 'static'. + int clang_CXXMethod_isStatic(CXCursor C) { + return _clang_CXXMethod_isStatic(C); } - late final _clang_ModuleMapDescriptor_writeToBufferPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - CXModuleMapDescriptor, - ffi.UnsignedInt, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('clang_ModuleMapDescriptor_writeToBuffer'); - late final _clang_ModuleMapDescriptor_writeToBuffer = - _clang_ModuleMapDescriptor_writeToBufferPtr - .asFunction< - int Function( - CXModuleMapDescriptor, - int, - ffi.Pointer>, - ffi.Pointer, - ) - >(); + late final _clang_CXXMethod_isStaticPtr = + _lookup>( + 'clang_CXXMethod_isStatic', + ); + late final _clang_CXXMethod_isStatic = _clang_CXXMethod_isStaticPtr + .asFunction(); - /// Dispose a CXModuleMapDescriptor object. - void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor arg0) { - return _clang_ModuleMapDescriptor_dispose(arg0); + /// Determine if a C++ member function or member function template is + /// explicitly declared 'virtual' or if it overrides a virtual method from one + /// of the base classes. + int clang_CXXMethod_isVirtual(CXCursor C) { + return _clang_CXXMethod_isVirtual(C); } - late final _clang_ModuleMapDescriptor_disposePtr = - _lookup>( - 'clang_ModuleMapDescriptor_dispose', + late final _clang_CXXMethod_isVirtualPtr = + _lookup>( + 'clang_CXXMethod_isVirtual', ); - late final _clang_ModuleMapDescriptor_dispose = - _clang_ModuleMapDescriptor_disposePtr - .asFunction(); + late final _clang_CXXMethod_isVirtual = _clang_CXXMethod_isVirtualPtr + .asFunction(); - /// Provides a shared context for creating translation units. - CXIndex clang_createIndex( - int excludeDeclarationsFromPCH, - int displayDiagnostics, - ) { - return _clang_createIndex(excludeDeclarationsFromPCH, displayDiagnostics); + /// Determine if a C++ record is abstract, i.e. whether a class or struct has + /// a pure virtual member function. + int clang_CXXRecord_isAbstract(CXCursor C) { + return _clang_CXXRecord_isAbstract(C); } - late final _clang_createIndexPtr = - _lookup>( - 'clang_createIndex', + late final _clang_CXXRecord_isAbstractPtr = + _lookup>( + 'clang_CXXRecord_isAbstract', ); - late final _clang_createIndex = _clang_createIndexPtr - .asFunction(); + late final _clang_CXXRecord_isAbstract = _clang_CXXRecord_isAbstractPtr + .asFunction(); - /// Destroy the given index. - void clang_disposeIndex(CXIndex index) { - return _clang_disposeIndex(index); + /// If cursor is a statement declaration tries to evaluate the statement and + /// if its variable, tries to evaluate its initializer, into its corresponding + /// type. + CXEvalResult clang_Cursor_Evaluate(CXCursor C) { + return _clang_Cursor_Evaluate(C); } - late final _clang_disposeIndexPtr = - _lookup>( - 'clang_disposeIndex', + late final _clang_Cursor_EvaluatePtr = + _lookup>( + 'clang_Cursor_Evaluate', ); - late final _clang_disposeIndex = _clang_disposeIndexPtr - .asFunction(); + late final _clang_Cursor_Evaluate = _clang_Cursor_EvaluatePtr + .asFunction(); - /// Sets general options associated with a CXIndex. - void clang_CXIndex_setGlobalOptions(CXIndex arg0, int options) { - return _clang_CXIndex_setGlobalOptions(arg0, options); + /// Retrieve the argument cursor of a function or method. + CXCursor clang_Cursor_getArgument(CXCursor C, int i) { + return _clang_Cursor_getArgument(C, i); } - late final _clang_CXIndex_setGlobalOptionsPtr = - _lookup>( - 'clang_CXIndex_setGlobalOptions', + late final _clang_Cursor_getArgumentPtr = + _lookup>( + 'clang_Cursor_getArgument', ); - late final _clang_CXIndex_setGlobalOptions = - _clang_CXIndex_setGlobalOptionsPtr - .asFunction(); + late final _clang_Cursor_getArgument = _clang_Cursor_getArgumentPtr + .asFunction(); - /// Gets the general options associated with a CXIndex. - int clang_CXIndex_getGlobalOptions(CXIndex arg0) { - return _clang_CXIndex_getGlobalOptions(arg0); + /// Given a cursor that represents a documentable entity (e.g., declaration), + /// return the associated first paragraph. + CXString clang_Cursor_getBriefCommentText(CXCursor C) { + return _clang_Cursor_getBriefCommentText(C); } - late final _clang_CXIndex_getGlobalOptionsPtr = - _lookup>( - 'clang_CXIndex_getGlobalOptions', + late final _clang_Cursor_getBriefCommentTextPtr = + _lookup>( + 'clang_Cursor_getBriefCommentText', ); - late final _clang_CXIndex_getGlobalOptions = - _clang_CXIndex_getGlobalOptionsPtr.asFunction(); + late final _clang_Cursor_getBriefCommentText = + _clang_Cursor_getBriefCommentTextPtr + .asFunction(); - /// Sets the invocation emission path option in a CXIndex. - void clang_CXIndex_setInvocationEmissionPathOption( - CXIndex arg0, - ffi.Pointer Path, - ) { - return _clang_CXIndex_setInvocationEmissionPathOption(arg0, Path); + /// Retrieve the CXStrings representing the mangled symbols of the C++ + /// constructor or destructor at the cursor. + ffi.Pointer clang_Cursor_getCXXManglings(CXCursor arg0) { + return _clang_Cursor_getCXXManglings(arg0); } - late final _clang_CXIndex_setInvocationEmissionPathOptionPtr = - _lookup< - ffi.NativeFunction)> - >('clang_CXIndex_setInvocationEmissionPathOption'); - late final _clang_CXIndex_setInvocationEmissionPathOption = - _clang_CXIndex_setInvocationEmissionPathOptionPtr - .asFunction)>(); + late final _clang_Cursor_getCXXManglingsPtr = + _lookup Function(CXCursor)>>( + 'clang_Cursor_getCXXManglings', + ); + late final _clang_Cursor_getCXXManglings = _clang_Cursor_getCXXManglingsPtr + .asFunction Function(CXCursor)>(); - /// Retrieve the complete file and path name of the given file. - CXString clang_getFileName(CXFile SFile) { - return _clang_getFileName(SFile); + /// Given a cursor that represents a declaration, return the associated + /// comment's source range. The range may include multiple consecutive + /// comments with whitespace in between. + CXSourceRange clang_Cursor_getCommentRange(CXCursor C) { + return _clang_Cursor_getCommentRange(C); } - late final _clang_getFileNamePtr = - _lookup>( - 'clang_getFileName', + late final _clang_Cursor_getCommentRangePtr = + _lookup>( + 'clang_Cursor_getCommentRange', ); - late final _clang_getFileName = _clang_getFileNamePtr - .asFunction(); + late final _clang_Cursor_getCommentRange = _clang_Cursor_getCommentRangePtr + .asFunction(); - /// Retrieve the last modification time of the given file. - int clang_getFileTime(CXFile SFile) { - return _clang_getFileTime(SFile); + /// Retrieve the CXString representing the mangled name of the cursor. + CXString clang_Cursor_getMangling(CXCursor arg0) { + return _clang_Cursor_getMangling(arg0); } - late final _clang_getFileTimePtr = - _lookup>( - 'clang_getFileTime', + late final _clang_Cursor_getManglingPtr = + _lookup>( + 'clang_Cursor_getMangling', ); - late final _clang_getFileTime = _clang_getFileTimePtr - .asFunction(); - - /// Retrieve the unique ID for the given file. - int clang_getFileUniqueID(CXFile file, ffi.Pointer outID) { - return _clang_getFileUniqueID(file, outID); - } - - late final _clang_getFileUniqueIDPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(CXFile, ffi.Pointer) - > - >('clang_getFileUniqueID'); - late final _clang_getFileUniqueID = _clang_getFileUniqueIDPtr - .asFunction)>(); - - /// Determine whether the given header is guarded against multiple inclusions, - /// either with the conventional #ifndef/#define/#endif macro guards or with - /// #pragma once. - int clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file) { - return _clang_isFileMultipleIncludeGuarded(tu, file); - } - - late final _clang_isFileMultipleIncludeGuardedPtr = - _lookup< - ffi.NativeFunction - >('clang_isFileMultipleIncludeGuarded'); - late final _clang_isFileMultipleIncludeGuarded = - _clang_isFileMultipleIncludeGuardedPtr - .asFunction(); + late final _clang_Cursor_getMangling = _clang_Cursor_getManglingPtr + .asFunction(); - /// Retrieve a file handle within the given translation unit. - CXFile clang_getFile(CXTranslationUnit tu, ffi.Pointer file_name) { - return _clang_getFile(tu, file_name); + /// Given a CXCursor_ModuleImportDecl cursor, return the associated module. + CXModule clang_Cursor_getModule(CXCursor C) { + return _clang_Cursor_getModule(C); } - late final _clang_getFilePtr = - _lookup< - ffi.NativeFunction< - CXFile Function(CXTranslationUnit, ffi.Pointer) - > - >('clang_getFile'); - late final _clang_getFile = _clang_getFilePtr - .asFunction)>(); + late final _clang_Cursor_getModulePtr = + _lookup>( + 'clang_Cursor_getModule', + ); + late final _clang_Cursor_getModule = _clang_Cursor_getModulePtr + .asFunction(); - /// Retrieve the buffer associated with the given file. - ffi.Pointer clang_getFileContents( - CXTranslationUnit tu, - CXFile file, - ffi.Pointer size, - ) { - return _clang_getFileContents(tu, file, size); + /// Retrieve the number of non-variadic arguments associated with a given + /// cursor. + int clang_Cursor_getNumArguments(CXCursor C) { + return _clang_Cursor_getNumArguments(C); } - late final _clang_getFileContentsPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - CXTranslationUnit, - CXFile, - ffi.Pointer, - ) - > - >('clang_getFileContents'); - late final _clang_getFileContents = _clang_getFileContentsPtr - .asFunction< - ffi.Pointer Function( - CXTranslationUnit, - CXFile, - ffi.Pointer, - ) - >(); + late final _clang_Cursor_getNumArgumentsPtr = + _lookup>( + 'clang_Cursor_getNumArguments', + ); + late final _clang_Cursor_getNumArguments = _clang_Cursor_getNumArgumentsPtr + .asFunction(); - /// Returns non-zero if the file1 and file2 point to the same file, or they - /// are both NULL. - int clang_File_isEqual(CXFile file1, CXFile file2) { - return _clang_File_isEqual(file1, file2); + /// Returns the number of template args of a function decl representing a + /// template specialization. + int clang_Cursor_getNumTemplateArguments(CXCursor C) { + return _clang_Cursor_getNumTemplateArguments(C); } - late final _clang_File_isEqualPtr = - _lookup>( - 'clang_File_isEqual', + late final _clang_Cursor_getNumTemplateArgumentsPtr = + _lookup>( + 'clang_Cursor_getNumTemplateArguments', ); - late final _clang_File_isEqual = _clang_File_isEqualPtr - .asFunction(); + late final _clang_Cursor_getNumTemplateArguments = + _clang_Cursor_getNumTemplateArgumentsPtr + .asFunction(); - /// Returns the real path name of file. - CXString clang_File_tryGetRealPathName(CXFile file) { - return _clang_File_tryGetRealPathName(file); + /// Given a cursor that represents an Objective-C method or parameter + /// declaration, return the associated Objective-C qualifiers for the return + /// type or the parameter respectively. The bits are formed from + /// CXObjCDeclQualifierKind. + int clang_Cursor_getObjCDeclQualifiers(CXCursor C) { + return _clang_Cursor_getObjCDeclQualifiers(C); } - late final _clang_File_tryGetRealPathNamePtr = - _lookup>( - 'clang_File_tryGetRealPathName', + late final _clang_Cursor_getObjCDeclQualifiersPtr = + _lookup>( + 'clang_Cursor_getObjCDeclQualifiers', ); - late final _clang_File_tryGetRealPathName = _clang_File_tryGetRealPathNamePtr - .asFunction(); + late final _clang_Cursor_getObjCDeclQualifiers = + _clang_Cursor_getObjCDeclQualifiersPtr + .asFunction(); - /// Retrieve a NULL (invalid) source location. - CXSourceLocation clang_getNullLocation() { - return _clang_getNullLocation(); + /// Retrieve the CXStrings representing the mangled symbols of the ObjC class + /// interface or implementation at the cursor. + ffi.Pointer clang_Cursor_getObjCManglings(CXCursor arg0) { + return _clang_Cursor_getObjCManglings(arg0); } - late final _clang_getNullLocationPtr = - _lookup>( - 'clang_getNullLocation', + late final _clang_Cursor_getObjCManglingsPtr = + _lookup Function(CXCursor)>>( + 'clang_Cursor_getObjCManglings', ); - late final _clang_getNullLocation = _clang_getNullLocationPtr - .asFunction(); + late final _clang_Cursor_getObjCManglings = _clang_Cursor_getObjCManglingsPtr + .asFunction Function(CXCursor)>(); - /// Determine whether two source locations, which must refer into the same - /// translation unit, refer to exactly the same point in the source code. - int clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2) { - return _clang_equalLocations(loc1, loc2); + /// Given a cursor that represents a property declaration, return the + /// associated property attributes. The bits are formed from + /// CXObjCPropertyAttrKind. + int clang_Cursor_getObjCPropertyAttributes(CXCursor C, int reserved) { + return _clang_Cursor_getObjCPropertyAttributes(C, reserved); } - late final _clang_equalLocationsPtr = + late final _clang_Cursor_getObjCPropertyAttributesPtr = _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXSourceLocation, CXSourceLocation) - > - >('clang_equalLocations'); - late final _clang_equalLocations = _clang_equalLocationsPtr - .asFunction(); + ffi.NativeFunction + >('clang_Cursor_getObjCPropertyAttributes'); + late final _clang_Cursor_getObjCPropertyAttributes = + _clang_Cursor_getObjCPropertyAttributesPtr + .asFunction(); - /// Retrieves the source location associated with a given file/line/column in - /// a particular translation unit. - CXSourceLocation clang_getLocation( - CXTranslationUnit tu, - CXFile file, - int line, - int column, - ) { - return _clang_getLocation(tu, file, line, column); + /// Given a cursor that represents a property declaration, return the name of + /// the method that implements the getter. + CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C) { + return _clang_Cursor_getObjCPropertyGetterName(C); } - late final _clang_getLocationPtr = - _lookup< - ffi.NativeFunction< - CXSourceLocation Function( - CXTranslationUnit, - CXFile, - ffi.UnsignedInt, - ffi.UnsignedInt, - ) - > - >('clang_getLocation'); - late final _clang_getLocation = _clang_getLocationPtr - .asFunction< - CXSourceLocation Function(CXTranslationUnit, CXFile, int, int) - >(); + late final _clang_Cursor_getObjCPropertyGetterNamePtr = + _lookup>( + 'clang_Cursor_getObjCPropertyGetterName', + ); + late final _clang_Cursor_getObjCPropertyGetterName = + _clang_Cursor_getObjCPropertyGetterNamePtr + .asFunction(); - /// Retrieves the source location associated with a given character offset in - /// a particular translation unit. - CXSourceLocation clang_getLocationForOffset( - CXTranslationUnit tu, - CXFile file, - int offset, - ) { - return _clang_getLocationForOffset(tu, file, offset); + /// Given a cursor that represents a property declaration, return the name of + /// the method that implements the setter, if any. + CXString clang_Cursor_getObjCPropertySetterName(CXCursor C) { + return _clang_Cursor_getObjCPropertySetterName(C); } - late final _clang_getLocationForOffsetPtr = - _lookup< - ffi.NativeFunction< - CXSourceLocation Function(CXTranslationUnit, CXFile, ffi.UnsignedInt) - > - >('clang_getLocationForOffset'); - late final _clang_getLocationForOffset = _clang_getLocationForOffsetPtr - .asFunction(); + late final _clang_Cursor_getObjCPropertySetterNamePtr = + _lookup>( + 'clang_Cursor_getObjCPropertySetterName', + ); + late final _clang_Cursor_getObjCPropertySetterName = + _clang_Cursor_getObjCPropertySetterNamePtr + .asFunction(); - /// Returns non-zero if the given source location is in a system header. - int clang_Location_isInSystemHeader(CXSourceLocation location) { - return _clang_Location_isInSystemHeader(location); + /// If the cursor points to a selector identifier in an Objective-C method or + /// message expression, this returns the selector index. + int clang_Cursor_getObjCSelectorIndex(CXCursor arg0) { + return _clang_Cursor_getObjCSelectorIndex(arg0); } - late final _clang_Location_isInSystemHeaderPtr = - _lookup>( - 'clang_Location_isInSystemHeader', + late final _clang_Cursor_getObjCSelectorIndexPtr = + _lookup>( + 'clang_Cursor_getObjCSelectorIndex', ); - late final _clang_Location_isInSystemHeader = - _clang_Location_isInSystemHeaderPtr - .asFunction(); + late final _clang_Cursor_getObjCSelectorIndex = + _clang_Cursor_getObjCSelectorIndexPtr + .asFunction(); - /// Returns non-zero if the given source location is in the main file of the - /// corresponding translation unit. - int clang_Location_isFromMainFile(CXSourceLocation location) { - return _clang_Location_isFromMainFile(location); + /// Return the offset of the field represented by the Cursor. + int clang_Cursor_getOffsetOfField(CXCursor C) { + return _clang_Cursor_getOffsetOfField(C); } - late final _clang_Location_isFromMainFilePtr = - _lookup>( - 'clang_Location_isFromMainFile', - ); - late final _clang_Location_isFromMainFile = _clang_Location_isFromMainFilePtr - .asFunction(); + late final _clang_Cursor_getOffsetOfFieldPtr = + _lookup>( + 'clang_Cursor_getOffsetOfField', + ); + late final _clang_Cursor_getOffsetOfField = _clang_Cursor_getOffsetOfFieldPtr + .asFunction(); - /// Retrieve a NULL (invalid) source range. - CXSourceRange clang_getNullRange() { - return _clang_getNullRange(); + /// Given a cursor that represents a declaration, return the associated + /// comment text, including comment markers. + CXString clang_Cursor_getRawCommentText(CXCursor C) { + return _clang_Cursor_getRawCommentText(C); } - late final _clang_getNullRangePtr = - _lookup>( - 'clang_getNullRange', + late final _clang_Cursor_getRawCommentTextPtr = + _lookup>( + 'clang_Cursor_getRawCommentText', ); - late final _clang_getNullRange = _clang_getNullRangePtr - .asFunction(); + late final _clang_Cursor_getRawCommentText = + _clang_Cursor_getRawCommentTextPtr + .asFunction(); - /// Retrieve a source range given the beginning and ending source locations. - CXSourceRange clang_getRange(CXSourceLocation begin, CXSourceLocation end) { - return _clang_getRange(begin, end); + /// Given a cursor pointing to an Objective-C message or property reference, + /// or C++ method call, returns the CXType of the receiver. + CXType clang_Cursor_getReceiverType(CXCursor C) { + return _clang_Cursor_getReceiverType(C); } - late final _clang_getRangePtr = - _lookup< - ffi.NativeFunction< - CXSourceRange Function(CXSourceLocation, CXSourceLocation) - > - >('clang_getRange'); - late final _clang_getRange = _clang_getRangePtr - .asFunction(); + late final _clang_Cursor_getReceiverTypePtr = + _lookup>( + 'clang_Cursor_getReceiverType', + ); + late final _clang_Cursor_getReceiverType = _clang_Cursor_getReceiverTypePtr + .asFunction(); - /// Determine whether two ranges are equivalent. - int clang_equalRanges(CXSourceRange range1, CXSourceRange range2) { - return _clang_equalRanges(range1, range2); + /// Retrieve a range for a piece that forms the cursors spelling name. Most of + /// the times there is only one range for the complete spelling but for + /// Objective-C methods and Objective-C message expressions, there are + /// multiple pieces for each selector identifier. + CXSourceRange clang_Cursor_getSpellingNameRange( + CXCursor arg0, + int pieceIndex, + int options, + ) { + return _clang_Cursor_getSpellingNameRange(arg0, pieceIndex, options); } - late final _clang_equalRangesPtr = + late final _clang_Cursor_getSpellingNameRangePtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function(CXSourceRange, CXSourceRange) + CXSourceRange Function(CXCursor, ffi.UnsignedInt, ffi.UnsignedInt) > - >('clang_equalRanges'); - late final _clang_equalRanges = _clang_equalRangesPtr - .asFunction(); + >('clang_Cursor_getSpellingNameRange'); + late final _clang_Cursor_getSpellingNameRange = + _clang_Cursor_getSpellingNameRangePtr + .asFunction(); - /// Returns non-zero if range is null. - int clang_Range_isNull(CXSourceRange range) { - return _clang_Range_isNull(range); + /// Returns the storage class for a function or variable declaration. + CX_StorageClass clang_Cursor_getStorageClass(CXCursor arg0) { + return CX_StorageClass.fromValue(_clang_Cursor_getStorageClass(arg0)); } - late final _clang_Range_isNullPtr = - _lookup>( - 'clang_Range_isNull', + late final _clang_Cursor_getStorageClassPtr = + _lookup>( + 'clang_Cursor_getStorageClass', ); - late final _clang_Range_isNull = _clang_Range_isNullPtr - .asFunction(); + late final _clang_Cursor_getStorageClass = _clang_Cursor_getStorageClassPtr + .asFunction(); - /// Retrieve the file, line, column, and offset represented by the given - /// source location. - void clang_getExpansionLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, + /// Retrieve the kind of the I'th template argument of the CXCursor C. + CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( + CXCursor C, + int I, ) { - return _clang_getExpansionLocation(location, file, line, column, offset); + return CXTemplateArgumentKind.fromValue( + _clang_Cursor_getTemplateArgumentKind(C, I), + ); } - late final _clang_getExpansionLocationPtr = + late final _clang_Cursor_getTemplateArgumentKindPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('clang_getExpansionLocation'); - late final _clang_getExpansionLocation = _clang_getExpansionLocationPtr - .asFunction< - void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + ffi.NativeFunction + >('clang_Cursor_getTemplateArgumentKind'); + late final _clang_Cursor_getTemplateArgumentKind = + _clang_Cursor_getTemplateArgumentKindPtr + .asFunction(); - /// Retrieve the file, line and column represented by the given source - /// location, as specified in a # line directive. - void clang_getPresumedLocation( - CXSourceLocation location, - ffi.Pointer filename, - ffi.Pointer line, - ffi.Pointer column, - ) { - return _clang_getPresumedLocation(location, filename, line, column); + /// Retrieve a CXType representing the type of a TemplateArgument of a + /// function decl representing a template specialization. + CXType clang_Cursor_getTemplateArgumentType(CXCursor C, int I) { + return _clang_Cursor_getTemplateArgumentType(C, I); } - late final _clang_getPresumedLocationPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('clang_getPresumedLocation'); - late final _clang_getPresumedLocation = _clang_getPresumedLocationPtr - .asFunction< - void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + late final _clang_Cursor_getTemplateArgumentTypePtr = + _lookup>( + 'clang_Cursor_getTemplateArgumentType', + ); + late final _clang_Cursor_getTemplateArgumentType = + _clang_Cursor_getTemplateArgumentTypePtr + .asFunction(); - /// Legacy API to retrieve the file, line, column, and offset represented by - /// the given source location. - void clang_getInstantiationLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getInstantiationLocation( - location, - file, - line, - column, - offset, - ); + /// Retrieve the value of an Integral TemplateArgument (of a function decl + /// representing a template specialization) as an unsigned long long. + int clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, int I) { + return _clang_Cursor_getTemplateArgumentUnsignedValue(C, I); } - late final _clang_getInstantiationLocationPtr = + late final _clang_Cursor_getTemplateArgumentUnsignedValuePtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.UnsignedLongLong Function(CXCursor, ffi.UnsignedInt) > - >('clang_getInstantiationLocation'); - late final _clang_getInstantiationLocation = - _clang_getInstantiationLocationPtr - .asFunction< - void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('clang_Cursor_getTemplateArgumentUnsignedValue'); + late final _clang_Cursor_getTemplateArgumentUnsignedValue = + _clang_Cursor_getTemplateArgumentUnsignedValuePtr + .asFunction(); - /// Retrieve the file, line, column, and offset represented by the given - /// source location. - void clang_getSpellingLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getSpellingLocation(location, file, line, column, offset); + /// Retrieve the value of an Integral TemplateArgument (of a function decl + /// representing a template specialization) as a signed long long. + int clang_Cursor_getTemplateArgumentValue(CXCursor C, int I) { + return _clang_Cursor_getTemplateArgumentValue(C, I); } - late final _clang_getSpellingLocationPtr = + late final _clang_Cursor_getTemplateArgumentValuePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('clang_getSpellingLocation'); - late final _clang_getSpellingLocation = _clang_getSpellingLocationPtr - .asFunction< - void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - /// Retrieve the file, line, column, and offset represented by the given - /// source location. - void clang_getFileLocation( - CXSourceLocation location, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_getFileLocation(location, file, line, column, offset); - } - - late final _clang_getFileLocationPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('clang_getFileLocation'); - late final _clang_getFileLocation = _clang_getFileLocationPtr - .asFunction< - void Function( - CXSourceLocation, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + ffi.NativeFunction + >('clang_Cursor_getTemplateArgumentValue'); + late final _clang_Cursor_getTemplateArgumentValue = + _clang_Cursor_getTemplateArgumentValuePtr + .asFunction(); - /// Retrieve a source location representing the first character within a - /// source range. - CXSourceLocation clang_getRangeStart(CXSourceRange range) { - return _clang_getRangeStart(range); + /// Returns the translation unit that a cursor originated from. + CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor arg0) { + return _clang_Cursor_getTranslationUnit(arg0); } - late final _clang_getRangeStartPtr = - _lookup>( - 'clang_getRangeStart', + late final _clang_Cursor_getTranslationUnitPtr = + _lookup>( + 'clang_Cursor_getTranslationUnit', ); - late final _clang_getRangeStart = _clang_getRangeStartPtr - .asFunction(); + late final _clang_Cursor_getTranslationUnit = + _clang_Cursor_getTranslationUnitPtr + .asFunction(); - /// Retrieve a source location representing the last character within a source - /// range. - CXSourceLocation clang_getRangeEnd(CXSourceRange range) { - return _clang_getRangeEnd(range); + /// Determine whether the given cursor has any attributes. + int clang_Cursor_hasAttrs(CXCursor C) { + return _clang_Cursor_hasAttrs(C); } - late final _clang_getRangeEndPtr = - _lookup>( - 'clang_getRangeEnd', + late final _clang_Cursor_hasAttrsPtr = + _lookup>( + 'clang_Cursor_hasAttrs', ); - late final _clang_getRangeEnd = _clang_getRangeEndPtr - .asFunction(); - - /// Retrieve all ranges that were skipped by the preprocessor. - ffi.Pointer clang_getSkippedRanges( - CXTranslationUnit tu, - CXFile file, - ) { - return _clang_getSkippedRanges(tu, file); - } - - late final _clang_getSkippedRangesPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CXTranslationUnit, CXFile) - > - >('clang_getSkippedRanges'); - late final _clang_getSkippedRanges = _clang_getSkippedRangesPtr - .asFunction< - ffi.Pointer Function(CXTranslationUnit, CXFile) - >(); + late final _clang_Cursor_hasAttrs = _clang_Cursor_hasAttrsPtr + .asFunction(); - /// Retrieve all ranges from all files that were skipped by the preprocessor. - ffi.Pointer clang_getAllSkippedRanges( - CXTranslationUnit tu, - ) { - return _clang_getAllSkippedRanges(tu); + /// Determine whether the given cursor represents an anonymous tag or + /// namespace + int clang_Cursor_isAnonymous(CXCursor C) { + return _clang_Cursor_isAnonymous(C); } - late final _clang_getAllSkippedRangesPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(CXTranslationUnit) - > - >('clang_getAllSkippedRanges'); - late final _clang_getAllSkippedRanges = _clang_getAllSkippedRangesPtr - .asFunction Function(CXTranslationUnit)>(); + late final _clang_Cursor_isAnonymousPtr = + _lookup>( + 'clang_Cursor_isAnonymous', + ); + late final _clang_Cursor_isAnonymous = _clang_Cursor_isAnonymousPtr + .asFunction(); - /// Destroy the given CXSourceRangeList. - void clang_disposeSourceRangeList(ffi.Pointer ranges) { - return _clang_disposeSourceRangeList(ranges); + /// Determine whether the given cursor represents an anonymous record + /// declaration. + int clang_Cursor_isAnonymousRecordDecl(CXCursor C) { + return _clang_Cursor_isAnonymousRecordDecl(C); } - late final _clang_disposeSourceRangeListPtr = - _lookup< - ffi.NativeFunction)> - >('clang_disposeSourceRangeList'); - late final _clang_disposeSourceRangeList = _clang_disposeSourceRangeListPtr - .asFunction)>(); + late final _clang_Cursor_isAnonymousRecordDeclPtr = + _lookup>( + 'clang_Cursor_isAnonymousRecordDecl', + ); + late final _clang_Cursor_isAnonymousRecordDecl = + _clang_Cursor_isAnonymousRecordDeclPtr + .asFunction(); - /// Determine the number of diagnostics in a CXDiagnosticSet. - int clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags) { - return _clang_getNumDiagnosticsInSet(Diags); + /// Returns non-zero if the cursor specifies a Record member that is a + /// bitfield. + int clang_Cursor_isBitField(CXCursor C) { + return _clang_Cursor_isBitField(C); } - late final _clang_getNumDiagnosticsInSetPtr = - _lookup>( - 'clang_getNumDiagnosticsInSet', + late final _clang_Cursor_isBitFieldPtr = + _lookup>( + 'clang_Cursor_isBitField', ); - late final _clang_getNumDiagnosticsInSet = _clang_getNumDiagnosticsInSetPtr - .asFunction(); + late final _clang_Cursor_isBitField = _clang_Cursor_isBitFieldPtr + .asFunction(); - /// Retrieve a diagnostic associated with the given CXDiagnosticSet. - CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, int Index) { - return _clang_getDiagnosticInSet(Diags, Index); + /// Given a cursor pointing to a C++ method call or an Objective-C message, + /// returns non-zero if the method/message is "dynamic", meaning: + int clang_Cursor_isDynamicCall(CXCursor C) { + return _clang_Cursor_isDynamicCall(C); } - late final _clang_getDiagnosticInSetPtr = - _lookup< - ffi.NativeFunction< - CXDiagnostic Function(CXDiagnosticSet, ffi.UnsignedInt) - > - >('clang_getDiagnosticInSet'); - late final _clang_getDiagnosticInSet = _clang_getDiagnosticInSetPtr - .asFunction(); + late final _clang_Cursor_isDynamicCallPtr = + _lookup>( + 'clang_Cursor_isDynamicCall', + ); + late final _clang_Cursor_isDynamicCall = _clang_Cursor_isDynamicCallPtr + .asFunction(); - /// Deserialize a set of diagnostics from a Clang diagnostics bitcode file. - CXDiagnosticSet clang_loadDiagnostics( - ffi.Pointer file, - ffi.Pointer error, - ffi.Pointer errorString, + /// Returns non-zero if the given cursor points to a symbol marked with + /// external_source_symbol attribute. + int clang_Cursor_isExternalSymbol( + CXCursor C, + ffi.Pointer language, + ffi.Pointer definedIn, + ffi.Pointer isGenerated, ) { - return _clang_loadDiagnostics(file, error, errorString); + return _clang_Cursor_isExternalSymbol(C, language, definedIn, isGenerated); } - late final _clang_loadDiagnosticsPtr = + late final _clang_Cursor_isExternalSymbolPtr = _lookup< ffi.NativeFunction< - CXDiagnosticSet Function( - ffi.Pointer, - ffi.Pointer, + ffi.UnsignedInt Function( + CXCursor, ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) > - >('clang_loadDiagnostics'); - late final _clang_loadDiagnostics = _clang_loadDiagnosticsPtr + >('clang_Cursor_isExternalSymbol'); + late final _clang_Cursor_isExternalSymbol = _clang_Cursor_isExternalSymbolPtr .asFunction< - CXDiagnosticSet Function( - ffi.Pointer, - ffi.Pointer, + int Function( + CXCursor, + ffi.Pointer, ffi.Pointer, + ffi.Pointer, ) >(); - /// Release a CXDiagnosticSet and all of its contained diagnostics. - void clang_disposeDiagnosticSet(CXDiagnosticSet Diags) { - return _clang_disposeDiagnosticSet(Diags); + /// Determine whether a CXCursor that is a function declaration, is an inline + /// declaration. + int clang_Cursor_isFunctionInlined(CXCursor C) { + return _clang_Cursor_isFunctionInlined(C); } - late final _clang_disposeDiagnosticSetPtr = - _lookup>( - 'clang_disposeDiagnosticSet', + late final _clang_Cursor_isFunctionInlinedPtr = + _lookup>( + 'clang_Cursor_isFunctionInlined', ); - late final _clang_disposeDiagnosticSet = _clang_disposeDiagnosticSetPtr - .asFunction(); + late final _clang_Cursor_isFunctionInlined = + _clang_Cursor_isFunctionInlinedPtr.asFunction(); - /// Retrieve the child diagnostics of a CXDiagnostic. - CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D) { - return _clang_getChildDiagnostics(D); + /// Determine whether the given cursor represents an inline namespace + /// declaration. + int clang_Cursor_isInlineNamespace(CXCursor C) { + return _clang_Cursor_isInlineNamespace(C); } - late final _clang_getChildDiagnosticsPtr = - _lookup>( - 'clang_getChildDiagnostics', + late final _clang_Cursor_isInlineNamespacePtr = + _lookup>( + 'clang_Cursor_isInlineNamespace', ); - late final _clang_getChildDiagnostics = _clang_getChildDiagnosticsPtr - .asFunction(); + late final _clang_Cursor_isInlineNamespace = + _clang_Cursor_isInlineNamespacePtr.asFunction(); - /// Determine the number of diagnostics produced for the given translation - /// unit. - int clang_getNumDiagnostics(CXTranslationUnit Unit) { - return _clang_getNumDiagnostics(Unit); + /// Determine whether a CXCursor that is a macro, is a builtin one. + int clang_Cursor_isMacroBuiltin(CXCursor C) { + return _clang_Cursor_isMacroBuiltin(C); } - late final _clang_getNumDiagnosticsPtr = - _lookup>( - 'clang_getNumDiagnostics', + late final _clang_Cursor_isMacroBuiltinPtr = + _lookup>( + 'clang_Cursor_isMacroBuiltin', ); - late final _clang_getNumDiagnostics = _clang_getNumDiagnosticsPtr - .asFunction(); + late final _clang_Cursor_isMacroBuiltin = _clang_Cursor_isMacroBuiltinPtr + .asFunction(); - /// Retrieve a diagnostic associated with the given translation unit. - CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, int Index) { - return _clang_getDiagnostic(Unit, Index); + /// Determine whether a CXCursor that is a macro, is function like. + int clang_Cursor_isMacroFunctionLike(CXCursor C) { + return _clang_Cursor_isMacroFunctionLike(C); } - late final _clang_getDiagnosticPtr = - _lookup< - ffi.NativeFunction< - CXDiagnostic Function(CXTranslationUnit, ffi.UnsignedInt) - > - >('clang_getDiagnostic'); - late final _clang_getDiagnostic = _clang_getDiagnosticPtr - .asFunction(); + late final _clang_Cursor_isMacroFunctionLikePtr = + _lookup>( + 'clang_Cursor_isMacroFunctionLike', + ); + late final _clang_Cursor_isMacroFunctionLike = + _clang_Cursor_isMacroFunctionLikePtr.asFunction(); - /// Retrieve the complete set of diagnostics associated with a translation - /// unit. - CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) { - return _clang_getDiagnosticSetFromTU(Unit); + /// Returns non-zero if cursor is null. + int clang_Cursor_isNull(CXCursor cursor) { + return _clang_Cursor_isNull(cursor); } - late final _clang_getDiagnosticSetFromTUPtr = - _lookup>( - 'clang_getDiagnosticSetFromTU', + late final _clang_Cursor_isNullPtr = + _lookup>( + 'clang_Cursor_isNull', ); - late final _clang_getDiagnosticSetFromTU = _clang_getDiagnosticSetFromTUPtr - .asFunction(); + late final _clang_Cursor_isNull = _clang_Cursor_isNullPtr + .asFunction(); - /// Destroy a diagnostic. - void clang_disposeDiagnostic(CXDiagnostic Diagnostic) { - return _clang_disposeDiagnostic(Diagnostic); + /// Given a cursor that represents an Objective-C method or property + /// declaration, return non-zero if the declaration was affected by + /// "\@optional". Returns zero if the cursor is not such a declaration or it + /// is "\@required". + int clang_Cursor_isObjCOptional(CXCursor C) { + return _clang_Cursor_isObjCOptional(C); } - late final _clang_disposeDiagnosticPtr = - _lookup>( - 'clang_disposeDiagnostic', + late final _clang_Cursor_isObjCOptionalPtr = + _lookup>( + 'clang_Cursor_isObjCOptional', ); - late final _clang_disposeDiagnostic = _clang_disposeDiagnosticPtr - .asFunction(); + late final _clang_Cursor_isObjCOptional = _clang_Cursor_isObjCOptionalPtr + .asFunction(); - /// Format the given diagnostic in a manner that is suitable for display. - CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, int Options) { - return _clang_formatDiagnostic(Diagnostic, Options); + /// Returns non-zero if the given cursor is a variadic function or method. + int clang_Cursor_isVariadic(CXCursor C) { + return _clang_Cursor_isVariadic(C); } - late final _clang_formatDiagnosticPtr = - _lookup< - ffi.NativeFunction - >('clang_formatDiagnostic'); - late final _clang_formatDiagnostic = _clang_formatDiagnosticPtr - .asFunction(); + late final _clang_Cursor_isVariadicPtr = + _lookup>( + 'clang_Cursor_isVariadic', + ); + late final _clang_Cursor_isVariadic = _clang_Cursor_isVariadicPtr + .asFunction(); - /// Retrieve the set of display options most similar to the default behavior - /// of the clang compiler. - int clang_defaultDiagnosticDisplayOptions() { - return _clang_defaultDiagnosticDisplayOptions(); + /// Determine if an enum declaration refers to a scoped enum. + int clang_EnumDecl_isScoped(CXCursor C) { + return _clang_EnumDecl_isScoped(C); } - late final _clang_defaultDiagnosticDisplayOptionsPtr = - _lookup>( - 'clang_defaultDiagnosticDisplayOptions', + late final _clang_EnumDecl_isScopedPtr = + _lookup>( + 'clang_EnumDecl_isScoped', ); - late final _clang_defaultDiagnosticDisplayOptions = - _clang_defaultDiagnosticDisplayOptionsPtr.asFunction(); + late final _clang_EnumDecl_isScoped = _clang_EnumDecl_isScopedPtr + .asFunction(); - /// Determine the severity of the given diagnostic. - CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic arg0) { - return CXDiagnosticSeverity.fromValue(_clang_getDiagnosticSeverity(arg0)); + /// Disposes the created Eval memory. + void clang_EvalResult_dispose(CXEvalResult E) { + return _clang_EvalResult_dispose(E); } - late final _clang_getDiagnosticSeverityPtr = - _lookup>( - 'clang_getDiagnosticSeverity', + late final _clang_EvalResult_disposePtr = + _lookup>( + 'clang_EvalResult_dispose', ); - late final _clang_getDiagnosticSeverity = _clang_getDiagnosticSeverityPtr - .asFunction(); + late final _clang_EvalResult_dispose = _clang_EvalResult_disposePtr + .asFunction(); - /// Retrieve the source location of the given diagnostic. - CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic arg0) { - return _clang_getDiagnosticLocation(arg0); + /// Returns the evaluation result as double if the kind is double. + double clang_EvalResult_getAsDouble(CXEvalResult E) { + return _clang_EvalResult_getAsDouble(E); } - late final _clang_getDiagnosticLocationPtr = - _lookup>( - 'clang_getDiagnosticLocation', + late final _clang_EvalResult_getAsDoublePtr = + _lookup>( + 'clang_EvalResult_getAsDouble', ); - late final _clang_getDiagnosticLocation = _clang_getDiagnosticLocationPtr - .asFunction(); + late final _clang_EvalResult_getAsDouble = _clang_EvalResult_getAsDoublePtr + .asFunction(); - /// Retrieve the text of the given diagnostic. - CXString clang_getDiagnosticSpelling(CXDiagnostic arg0) { - return _clang_getDiagnosticSpelling(arg0); + /// Returns the evaluation result as integer if the kind is Int. + int clang_EvalResult_getAsInt(CXEvalResult E) { + return _clang_EvalResult_getAsInt(E); } - late final _clang_getDiagnosticSpellingPtr = - _lookup>( - 'clang_getDiagnosticSpelling', + late final _clang_EvalResult_getAsIntPtr = + _lookup>( + 'clang_EvalResult_getAsInt', ); - late final _clang_getDiagnosticSpelling = _clang_getDiagnosticSpellingPtr - .asFunction(); + late final _clang_EvalResult_getAsInt = _clang_EvalResult_getAsIntPtr + .asFunction(); - /// Retrieve the name of the command-line option that enabled this diagnostic. - CXString clang_getDiagnosticOption( - CXDiagnostic Diag, - ffi.Pointer Disable, - ) { - return _clang_getDiagnosticOption(Diag, Disable); + /// Returns the evaluation result as a long long integer if the kind is Int. + /// This prevents overflows that may happen if the result is returned with + /// clang_EvalResult_getAsInt. + int clang_EvalResult_getAsLongLong(CXEvalResult E) { + return _clang_EvalResult_getAsLongLong(E); } - late final _clang_getDiagnosticOptionPtr = - _lookup< - ffi.NativeFunction< - CXString Function(CXDiagnostic, ffi.Pointer) - > - >('clang_getDiagnosticOption'); - late final _clang_getDiagnosticOption = _clang_getDiagnosticOptionPtr - .asFunction)>(); + late final _clang_EvalResult_getAsLongLongPtr = + _lookup>( + 'clang_EvalResult_getAsLongLong', + ); + late final _clang_EvalResult_getAsLongLong = + _clang_EvalResult_getAsLongLongPtr + .asFunction(); - /// Retrieve the category number for this diagnostic. - int clang_getDiagnosticCategory(CXDiagnostic arg0) { - return _clang_getDiagnosticCategory(arg0); + /// Returns the evaluation result as a constant string if the kind is other + /// than Int or float. User must not free this pointer, instead call + /// clang_EvalResult_dispose on the CXEvalResult returned by + /// clang_Cursor_Evaluate. + ffi.Pointer clang_EvalResult_getAsStr(CXEvalResult E) { + return _clang_EvalResult_getAsStr(E); } - late final _clang_getDiagnosticCategoryPtr = - _lookup>( - 'clang_getDiagnosticCategory', + late final _clang_EvalResult_getAsStrPtr = + _lookup Function(CXEvalResult)>>( + 'clang_EvalResult_getAsStr', ); - late final _clang_getDiagnosticCategory = _clang_getDiagnosticCategoryPtr - .asFunction(); + late final _clang_EvalResult_getAsStr = _clang_EvalResult_getAsStrPtr + .asFunction Function(CXEvalResult)>(); - /// Retrieve the name of a particular diagnostic category. This is now - /// deprecated. Use clang_getDiagnosticCategoryText() instead. - CXString clang_getDiagnosticCategoryName(int Category) { - return _clang_getDiagnosticCategoryName(Category); + /// Returns the evaluation result as an unsigned integer if the kind is Int + /// and clang_EvalResult_isUnsignedInt is non-zero. + int clang_EvalResult_getAsUnsigned(CXEvalResult E) { + return _clang_EvalResult_getAsUnsigned(E); } - late final _clang_getDiagnosticCategoryNamePtr = - _lookup>( - 'clang_getDiagnosticCategoryName', + late final _clang_EvalResult_getAsUnsignedPtr = + _lookup>( + 'clang_EvalResult_getAsUnsigned', ); - late final _clang_getDiagnosticCategoryName = - _clang_getDiagnosticCategoryNamePtr.asFunction(); + late final _clang_EvalResult_getAsUnsigned = + _clang_EvalResult_getAsUnsignedPtr + .asFunction(); - /// Retrieve the diagnostic category text for a given diagnostic. - CXString clang_getDiagnosticCategoryText(CXDiagnostic arg0) { - return _clang_getDiagnosticCategoryText(arg0); + /// Returns the kind of the evaluated result. + CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E) { + return CXEvalResultKind.fromValue(_clang_EvalResult_getKind(E)); } - late final _clang_getDiagnosticCategoryTextPtr = - _lookup>( - 'clang_getDiagnosticCategoryText', + late final _clang_EvalResult_getKindPtr = + _lookup>( + 'clang_EvalResult_getKind', ); - late final _clang_getDiagnosticCategoryText = - _clang_getDiagnosticCategoryTextPtr - .asFunction(); + late final _clang_EvalResult_getKind = _clang_EvalResult_getKindPtr + .asFunction(); - /// Determine the number of source ranges associated with the given - /// diagnostic. - int clang_getDiagnosticNumRanges(CXDiagnostic arg0) { - return _clang_getDiagnosticNumRanges(arg0); + /// Returns a non-zero value if the kind is Int and the evaluation result + /// resulted in an unsigned integer. + int clang_EvalResult_isUnsignedInt(CXEvalResult E) { + return _clang_EvalResult_isUnsignedInt(E); } - late final _clang_getDiagnosticNumRangesPtr = - _lookup>( - 'clang_getDiagnosticNumRanges', + late final _clang_EvalResult_isUnsignedIntPtr = + _lookup>( + 'clang_EvalResult_isUnsignedInt', ); - late final _clang_getDiagnosticNumRanges = _clang_getDiagnosticNumRangesPtr - .asFunction(); + late final _clang_EvalResult_isUnsignedInt = + _clang_EvalResult_isUnsignedIntPtr + .asFunction(); - /// Retrieve a source range associated with the diagnostic. - CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, int Range) { - return _clang_getDiagnosticRange(Diagnostic, Range); + /// Returns non-zero if the file1 and file2 point to the same file, or they + /// are both NULL. + int clang_File_isEqual(CXFile file1, CXFile file2) { + return _clang_File_isEqual(file1, file2); } - late final _clang_getDiagnosticRangePtr = - _lookup< - ffi.NativeFunction< - CXSourceRange Function(CXDiagnostic, ffi.UnsignedInt) - > - >('clang_getDiagnosticRange'); - late final _clang_getDiagnosticRange = _clang_getDiagnosticRangePtr - .asFunction(); - - /// Determine the number of fix-it hints associated with the given diagnostic. - int clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic) { - return _clang_getDiagnosticNumFixIts(Diagnostic); + late final _clang_File_isEqualPtr = + _lookup>( + 'clang_File_isEqual', + ); + late final _clang_File_isEqual = _clang_File_isEqualPtr + .asFunction(); + + /// Returns the real path name of file. + CXString clang_File_tryGetRealPathName(CXFile file) { + return _clang_File_tryGetRealPathName(file); } - late final _clang_getDiagnosticNumFixItsPtr = - _lookup>( - 'clang_getDiagnosticNumFixIts', + late final _clang_File_tryGetRealPathNamePtr = + _lookup>( + 'clang_File_tryGetRealPathName', ); - late final _clang_getDiagnosticNumFixIts = _clang_getDiagnosticNumFixItsPtr - .asFunction(); + late final _clang_File_tryGetRealPathName = _clang_File_tryGetRealPathNamePtr + .asFunction(); - /// Retrieve the replacement information for a given fix-it. - CXString clang_getDiagnosticFixIt( - CXDiagnostic Diagnostic, - int FixIt, - ffi.Pointer ReplacementRange, - ) { - return _clang_getDiagnosticFixIt(Diagnostic, FixIt, ReplacementRange); + /// An indexing action/session, to be applied to one or multiple translation + /// units. + CXIndexAction clang_IndexAction_create(CXIndex CIdx) { + return _clang_IndexAction_create(CIdx); } - late final _clang_getDiagnosticFixItPtr = + late final _clang_IndexAction_createPtr = + _lookup>( + 'clang_IndexAction_create', + ); + late final _clang_IndexAction_create = _clang_IndexAction_createPtr + .asFunction(); + + /// Destroy the given index action. + void clang_IndexAction_dispose(CXIndexAction arg0) { + return _clang_IndexAction_dispose(arg0); + } + + late final _clang_IndexAction_disposePtr = + _lookup>( + 'clang_IndexAction_dispose', + ); + late final _clang_IndexAction_dispose = _clang_IndexAction_disposePtr + .asFunction(); + + /// Returns non-zero if the given source location is in the main file of the + /// corresponding translation unit. + int clang_Location_isFromMainFile(CXSourceLocation location) { + return _clang_Location_isFromMainFile(location); + } + + late final _clang_Location_isFromMainFilePtr = + _lookup>( + 'clang_Location_isFromMainFile', + ); + late final _clang_Location_isFromMainFile = _clang_Location_isFromMainFilePtr + .asFunction(); + + /// Returns non-zero if the given source location is in a system header. + int clang_Location_isInSystemHeader(CXSourceLocation location) { + return _clang_Location_isInSystemHeader(location); + } + + late final _clang_Location_isInSystemHeaderPtr = + _lookup>( + 'clang_Location_isInSystemHeader', + ); + late final _clang_Location_isInSystemHeader = + _clang_Location_isInSystemHeaderPtr + .asFunction(); + + /// Create a CXModuleMapDescriptor object. Must be disposed with + /// clang_ModuleMapDescriptor_dispose(). + CXModuleMapDescriptor clang_ModuleMapDescriptor_create(int options) { + return _clang_ModuleMapDescriptor_create(options); + } + + late final _clang_ModuleMapDescriptor_createPtr = _lookup< - ffi.NativeFunction< - CXString Function( - CXDiagnostic, - ffi.UnsignedInt, - ffi.Pointer, - ) - > - >('clang_getDiagnosticFixIt'); - late final _clang_getDiagnosticFixIt = _clang_getDiagnosticFixItPtr - .asFunction< - CXString Function(CXDiagnostic, int, ffi.Pointer) - >(); + ffi.NativeFunction + >('clang_ModuleMapDescriptor_create'); + late final _clang_ModuleMapDescriptor_create = + _clang_ModuleMapDescriptor_createPtr + .asFunction(); - /// Get the original translation unit source file name. - CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) { - return _clang_getTranslationUnitSpelling(CTUnit); + /// Dispose a CXModuleMapDescriptor object. + void clang_ModuleMapDescriptor_dispose(CXModuleMapDescriptor arg0) { + return _clang_ModuleMapDescriptor_dispose(arg0); } - late final _clang_getTranslationUnitSpellingPtr = - _lookup>( - 'clang_getTranslationUnitSpelling', + late final _clang_ModuleMapDescriptor_disposePtr = + _lookup>( + 'clang_ModuleMapDescriptor_dispose', ); - late final _clang_getTranslationUnitSpelling = - _clang_getTranslationUnitSpellingPtr - .asFunction(); + late final _clang_ModuleMapDescriptor_dispose = + _clang_ModuleMapDescriptor_disposePtr + .asFunction(); - /// Return the CXTranslationUnit for a given source file and the provided - /// command line arguments one would pass to the compiler. - CXTranslationUnit clang_createTranslationUnitFromSourceFile( - CXIndex CIdx, - ffi.Pointer source_filename, - int num_clang_command_line_args, - ffi.Pointer> clang_command_line_args, - int num_unsaved_files, - ffi.Pointer unsaved_files, + /// Sets the framework module name that the module.map describes. + CXErrorCode clang_ModuleMapDescriptor_setFrameworkModuleName( + CXModuleMapDescriptor arg0, + ffi.Pointer name, ) { - return _clang_createTranslationUnitFromSourceFile( - CIdx, - source_filename, - num_clang_command_line_args, - clang_command_line_args, - num_unsaved_files, - unsaved_files, + return CXErrorCode.fromValue( + _clang_ModuleMapDescriptor_setFrameworkModuleName(arg0, name), ); } - late final _clang_createTranslationUnitFromSourceFilePtr = + late final _clang_ModuleMapDescriptor_setFrameworkModuleNamePtr = _lookup< ffi.NativeFunction< - CXTranslationUnit Function( - CXIndex, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.UnsignedInt, - ffi.Pointer, - ) + ffi.UnsignedInt Function(CXModuleMapDescriptor, ffi.Pointer) > - >('clang_createTranslationUnitFromSourceFile'); - late final _clang_createTranslationUnitFromSourceFile = - _clang_createTranslationUnitFromSourceFilePtr + >('clang_ModuleMapDescriptor_setFrameworkModuleName'); + late final _clang_ModuleMapDescriptor_setFrameworkModuleName = + _clang_ModuleMapDescriptor_setFrameworkModuleNamePtr .asFunction< - CXTranslationUnit Function( - CXIndex, - ffi.Pointer, - int, - ffi.Pointer>, - int, - ffi.Pointer, - ) + int Function(CXModuleMapDescriptor, ffi.Pointer) >(); - /// Same as clang_createTranslationUnit2, but returns the CXTranslationUnit - /// instead of an error code. In case of an error this routine returns a NULL - /// CXTranslationUnit, without further detailed error codes. - CXTranslationUnit clang_createTranslationUnit( - CXIndex CIdx, - ffi.Pointer ast_filename, + /// Sets the umbrealla header name that the module.map describes. + CXErrorCode clang_ModuleMapDescriptor_setUmbrellaHeader( + CXModuleMapDescriptor arg0, + ffi.Pointer name, ) { - return _clang_createTranslationUnit(CIdx, ast_filename); + return CXErrorCode.fromValue( + _clang_ModuleMapDescriptor_setUmbrellaHeader(arg0, name), + ); } - late final _clang_createTranslationUnitPtr = + late final _clang_ModuleMapDescriptor_setUmbrellaHeaderPtr = _lookup< ffi.NativeFunction< - CXTranslationUnit Function(CXIndex, ffi.Pointer) + ffi.UnsignedInt Function(CXModuleMapDescriptor, ffi.Pointer) > - >('clang_createTranslationUnit'); - late final _clang_createTranslationUnit = _clang_createTranslationUnitPtr - .asFunction)>(); + >('clang_ModuleMapDescriptor_setUmbrellaHeader'); + late final _clang_ModuleMapDescriptor_setUmbrellaHeader = + _clang_ModuleMapDescriptor_setUmbrellaHeaderPtr + .asFunction< + int Function(CXModuleMapDescriptor, ffi.Pointer) + >(); - /// Create a translation unit from an AST file ( -emit-ast). - CXErrorCode clang_createTranslationUnit2( - CXIndex CIdx, - ffi.Pointer ast_filename, - ffi.Pointer out_TU, + /// Write out the CXModuleMapDescriptor object to a char buffer. + CXErrorCode clang_ModuleMapDescriptor_writeToBuffer( + CXModuleMapDescriptor arg0, + int options, + ffi.Pointer> out_buffer_ptr, + ffi.Pointer out_buffer_size, ) { return CXErrorCode.fromValue( - _clang_createTranslationUnit2(CIdx, ast_filename, out_TU), + _clang_ModuleMapDescriptor_writeToBuffer( + arg0, + options, + out_buffer_ptr, + out_buffer_size, + ), ); } - late final _clang_createTranslationUnit2Ptr = + late final _clang_ModuleMapDescriptor_writeToBufferPtr = _lookup< ffi.NativeFunction< ffi.UnsignedInt Function( - CXIndex, - ffi.Pointer, - ffi.Pointer, + CXModuleMapDescriptor, + ffi.UnsignedInt, + ffi.Pointer>, + ffi.Pointer, ) > - >('clang_createTranslationUnit2'); - late final _clang_createTranslationUnit2 = _clang_createTranslationUnit2Ptr - .asFunction< - int Function( - CXIndex, - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('clang_ModuleMapDescriptor_writeToBuffer'); + late final _clang_ModuleMapDescriptor_writeToBuffer = + _clang_ModuleMapDescriptor_writeToBufferPtr + .asFunction< + int Function( + CXModuleMapDescriptor, + int, + ffi.Pointer>, + ffi.Pointer, + ) + >(); - /// Returns the set of flags that is suitable for parsing a translation unit - /// that is being edited. - int clang_defaultEditingTranslationUnitOptions() { - return _clang_defaultEditingTranslationUnitOptions(); + /// Returns the module file where the provided module object came from. + CXFile clang_Module_getASTFile(CXModule Module) { + return _clang_Module_getASTFile(Module); } - late final _clang_defaultEditingTranslationUnitOptionsPtr = - _lookup>( - 'clang_defaultEditingTranslationUnitOptions', + late final _clang_Module_getASTFilePtr = + _lookup>( + 'clang_Module_getASTFile', ); - late final _clang_defaultEditingTranslationUnitOptions = - _clang_defaultEditingTranslationUnitOptionsPtr - .asFunction(); + late final _clang_Module_getASTFile = _clang_Module_getASTFilePtr + .asFunction(); - /// Same as clang_parseTranslationUnit2, but returns the CXTranslationUnit - /// instead of an error code. In case of an error this routine returns a NULL - /// CXTranslationUnit, without further detailed error codes. - CXTranslationUnit clang_parseTranslationUnit( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ) { - return _clang_parseTranslationUnit( - CIdx, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - options, - ); + /// Returns the full name of the module, e.g. "std.vector". + CXString clang_Module_getFullName(CXModule Module) { + return _clang_Module_getFullName(Module); } - late final _clang_parseTranslationUnitPtr = - _lookup< - ffi.NativeFunction< - CXTranslationUnit Function( - CXIndex, - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ) - > - >('clang_parseTranslationUnit'); - late final _clang_parseTranslationUnit = _clang_parseTranslationUnitPtr - .asFunction< - CXTranslationUnit Function( - CXIndex, - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer, - int, - int, - ) - >(); + late final _clang_Module_getFullNamePtr = + _lookup>( + 'clang_Module_getFullName', + ); + late final _clang_Module_getFullName = _clang_Module_getFullNamePtr + .asFunction(); - /// Parse the given source file and the translation unit corresponding to that - /// file. - CXErrorCode clang_parseTranslationUnit2( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ffi.Pointer out_TU, - ) { - return CXErrorCode.fromValue( - _clang_parseTranslationUnit2( - CIdx, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - options, - out_TU, - ), - ); + /// Returns the name of the module, e.g. for the 'std.vector' sub-module it + /// will return "vector". + CXString clang_Module_getName(CXModule Module) { + return _clang_Module_getName(Module); } - late final _clang_parseTranslationUnit2Ptr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - CXIndex, - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, - ) - > - >('clang_parseTranslationUnit2'); - late final _clang_parseTranslationUnit2 = _clang_parseTranslationUnit2Ptr - .asFunction< - int Function( - CXIndex, - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); + late final _clang_Module_getNamePtr = + _lookup>( + 'clang_Module_getName', + ); + late final _clang_Module_getName = _clang_Module_getNamePtr + .asFunction(); - /// Same as clang_parseTranslationUnit2 but requires a full command line for - /// command_line_args including argv[0]. This is useful if the standard - /// library paths are relative to the binary. - CXErrorCode clang_parseTranslationUnit2FullArgv( - CXIndex CIdx, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ffi.Pointer out_TU, + /// Returns the number of top level headers associated with this module. + int clang_Module_getNumTopLevelHeaders( + CXTranslationUnit arg0, + CXModule Module, ) { - return CXErrorCode.fromValue( - _clang_parseTranslationUnit2FullArgv( - CIdx, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - options, - out_TU, - ), - ); + return _clang_Module_getNumTopLevelHeaders(arg0, Module); } - late final _clang_parseTranslationUnit2FullArgvPtr = + late final _clang_Module_getNumTopLevelHeadersPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function( - CXIndex, - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, - ) + ffi.UnsignedInt Function(CXTranslationUnit, CXModule) > - >('clang_parseTranslationUnit2FullArgv'); - late final _clang_parseTranslationUnit2FullArgv = - _clang_parseTranslationUnit2FullArgvPtr - .asFunction< - int Function( - CXIndex, - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer, - int, - int, - ffi.Pointer, - ) - >(); + >('clang_Module_getNumTopLevelHeaders'); + late final _clang_Module_getNumTopLevelHeaders = + _clang_Module_getNumTopLevelHeadersPtr + .asFunction(); - /// Returns the set of flags that is suitable for saving a translation unit. - int clang_defaultSaveOptions(CXTranslationUnit TU) { - return _clang_defaultSaveOptions(TU); + /// Returns the parent of a sub-module or NULL if the given module is + /// top-level, e.g. for 'std.vector' it will return the 'std' module. + CXModule clang_Module_getParent(CXModule Module) { + return _clang_Module_getParent(Module); } - late final _clang_defaultSaveOptionsPtr = - _lookup>( - 'clang_defaultSaveOptions', + late final _clang_Module_getParentPtr = + _lookup>( + 'clang_Module_getParent', ); - late final _clang_defaultSaveOptions = _clang_defaultSaveOptionsPtr - .asFunction(); + late final _clang_Module_getParent = _clang_Module_getParentPtr + .asFunction(); - /// Saves a translation unit into a serialized representation of that - /// translation unit on disk. - int clang_saveTranslationUnit( - CXTranslationUnit TU, - ffi.Pointer FileName, - int options, + /// Returns the specified top level header associated with the module. + CXFile clang_Module_getTopLevelHeader( + CXTranslationUnit arg0, + CXModule Module, + int Index, ) { - return _clang_saveTranslationUnit(TU, FileName, options); + return _clang_Module_getTopLevelHeader(arg0, Module, Index); } - late final _clang_saveTranslationUnitPtr = + late final _clang_Module_getTopLevelHeaderPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - CXTranslationUnit, - ffi.Pointer, - ffi.UnsignedInt, - ) + CXFile Function(CXTranslationUnit, CXModule, ffi.UnsignedInt) > - >('clang_saveTranslationUnit'); - late final _clang_saveTranslationUnit = _clang_saveTranslationUnitPtr - .asFunction< - int Function(CXTranslationUnit, ffi.Pointer, int) - >(); + >('clang_Module_getTopLevelHeader'); + late final _clang_Module_getTopLevelHeader = + _clang_Module_getTopLevelHeaderPtr + .asFunction(); - /// Suspend a translation unit in order to free memory associated with it. - int clang_suspendTranslationUnit(CXTranslationUnit arg0) { - return _clang_suspendTranslationUnit(arg0); + /// Returns non-zero if the module is a system one. + int clang_Module_isSystem(CXModule Module) { + return _clang_Module_isSystem(Module); } - late final _clang_suspendTranslationUnitPtr = - _lookup>( - 'clang_suspendTranslationUnit', + late final _clang_Module_isSystemPtr = + _lookup>( + 'clang_Module_isSystem', ); - late final _clang_suspendTranslationUnit = _clang_suspendTranslationUnitPtr - .asFunction(); + late final _clang_Module_isSystem = _clang_Module_isSystemPtr + .asFunction(); - /// Destroy the specified CXTranslationUnit object. - void clang_disposeTranslationUnit(CXTranslationUnit arg0) { - return _clang_disposeTranslationUnit(arg0); + /// Release a printing policy. + void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy) { + return _clang_PrintingPolicy_dispose(Policy); } - late final _clang_disposeTranslationUnitPtr = - _lookup>( - 'clang_disposeTranslationUnit', - ); - late final _clang_disposeTranslationUnit = _clang_disposeTranslationUnitPtr - .asFunction(); - - /// Returns the set of flags that is suitable for reparsing a translation - /// unit. - int clang_defaultReparseOptions(CXTranslationUnit TU) { - return _clang_defaultReparseOptions(TU); - } - - late final _clang_defaultReparseOptionsPtr = - _lookup>( - 'clang_defaultReparseOptions', + late final _clang_PrintingPolicy_disposePtr = + _lookup>( + 'clang_PrintingPolicy_dispose', ); - late final _clang_defaultReparseOptions = _clang_defaultReparseOptionsPtr - .asFunction(); + late final _clang_PrintingPolicy_dispose = _clang_PrintingPolicy_disposePtr + .asFunction(); - /// Reparse the source files that produced this translation unit. - int clang_reparseTranslationUnit( - CXTranslationUnit TU, - int num_unsaved_files, - ffi.Pointer unsaved_files, - int options, + /// Get a property value for the given printing policy. + int clang_PrintingPolicy_getProperty( + CXPrintingPolicy Policy, + CXPrintingPolicyProperty Property, ) { - return _clang_reparseTranslationUnit( - TU, - num_unsaved_files, - unsaved_files, - options, - ); + return _clang_PrintingPolicy_getProperty(Policy, Property.value); } - late final _clang_reparseTranslationUnitPtr = + late final _clang_PrintingPolicy_getPropertyPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - CXTranslationUnit, - ffi.UnsignedInt, - ffi.Pointer, - ffi.UnsignedInt, - ) + ffi.UnsignedInt Function(CXPrintingPolicy, ffi.UnsignedInt) > - >('clang_reparseTranslationUnit'); - late final _clang_reparseTranslationUnit = _clang_reparseTranslationUnitPtr - .asFunction< - int Function(CXTranslationUnit, int, ffi.Pointer, int) - >(); + >('clang_PrintingPolicy_getProperty'); + late final _clang_PrintingPolicy_getProperty = + _clang_PrintingPolicy_getPropertyPtr + .asFunction(); - /// Returns the human-readable null-terminated C string that represents the - /// name of the memory category. This string should never be freed. - ffi.Pointer clang_getTUResourceUsageName( - CXTUResourceUsageKind kind, + /// Set a property value for the given printing policy. + void clang_PrintingPolicy_setProperty( + CXPrintingPolicy Policy, + CXPrintingPolicyProperty Property, + int Value, ) { - return _clang_getTUResourceUsageName(kind.value); - } - - late final _clang_getTUResourceUsageNamePtr = - _lookup< - ffi.NativeFunction Function(ffi.UnsignedInt)> - >('clang_getTUResourceUsageName'); - late final _clang_getTUResourceUsageName = _clang_getTUResourceUsageNamePtr - .asFunction Function(int)>(); - - /// Return the memory usage of a translation unit. This object should be - /// released with clang_disposeCXTUResourceUsage(). - CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { - return _clang_getCXTUResourceUsage(TU); + return _clang_PrintingPolicy_setProperty(Policy, Property.value, Value); } - late final _clang_getCXTUResourceUsagePtr = + late final _clang_PrintingPolicy_setPropertyPtr = _lookup< - ffi.NativeFunction - >('clang_getCXTUResourceUsage'); - late final _clang_getCXTUResourceUsage = _clang_getCXTUResourceUsagePtr - .asFunction(); - - void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage) { - return _clang_disposeCXTUResourceUsage(usage); - } - - late final _clang_disposeCXTUResourceUsagePtr = - _lookup>( - 'clang_disposeCXTUResourceUsage', - ); - late final _clang_disposeCXTUResourceUsage = - _clang_disposeCXTUResourceUsagePtr - .asFunction(); + ffi.NativeFunction< + ffi.Void Function(CXPrintingPolicy, ffi.UnsignedInt, ffi.UnsignedInt) + > + >('clang_PrintingPolicy_setProperty'); + late final _clang_PrintingPolicy_setProperty = + _clang_PrintingPolicy_setPropertyPtr + .asFunction(); - /// Get target information for this translation unit. - CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit) { - return _clang_getTranslationUnitTargetInfo(CTUnit); + /// Returns non-zero if range is null. + int clang_Range_isNull(CXSourceRange range) { + return _clang_Range_isNull(range); } - late final _clang_getTranslationUnitTargetInfoPtr = - _lookup>( - 'clang_getTranslationUnitTargetInfo', + late final _clang_Range_isNullPtr = + _lookup>( + 'clang_Range_isNull', ); - late final _clang_getTranslationUnitTargetInfo = - _clang_getTranslationUnitTargetInfoPtr - .asFunction(); + late final _clang_Range_isNull = _clang_Range_isNullPtr + .asFunction(); /// Destroy the CXTargetInfo object. void clang_TargetInfo_dispose(CXTargetInfo Info) { @@ -1664,18 +1239,6 @@ class LibClang { late final _clang_TargetInfo_dispose = _clang_TargetInfo_disposePtr .asFunction(); - /// Get the normalized target triple as a string. - CXString clang_TargetInfo_getTriple(CXTargetInfo Info) { - return _clang_TargetInfo_getTriple(Info); - } - - late final _clang_TargetInfo_getTriplePtr = - _lookup>( - 'clang_TargetInfo_getTriple', - ); - late final _clang_TargetInfo_getTriple = _clang_TargetInfo_getTriplePtr - .asFunction(); - /// Get the pointer width of the target in bits. int clang_TargetInfo_getPointerWidth(CXTargetInfo Info) { return _clang_TargetInfo_getPointerWidth(Info); @@ -1689,1096 +1252,1245 @@ class LibClang { _clang_TargetInfo_getPointerWidthPtr .asFunction(); - /// Retrieve the NULL cursor, which represents no entity. - CXCursor clang_getNullCursor() { - return _clang_getNullCursor(); + /// Get the normalized target triple as a string. + CXString clang_TargetInfo_getTriple(CXTargetInfo Info) { + return _clang_TargetInfo_getTriple(Info); } - late final _clang_getNullCursorPtr = - _lookup>('clang_getNullCursor'); - late final _clang_getNullCursor = _clang_getNullCursorPtr - .asFunction(); + late final _clang_TargetInfo_getTriplePtr = + _lookup>( + 'clang_TargetInfo_getTriple', + ); + late final _clang_TargetInfo_getTriple = _clang_TargetInfo_getTriplePtr + .asFunction(); - /// Retrieve the cursor that represents the given translation unit. - CXCursor clang_getTranslationUnitCursor(CXTranslationUnit arg0) { - return _clang_getTranslationUnitCursor(arg0); + /// Return the alignment of a type in bytes as per C++[expr.alignof] standard. + int clang_Type_getAlignOf(CXType T) { + return _clang_Type_getAlignOf(T); } - late final _clang_getTranslationUnitCursorPtr = - _lookup>( - 'clang_getTranslationUnitCursor', + late final _clang_Type_getAlignOfPtr = + _lookup>( + 'clang_Type_getAlignOf', ); - late final _clang_getTranslationUnitCursor = - _clang_getTranslationUnitCursorPtr - .asFunction(); + late final _clang_Type_getAlignOf = _clang_Type_getAlignOfPtr + .asFunction(); - /// Determine whether two cursors are equivalent. - int clang_equalCursors(CXCursor arg0, CXCursor arg1) { - return _clang_equalCursors(arg0, arg1); + /// Retrieve the ref-qualifier kind of a function or method. + CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T) { + return CXRefQualifierKind.fromValue(_clang_Type_getCXXRefQualifier(T)); } - late final _clang_equalCursorsPtr = - _lookup>( - 'clang_equalCursors', + late final _clang_Type_getCXXRefQualifierPtr = + _lookup>( + 'clang_Type_getCXXRefQualifier', ); - late final _clang_equalCursors = _clang_equalCursorsPtr - .asFunction(); + late final _clang_Type_getCXXRefQualifier = _clang_Type_getCXXRefQualifierPtr + .asFunction(); - /// Returns non-zero if cursor is null. - int clang_Cursor_isNull(CXCursor cursor) { - return _clang_Cursor_isNull(cursor); + /// Return the class type of an member pointer type. + CXType clang_Type_getClassType(CXType T) { + return _clang_Type_getClassType(T); } - late final _clang_Cursor_isNullPtr = - _lookup>( - 'clang_Cursor_isNull', + late final _clang_Type_getClassTypePtr = + _lookup>( + 'clang_Type_getClassType', ); - late final _clang_Cursor_isNull = _clang_Cursor_isNullPtr - .asFunction(); + late final _clang_Type_getClassType = _clang_Type_getClassTypePtr + .asFunction(); - /// Compute a hash value for the given cursor. - int clang_hashCursor(CXCursor arg0) { - return _clang_hashCursor(arg0); + /// Return the type that was modified by this attributed type. + CXType clang_Type_getModifiedType(CXType T) { + return _clang_Type_getModifiedType(T); } - late final _clang_hashCursorPtr = - _lookup>( - 'clang_hashCursor', + late final _clang_Type_getModifiedTypePtr = + _lookup>( + 'clang_Type_getModifiedType', ); - late final _clang_hashCursor = _clang_hashCursorPtr - .asFunction(); + late final _clang_Type_getModifiedType = _clang_Type_getModifiedTypePtr + .asFunction(); - /// Retrieve the kind of the given cursor. - CXCursorKind clang_getCursorKind(CXCursor arg0) { - return CXCursorKind.fromValue(_clang_getCursorKind(arg0)); + /// Retrieve the type named by the qualified-id. + CXType clang_Type_getNamedType(CXType T) { + return _clang_Type_getNamedType(T); } - late final _clang_getCursorKindPtr = - _lookup>( - 'clang_getCursorKind', + late final _clang_Type_getNamedTypePtr = + _lookup>( + 'clang_Type_getNamedType', ); - late final _clang_getCursorKind = _clang_getCursorKindPtr - .asFunction(); + late final _clang_Type_getNamedType = _clang_Type_getNamedTypePtr + .asFunction(); - /// Determine whether the given cursor kind represents a declaration. - int clang_isDeclaration(CXCursorKind arg0) { - return _clang_isDeclaration(arg0.value); + /// Retrieve the nullability kind of a pointer type. + CXTypeNullabilityKind clang_Type_getNullability(CXType T) { + return CXTypeNullabilityKind.fromValue(_clang_Type_getNullability(T)); } - late final _clang_isDeclarationPtr = - _lookup>( - 'clang_isDeclaration', + late final _clang_Type_getNullabilityPtr = + _lookup>( + 'clang_Type_getNullability', ); - late final _clang_isDeclaration = _clang_isDeclarationPtr - .asFunction(); + late final _clang_Type_getNullability = _clang_Type_getNullabilityPtr + .asFunction(); - /// Determine whether the given declaration is invalid. - int clang_isInvalidDeclaration(CXCursor arg0) { - return _clang_isInvalidDeclaration(arg0); + /// Retrieve the number of protocol references associated with an ObjC + /// object/id. + int clang_Type_getNumObjCProtocolRefs(CXType T) { + return _clang_Type_getNumObjCProtocolRefs(T); } - late final _clang_isInvalidDeclarationPtr = - _lookup>( - 'clang_isInvalidDeclaration', - ); - late final _clang_isInvalidDeclaration = _clang_isInvalidDeclarationPtr - .asFunction(); - - /// Determine whether the given cursor kind represents a simple reference. - int clang_isReference(CXCursorKind arg0) { - return _clang_isReference(arg0.value); - } - - late final _clang_isReferencePtr = - _lookup>( - 'clang_isReference', + late final _clang_Type_getNumObjCProtocolRefsPtr = + _lookup>( + 'clang_Type_getNumObjCProtocolRefs', ); - late final _clang_isReference = _clang_isReferencePtr - .asFunction(); + late final _clang_Type_getNumObjCProtocolRefs = + _clang_Type_getNumObjCProtocolRefsPtr.asFunction(); - /// Determine whether the given cursor kind represents an expression. - int clang_isExpression(CXCursorKind arg0) { - return _clang_isExpression(arg0.value); + /// Retreive the number of type arguments associated with an ObjC object. + int clang_Type_getNumObjCTypeArgs(CXType T) { + return _clang_Type_getNumObjCTypeArgs(T); } - late final _clang_isExpressionPtr = - _lookup>( - 'clang_isExpression', + late final _clang_Type_getNumObjCTypeArgsPtr = + _lookup>( + 'clang_Type_getNumObjCTypeArgs', ); - late final _clang_isExpression = _clang_isExpressionPtr - .asFunction(); + late final _clang_Type_getNumObjCTypeArgs = _clang_Type_getNumObjCTypeArgsPtr + .asFunction(); - /// Determine whether the given cursor kind represents a statement. - int clang_isStatement(CXCursorKind arg0) { - return _clang_isStatement(arg0.value); + /// Returns the number of template arguments for given template + /// specialization, or -1 if type T is not a template specialization. + int clang_Type_getNumTemplateArguments(CXType T) { + return _clang_Type_getNumTemplateArguments(T); } - late final _clang_isStatementPtr = - _lookup>( - 'clang_isStatement', + late final _clang_Type_getNumTemplateArgumentsPtr = + _lookup>( + 'clang_Type_getNumTemplateArguments', ); - late final _clang_isStatement = _clang_isStatementPtr - .asFunction(); + late final _clang_Type_getNumTemplateArguments = + _clang_Type_getNumTemplateArgumentsPtr.asFunction(); - /// Determine whether the given cursor kind represents an attribute. - int clang_isAttribute(CXCursorKind arg0) { - return _clang_isAttribute(arg0.value); + /// Returns the Objective-C type encoding for the specified CXType. + CXString clang_Type_getObjCEncoding(CXType type) { + return _clang_Type_getObjCEncoding(type); } - late final _clang_isAttributePtr = - _lookup>( - 'clang_isAttribute', + late final _clang_Type_getObjCEncodingPtr = + _lookup>( + 'clang_Type_getObjCEncoding', ); - late final _clang_isAttribute = _clang_isAttributePtr - .asFunction(); + late final _clang_Type_getObjCEncoding = _clang_Type_getObjCEncodingPtr + .asFunction(); - /// Determine whether the given cursor has any attributes. - int clang_Cursor_hasAttrs(CXCursor C) { - return _clang_Cursor_hasAttrs(C); + /// Retrieves the base type of the ObjCObjectType. + CXType clang_Type_getObjCObjectBaseType(CXType T) { + return _clang_Type_getObjCObjectBaseType(T); } - late final _clang_Cursor_hasAttrsPtr = - _lookup>( - 'clang_Cursor_hasAttrs', + late final _clang_Type_getObjCObjectBaseTypePtr = + _lookup>( + 'clang_Type_getObjCObjectBaseType', ); - late final _clang_Cursor_hasAttrs = _clang_Cursor_hasAttrsPtr - .asFunction(); + late final _clang_Type_getObjCObjectBaseType = + _clang_Type_getObjCObjectBaseTypePtr + .asFunction(); - /// Determine whether the given cursor kind represents an invalid cursor. - int clang_isInvalid(CXCursorKind arg0) { - return _clang_isInvalid(arg0.value); + /// Retrieve the decl for a protocol reference for an ObjC object/id. + CXCursor clang_Type_getObjCProtocolDecl(CXType T, int i) { + return _clang_Type_getObjCProtocolDecl(T, i); } - late final _clang_isInvalidPtr = - _lookup>( - 'clang_isInvalid', + late final _clang_Type_getObjCProtocolDeclPtr = + _lookup>( + 'clang_Type_getObjCProtocolDecl', ); - late final _clang_isInvalid = _clang_isInvalidPtr - .asFunction(); + late final _clang_Type_getObjCProtocolDecl = + _clang_Type_getObjCProtocolDeclPtr + .asFunction(); - /// Determine whether the given cursor kind represents a translation unit. - int clang_isTranslationUnit(CXCursorKind arg0) { - return _clang_isTranslationUnit(arg0.value); + /// Retrieve a type argument associated with an ObjC object. + CXType clang_Type_getObjCTypeArg(CXType T, int i) { + return _clang_Type_getObjCTypeArg(T, i); } - late final _clang_isTranslationUnitPtr = - _lookup>( - 'clang_isTranslationUnit', + late final _clang_Type_getObjCTypeArgPtr = + _lookup>( + 'clang_Type_getObjCTypeArg', ); - late final _clang_isTranslationUnit = _clang_isTranslationUnitPtr - .asFunction(); + late final _clang_Type_getObjCTypeArg = _clang_Type_getObjCTypeArgPtr + .asFunction(); - /// * Determine whether the given cursor represents a preprocessing element, - /// such as a preprocessor directive or macro instantiation. - int clang_isPreprocessing(CXCursorKind arg0) { - return _clang_isPreprocessing(arg0.value); + /// Return the offset of a field named S in a record of type T in bits as it + /// would be returned by __offsetof__ as per C++11[18.2p4] + int clang_Type_getOffsetOf(CXType T, ffi.Pointer S) { + return _clang_Type_getOffsetOf(T, S); } - late final _clang_isPreprocessingPtr = - _lookup>( - 'clang_isPreprocessing', - ); - late final _clang_isPreprocessing = _clang_isPreprocessingPtr - .asFunction(); + late final _clang_Type_getOffsetOfPtr = + _lookup< + ffi.NativeFunction)> + >('clang_Type_getOffsetOf'); + late final _clang_Type_getOffsetOf = _clang_Type_getOffsetOfPtr + .asFunction)>(); - /// * Determine whether the given cursor represents a currently unexposed - /// piece of the AST (e.g., CXCursor_UnexposedStmt). - int clang_isUnexposed(CXCursorKind arg0) { - return _clang_isUnexposed(arg0.value); + /// Return the size of a type in bytes as per C++[expr.sizeof] standard. + int clang_Type_getSizeOf(CXType T) { + return _clang_Type_getSizeOf(T); } - late final _clang_isUnexposedPtr = - _lookup>( - 'clang_isUnexposed', + late final _clang_Type_getSizeOfPtr = + _lookup>( + 'clang_Type_getSizeOf', ); - late final _clang_isUnexposed = _clang_isUnexposedPtr - .asFunction(); + late final _clang_Type_getSizeOf = _clang_Type_getSizeOfPtr + .asFunction(); - /// Determine the linkage of the entity referred to by a given cursor. - CXLinkageKind clang_getCursorLinkage(CXCursor cursor) { - return CXLinkageKind.fromValue(_clang_getCursorLinkage(cursor)); + /// Returns the type template argument of a template class specialization at + /// given index. + CXType clang_Type_getTemplateArgumentAsType(CXType T, int i) { + return _clang_Type_getTemplateArgumentAsType(T, i); } - late final _clang_getCursorLinkagePtr = - _lookup>( - 'clang_getCursorLinkage', + late final _clang_Type_getTemplateArgumentAsTypePtr = + _lookup>( + 'clang_Type_getTemplateArgumentAsType', ); - late final _clang_getCursorLinkage = _clang_getCursorLinkagePtr - .asFunction(); + late final _clang_Type_getTemplateArgumentAsType = + _clang_Type_getTemplateArgumentAsTypePtr + .asFunction(); - /// Describe the visibility of the entity referred to by a cursor. - CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) { - return CXVisibilityKind.fromValue(_clang_getCursorVisibility(cursor)); + /// Determine if a typedef is 'transparent' tag. + int clang_Type_isTransparentTagTypedef(CXType T) { + return _clang_Type_isTransparentTagTypedef(T); } - late final _clang_getCursorVisibilityPtr = - _lookup>( - 'clang_getCursorVisibility', + late final _clang_Type_isTransparentTagTypedefPtr = + _lookup>( + 'clang_Type_isTransparentTagTypedef', ); - late final _clang_getCursorVisibility = _clang_getCursorVisibilityPtr - .asFunction(); + late final _clang_Type_isTransparentTagTypedef = + _clang_Type_isTransparentTagTypedefPtr.asFunction(); - /// Determine the availability of the entity that this cursor refers to, - /// taking the current target platform into account. - CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) { - return CXAvailabilityKind.fromValue(_clang_getCursorAvailability(cursor)); + /// Visit the fields of a particular type. + int clang_Type_visitFields( + CXType T, + CXFieldVisitor visitor, + CXClientData client_data, + ) { + return _clang_Type_visitFields(T, visitor, client_data); } - late final _clang_getCursorAvailabilityPtr = - _lookup>( - 'clang_getCursorAvailability', - ); - late final _clang_getCursorAvailability = _clang_getCursorAvailabilityPtr - .asFunction(); + late final _clang_Type_visitFieldsPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(CXType, CXFieldVisitor, CXClientData) + > + >('clang_Type_visitFields'); + late final _clang_Type_visitFields = _clang_Type_visitFieldsPtr + .asFunction(); - /// Determine the availability of the entity that this cursor refers to on any - /// platforms for which availability information is known. - int clang_getCursorPlatformAvailability( - CXCursor cursor, - ffi.Pointer always_deprecated, - ffi.Pointer deprecated_message, - ffi.Pointer always_unavailable, - ffi.Pointer unavailable_message, - ffi.Pointer availability, - int availability_size, + /// Map an absolute virtual file path to an absolute real one. The virtual + /// path must be canonicalized (not contain "."/".."). + CXErrorCode clang_VirtualFileOverlay_addFileMapping( + CXVirtualFileOverlay arg0, + ffi.Pointer virtualPath, + ffi.Pointer realPath, ) { - return _clang_getCursorPlatformAvailability( - cursor, - always_deprecated, - deprecated_message, - always_unavailable, - unavailable_message, - availability, - availability_size, + return CXErrorCode.fromValue( + _clang_VirtualFileOverlay_addFileMapping(arg0, virtualPath, realPath), ); } - late final _clang_getCursorPlatformAvailabilityPtr = + late final _clang_VirtualFileOverlay_addFileMappingPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - CXCursor, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, + ffi.UnsignedInt Function( + CXVirtualFileOverlay, + ffi.Pointer, + ffi.Pointer, ) > - >('clang_getCursorPlatformAvailability'); - late final _clang_getCursorPlatformAvailability = - _clang_getCursorPlatformAvailabilityPtr + >('clang_VirtualFileOverlay_addFileMapping'); + late final _clang_VirtualFileOverlay_addFileMapping = + _clang_VirtualFileOverlay_addFileMappingPtr .asFunction< int Function( - CXCursor, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, + CXVirtualFileOverlay, + ffi.Pointer, + ffi.Pointer, ) >(); - /// Free the memory associated with a CXPlatformAvailability structure. - void clang_disposeCXPlatformAvailability( - ffi.Pointer availability, - ) { - return _clang_disposeCXPlatformAvailability(availability); + /// Create a CXVirtualFileOverlay object. Must be disposed with + /// clang_VirtualFileOverlay_dispose(). + CXVirtualFileOverlay clang_VirtualFileOverlay_create(int options) { + return _clang_VirtualFileOverlay_create(options); } - late final _clang_disposeCXPlatformAvailabilityPtr = + late final _clang_VirtualFileOverlay_createPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >('clang_disposeCXPlatformAvailability'); - late final _clang_disposeCXPlatformAvailability = - _clang_disposeCXPlatformAvailabilityPtr - .asFunction)>(); - - /// Determine the "language" of the entity referred to by a given cursor. - CXLanguageKind clang_getCursorLanguage(CXCursor cursor) { - return CXLanguageKind.fromValue(_clang_getCursorLanguage(cursor)); - } - - late final _clang_getCursorLanguagePtr = - _lookup>( - 'clang_getCursorLanguage', - ); - late final _clang_getCursorLanguage = _clang_getCursorLanguagePtr - .asFunction(); - - /// Determine the "thread-local storage (TLS) kind" of the declaration - /// referred to by a cursor. - CXTLSKind clang_getCursorTLSKind(CXCursor cursor) { - return CXTLSKind.fromValue(_clang_getCursorTLSKind(cursor)); - } - - late final _clang_getCursorTLSKindPtr = - _lookup>( - 'clang_getCursorTLSKind', - ); - late final _clang_getCursorTLSKind = _clang_getCursorTLSKindPtr - .asFunction(); - - /// Returns the translation unit that a cursor originated from. - CXTranslationUnit clang_Cursor_getTranslationUnit(CXCursor arg0) { - return _clang_Cursor_getTranslationUnit(arg0); - } - - late final _clang_Cursor_getTranslationUnitPtr = - _lookup>( - 'clang_Cursor_getTranslationUnit', - ); - late final _clang_Cursor_getTranslationUnit = - _clang_Cursor_getTranslationUnitPtr - .asFunction(); - - /// Creates an empty CXCursorSet. - CXCursorSet clang_createCXCursorSet() { - return _clang_createCXCursorSet(); - } - - late final _clang_createCXCursorSetPtr = - _lookup>( - 'clang_createCXCursorSet', - ); - late final _clang_createCXCursorSet = _clang_createCXCursorSetPtr - .asFunction(); + ffi.NativeFunction + >('clang_VirtualFileOverlay_create'); + late final _clang_VirtualFileOverlay_create = + _clang_VirtualFileOverlay_createPtr + .asFunction(); - /// Disposes a CXCursorSet and releases its associated memory. - void clang_disposeCXCursorSet(CXCursorSet cset) { - return _clang_disposeCXCursorSet(cset); + /// Dispose a CXVirtualFileOverlay object. + void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay arg0) { + return _clang_VirtualFileOverlay_dispose(arg0); } - late final _clang_disposeCXCursorSetPtr = - _lookup>( - 'clang_disposeCXCursorSet', + late final _clang_VirtualFileOverlay_disposePtr = + _lookup>( + 'clang_VirtualFileOverlay_dispose', ); - late final _clang_disposeCXCursorSet = _clang_disposeCXCursorSetPtr - .asFunction(); + late final _clang_VirtualFileOverlay_dispose = + _clang_VirtualFileOverlay_disposePtr + .asFunction(); - /// Queries a CXCursorSet to see if it contains a specific CXCursor. - int clang_CXCursorSet_contains(CXCursorSet cset, CXCursor cursor) { - return _clang_CXCursorSet_contains(cset, cursor); + /// Set the case sensitivity for the CXVirtualFileOverlay object. The + /// CXVirtualFileOverlay object is case-sensitive by default, this option can + /// be used to override the default. + CXErrorCode clang_VirtualFileOverlay_setCaseSensitivity( + CXVirtualFileOverlay arg0, + int caseSensitive, + ) { + return CXErrorCode.fromValue( + _clang_VirtualFileOverlay_setCaseSensitivity(arg0, caseSensitive), + ); } - late final _clang_CXCursorSet_containsPtr = + late final _clang_VirtualFileOverlay_setCaseSensitivityPtr = _lookup< - ffi.NativeFunction - >('clang_CXCursorSet_contains'); - late final _clang_CXCursorSet_contains = _clang_CXCursorSet_containsPtr - .asFunction(); + ffi.NativeFunction< + ffi.UnsignedInt Function(CXVirtualFileOverlay, ffi.Int) + > + >('clang_VirtualFileOverlay_setCaseSensitivity'); + late final _clang_VirtualFileOverlay_setCaseSensitivity = + _clang_VirtualFileOverlay_setCaseSensitivityPtr + .asFunction(); - /// Inserts a CXCursor into a CXCursorSet. - int clang_CXCursorSet_insert(CXCursorSet cset, CXCursor cursor) { - return _clang_CXCursorSet_insert(cset, cursor); + /// Write out the CXVirtualFileOverlay object to a char buffer. + CXErrorCode clang_VirtualFileOverlay_writeToBuffer( + CXVirtualFileOverlay arg0, + int options, + ffi.Pointer> out_buffer_ptr, + ffi.Pointer out_buffer_size, + ) { + return CXErrorCode.fromValue( + _clang_VirtualFileOverlay_writeToBuffer( + arg0, + options, + out_buffer_ptr, + out_buffer_size, + ), + ); } - late final _clang_CXCursorSet_insertPtr = + late final _clang_VirtualFileOverlay_writeToBufferPtr = _lookup< - ffi.NativeFunction - >('clang_CXCursorSet_insert'); - late final _clang_CXCursorSet_insert = _clang_CXCursorSet_insertPtr - .asFunction(); - - /// Determine the semantic parent of the given cursor. - CXCursor clang_getCursorSemanticParent(CXCursor cursor) { - return _clang_getCursorSemanticParent(cursor); - } - - late final _clang_getCursorSemanticParentPtr = - _lookup>( - 'clang_getCursorSemanticParent', - ); - late final _clang_getCursorSemanticParent = _clang_getCursorSemanticParentPtr - .asFunction(); - - /// Determine the lexical parent of the given cursor. - CXCursor clang_getCursorLexicalParent(CXCursor cursor) { - return _clang_getCursorLexicalParent(cursor); - } - - late final _clang_getCursorLexicalParentPtr = - _lookup>( - 'clang_getCursorLexicalParent', - ); - late final _clang_getCursorLexicalParent = _clang_getCursorLexicalParentPtr - .asFunction(); + ffi.NativeFunction< + ffi.UnsignedInt Function( + CXVirtualFileOverlay, + ffi.UnsignedInt, + ffi.Pointer>, + ffi.Pointer, + ) + > + >('clang_VirtualFileOverlay_writeToBuffer'); + late final _clang_VirtualFileOverlay_writeToBuffer = + _clang_VirtualFileOverlay_writeToBufferPtr + .asFunction< + int Function( + CXVirtualFileOverlay, + int, + ffi.Pointer>, + ffi.Pointer, + ) + >(); - /// Determine the set of methods that are overridden by the given method. - void clang_getOverriddenCursors( - CXCursor cursor, - ffi.Pointer> overridden, - ffi.Pointer num_overridden, + /// Annotate the given set of tokens by providing cursors for each token that + /// can be mapped to a specific entity within the abstract syntax tree. + void clang_annotateTokens( + CXTranslationUnit TU, + ffi.Pointer Tokens, + int NumTokens, + ffi.Pointer Cursors, ) { - return _clang_getOverriddenCursors(cursor, overridden, num_overridden); + return _clang_annotateTokens(TU, Tokens, NumTokens, Cursors); } - late final _clang_getOverriddenCursorsPtr = + late final _clang_annotateTokensPtr = _lookup< ffi.NativeFunction< ffi.Void Function( - CXCursor, - ffi.Pointer>, - ffi.Pointer, + CXTranslationUnit, + ffi.Pointer, + ffi.UnsignedInt, + ffi.Pointer, ) > - >('clang_getOverriddenCursors'); - late final _clang_getOverriddenCursors = _clang_getOverriddenCursorsPtr + >('clang_annotateTokens'); + late final _clang_annotateTokens = _clang_annotateTokensPtr .asFunction< void Function( - CXCursor, - ffi.Pointer>, - ffi.Pointer, + CXTranslationUnit, + ffi.Pointer, + int, + ffi.Pointer, ) >(); - /// Free the set of overridden cursors returned by - /// clang_getOverriddenCursors(). - void clang_disposeOverriddenCursors(ffi.Pointer overridden) { - return _clang_disposeOverriddenCursors(overridden); + /// Perform code completion at a given location in a translation unit. + ffi.Pointer clang_codeCompleteAt( + CXTranslationUnit TU, + ffi.Pointer complete_filename, + int complete_line, + int complete_column, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ) { + return _clang_codeCompleteAt( + TU, + complete_filename, + complete_line, + complete_column, + unsaved_files, + num_unsaved_files, + options, + ); } - late final _clang_disposeOverriddenCursorsPtr = - _lookup)>>( - 'clang_disposeOverriddenCursors', - ); - late final _clang_disposeOverriddenCursors = - _clang_disposeOverriddenCursorsPtr - .asFunction)>(); + late final _clang_codeCompleteAtPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + CXTranslationUnit, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ) + > + >('clang_codeCompleteAt'); + late final _clang_codeCompleteAt = _clang_codeCompleteAtPtr + .asFunction< + ffi.Pointer Function( + CXTranslationUnit, + ffi.Pointer, + int, + int, + ffi.Pointer, + int, + int, + ) + >(); - /// Retrieve the file that is included by the given inclusion directive - /// cursor. - CXFile clang_getIncludedFile(CXCursor cursor) { - return _clang_getIncludedFile(cursor); + /// Returns the cursor kind for the container for the current code completion + /// context. The container is only guaranteed to be set for contexts where a + /// container exists (i.e. member accesses or Objective-C message sends); if + /// there is not a container, this function will return CXCursor_InvalidCode. + CXCursorKind clang_codeCompleteGetContainerKind( + ffi.Pointer Results, + ffi.Pointer IsIncomplete, + ) { + return CXCursorKind.fromValue( + _clang_codeCompleteGetContainerKind(Results, IsIncomplete), + ); } - late final _clang_getIncludedFilePtr = - _lookup>( - 'clang_getIncludedFile', - ); - late final _clang_getIncludedFile = _clang_getIncludedFilePtr - .asFunction(); + late final _clang_codeCompleteGetContainerKindPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >('clang_codeCompleteGetContainerKind'); + late final _clang_codeCompleteGetContainerKind = + _clang_codeCompleteGetContainerKindPtr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); - /// Map a source location to the cursor that describes the entity at that - /// location in the source code. - CXCursor clang_getCursor(CXTranslationUnit arg0, CXSourceLocation arg1) { - return _clang_getCursor(arg0, arg1); + /// Returns the USR for the container for the current code completion context. + /// If there is not a container for the current context, this function will + /// return the empty string. + CXString clang_codeCompleteGetContainerUSR( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetContainerUSR(Results); } - late final _clang_getCursorPtr = + late final _clang_codeCompleteGetContainerUSRPtr = _lookup< ffi.NativeFunction< - CXCursor Function(CXTranslationUnit, CXSourceLocation) + CXString Function(ffi.Pointer) > - >('clang_getCursor'); - late final _clang_getCursor = _clang_getCursorPtr - .asFunction(); + >('clang_codeCompleteGetContainerUSR'); + late final _clang_codeCompleteGetContainerUSR = + _clang_codeCompleteGetContainerUSRPtr + .asFunction)>(); - /// Retrieve the physical location of the source constructor referenced by the - /// given cursor. - CXSourceLocation clang_getCursorLocation(CXCursor arg0) { - return _clang_getCursorLocation(arg0); + /// Determines what completions are appropriate for the context the given code + /// completion. + int clang_codeCompleteGetContexts( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetContexts(Results); } - late final _clang_getCursorLocationPtr = - _lookup>( - 'clang_getCursorLocation', - ); - late final _clang_getCursorLocation = _clang_getCursorLocationPtr - .asFunction(); + late final _clang_codeCompleteGetContextsPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedLongLong Function(ffi.Pointer) + > + >('clang_codeCompleteGetContexts'); + late final _clang_codeCompleteGetContexts = _clang_codeCompleteGetContextsPtr + .asFunction)>(); - /// Retrieve the physical extent of the source construct referenced by the - /// given cursor. - CXSourceRange clang_getCursorExtent(CXCursor arg0) { - return _clang_getCursorExtent(arg0); + /// Retrieve a diagnostic associated with the given code completion. + CXDiagnostic clang_codeCompleteGetDiagnostic( + ffi.Pointer Results, + int Index, + ) { + return _clang_codeCompleteGetDiagnostic(Results, Index); } - late final _clang_getCursorExtentPtr = - _lookup>( - 'clang_getCursorExtent', - ); - late final _clang_getCursorExtent = _clang_getCursorExtentPtr - .asFunction(); + late final _clang_codeCompleteGetDiagnosticPtr = + _lookup< + ffi.NativeFunction< + CXDiagnostic Function( + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('clang_codeCompleteGetDiagnostic'); + late final _clang_codeCompleteGetDiagnostic = + _clang_codeCompleteGetDiagnosticPtr + .asFunction< + CXDiagnostic Function(ffi.Pointer, int) + >(); - /// Retrieve the type of a CXCursor (if any). - CXType clang_getCursorType(CXCursor C) { - return _clang_getCursorType(C); + /// Determine the number of diagnostics produced prior to the location where + /// code completion was performed. + int clang_codeCompleteGetNumDiagnostics( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetNumDiagnostics(Results); } - late final _clang_getCursorTypePtr = - _lookup>( - 'clang_getCursorType', - ); - late final _clang_getCursorType = _clang_getCursorTypePtr - .asFunction(); + late final _clang_codeCompleteGetNumDiagnosticsPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.Pointer) + > + >('clang_codeCompleteGetNumDiagnostics'); + late final _clang_codeCompleteGetNumDiagnostics = + _clang_codeCompleteGetNumDiagnosticsPtr + .asFunction)>(); - /// Pretty-print the underlying type using the rules of the language of the - /// translation unit from which it came. - CXString clang_getTypeSpelling(CXType CT) { - return _clang_getTypeSpelling(CT); + /// Returns the currently-entered selector for an Objective-C message send, + /// formatted like "initWithFoo:bar:". Only guaranteed to return a non-empty + /// string for CXCompletionContext_ObjCInstanceMessage and + /// CXCompletionContext_ObjCClassMessage. + CXString clang_codeCompleteGetObjCSelector( + ffi.Pointer Results, + ) { + return _clang_codeCompleteGetObjCSelector(Results); } - late final _clang_getTypeSpellingPtr = - _lookup>( - 'clang_getTypeSpelling', - ); - late final _clang_getTypeSpelling = _clang_getTypeSpellingPtr - .asFunction(); + late final _clang_codeCompleteGetObjCSelectorPtr = + _lookup< + ffi.NativeFunction< + CXString Function(ffi.Pointer) + > + >('clang_codeCompleteGetObjCSelector'); + late final _clang_codeCompleteGetObjCSelector = + _clang_codeCompleteGetObjCSelectorPtr + .asFunction)>(); - /// Retrieve the underlying type of a typedef declaration. - CXType clang_getTypedefDeclUnderlyingType(CXCursor C) { - return _clang_getTypedefDeclUnderlyingType(C); + /// Construct a USR for a specified Objective-C category. + CXString clang_constructUSR_ObjCCategory( + ffi.Pointer class_name, + ffi.Pointer category_name, + ) { + return _clang_constructUSR_ObjCCategory(class_name, category_name); } - late final _clang_getTypedefDeclUnderlyingTypePtr = - _lookup>( - 'clang_getTypedefDeclUnderlyingType', - ); - late final _clang_getTypedefDeclUnderlyingType = - _clang_getTypedefDeclUnderlyingTypePtr - .asFunction(); + late final _clang_constructUSR_ObjCCategoryPtr = + _lookup< + ffi.NativeFunction< + CXString Function(ffi.Pointer, ffi.Pointer) + > + >('clang_constructUSR_ObjCCategory'); + late final _clang_constructUSR_ObjCCategory = + _clang_constructUSR_ObjCCategoryPtr + .asFunction< + CXString Function(ffi.Pointer, ffi.Pointer) + >(); - /// Retrieve the integer type of an enum declaration. - CXType clang_getEnumDeclIntegerType(CXCursor C) { - return _clang_getEnumDeclIntegerType(C); + /// Construct a USR for a specified Objective-C class. + CXString clang_constructUSR_ObjCClass(ffi.Pointer class_name) { + return _clang_constructUSR_ObjCClass(class_name); } - late final _clang_getEnumDeclIntegerTypePtr = - _lookup>( - 'clang_getEnumDeclIntegerType', + late final _clang_constructUSR_ObjCClassPtr = + _lookup)>>( + 'clang_constructUSR_ObjCClass', ); - late final _clang_getEnumDeclIntegerType = _clang_getEnumDeclIntegerTypePtr - .asFunction(); + late final _clang_constructUSR_ObjCClass = _clang_constructUSR_ObjCClassPtr + .asFunction)>(); - /// Retrieve the integer value of an enum constant declaration as a signed - /// long long. - int clang_getEnumConstantDeclValue(CXCursor C) { - return _clang_getEnumConstantDeclValue(C); + /// Construct a USR for a specified Objective-C instance variable and the USR + /// for its containing class. + CXString clang_constructUSR_ObjCIvar( + ffi.Pointer name, + CXString classUSR, + ) { + return _clang_constructUSR_ObjCIvar(name, classUSR); } - late final _clang_getEnumConstantDeclValuePtr = - _lookup>( - 'clang_getEnumConstantDeclValue', - ); - late final _clang_getEnumConstantDeclValue = - _clang_getEnumConstantDeclValuePtr.asFunction(); + late final _clang_constructUSR_ObjCIvarPtr = + _lookup< + ffi.NativeFunction, CXString)> + >('clang_constructUSR_ObjCIvar'); + late final _clang_constructUSR_ObjCIvar = _clang_constructUSR_ObjCIvarPtr + .asFunction, CXString)>(); - /// Retrieve the integer value of an enum constant declaration as an unsigned - /// long long. - int clang_getEnumConstantDeclUnsignedValue(CXCursor C) { - return _clang_getEnumConstantDeclUnsignedValue(C); + /// Construct a USR for a specified Objective-C method and the USR for its + /// containing class. + CXString clang_constructUSR_ObjCMethod( + ffi.Pointer name, + int isInstanceMethod, + CXString classUSR, + ) { + return _clang_constructUSR_ObjCMethod(name, isInstanceMethod, classUSR); } - late final _clang_getEnumConstantDeclUnsignedValuePtr = - _lookup>( - 'clang_getEnumConstantDeclUnsignedValue', - ); - late final _clang_getEnumConstantDeclUnsignedValue = - _clang_getEnumConstantDeclUnsignedValuePtr - .asFunction(); + late final _clang_constructUSR_ObjCMethodPtr = + _lookup< + ffi.NativeFunction< + CXString Function(ffi.Pointer, ffi.UnsignedInt, CXString) + > + >('clang_constructUSR_ObjCMethod'); + late final _clang_constructUSR_ObjCMethod = _clang_constructUSR_ObjCMethodPtr + .asFunction, int, CXString)>(); - /// Retrieve the bit width of a bit field declaration as an integer. - int clang_getFieldDeclBitWidth(CXCursor C) { - return _clang_getFieldDeclBitWidth(C); + /// Construct a USR for a specified Objective-C property and the USR for its + /// containing class. + CXString clang_constructUSR_ObjCProperty( + ffi.Pointer property, + CXString classUSR, + ) { + return _clang_constructUSR_ObjCProperty(property, classUSR); } - late final _clang_getFieldDeclBitWidthPtr = - _lookup>( - 'clang_getFieldDeclBitWidth', - ); - late final _clang_getFieldDeclBitWidth = _clang_getFieldDeclBitWidthPtr - .asFunction(); + late final _clang_constructUSR_ObjCPropertyPtr = + _lookup< + ffi.NativeFunction, CXString)> + >('clang_constructUSR_ObjCProperty'); + late final _clang_constructUSR_ObjCProperty = + _clang_constructUSR_ObjCPropertyPtr + .asFunction, CXString)>(); - /// Retrieve the number of non-variadic arguments associated with a given - /// cursor. - int clang_Cursor_getNumArguments(CXCursor C) { - return _clang_Cursor_getNumArguments(C); + /// Construct a USR for a specified Objective-C protocol. + CXString clang_constructUSR_ObjCProtocol( + ffi.Pointer protocol_name, + ) { + return _clang_constructUSR_ObjCProtocol(protocol_name); } - late final _clang_Cursor_getNumArgumentsPtr = - _lookup>( - 'clang_Cursor_getNumArguments', + late final _clang_constructUSR_ObjCProtocolPtr = + _lookup)>>( + 'clang_constructUSR_ObjCProtocol', ); - late final _clang_Cursor_getNumArguments = _clang_Cursor_getNumArgumentsPtr - .asFunction(); + late final _clang_constructUSR_ObjCProtocol = + _clang_constructUSR_ObjCProtocolPtr + .asFunction)>(); - /// Retrieve the argument cursor of a function or method. - CXCursor clang_Cursor_getArgument(CXCursor C, int i) { - return _clang_Cursor_getArgument(C, i); + /// Creates an empty CXCursorSet. + CXCursorSet clang_createCXCursorSet() { + return _clang_createCXCursorSet(); } - late final _clang_Cursor_getArgumentPtr = - _lookup>( - 'clang_Cursor_getArgument', + late final _clang_createCXCursorSetPtr = + _lookup>( + 'clang_createCXCursorSet', ); - late final _clang_Cursor_getArgument = _clang_Cursor_getArgumentPtr - .asFunction(); + late final _clang_createCXCursorSet = _clang_createCXCursorSetPtr + .asFunction(); - /// Returns the number of template args of a function decl representing a - /// template specialization. - int clang_Cursor_getNumTemplateArguments(CXCursor C) { - return _clang_Cursor_getNumTemplateArguments(C); + /// Provides a shared context for creating translation units. + CXIndex clang_createIndex( + int excludeDeclarationsFromPCH, + int displayDiagnostics, + ) { + return _clang_createIndex(excludeDeclarationsFromPCH, displayDiagnostics); } - late final _clang_Cursor_getNumTemplateArgumentsPtr = - _lookup>( - 'clang_Cursor_getNumTemplateArguments', + late final _clang_createIndexPtr = + _lookup>( + 'clang_createIndex', ); - late final _clang_Cursor_getNumTemplateArguments = - _clang_Cursor_getNumTemplateArgumentsPtr - .asFunction(); + late final _clang_createIndex = _clang_createIndexPtr + .asFunction(); - /// Retrieve the kind of the I'th template argument of the CXCursor C. - CXTemplateArgumentKind clang_Cursor_getTemplateArgumentKind( - CXCursor C, - int I, + /// Same as clang_createTranslationUnit2, but returns the CXTranslationUnit + /// instead of an error code. In case of an error this routine returns a NULL + /// CXTranslationUnit, without further detailed error codes. + CXTranslationUnit clang_createTranslationUnit( + CXIndex CIdx, + ffi.Pointer ast_filename, ) { - return CXTemplateArgumentKind.fromValue( - _clang_Cursor_getTemplateArgumentKind(C, I), - ); + return _clang_createTranslationUnit(CIdx, ast_filename); } - late final _clang_Cursor_getTemplateArgumentKindPtr = + late final _clang_createTranslationUnitPtr = _lookup< - ffi.NativeFunction - >('clang_Cursor_getTemplateArgumentKind'); - late final _clang_Cursor_getTemplateArgumentKind = - _clang_Cursor_getTemplateArgumentKindPtr - .asFunction(); - - /// Retrieve a CXType representing the type of a TemplateArgument of a - /// function decl representing a template specialization. - CXType clang_Cursor_getTemplateArgumentType(CXCursor C, int I) { - return _clang_Cursor_getTemplateArgumentType(C, I); - } - - late final _clang_Cursor_getTemplateArgumentTypePtr = - _lookup>( - 'clang_Cursor_getTemplateArgumentType', - ); - late final _clang_Cursor_getTemplateArgumentType = - _clang_Cursor_getTemplateArgumentTypePtr - .asFunction(); + ffi.NativeFunction< + CXTranslationUnit Function(CXIndex, ffi.Pointer) + > + >('clang_createTranslationUnit'); + late final _clang_createTranslationUnit = _clang_createTranslationUnitPtr + .asFunction)>(); - /// Retrieve the value of an Integral TemplateArgument (of a function decl - /// representing a template specialization) as a signed long long. - int clang_Cursor_getTemplateArgumentValue(CXCursor C, int I) { - return _clang_Cursor_getTemplateArgumentValue(C, I); + /// Create a translation unit from an AST file ( -emit-ast). + CXErrorCode clang_createTranslationUnit2( + CXIndex CIdx, + ffi.Pointer ast_filename, + ffi.Pointer out_TU, + ) { + return CXErrorCode.fromValue( + _clang_createTranslationUnit2(CIdx, ast_filename, out_TU), + ); } - late final _clang_Cursor_getTemplateArgumentValuePtr = + late final _clang_createTranslationUnit2Ptr = _lookup< - ffi.NativeFunction - >('clang_Cursor_getTemplateArgumentValue'); - late final _clang_Cursor_getTemplateArgumentValue = - _clang_Cursor_getTemplateArgumentValuePtr - .asFunction(); + ffi.NativeFunction< + ffi.UnsignedInt Function( + CXIndex, + ffi.Pointer, + ffi.Pointer, + ) + > + >('clang_createTranslationUnit2'); + late final _clang_createTranslationUnit2 = _clang_createTranslationUnit2Ptr + .asFunction< + int Function( + CXIndex, + ffi.Pointer, + ffi.Pointer, + ) + >(); - /// Retrieve the value of an Integral TemplateArgument (of a function decl - /// representing a template specialization) as an unsigned long long. - int clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C, int I) { - return _clang_Cursor_getTemplateArgumentUnsignedValue(C, I); + /// Return the CXTranslationUnit for a given source file and the provided + /// command line arguments one would pass to the compiler. + CXTranslationUnit clang_createTranslationUnitFromSourceFile( + CXIndex CIdx, + ffi.Pointer source_filename, + int num_clang_command_line_args, + ffi.Pointer> clang_command_line_args, + int num_unsaved_files, + ffi.Pointer unsaved_files, + ) { + return _clang_createTranslationUnitFromSourceFile( + CIdx, + source_filename, + num_clang_command_line_args, + clang_command_line_args, + num_unsaved_files, + unsaved_files, + ); } - late final _clang_Cursor_getTemplateArgumentUnsignedValuePtr = + late final _clang_createTranslationUnitFromSourceFilePtr = _lookup< ffi.NativeFunction< - ffi.UnsignedLongLong Function(CXCursor, ffi.UnsignedInt) + CXTranslationUnit Function( + CXIndex, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.UnsignedInt, + ffi.Pointer, + ) > - >('clang_Cursor_getTemplateArgumentUnsignedValue'); - late final _clang_Cursor_getTemplateArgumentUnsignedValue = - _clang_Cursor_getTemplateArgumentUnsignedValuePtr - .asFunction(); + >('clang_createTranslationUnitFromSourceFile'); + late final _clang_createTranslationUnitFromSourceFile = + _clang_createTranslationUnitFromSourceFilePtr + .asFunction< + CXTranslationUnit Function( + CXIndex, + ffi.Pointer, + int, + ffi.Pointer>, + int, + ffi.Pointer, + ) + >(); - /// Determine whether two CXTypes represent the same type. - int clang_equalTypes(CXType A, CXType B) { - return _clang_equalTypes(A, B); + /// Returns a default set of code-completion options that can be passed to + /// clang_codeCompleteAt(). + int clang_defaultCodeCompleteOptions() { + return _clang_defaultCodeCompleteOptions(); } - late final _clang_equalTypesPtr = - _lookup>( - 'clang_equalTypes', + late final _clang_defaultCodeCompleteOptionsPtr = + _lookup>( + 'clang_defaultCodeCompleteOptions', ); - late final _clang_equalTypes = _clang_equalTypesPtr - .asFunction(); - - /// Return the canonical type for a CXType. - CXType clang_getCanonicalType(CXType T) { - return _clang_getCanonicalType(T); + late final _clang_defaultCodeCompleteOptions = + _clang_defaultCodeCompleteOptionsPtr.asFunction(); + + /// Retrieve the set of display options most similar to the default behavior + /// of the clang compiler. + int clang_defaultDiagnosticDisplayOptions() { + return _clang_defaultDiagnosticDisplayOptions(); } - late final _clang_getCanonicalTypePtr = - _lookup>( - 'clang_getCanonicalType', + late final _clang_defaultDiagnosticDisplayOptionsPtr = + _lookup>( + 'clang_defaultDiagnosticDisplayOptions', ); - late final _clang_getCanonicalType = _clang_getCanonicalTypePtr - .asFunction(); + late final _clang_defaultDiagnosticDisplayOptions = + _clang_defaultDiagnosticDisplayOptionsPtr.asFunction(); - /// Determine whether a CXType has the "const" qualifier set, without looking - /// through typedefs that may have added "const" at a different level. - int clang_isConstQualifiedType(CXType T) { - return _clang_isConstQualifiedType(T); + /// Returns the set of flags that is suitable for parsing a translation unit + /// that is being edited. + int clang_defaultEditingTranslationUnitOptions() { + return _clang_defaultEditingTranslationUnitOptions(); } - late final _clang_isConstQualifiedTypePtr = - _lookup>( - 'clang_isConstQualifiedType', + late final _clang_defaultEditingTranslationUnitOptionsPtr = + _lookup>( + 'clang_defaultEditingTranslationUnitOptions', ); - late final _clang_isConstQualifiedType = _clang_isConstQualifiedTypePtr - .asFunction(); + late final _clang_defaultEditingTranslationUnitOptions = + _clang_defaultEditingTranslationUnitOptionsPtr + .asFunction(); - /// Determine whether a CXCursor that is a macro, is function like. - int clang_Cursor_isMacroFunctionLike(CXCursor C) { - return _clang_Cursor_isMacroFunctionLike(C); + /// Returns the set of flags that is suitable for reparsing a translation + /// unit. + int clang_defaultReparseOptions(CXTranslationUnit TU) { + return _clang_defaultReparseOptions(TU); } - late final _clang_Cursor_isMacroFunctionLikePtr = - _lookup>( - 'clang_Cursor_isMacroFunctionLike', + late final _clang_defaultReparseOptionsPtr = + _lookup>( + 'clang_defaultReparseOptions', ); - late final _clang_Cursor_isMacroFunctionLike = - _clang_Cursor_isMacroFunctionLikePtr.asFunction(); + late final _clang_defaultReparseOptions = _clang_defaultReparseOptionsPtr + .asFunction(); - /// Determine whether a CXCursor that is a macro, is a builtin one. - int clang_Cursor_isMacroBuiltin(CXCursor C) { - return _clang_Cursor_isMacroBuiltin(C); + /// Returns the set of flags that is suitable for saving a translation unit. + int clang_defaultSaveOptions(CXTranslationUnit TU) { + return _clang_defaultSaveOptions(TU); } - late final _clang_Cursor_isMacroBuiltinPtr = - _lookup>( - 'clang_Cursor_isMacroBuiltin', + late final _clang_defaultSaveOptionsPtr = + _lookup>( + 'clang_defaultSaveOptions', ); - late final _clang_Cursor_isMacroBuiltin = _clang_Cursor_isMacroBuiltinPtr - .asFunction(); + late final _clang_defaultSaveOptions = _clang_defaultSaveOptionsPtr + .asFunction(); - /// Determine whether a CXCursor that is a function declaration, is an inline - /// declaration. - int clang_Cursor_isFunctionInlined(CXCursor C) { - return _clang_Cursor_isFunctionInlined(C); + /// Disposes a CXCursorSet and releases its associated memory. + void clang_disposeCXCursorSet(CXCursorSet cset) { + return _clang_disposeCXCursorSet(cset); } - late final _clang_Cursor_isFunctionInlinedPtr = - _lookup>( - 'clang_Cursor_isFunctionInlined', + late final _clang_disposeCXCursorSetPtr = + _lookup>( + 'clang_disposeCXCursorSet', ); - late final _clang_Cursor_isFunctionInlined = - _clang_Cursor_isFunctionInlinedPtr.asFunction(); + late final _clang_disposeCXCursorSet = _clang_disposeCXCursorSetPtr + .asFunction(); - /// Determine whether a CXType has the "volatile" qualifier set, without - /// looking through typedefs that may have added "volatile" at a different - /// level. - int clang_isVolatileQualifiedType(CXType T) { - return _clang_isVolatileQualifiedType(T); + /// Free the memory associated with a CXPlatformAvailability structure. + void clang_disposeCXPlatformAvailability( + ffi.Pointer availability, + ) { + return _clang_disposeCXPlatformAvailability(availability); } - late final _clang_isVolatileQualifiedTypePtr = - _lookup>( - 'clang_isVolatileQualifiedType', - ); - late final _clang_isVolatileQualifiedType = _clang_isVolatileQualifiedTypePtr - .asFunction(); + late final _clang_disposeCXPlatformAvailabilityPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >('clang_disposeCXPlatformAvailability'); + late final _clang_disposeCXPlatformAvailability = + _clang_disposeCXPlatformAvailabilityPtr + .asFunction)>(); - /// Determine whether a CXType has the "restrict" qualifier set, without - /// looking through typedefs that may have added "restrict" at a different - /// level. - int clang_isRestrictQualifiedType(CXType T) { - return _clang_isRestrictQualifiedType(T); + void clang_disposeCXTUResourceUsage(CXTUResourceUsage usage) { + return _clang_disposeCXTUResourceUsage(usage); } - late final _clang_isRestrictQualifiedTypePtr = - _lookup>( - 'clang_isRestrictQualifiedType', + late final _clang_disposeCXTUResourceUsagePtr = + _lookup>( + 'clang_disposeCXTUResourceUsage', ); - late final _clang_isRestrictQualifiedType = _clang_isRestrictQualifiedTypePtr - .asFunction(); + late final _clang_disposeCXTUResourceUsage = + _clang_disposeCXTUResourceUsagePtr + .asFunction(); - /// Returns the address space of the given type. - int clang_getAddressSpace(CXType T) { - return _clang_getAddressSpace(T); + /// Free the given set of code-completion results. + void clang_disposeCodeCompleteResults( + ffi.Pointer Results, + ) { + return _clang_disposeCodeCompleteResults(Results); } - late final _clang_getAddressSpacePtr = - _lookup>( - 'clang_getAddressSpace', - ); - late final _clang_getAddressSpace = _clang_getAddressSpacePtr - .asFunction(); + late final _clang_disposeCodeCompleteResultsPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >('clang_disposeCodeCompleteResults'); + late final _clang_disposeCodeCompleteResults = + _clang_disposeCodeCompleteResultsPtr + .asFunction)>(); - /// Returns the typedef name of the given type. - CXString clang_getTypedefName(CXType CT) { - return _clang_getTypedefName(CT); + /// Destroy a diagnostic. + void clang_disposeDiagnostic(CXDiagnostic Diagnostic) { + return _clang_disposeDiagnostic(Diagnostic); } - late final _clang_getTypedefNamePtr = - _lookup>( - 'clang_getTypedefName', + late final _clang_disposeDiagnosticPtr = + _lookup>( + 'clang_disposeDiagnostic', ); - late final _clang_getTypedefName = _clang_getTypedefNamePtr - .asFunction(); + late final _clang_disposeDiagnostic = _clang_disposeDiagnosticPtr + .asFunction(); - /// For pointer types, returns the type of the pointee. - CXType clang_getPointeeType(CXType T) { - return _clang_getPointeeType(T); + /// Release a CXDiagnosticSet and all of its contained diagnostics. + void clang_disposeDiagnosticSet(CXDiagnosticSet Diags) { + return _clang_disposeDiagnosticSet(Diags); } - late final _clang_getPointeeTypePtr = - _lookup>( - 'clang_getPointeeType', + late final _clang_disposeDiagnosticSetPtr = + _lookup>( + 'clang_disposeDiagnosticSet', ); - late final _clang_getPointeeType = _clang_getPointeeTypePtr - .asFunction(); + late final _clang_disposeDiagnosticSet = _clang_disposeDiagnosticSetPtr + .asFunction(); - /// Return the cursor for the declaration of the given type. - CXCursor clang_getTypeDeclaration(CXType T) { - return _clang_getTypeDeclaration(T); + /// Destroy the given index. + void clang_disposeIndex(CXIndex index) { + return _clang_disposeIndex(index); } - late final _clang_getTypeDeclarationPtr = - _lookup>( - 'clang_getTypeDeclaration', + late final _clang_disposeIndexPtr = + _lookup>( + 'clang_disposeIndex', ); - late final _clang_getTypeDeclaration = _clang_getTypeDeclarationPtr - .asFunction(); + late final _clang_disposeIndex = _clang_disposeIndexPtr + .asFunction(); - /// Returns the Objective-C type encoding for the specified declaration. - CXString clang_getDeclObjCTypeEncoding(CXCursor C) { - return _clang_getDeclObjCTypeEncoding(C); + /// Free the set of overridden cursors returned by + /// clang_getOverriddenCursors(). + void clang_disposeOverriddenCursors(ffi.Pointer overridden) { + return _clang_disposeOverriddenCursors(overridden); } - late final _clang_getDeclObjCTypeEncodingPtr = - _lookup>( - 'clang_getDeclObjCTypeEncoding', + late final _clang_disposeOverriddenCursorsPtr = + _lookup)>>( + 'clang_disposeOverriddenCursors', ); - late final _clang_getDeclObjCTypeEncoding = _clang_getDeclObjCTypeEncodingPtr - .asFunction(); + late final _clang_disposeOverriddenCursors = + _clang_disposeOverriddenCursorsPtr + .asFunction)>(); - /// Returns the Objective-C type encoding for the specified CXType. - CXString clang_Type_getObjCEncoding(CXType type) { - return _clang_Type_getObjCEncoding(type); + /// Destroy the given CXSourceRangeList. + void clang_disposeSourceRangeList(ffi.Pointer ranges) { + return _clang_disposeSourceRangeList(ranges); } - late final _clang_Type_getObjCEncodingPtr = - _lookup>( - 'clang_Type_getObjCEncoding', - ); - late final _clang_Type_getObjCEncoding = _clang_Type_getObjCEncodingPtr - .asFunction(); + late final _clang_disposeSourceRangeListPtr = + _lookup< + ffi.NativeFunction)> + >('clang_disposeSourceRangeList'); + late final _clang_disposeSourceRangeList = _clang_disposeSourceRangeListPtr + .asFunction)>(); - /// Retrieve the spelling of a given CXTypeKind. - CXString clang_getTypeKindSpelling(CXTypeKind K) { - return _clang_getTypeKindSpelling(K.value); + /// Free the given string. + void clang_disposeString(CXString string) { + return _clang_disposeString(string); } - late final _clang_getTypeKindSpellingPtr = - _lookup>( - 'clang_getTypeKindSpelling', + late final _clang_disposeStringPtr = + _lookup>( + 'clang_disposeString', ); - late final _clang_getTypeKindSpelling = _clang_getTypeKindSpellingPtr - .asFunction(); + late final _clang_disposeString = _clang_disposeStringPtr + .asFunction(); - /// Retrieve the calling convention associated with a function type. - CXCallingConv clang_getFunctionTypeCallingConv(CXType T) { - return CXCallingConv.fromValue(_clang_getFunctionTypeCallingConv(T)); + /// Free the given string set. + void clang_disposeStringSet(ffi.Pointer set) { + return _clang_disposeStringSet(set); } - late final _clang_getFunctionTypeCallingConvPtr = - _lookup>( - 'clang_getFunctionTypeCallingConv', + late final _clang_disposeStringSetPtr = + _lookup)>>( + 'clang_disposeStringSet', ); - late final _clang_getFunctionTypeCallingConv = - _clang_getFunctionTypeCallingConvPtr.asFunction(); + late final _clang_disposeStringSet = _clang_disposeStringSetPtr + .asFunction)>(); - /// Retrieve the return type associated with a function type. - CXType clang_getResultType(CXType T) { - return _clang_getResultType(T); + /// Free the given set of tokens. + void clang_disposeTokens( + CXTranslationUnit TU, + ffi.Pointer Tokens, + int NumTokens, + ) { + return _clang_disposeTokens(TU, Tokens, NumTokens); } - late final _clang_getResultTypePtr = - _lookup>( - 'clang_getResultType', - ); - late final _clang_getResultType = _clang_getResultTypePtr - .asFunction(); + late final _clang_disposeTokensPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + CXTranslationUnit, + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('clang_disposeTokens'); + late final _clang_disposeTokens = _clang_disposeTokensPtr + .asFunction< + void Function(CXTranslationUnit, ffi.Pointer, int) + >(); - /// Retrieve the exception specification type associated with a function type. - /// This is a value of type CXCursor_ExceptionSpecificationKind. - int clang_getExceptionSpecificationType(CXType T) { - return _clang_getExceptionSpecificationType(T); + /// Destroy the specified CXTranslationUnit object. + void clang_disposeTranslationUnit(CXTranslationUnit arg0) { + return _clang_disposeTranslationUnit(arg0); } - late final _clang_getExceptionSpecificationTypePtr = - _lookup>( - 'clang_getExceptionSpecificationType', + late final _clang_disposeTranslationUnitPtr = + _lookup>( + 'clang_disposeTranslationUnit', ); - late final _clang_getExceptionSpecificationType = - _clang_getExceptionSpecificationTypePtr - .asFunction(); + late final _clang_disposeTranslationUnit = _clang_disposeTranslationUnitPtr + .asFunction(); - /// Retrieve the number of non-variadic parameters associated with a function - /// type. - int clang_getNumArgTypes(CXType T) { - return _clang_getNumArgTypes(T); + void clang_enableStackTraces() { + return _clang_enableStackTraces(); } - late final _clang_getNumArgTypesPtr = - _lookup>( - 'clang_getNumArgTypes', + late final _clang_enableStackTracesPtr = + _lookup>( + 'clang_enableStackTraces', ); - late final _clang_getNumArgTypes = _clang_getNumArgTypesPtr - .asFunction(); + late final _clang_enableStackTraces = _clang_enableStackTracesPtr + .asFunction(); - /// Retrieve the type of a parameter of a function type. - CXType clang_getArgType(CXType T, int i) { - return _clang_getArgType(T, i); + /// Determine whether two cursors are equivalent. + int clang_equalCursors(CXCursor arg0, CXCursor arg1) { + return _clang_equalCursors(arg0, arg1); } - late final _clang_getArgTypePtr = - _lookup>( - 'clang_getArgType', + late final _clang_equalCursorsPtr = + _lookup>( + 'clang_equalCursors', ); - late final _clang_getArgType = _clang_getArgTypePtr - .asFunction(); + late final _clang_equalCursors = _clang_equalCursorsPtr + .asFunction(); - /// Retrieves the base type of the ObjCObjectType. - CXType clang_Type_getObjCObjectBaseType(CXType T) { - return _clang_Type_getObjCObjectBaseType(T); + /// Determine whether two source locations, which must refer into the same + /// translation unit, refer to exactly the same point in the source code. + int clang_equalLocations(CXSourceLocation loc1, CXSourceLocation loc2) { + return _clang_equalLocations(loc1, loc2); } - late final _clang_Type_getObjCObjectBaseTypePtr = - _lookup>( - 'clang_Type_getObjCObjectBaseType', - ); - late final _clang_Type_getObjCObjectBaseType = - _clang_Type_getObjCObjectBaseTypePtr - .asFunction(); + late final _clang_equalLocationsPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(CXSourceLocation, CXSourceLocation) + > + >('clang_equalLocations'); + late final _clang_equalLocations = _clang_equalLocationsPtr + .asFunction(); - /// Retrieve the number of protocol references associated with an ObjC - /// object/id. - int clang_Type_getNumObjCProtocolRefs(CXType T) { - return _clang_Type_getNumObjCProtocolRefs(T); + /// Determine whether two ranges are equivalent. + int clang_equalRanges(CXSourceRange range1, CXSourceRange range2) { + return _clang_equalRanges(range1, range2); } - late final _clang_Type_getNumObjCProtocolRefsPtr = - _lookup>( - 'clang_Type_getNumObjCProtocolRefs', - ); - late final _clang_Type_getNumObjCProtocolRefs = - _clang_Type_getNumObjCProtocolRefsPtr.asFunction(); + late final _clang_equalRangesPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(CXSourceRange, CXSourceRange) + > + >('clang_equalRanges'); + late final _clang_equalRanges = _clang_equalRangesPtr + .asFunction(); - /// Retrieve the decl for a protocol reference for an ObjC object/id. - CXCursor clang_Type_getObjCProtocolDecl(CXType T, int i) { - return _clang_Type_getObjCProtocolDecl(T, i); + /// Determine whether two CXTypes represent the same type. + int clang_equalTypes(CXType A, CXType B) { + return _clang_equalTypes(A, B); } - late final _clang_Type_getObjCProtocolDeclPtr = - _lookup>( - 'clang_Type_getObjCProtocolDecl', + late final _clang_equalTypesPtr = + _lookup>( + 'clang_equalTypes', ); - late final _clang_Type_getObjCProtocolDecl = - _clang_Type_getObjCProtocolDeclPtr - .asFunction(); + late final _clang_equalTypes = _clang_equalTypesPtr + .asFunction(); - /// Retreive the number of type arguments associated with an ObjC object. - int clang_Type_getNumObjCTypeArgs(CXType T) { - return _clang_Type_getNumObjCTypeArgs(T); + void clang_executeOnThread( + ffi.Pointer)>> + fn, + ffi.Pointer user_data, + int stack_size, + ) { + return _clang_executeOnThread(fn, user_data, stack_size); } - late final _clang_Type_getNumObjCTypeArgsPtr = - _lookup>( - 'clang_Type_getNumObjCTypeArgs', - ); - late final _clang_Type_getNumObjCTypeArgs = _clang_Type_getNumObjCTypeArgsPtr - .asFunction(); + late final _clang_executeOnThreadPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('clang_executeOnThread'); + late final _clang_executeOnThread = _clang_executeOnThreadPtr + .asFunction< + void Function( + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + int, + ) + >(); - /// Retrieve a type argument associated with an ObjC object. - CXType clang_Type_getObjCTypeArg(CXType T, int i) { - return _clang_Type_getObjCTypeArg(T, i); + /// Find #import/#include directives in a specific file. + CXResult clang_findIncludesInFile( + CXTranslationUnit TU, + CXFile file, + CXCursorAndRangeVisitor visitor, + ) { + return CXResult.fromValue(_clang_findIncludesInFile(TU, file, visitor)); } - late final _clang_Type_getObjCTypeArgPtr = - _lookup>( - 'clang_Type_getObjCTypeArg', - ); - late final _clang_Type_getObjCTypeArg = _clang_Type_getObjCTypeArgPtr - .asFunction(); + late final _clang_findIncludesInFilePtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function( + CXTranslationUnit, + CXFile, + CXCursorAndRangeVisitor, + ) + > + >('clang_findIncludesInFile'); + late final _clang_findIncludesInFile = _clang_findIncludesInFilePtr + .asFunction< + int Function(CXTranslationUnit, CXFile, CXCursorAndRangeVisitor) + >(); - /// Return 1 if the CXType is a variadic function type, and 0 otherwise. - int clang_isFunctionTypeVariadic(CXType T) { - return _clang_isFunctionTypeVariadic(T); + /// Find references of a declaration in a specific file. + CXResult clang_findReferencesInFile( + CXCursor cursor, + CXFile file, + CXCursorAndRangeVisitor visitor, + ) { + return CXResult.fromValue( + _clang_findReferencesInFile(cursor, file, visitor), + ); } - late final _clang_isFunctionTypeVariadicPtr = - _lookup>( - 'clang_isFunctionTypeVariadic', - ); - late final _clang_isFunctionTypeVariadic = _clang_isFunctionTypeVariadicPtr - .asFunction(); + late final _clang_findReferencesInFilePtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(CXCursor, CXFile, CXCursorAndRangeVisitor) + > + >('clang_findReferencesInFile'); + late final _clang_findReferencesInFile = _clang_findReferencesInFilePtr + .asFunction(); - /// Retrieve the return type associated with a given cursor. - CXType clang_getCursorResultType(CXCursor C) { - return _clang_getCursorResultType(C); + /// Format the given diagnostic in a manner that is suitable for display. + CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, int Options) { + return _clang_formatDiagnostic(Diagnostic, Options); } - late final _clang_getCursorResultTypePtr = - _lookup>( - 'clang_getCursorResultType', - ); - late final _clang_getCursorResultType = _clang_getCursorResultTypePtr - .asFunction(); + late final _clang_formatDiagnosticPtr = + _lookup< + ffi.NativeFunction + >('clang_formatDiagnostic'); + late final _clang_formatDiagnostic = _clang_formatDiagnosticPtr + .asFunction(); - /// Retrieve the exception specification type associated with a given cursor. - /// This is a value of type CXCursor_ExceptionSpecificationKind. - int clang_getCursorExceptionSpecificationType(CXCursor C) { - return _clang_getCursorExceptionSpecificationType(C); + /// free memory allocated by libclang, such as the buffer returned by + /// CXVirtualFileOverlay() or clang_ModuleMapDescriptor_writeToBuffer(). + void clang_free(ffi.Pointer buffer) { + return _clang_free(buffer); } - late final _clang_getCursorExceptionSpecificationTypePtr = - _lookup>( - 'clang_getCursorExceptionSpecificationType', + late final _clang_freePtr = + _lookup)>>( + 'clang_free', ); - late final _clang_getCursorExceptionSpecificationType = - _clang_getCursorExceptionSpecificationTypePtr - .asFunction(); + late final _clang_free = _clang_freePtr + .asFunction)>(); - /// Return 1 if the CXType is a POD (plain old data) type, and 0 otherwise. - int clang_isPODType(CXType T) { - return _clang_isPODType(T); + /// Returns the address space of the given type. + int clang_getAddressSpace(CXType T) { + return _clang_getAddressSpace(T); } - late final _clang_isPODTypePtr = + late final _clang_getAddressSpacePtr = _lookup>( - 'clang_isPODType', + 'clang_getAddressSpace', ); - late final _clang_isPODType = _clang_isPODTypePtr + late final _clang_getAddressSpace = _clang_getAddressSpacePtr .asFunction(); - /// Return the element type of an array, complex, or vector type. - CXType clang_getElementType(CXType T) { - return _clang_getElementType(T); + /// Retrieve all ranges from all files that were skipped by the preprocessor. + ffi.Pointer clang_getAllSkippedRanges( + CXTranslationUnit tu, + ) { + return _clang_getAllSkippedRanges(tu); } - late final _clang_getElementTypePtr = - _lookup>( - 'clang_getElementType', - ); - late final _clang_getElementType = _clang_getElementTypePtr - .asFunction(); + late final _clang_getAllSkippedRangesPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(CXTranslationUnit) + > + >('clang_getAllSkippedRanges'); + late final _clang_getAllSkippedRanges = _clang_getAllSkippedRangesPtr + .asFunction Function(CXTranslationUnit)>(); - /// Return the number of elements of an array or vector type. - int clang_getNumElements(CXType T) { - return _clang_getNumElements(T); + /// Retrieve the type of a parameter of a function type. + CXType clang_getArgType(CXType T, int i) { + return _clang_getArgType(T, i); } - late final _clang_getNumElementsPtr = - _lookup>( - 'clang_getNumElements', + late final _clang_getArgTypePtr = + _lookup>( + 'clang_getArgType', ); - late final _clang_getNumElements = _clang_getNumElementsPtr - .asFunction(); + late final _clang_getArgType = _clang_getArgTypePtr + .asFunction(); /// Return the element type of an array type. CXType clang_getArrayElementType(CXType T) { @@ -2804,484 +2516,547 @@ class LibClang { late final _clang_getArraySize = _clang_getArraySizePtr .asFunction(); - /// Retrieve the type named by the qualified-id. - CXType clang_Type_getNamedType(CXType T) { - return _clang_Type_getNamedType(T); + /// Return the timestamp for use with Clang's -fbuild-session-timestamp= + /// option. + int clang_getBuildSessionTimestamp() { + return _clang_getBuildSessionTimestamp(); } - late final _clang_Type_getNamedTypePtr = - _lookup>( - 'clang_Type_getNamedType', + late final _clang_getBuildSessionTimestampPtr = + _lookup>( + 'clang_getBuildSessionTimestamp', ); - late final _clang_Type_getNamedType = _clang_Type_getNamedTypePtr - .asFunction(); + late final _clang_getBuildSessionTimestamp = + _clang_getBuildSessionTimestampPtr.asFunction(); - /// Determine if a typedef is 'transparent' tag. - int clang_Type_isTransparentTagTypedef(CXType T) { - return _clang_Type_isTransparentTagTypedef(T); + /// Retrieve the character data associated with the given string. + ffi.Pointer clang_getCString(CXString string) { + return _clang_getCString(string); } - late final _clang_Type_isTransparentTagTypedefPtr = - _lookup>( - 'clang_Type_isTransparentTagTypedef', + late final _clang_getCStringPtr = + _lookup Function(CXString)>>( + 'clang_getCString', ); - late final _clang_Type_isTransparentTagTypedef = - _clang_Type_isTransparentTagTypedefPtr.asFunction(); + late final _clang_getCString = _clang_getCStringPtr + .asFunction Function(CXString)>(); - /// Retrieve the nullability kind of a pointer type. - CXTypeNullabilityKind clang_Type_getNullability(CXType T) { - return CXTypeNullabilityKind.fromValue(_clang_Type_getNullability(T)); + /// Return the memory usage of a translation unit. This object should be + /// released with clang_disposeCXTUResourceUsage(). + CXTUResourceUsage clang_getCXTUResourceUsage(CXTranslationUnit TU) { + return _clang_getCXTUResourceUsage(TU); } - late final _clang_Type_getNullabilityPtr = - _lookup>( - 'clang_Type_getNullability', + late final _clang_getCXTUResourceUsagePtr = + _lookup< + ffi.NativeFunction + >('clang_getCXTUResourceUsage'); + late final _clang_getCXTUResourceUsage = _clang_getCXTUResourceUsagePtr + .asFunction(); + + /// Returns the access control level for the referenced object. + CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor arg0) { + return CX_CXXAccessSpecifier.fromValue(_clang_getCXXAccessSpecifier(arg0)); + } + + late final _clang_getCXXAccessSpecifierPtr = + _lookup>( + 'clang_getCXXAccessSpecifier', ); - late final _clang_Type_getNullability = _clang_Type_getNullabilityPtr - .asFunction(); + late final _clang_getCXXAccessSpecifier = _clang_getCXXAccessSpecifierPtr + .asFunction(); - /// Return the alignment of a type in bytes as per C++[expr.alignof] standard. - int clang_Type_getAlignOf(CXType T) { - return _clang_Type_getAlignOf(T); + /// Retrieve the canonical cursor corresponding to the given cursor. + CXCursor clang_getCanonicalCursor(CXCursor arg0) { + return _clang_getCanonicalCursor(arg0); } - late final _clang_Type_getAlignOfPtr = - _lookup>( - 'clang_Type_getAlignOf', + late final _clang_getCanonicalCursorPtr = + _lookup>( + 'clang_getCanonicalCursor', ); - late final _clang_Type_getAlignOf = _clang_Type_getAlignOfPtr - .asFunction(); + late final _clang_getCanonicalCursor = _clang_getCanonicalCursorPtr + .asFunction(); - /// Return the class type of an member pointer type. - CXType clang_Type_getClassType(CXType T) { - return _clang_Type_getClassType(T); + /// Return the canonical type for a CXType. + CXType clang_getCanonicalType(CXType T) { + return _clang_getCanonicalType(T); } - late final _clang_Type_getClassTypePtr = + late final _clang_getCanonicalTypePtr = _lookup>( - 'clang_Type_getClassType', + 'clang_getCanonicalType', ); - late final _clang_Type_getClassType = _clang_Type_getClassTypePtr + late final _clang_getCanonicalType = _clang_getCanonicalTypePtr .asFunction(); - /// Return the size of a type in bytes as per C++[expr.sizeof] standard. - int clang_Type_getSizeOf(CXType T) { - return _clang_Type_getSizeOf(T); + /// Retrieve the child diagnostics of a CXDiagnostic. + CXDiagnosticSet clang_getChildDiagnostics(CXDiagnostic D) { + return _clang_getChildDiagnostics(D); } - late final _clang_Type_getSizeOfPtr = - _lookup>( - 'clang_Type_getSizeOf', + late final _clang_getChildDiagnosticsPtr = + _lookup>( + 'clang_getChildDiagnostics', ); - late final _clang_Type_getSizeOf = _clang_Type_getSizeOfPtr - .asFunction(); + late final _clang_getChildDiagnostics = _clang_getChildDiagnosticsPtr + .asFunction(); - /// Return the offset of a field named S in a record of type T in bits as it - /// would be returned by __offsetof__ as per C++11[18.2p4] - int clang_Type_getOffsetOf(CXType T, ffi.Pointer S) { - return _clang_Type_getOffsetOf(T, S); + /// Return a version string, suitable for showing to a user, but not intended + /// to be parsed (the format is not guaranteed to be stable). + CXString clang_getClangVersion() { + return _clang_getClangVersion(); } - late final _clang_Type_getOffsetOfPtr = + late final _clang_getClangVersionPtr = + _lookup>('clang_getClangVersion'); + late final _clang_getClangVersion = _clang_getClangVersionPtr + .asFunction(); + + /// Retrieve the annotation associated with the given completion string. + CXString clang_getCompletionAnnotation( + CXCompletionString completion_string, + int annotation_number, + ) { + return _clang_getCompletionAnnotation(completion_string, annotation_number); + } + + late final _clang_getCompletionAnnotationPtr = _lookup< - ffi.NativeFunction)> - >('clang_Type_getOffsetOf'); - late final _clang_Type_getOffsetOf = _clang_Type_getOffsetOfPtr - .asFunction)>(); + ffi.NativeFunction< + CXString Function(CXCompletionString, ffi.UnsignedInt) + > + >('clang_getCompletionAnnotation'); + late final _clang_getCompletionAnnotation = _clang_getCompletionAnnotationPtr + .asFunction(); - /// Return the type that was modified by this attributed type. - CXType clang_Type_getModifiedType(CXType T) { - return _clang_Type_getModifiedType(T); + /// Determine the availability of the entity that this code-completion string + /// refers to. + CXAvailabilityKind clang_getCompletionAvailability( + CXCompletionString completion_string, + ) { + return CXAvailabilityKind.fromValue( + _clang_getCompletionAvailability(completion_string), + ); } - late final _clang_Type_getModifiedTypePtr = - _lookup>( - 'clang_Type_getModifiedType', + late final _clang_getCompletionAvailabilityPtr = + _lookup>( + 'clang_getCompletionAvailability', ); - late final _clang_Type_getModifiedType = _clang_Type_getModifiedTypePtr - .asFunction(); + late final _clang_getCompletionAvailability = + _clang_getCompletionAvailabilityPtr + .asFunction(); - /// Return the offset of the field represented by the Cursor. - int clang_Cursor_getOffsetOfField(CXCursor C) { - return _clang_Cursor_getOffsetOfField(C); + /// Retrieve the brief documentation comment attached to the declaration that + /// corresponds to the given completion string. + CXString clang_getCompletionBriefComment( + CXCompletionString completion_string, + ) { + return _clang_getCompletionBriefComment(completion_string); } - late final _clang_Cursor_getOffsetOfFieldPtr = - _lookup>( - 'clang_Cursor_getOffsetOfField', + late final _clang_getCompletionBriefCommentPtr = + _lookup>( + 'clang_getCompletionBriefComment', ); - late final _clang_Cursor_getOffsetOfField = _clang_Cursor_getOffsetOfFieldPtr - .asFunction(); + late final _clang_getCompletionBriefComment = + _clang_getCompletionBriefCommentPtr + .asFunction(); - /// Determine whether the given cursor represents an anonymous tag or - /// namespace - int clang_Cursor_isAnonymous(CXCursor C) { - return _clang_Cursor_isAnonymous(C); + /// Retrieve the completion string associated with a particular chunk within a + /// completion string. + CXCompletionString clang_getCompletionChunkCompletionString( + CXCompletionString completion_string, + int chunk_number, + ) { + return _clang_getCompletionChunkCompletionString( + completion_string, + chunk_number, + ); } - late final _clang_Cursor_isAnonymousPtr = - _lookup>( - 'clang_Cursor_isAnonymous', - ); - late final _clang_Cursor_isAnonymous = _clang_Cursor_isAnonymousPtr - .asFunction(); + late final _clang_getCompletionChunkCompletionStringPtr = + _lookup< + ffi.NativeFunction< + CXCompletionString Function(CXCompletionString, ffi.UnsignedInt) + > + >('clang_getCompletionChunkCompletionString'); + late final _clang_getCompletionChunkCompletionString = + _clang_getCompletionChunkCompletionStringPtr + .asFunction(); - /// Determine whether the given cursor represents an anonymous record - /// declaration. - int clang_Cursor_isAnonymousRecordDecl(CXCursor C) { - return _clang_Cursor_isAnonymousRecordDecl(C); + /// Determine the kind of a particular chunk within a completion string. + CXCompletionChunkKind clang_getCompletionChunkKind( + CXCompletionString completion_string, + int chunk_number, + ) { + return CXCompletionChunkKind.fromValue( + _clang_getCompletionChunkKind(completion_string, chunk_number), + ); } - late final _clang_Cursor_isAnonymousRecordDeclPtr = - _lookup>( - 'clang_Cursor_isAnonymousRecordDecl', - ); - late final _clang_Cursor_isAnonymousRecordDecl = - _clang_Cursor_isAnonymousRecordDeclPtr - .asFunction(); + late final _clang_getCompletionChunkKindPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(CXCompletionString, ffi.UnsignedInt) + > + >('clang_getCompletionChunkKind'); + late final _clang_getCompletionChunkKind = _clang_getCompletionChunkKindPtr + .asFunction(); - /// Determine whether the given cursor represents an inline namespace - /// declaration. - int clang_Cursor_isInlineNamespace(CXCursor C) { - return _clang_Cursor_isInlineNamespace(C); + /// Retrieve the text associated with a particular chunk within a completion + /// string. + CXString clang_getCompletionChunkText( + CXCompletionString completion_string, + int chunk_number, + ) { + return _clang_getCompletionChunkText(completion_string, chunk_number); } - late final _clang_Cursor_isInlineNamespacePtr = - _lookup>( - 'clang_Cursor_isInlineNamespace', - ); - late final _clang_Cursor_isInlineNamespace = - _clang_Cursor_isInlineNamespacePtr.asFunction(); + late final _clang_getCompletionChunkTextPtr = + _lookup< + ffi.NativeFunction< + CXString Function(CXCompletionString, ffi.UnsignedInt) + > + >('clang_getCompletionChunkText'); + late final _clang_getCompletionChunkText = _clang_getCompletionChunkTextPtr + .asFunction(); - /// Returns the number of template arguments for given template - /// specialization, or -1 if type T is not a template specialization. - int clang_Type_getNumTemplateArguments(CXType T) { - return _clang_Type_getNumTemplateArguments(T); + /// Fix-its that *must* be applied before inserting the text for the + /// corresponding completion. + CXString clang_getCompletionFixIt( + ffi.Pointer results, + int completion_index, + int fixit_index, + ffi.Pointer replacement_range, + ) { + return _clang_getCompletionFixIt( + results, + completion_index, + fixit_index, + replacement_range, + ); } - late final _clang_Type_getNumTemplateArgumentsPtr = - _lookup>( - 'clang_Type_getNumTemplateArguments', - ); - late final _clang_Type_getNumTemplateArguments = - _clang_Type_getNumTemplateArgumentsPtr.asFunction(); + late final _clang_getCompletionFixItPtr = + _lookup< + ffi.NativeFunction< + CXString Function( + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.Pointer, + ) + > + >('clang_getCompletionFixIt'); + late final _clang_getCompletionFixIt = _clang_getCompletionFixItPtr + .asFunction< + CXString Function( + ffi.Pointer, + int, + int, + ffi.Pointer, + ) + >(); - /// Returns the type template argument of a template class specialization at - /// given index. - CXType clang_Type_getTemplateArgumentAsType(CXType T, int i) { - return _clang_Type_getTemplateArgumentAsType(T, i); + /// Retrieve the number of annotations associated with the given completion + /// string. + int clang_getCompletionNumAnnotations(CXCompletionString completion_string) { + return _clang_getCompletionNumAnnotations(completion_string); } - late final _clang_Type_getTemplateArgumentAsTypePtr = - _lookup>( - 'clang_Type_getTemplateArgumentAsType', + late final _clang_getCompletionNumAnnotationsPtr = + _lookup>( + 'clang_getCompletionNumAnnotations', ); - late final _clang_Type_getTemplateArgumentAsType = - _clang_Type_getTemplateArgumentAsTypePtr - .asFunction(); + late final _clang_getCompletionNumAnnotations = + _clang_getCompletionNumAnnotationsPtr + .asFunction(); - /// Retrieve the ref-qualifier kind of a function or method. - CXRefQualifierKind clang_Type_getCXXRefQualifier(CXType T) { - return CXRefQualifierKind.fromValue(_clang_Type_getCXXRefQualifier(T)); + /// Retrieve the number of fix-its for the given completion index. + int clang_getCompletionNumFixIts( + ffi.Pointer results, + int completion_index, + ) { + return _clang_getCompletionNumFixIts(results, completion_index); } - late final _clang_Type_getCXXRefQualifierPtr = - _lookup>( - 'clang_Type_getCXXRefQualifier', - ); - late final _clang_Type_getCXXRefQualifier = _clang_Type_getCXXRefQualifierPtr - .asFunction(); + late final _clang_getCompletionNumFixItsPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('clang_getCompletionNumFixIts'); + late final _clang_getCompletionNumFixIts = _clang_getCompletionNumFixItsPtr + .asFunction, int)>(); - /// Returns non-zero if the cursor specifies a Record member that is a - /// bitfield. - int clang_Cursor_isBitField(CXCursor C) { - return _clang_Cursor_isBitField(C); + /// Retrieve the parent context of the given completion string. + CXString clang_getCompletionParent( + CXCompletionString completion_string, + ffi.Pointer kind, + ) { + return _clang_getCompletionParent(completion_string, kind); } - late final _clang_Cursor_isBitFieldPtr = - _lookup>( - 'clang_Cursor_isBitField', - ); - late final _clang_Cursor_isBitField = _clang_Cursor_isBitFieldPtr - .asFunction(); + late final _clang_getCompletionParentPtr = + _lookup< + ffi.NativeFunction< + CXString Function(CXCompletionString, ffi.Pointer) + > + >('clang_getCompletionParent'); + late final _clang_getCompletionParent = _clang_getCompletionParentPtr + .asFunction< + CXString Function(CXCompletionString, ffi.Pointer) + >(); - /// Returns 1 if the base class specified by the cursor with kind - /// CX_CXXBaseSpecifier is virtual. - int clang_isVirtualBase(CXCursor arg0) { - return _clang_isVirtualBase(arg0); + /// Determine the priority of this code completion. + int clang_getCompletionPriority(CXCompletionString completion_string) { + return _clang_getCompletionPriority(completion_string); } - late final _clang_isVirtualBasePtr = - _lookup>( - 'clang_isVirtualBase', + late final _clang_getCompletionPriorityPtr = + _lookup>( + 'clang_getCompletionPriority', ); - late final _clang_isVirtualBase = _clang_isVirtualBasePtr - .asFunction(); + late final _clang_getCompletionPriority = _clang_getCompletionPriorityPtr + .asFunction(); - /// Returns the access control level for the referenced object. - CX_CXXAccessSpecifier clang_getCXXAccessSpecifier(CXCursor arg0) { - return CX_CXXAccessSpecifier.fromValue(_clang_getCXXAccessSpecifier(arg0)); + /// Map a source location to the cursor that describes the entity at that + /// location in the source code. + CXCursor clang_getCursor(CXTranslationUnit arg0, CXSourceLocation arg1) { + return _clang_getCursor(arg0, arg1); } - late final _clang_getCXXAccessSpecifierPtr = - _lookup>( - 'clang_getCXXAccessSpecifier', - ); - late final _clang_getCXXAccessSpecifier = _clang_getCXXAccessSpecifierPtr - .asFunction(); + late final _clang_getCursorPtr = + _lookup< + ffi.NativeFunction< + CXCursor Function(CXTranslationUnit, CXSourceLocation) + > + >('clang_getCursor'); + late final _clang_getCursor = _clang_getCursorPtr + .asFunction(); - /// Returns the storage class for a function or variable declaration. - CX_StorageClass clang_Cursor_getStorageClass(CXCursor arg0) { - return CX_StorageClass.fromValue(_clang_Cursor_getStorageClass(arg0)); + /// Determine the availability of the entity that this cursor refers to, + /// taking the current target platform into account. + CXAvailabilityKind clang_getCursorAvailability(CXCursor cursor) { + return CXAvailabilityKind.fromValue(_clang_getCursorAvailability(cursor)); } - late final _clang_Cursor_getStorageClassPtr = + late final _clang_getCursorAvailabilityPtr = _lookup>( - 'clang_Cursor_getStorageClass', + 'clang_getCursorAvailability', ); - late final _clang_Cursor_getStorageClass = _clang_Cursor_getStorageClassPtr + late final _clang_getCursorAvailability = _clang_getCursorAvailabilityPtr .asFunction(); - /// Determine the number of overloaded declarations referenced by a - /// CXCursor_OverloadedDeclRef cursor. - int clang_getNumOverloadedDecls(CXCursor cursor) { - return _clang_getNumOverloadedDecls(cursor); + /// Retrieve a completion string for an arbitrary declaration or macro + /// definition cursor. + CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { + return _clang_getCursorCompletionString(cursor); } - late final _clang_getNumOverloadedDeclsPtr = - _lookup>( - 'clang_getNumOverloadedDecls', + late final _clang_getCursorCompletionStringPtr = + _lookup>( + 'clang_getCursorCompletionString', ); - late final _clang_getNumOverloadedDecls = _clang_getNumOverloadedDeclsPtr - .asFunction(); + late final _clang_getCursorCompletionString = + _clang_getCursorCompletionStringPtr + .asFunction(); - /// Retrieve a cursor for one of the overloaded declarations referenced by a - /// CXCursor_OverloadedDeclRef cursor. - CXCursor clang_getOverloadedDecl(CXCursor cursor, int index) { - return _clang_getOverloadedDecl(cursor, index); + /// For a cursor that is either a reference to or a declaration of some + /// entity, retrieve a cursor that describes the definition of that entity. + CXCursor clang_getCursorDefinition(CXCursor arg0) { + return _clang_getCursorDefinition(arg0); } - late final _clang_getOverloadedDeclPtr = - _lookup>( - 'clang_getOverloadedDecl', + late final _clang_getCursorDefinitionPtr = + _lookup>( + 'clang_getCursorDefinition', ); - late final _clang_getOverloadedDecl = _clang_getOverloadedDeclPtr - .asFunction(); + late final _clang_getCursorDefinition = _clang_getCursorDefinitionPtr + .asFunction(); - /// For cursors representing an iboutletcollection attribute, this function - /// returns the collection element type. - CXType clang_getIBOutletCollectionType(CXCursor arg0) { - return _clang_getIBOutletCollectionType(arg0); + /// Retrieve the display name for the entity referenced by this cursor. + CXString clang_getCursorDisplayName(CXCursor arg0) { + return _clang_getCursorDisplayName(arg0); } - late final _clang_getIBOutletCollectionTypePtr = - _lookup>( - 'clang_getIBOutletCollectionType', + late final _clang_getCursorDisplayNamePtr = + _lookup>( + 'clang_getCursorDisplayName', ); - late final _clang_getIBOutletCollectionType = - _clang_getIBOutletCollectionTypePtr - .asFunction(); + late final _clang_getCursorDisplayName = _clang_getCursorDisplayNamePtr + .asFunction(); - /// Visit the children of a particular cursor. - int clang_visitChildren( - CXCursor parent, - CXCursorVisitor visitor, - CXClientData client_data, - ) { - return _clang_visitChildren(parent, visitor, client_data); + /// Retrieve the exception specification type associated with a given cursor. + /// This is a value of type CXCursor_ExceptionSpecificationKind. + int clang_getCursorExceptionSpecificationType(CXCursor C) { + return _clang_getCursorExceptionSpecificationType(C); } - late final _clang_visitChildrenPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXCursor, CXCursorVisitor, CXClientData) - > - >('clang_visitChildren'); - late final _clang_visitChildren = _clang_visitChildrenPtr - .asFunction(); + late final _clang_getCursorExceptionSpecificationTypePtr = + _lookup>( + 'clang_getCursorExceptionSpecificationType', + ); + late final _clang_getCursorExceptionSpecificationType = + _clang_getCursorExceptionSpecificationTypePtr + .asFunction(); - /// Retrieve a Unified Symbol Resolution (USR) for the entity referenced by - /// the given cursor. - CXString clang_getCursorUSR(CXCursor arg0) { - return _clang_getCursorUSR(arg0); + /// Retrieve the physical extent of the source construct referenced by the + /// given cursor. + CXSourceRange clang_getCursorExtent(CXCursor arg0) { + return _clang_getCursorExtent(arg0); } - late final _clang_getCursorUSRPtr = - _lookup>( - 'clang_getCursorUSR', + late final _clang_getCursorExtentPtr = + _lookup>( + 'clang_getCursorExtent', ); - late final _clang_getCursorUSR = _clang_getCursorUSRPtr - .asFunction(); + late final _clang_getCursorExtent = _clang_getCursorExtentPtr + .asFunction(); - /// Construct a USR for a specified Objective-C class. - CXString clang_constructUSR_ObjCClass(ffi.Pointer class_name) { - return _clang_constructUSR_ObjCClass(class_name); + /// Retrieve the kind of the given cursor. + CXCursorKind clang_getCursorKind(CXCursor arg0) { + return CXCursorKind.fromValue(_clang_getCursorKind(arg0)); } - late final _clang_constructUSR_ObjCClassPtr = - _lookup)>>( - 'clang_constructUSR_ObjCClass', + late final _clang_getCursorKindPtr = + _lookup>( + 'clang_getCursorKind', ); - late final _clang_constructUSR_ObjCClass = _clang_constructUSR_ObjCClassPtr - .asFunction)>(); + late final _clang_getCursorKind = _clang_getCursorKindPtr + .asFunction(); - /// Construct a USR for a specified Objective-C category. - CXString clang_constructUSR_ObjCCategory( - ffi.Pointer class_name, - ffi.Pointer category_name, - ) { - return _clang_constructUSR_ObjCCategory(class_name, category_name); + /// These routines are used for testing and debugging, only, and should not be + /// relied upon. + CXString clang_getCursorKindSpelling(CXCursorKind Kind) { + return _clang_getCursorKindSpelling(Kind.value); } - late final _clang_constructUSR_ObjCCategoryPtr = - _lookup< - ffi.NativeFunction< - CXString Function(ffi.Pointer, ffi.Pointer) - > - >('clang_constructUSR_ObjCCategory'); - late final _clang_constructUSR_ObjCCategory = - _clang_constructUSR_ObjCCategoryPtr - .asFunction< - CXString Function(ffi.Pointer, ffi.Pointer) - >(); + late final _clang_getCursorKindSpellingPtr = + _lookup>( + 'clang_getCursorKindSpelling', + ); + late final _clang_getCursorKindSpelling = _clang_getCursorKindSpellingPtr + .asFunction(); - /// Construct a USR for a specified Objective-C protocol. - CXString clang_constructUSR_ObjCProtocol( - ffi.Pointer protocol_name, - ) { - return _clang_constructUSR_ObjCProtocol(protocol_name); + /// Determine the "language" of the entity referred to by a given cursor. + CXLanguageKind clang_getCursorLanguage(CXCursor cursor) { + return CXLanguageKind.fromValue(_clang_getCursorLanguage(cursor)); } - late final _clang_constructUSR_ObjCProtocolPtr = - _lookup)>>( - 'clang_constructUSR_ObjCProtocol', + late final _clang_getCursorLanguagePtr = + _lookup>( + 'clang_getCursorLanguage', ); - late final _clang_constructUSR_ObjCProtocol = - _clang_constructUSR_ObjCProtocolPtr - .asFunction)>(); + late final _clang_getCursorLanguage = _clang_getCursorLanguagePtr + .asFunction(); - /// Construct a USR for a specified Objective-C instance variable and the USR - /// for its containing class. - CXString clang_constructUSR_ObjCIvar( - ffi.Pointer name, - CXString classUSR, - ) { - return _clang_constructUSR_ObjCIvar(name, classUSR); + /// Determine the lexical parent of the given cursor. + CXCursor clang_getCursorLexicalParent(CXCursor cursor) { + return _clang_getCursorLexicalParent(cursor); } - late final _clang_constructUSR_ObjCIvarPtr = - _lookup< - ffi.NativeFunction, CXString)> - >('clang_constructUSR_ObjCIvar'); - late final _clang_constructUSR_ObjCIvar = _clang_constructUSR_ObjCIvarPtr - .asFunction, CXString)>(); + late final _clang_getCursorLexicalParentPtr = + _lookup>( + 'clang_getCursorLexicalParent', + ); + late final _clang_getCursorLexicalParent = _clang_getCursorLexicalParentPtr + .asFunction(); - /// Construct a USR for a specified Objective-C method and the USR for its - /// containing class. - CXString clang_constructUSR_ObjCMethod( - ffi.Pointer name, - int isInstanceMethod, - CXString classUSR, - ) { - return _clang_constructUSR_ObjCMethod(name, isInstanceMethod, classUSR); + /// Determine the linkage of the entity referred to by a given cursor. + CXLinkageKind clang_getCursorLinkage(CXCursor cursor) { + return CXLinkageKind.fromValue(_clang_getCursorLinkage(cursor)); } - late final _clang_constructUSR_ObjCMethodPtr = - _lookup< - ffi.NativeFunction< - CXString Function(ffi.Pointer, ffi.UnsignedInt, CXString) - > - >('clang_constructUSR_ObjCMethod'); - late final _clang_constructUSR_ObjCMethod = _clang_constructUSR_ObjCMethodPtr - .asFunction, int, CXString)>(); + late final _clang_getCursorLinkagePtr = + _lookup>( + 'clang_getCursorLinkage', + ); + late final _clang_getCursorLinkage = _clang_getCursorLinkagePtr + .asFunction(); - /// Construct a USR for a specified Objective-C property and the USR for its - /// containing class. - CXString clang_constructUSR_ObjCProperty( - ffi.Pointer property, - CXString classUSR, - ) { - return _clang_constructUSR_ObjCProperty(property, classUSR); + /// Retrieve the physical location of the source constructor referenced by the + /// given cursor. + CXSourceLocation clang_getCursorLocation(CXCursor arg0) { + return _clang_getCursorLocation(arg0); } - late final _clang_constructUSR_ObjCPropertyPtr = - _lookup< - ffi.NativeFunction, CXString)> - >('clang_constructUSR_ObjCProperty'); - late final _clang_constructUSR_ObjCProperty = - _clang_constructUSR_ObjCPropertyPtr - .asFunction, CXString)>(); + late final _clang_getCursorLocationPtr = + _lookup>( + 'clang_getCursorLocation', + ); + late final _clang_getCursorLocation = _clang_getCursorLocationPtr + .asFunction(); - /// Retrieve a name for the entity referenced by this cursor. - CXString clang_getCursorSpelling(CXCursor arg0) { - return _clang_getCursorSpelling(arg0); + /// Determine the availability of the entity that this cursor refers to on any + /// platforms for which availability information is known. + int clang_getCursorPlatformAvailability( + CXCursor cursor, + ffi.Pointer always_deprecated, + ffi.Pointer deprecated_message, + ffi.Pointer always_unavailable, + ffi.Pointer unavailable_message, + ffi.Pointer availability, + int availability_size, + ) { + return _clang_getCursorPlatformAvailability( + cursor, + always_deprecated, + deprecated_message, + always_unavailable, + unavailable_message, + availability, + availability_size, + ); } - late final _clang_getCursorSpellingPtr = - _lookup>( - 'clang_getCursorSpelling', - ); - late final _clang_getCursorSpelling = _clang_getCursorSpellingPtr - .asFunction(); - - /// Retrieve a range for a piece that forms the cursors spelling name. Most of - /// the times there is only one range for the complete spelling but for - /// Objective-C methods and Objective-C message expressions, there are - /// multiple pieces for each selector identifier. - CXSourceRange clang_Cursor_getSpellingNameRange( - CXCursor arg0, - int pieceIndex, - int options, - ) { - return _clang_Cursor_getSpellingNameRange(arg0, pieceIndex, options); - } - - late final _clang_Cursor_getSpellingNameRangePtr = - _lookup< - ffi.NativeFunction< - CXSourceRange Function(CXCursor, ffi.UnsignedInt, ffi.UnsignedInt) - > - >('clang_Cursor_getSpellingNameRange'); - late final _clang_Cursor_getSpellingNameRange = - _clang_Cursor_getSpellingNameRangePtr - .asFunction(); - - /// Get a property value for the given printing policy. - int clang_PrintingPolicy_getProperty( - CXPrintingPolicy Policy, - CXPrintingPolicyProperty Property, - ) { - return _clang_PrintingPolicy_getProperty(Policy, Property.value); - } - - late final _clang_PrintingPolicy_getPropertyPtr = + late final _clang_getCursorPlatformAvailabilityPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function(CXPrintingPolicy, ffi.UnsignedInt) + ffi.Int Function( + CXCursor, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) > - >('clang_PrintingPolicy_getProperty'); - late final _clang_PrintingPolicy_getProperty = - _clang_PrintingPolicy_getPropertyPtr - .asFunction(); + >('clang_getCursorPlatformAvailability'); + late final _clang_getCursorPlatformAvailability = + _clang_getCursorPlatformAvailabilityPtr + .asFunction< + int Function( + CXCursor, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); - /// Set a property value for the given printing policy. - void clang_PrintingPolicy_setProperty( + /// Pretty print declarations. + CXString clang_getCursorPrettyPrinted( + CXCursor Cursor, CXPrintingPolicy Policy, - CXPrintingPolicyProperty Property, - int Value, ) { - return _clang_PrintingPolicy_setProperty(Policy, Property.value, Value); + return _clang_getCursorPrettyPrinted(Cursor, Policy); } - late final _clang_PrintingPolicy_setPropertyPtr = + late final _clang_getCursorPrettyPrintedPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(CXPrintingPolicy, ffi.UnsignedInt, ffi.UnsignedInt) - > - >('clang_PrintingPolicy_setProperty'); - late final _clang_PrintingPolicy_setProperty = - _clang_PrintingPolicy_setPropertyPtr - .asFunction(); + ffi.NativeFunction + >('clang_getCursorPrettyPrinted'); + late final _clang_getCursorPrettyPrinted = _clang_getCursorPrettyPrintedPtr + .asFunction(); /// Retrieve the default policy for the cursor. CXPrintingPolicy clang_getCursorPrintingPolicy(CXCursor arg0) { @@ -3295,44 +3070,25 @@ class LibClang { late final _clang_getCursorPrintingPolicy = _clang_getCursorPrintingPolicyPtr .asFunction(); - /// Release a printing policy. - void clang_PrintingPolicy_dispose(CXPrintingPolicy Policy) { - return _clang_PrintingPolicy_dispose(Policy); - } - - late final _clang_PrintingPolicy_disposePtr = - _lookup>( - 'clang_PrintingPolicy_dispose', - ); - late final _clang_PrintingPolicy_dispose = _clang_PrintingPolicy_disposePtr - .asFunction(); - - /// Pretty print declarations. - CXString clang_getCursorPrettyPrinted( - CXCursor Cursor, - CXPrintingPolicy Policy, + /// Given a cursor that references something else, return the source range + /// covering that reference. + CXSourceRange clang_getCursorReferenceNameRange( + CXCursor C, + int NameFlags, + int PieceIndex, ) { - return _clang_getCursorPrettyPrinted(Cursor, Policy); + return _clang_getCursorReferenceNameRange(C, NameFlags, PieceIndex); } - late final _clang_getCursorPrettyPrintedPtr = + late final _clang_getCursorReferenceNameRangePtr = _lookup< - ffi.NativeFunction - >('clang_getCursorPrettyPrinted'); - late final _clang_getCursorPrettyPrinted = _clang_getCursorPrettyPrintedPtr - .asFunction(); - - /// Retrieve the display name for the entity referenced by this cursor. - CXString clang_getCursorDisplayName(CXCursor arg0) { - return _clang_getCursorDisplayName(arg0); - } - - late final _clang_getCursorDisplayNamePtr = - _lookup>( - 'clang_getCursorDisplayName', - ); - late final _clang_getCursorDisplayName = _clang_getCursorDisplayNamePtr - .asFunction(); + ffi.NativeFunction< + CXSourceRange Function(CXCursor, ffi.UnsignedInt, ffi.UnsignedInt) + > + >('clang_getCursorReferenceNameRange'); + late final _clang_getCursorReferenceNameRange = + _clang_getCursorReferenceNameRangePtr + .asFunction(); /// For a cursor that is a reference, retrieve a cursor representing the /// entity that it references. @@ -3347,930 +3103,783 @@ class LibClang { late final _clang_getCursorReferenced = _clang_getCursorReferencedPtr .asFunction(); - /// For a cursor that is either a reference to or a declaration of some - /// entity, retrieve a cursor that describes the definition of that entity. - CXCursor clang_getCursorDefinition(CXCursor arg0) { - return _clang_getCursorDefinition(arg0); - } - - late final _clang_getCursorDefinitionPtr = - _lookup>( - 'clang_getCursorDefinition', - ); - late final _clang_getCursorDefinition = _clang_getCursorDefinitionPtr - .asFunction(); - - /// Determine whether the declaration pointed to by this cursor is also a - /// definition of that entity. - int clang_isCursorDefinition(CXCursor arg0) { - return _clang_isCursorDefinition(arg0); + /// Retrieve the return type associated with a given cursor. + CXType clang_getCursorResultType(CXCursor C) { + return _clang_getCursorResultType(C); } - late final _clang_isCursorDefinitionPtr = - _lookup>( - 'clang_isCursorDefinition', + late final _clang_getCursorResultTypePtr = + _lookup>( + 'clang_getCursorResultType', ); - late final _clang_isCursorDefinition = _clang_isCursorDefinitionPtr - .asFunction(); + late final _clang_getCursorResultType = _clang_getCursorResultTypePtr + .asFunction(); - /// Retrieve the canonical cursor corresponding to the given cursor. - CXCursor clang_getCanonicalCursor(CXCursor arg0) { - return _clang_getCanonicalCursor(arg0); + /// Determine the semantic parent of the given cursor. + CXCursor clang_getCursorSemanticParent(CXCursor cursor) { + return _clang_getCursorSemanticParent(cursor); } - late final _clang_getCanonicalCursorPtr = + late final _clang_getCursorSemanticParentPtr = _lookup>( - 'clang_getCanonicalCursor', + 'clang_getCursorSemanticParent', ); - late final _clang_getCanonicalCursor = _clang_getCanonicalCursorPtr + late final _clang_getCursorSemanticParent = _clang_getCursorSemanticParentPtr .asFunction(); - /// If the cursor points to a selector identifier in an Objective-C method or - /// message expression, this returns the selector index. - int clang_Cursor_getObjCSelectorIndex(CXCursor arg0) { - return _clang_Cursor_getObjCSelectorIndex(arg0); + /// Retrieve a name for the entity referenced by this cursor. + CXString clang_getCursorSpelling(CXCursor arg0) { + return _clang_getCursorSpelling(arg0); } - late final _clang_Cursor_getObjCSelectorIndexPtr = - _lookup>( - 'clang_Cursor_getObjCSelectorIndex', + late final _clang_getCursorSpellingPtr = + _lookup>( + 'clang_getCursorSpelling', ); - late final _clang_Cursor_getObjCSelectorIndex = - _clang_Cursor_getObjCSelectorIndexPtr - .asFunction(); + late final _clang_getCursorSpelling = _clang_getCursorSpellingPtr + .asFunction(); - /// Given a cursor pointing to a C++ method call or an Objective-C message, - /// returns non-zero if the method/message is "dynamic", meaning: - int clang_Cursor_isDynamicCall(CXCursor C) { - return _clang_Cursor_isDynamicCall(C); + /// Determine the "thread-local storage (TLS) kind" of the declaration + /// referred to by a cursor. + CXTLSKind clang_getCursorTLSKind(CXCursor cursor) { + return CXTLSKind.fromValue(_clang_getCursorTLSKind(cursor)); } - late final _clang_Cursor_isDynamicCallPtr = - _lookup>( - 'clang_Cursor_isDynamicCall', + late final _clang_getCursorTLSKindPtr = + _lookup>( + 'clang_getCursorTLSKind', ); - late final _clang_Cursor_isDynamicCall = _clang_Cursor_isDynamicCallPtr + late final _clang_getCursorTLSKind = _clang_getCursorTLSKindPtr .asFunction(); - /// Given a cursor pointing to an Objective-C message or property reference, - /// or C++ method call, returns the CXType of the receiver. - CXType clang_Cursor_getReceiverType(CXCursor C) { - return _clang_Cursor_getReceiverType(C); + /// Retrieve the type of a CXCursor (if any). + CXType clang_getCursorType(CXCursor C) { + return _clang_getCursorType(C); } - late final _clang_Cursor_getReceiverTypePtr = + late final _clang_getCursorTypePtr = _lookup>( - 'clang_Cursor_getReceiverType', + 'clang_getCursorType', ); - late final _clang_Cursor_getReceiverType = _clang_Cursor_getReceiverTypePtr + late final _clang_getCursorType = _clang_getCursorTypePtr .asFunction(); - /// Given a cursor that represents a property declaration, return the - /// associated property attributes. The bits are formed from - /// CXObjCPropertyAttrKind. - int clang_Cursor_getObjCPropertyAttributes(CXCursor C, int reserved) { - return _clang_Cursor_getObjCPropertyAttributes(C, reserved); - } - - late final _clang_Cursor_getObjCPropertyAttributesPtr = - _lookup< - ffi.NativeFunction - >('clang_Cursor_getObjCPropertyAttributes'); - late final _clang_Cursor_getObjCPropertyAttributes = - _clang_Cursor_getObjCPropertyAttributesPtr - .asFunction(); - - /// Given a cursor that represents a property declaration, return the name of - /// the method that implements the getter. - CXString clang_Cursor_getObjCPropertyGetterName(CXCursor C) { - return _clang_Cursor_getObjCPropertyGetterName(C); + /// Retrieve a Unified Symbol Resolution (USR) for the entity referenced by + /// the given cursor. + CXString clang_getCursorUSR(CXCursor arg0) { + return _clang_getCursorUSR(arg0); } - late final _clang_Cursor_getObjCPropertyGetterNamePtr = + late final _clang_getCursorUSRPtr = _lookup>( - 'clang_Cursor_getObjCPropertyGetterName', + 'clang_getCursorUSR', ); - late final _clang_Cursor_getObjCPropertyGetterName = - _clang_Cursor_getObjCPropertyGetterNamePtr - .asFunction(); + late final _clang_getCursorUSR = _clang_getCursorUSRPtr + .asFunction(); - /// Given a cursor that represents a property declaration, return the name of - /// the method that implements the setter, if any. - CXString clang_Cursor_getObjCPropertySetterName(CXCursor C) { - return _clang_Cursor_getObjCPropertySetterName(C); - } - - late final _clang_Cursor_getObjCPropertySetterNamePtr = - _lookup>( - 'clang_Cursor_getObjCPropertySetterName', - ); - late final _clang_Cursor_getObjCPropertySetterName = - _clang_Cursor_getObjCPropertySetterNamePtr - .asFunction(); - - /// Given a cursor that represents an Objective-C method or parameter - /// declaration, return the associated Objective-C qualifiers for the return - /// type or the parameter respectively. The bits are formed from - /// CXObjCDeclQualifierKind. - int clang_Cursor_getObjCDeclQualifiers(CXCursor C) { - return _clang_Cursor_getObjCDeclQualifiers(C); - } - - late final _clang_Cursor_getObjCDeclQualifiersPtr = - _lookup>( - 'clang_Cursor_getObjCDeclQualifiers', - ); - late final _clang_Cursor_getObjCDeclQualifiers = - _clang_Cursor_getObjCDeclQualifiersPtr - .asFunction(); - - /// Given a cursor that represents an Objective-C method or property - /// declaration, return non-zero if the declaration was affected by - /// "\@optional". Returns zero if the cursor is not such a declaration or it - /// is "\@required". - int clang_Cursor_isObjCOptional(CXCursor C) { - return _clang_Cursor_isObjCOptional(C); + /// Describe the visibility of the entity referred to by a cursor. + CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) { + return CXVisibilityKind.fromValue(_clang_getCursorVisibility(cursor)); } - late final _clang_Cursor_isObjCOptionalPtr = + late final _clang_getCursorVisibilityPtr = _lookup>( - 'clang_Cursor_isObjCOptional', + 'clang_getCursorVisibility', ); - late final _clang_Cursor_isObjCOptional = _clang_Cursor_isObjCOptionalPtr + late final _clang_getCursorVisibility = _clang_getCursorVisibilityPtr .asFunction(); - /// Returns non-zero if the given cursor is a variadic function or method. - int clang_Cursor_isVariadic(CXCursor C) { - return _clang_Cursor_isVariadic(C); + /// Returns the Objective-C type encoding for the specified declaration. + CXString clang_getDeclObjCTypeEncoding(CXCursor C) { + return _clang_getDeclObjCTypeEncoding(C); } - late final _clang_Cursor_isVariadicPtr = - _lookup>( - 'clang_Cursor_isVariadic', + late final _clang_getDeclObjCTypeEncodingPtr = + _lookup>( + 'clang_getDeclObjCTypeEncoding', ); - late final _clang_Cursor_isVariadic = _clang_Cursor_isVariadicPtr - .asFunction(); + late final _clang_getDeclObjCTypeEncoding = _clang_getDeclObjCTypeEncodingPtr + .asFunction(); - /// Returns non-zero if the given cursor points to a symbol marked with - /// external_source_symbol attribute. - int clang_Cursor_isExternalSymbol( - CXCursor C, - ffi.Pointer language, - ffi.Pointer definedIn, - ffi.Pointer isGenerated, + void clang_getDefinitionSpellingAndExtent( + CXCursor arg0, + ffi.Pointer> startBuf, + ffi.Pointer> endBuf, + ffi.Pointer startLine, + ffi.Pointer startColumn, + ffi.Pointer endLine, + ffi.Pointer endColumn, ) { - return _clang_Cursor_isExternalSymbol(C, language, definedIn, isGenerated); + return _clang_getDefinitionSpellingAndExtent( + arg0, + startBuf, + endBuf, + startLine, + startColumn, + endLine, + endColumn, + ); } - late final _clang_Cursor_isExternalSymbolPtr = + late final _clang_getDefinitionSpellingAndExtentPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function( + ffi.Void Function( CXCursor, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ffi.Pointer, ) > - >('clang_Cursor_isExternalSymbol'); - late final _clang_Cursor_isExternalSymbol = _clang_Cursor_isExternalSymbolPtr - .asFunction< - int Function( - CXCursor, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('clang_getDefinitionSpellingAndExtent'); + late final _clang_getDefinitionSpellingAndExtent = + _clang_getDefinitionSpellingAndExtentPtr + .asFunction< + void Function( + CXCursor, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - /// Given a cursor that represents a declaration, return the associated - /// comment's source range. The range may include multiple consecutive - /// comments with whitespace in between. - CXSourceRange clang_Cursor_getCommentRange(CXCursor C) { - return _clang_Cursor_getCommentRange(C); + /// Retrieve a diagnostic associated with the given translation unit. + CXDiagnostic clang_getDiagnostic(CXTranslationUnit Unit, int Index) { + return _clang_getDiagnostic(Unit, Index); } - late final _clang_Cursor_getCommentRangePtr = - _lookup>( - 'clang_Cursor_getCommentRange', - ); - late final _clang_Cursor_getCommentRange = _clang_Cursor_getCommentRangePtr - .asFunction(); + late final _clang_getDiagnosticPtr = + _lookup< + ffi.NativeFunction< + CXDiagnostic Function(CXTranslationUnit, ffi.UnsignedInt) + > + >('clang_getDiagnostic'); + late final _clang_getDiagnostic = _clang_getDiagnosticPtr + .asFunction(); - /// Given a cursor that represents a declaration, return the associated - /// comment text, including comment markers. - CXString clang_Cursor_getRawCommentText(CXCursor C) { - return _clang_Cursor_getRawCommentText(C); + /// Retrieve the category number for this diagnostic. + int clang_getDiagnosticCategory(CXDiagnostic arg0) { + return _clang_getDiagnosticCategory(arg0); } - late final _clang_Cursor_getRawCommentTextPtr = - _lookup>( - 'clang_Cursor_getRawCommentText', + late final _clang_getDiagnosticCategoryPtr = + _lookup>( + 'clang_getDiagnosticCategory', ); - late final _clang_Cursor_getRawCommentText = - _clang_Cursor_getRawCommentTextPtr - .asFunction(); + late final _clang_getDiagnosticCategory = _clang_getDiagnosticCategoryPtr + .asFunction(); - /// Given a cursor that represents a documentable entity (e.g., declaration), - /// return the associated first paragraph. - CXString clang_Cursor_getBriefCommentText(CXCursor C) { - return _clang_Cursor_getBriefCommentText(C); + /// Retrieve the name of a particular diagnostic category. This is now + /// deprecated. Use clang_getDiagnosticCategoryText() instead. + CXString clang_getDiagnosticCategoryName(int Category) { + return _clang_getDiagnosticCategoryName(Category); } - late final _clang_Cursor_getBriefCommentTextPtr = - _lookup>( - 'clang_Cursor_getBriefCommentText', + late final _clang_getDiagnosticCategoryNamePtr = + _lookup>( + 'clang_getDiagnosticCategoryName', ); - late final _clang_Cursor_getBriefCommentText = - _clang_Cursor_getBriefCommentTextPtr - .asFunction(); + late final _clang_getDiagnosticCategoryName = + _clang_getDiagnosticCategoryNamePtr.asFunction(); - /// Retrieve the CXString representing the mangled name of the cursor. - CXString clang_Cursor_getMangling(CXCursor arg0) { - return _clang_Cursor_getMangling(arg0); + /// Retrieve the diagnostic category text for a given diagnostic. + CXString clang_getDiagnosticCategoryText(CXDiagnostic arg0) { + return _clang_getDiagnosticCategoryText(arg0); } - late final _clang_Cursor_getManglingPtr = - _lookup>( - 'clang_Cursor_getMangling', + late final _clang_getDiagnosticCategoryTextPtr = + _lookup>( + 'clang_getDiagnosticCategoryText', ); - late final _clang_Cursor_getMangling = _clang_Cursor_getManglingPtr - .asFunction(); + late final _clang_getDiagnosticCategoryText = + _clang_getDiagnosticCategoryTextPtr + .asFunction(); - /// Retrieve the CXStrings representing the mangled symbols of the C++ - /// constructor or destructor at the cursor. - ffi.Pointer clang_Cursor_getCXXManglings(CXCursor arg0) { - return _clang_Cursor_getCXXManglings(arg0); + /// Retrieve the replacement information for a given fix-it. + CXString clang_getDiagnosticFixIt( + CXDiagnostic Diagnostic, + int FixIt, + ffi.Pointer ReplacementRange, + ) { + return _clang_getDiagnosticFixIt(Diagnostic, FixIt, ReplacementRange); } - late final _clang_Cursor_getCXXManglingsPtr = - _lookup Function(CXCursor)>>( - 'clang_Cursor_getCXXManglings', - ); - late final _clang_Cursor_getCXXManglings = _clang_Cursor_getCXXManglingsPtr - .asFunction Function(CXCursor)>(); + late final _clang_getDiagnosticFixItPtr = + _lookup< + ffi.NativeFunction< + CXString Function( + CXDiagnostic, + ffi.UnsignedInt, + ffi.Pointer, + ) + > + >('clang_getDiagnosticFixIt'); + late final _clang_getDiagnosticFixIt = _clang_getDiagnosticFixItPtr + .asFunction< + CXString Function(CXDiagnostic, int, ffi.Pointer) + >(); - /// Retrieve the CXStrings representing the mangled symbols of the ObjC class - /// interface or implementation at the cursor. - ffi.Pointer clang_Cursor_getObjCManglings(CXCursor arg0) { - return _clang_Cursor_getObjCManglings(arg0); + /// Retrieve a diagnostic associated with the given CXDiagnosticSet. + CXDiagnostic clang_getDiagnosticInSet(CXDiagnosticSet Diags, int Index) { + return _clang_getDiagnosticInSet(Diags, Index); } - late final _clang_Cursor_getObjCManglingsPtr = - _lookup Function(CXCursor)>>( - 'clang_Cursor_getObjCManglings', - ); - late final _clang_Cursor_getObjCManglings = _clang_Cursor_getObjCManglingsPtr - .asFunction Function(CXCursor)>(); + late final _clang_getDiagnosticInSetPtr = + _lookup< + ffi.NativeFunction< + CXDiagnostic Function(CXDiagnosticSet, ffi.UnsignedInt) + > + >('clang_getDiagnosticInSet'); + late final _clang_getDiagnosticInSet = _clang_getDiagnosticInSetPtr + .asFunction(); - /// Given a CXCursor_ModuleImportDecl cursor, return the associated module. - CXModule clang_Cursor_getModule(CXCursor C) { - return _clang_Cursor_getModule(C); + /// Retrieve the source location of the given diagnostic. + CXSourceLocation clang_getDiagnosticLocation(CXDiagnostic arg0) { + return _clang_getDiagnosticLocation(arg0); } - late final _clang_Cursor_getModulePtr = - _lookup>( - 'clang_Cursor_getModule', - ); - late final _clang_Cursor_getModule = _clang_Cursor_getModulePtr - .asFunction(); - - /// Given a CXFile header file, return the module that contains it, if one - /// exists. - CXModule clang_getModuleForFile(CXTranslationUnit arg0, CXFile arg1) { - return _clang_getModuleForFile(arg0, arg1); - } - - late final _clang_getModuleForFilePtr = - _lookup>( - 'clang_getModuleForFile', - ); - late final _clang_getModuleForFile = _clang_getModuleForFilePtr - .asFunction(); - - /// Returns the module file where the provided module object came from. - CXFile clang_Module_getASTFile(CXModule Module) { - return _clang_Module_getASTFile(Module); - } - - late final _clang_Module_getASTFilePtr = - _lookup>( - 'clang_Module_getASTFile', - ); - late final _clang_Module_getASTFile = _clang_Module_getASTFilePtr - .asFunction(); - - /// Returns the parent of a sub-module or NULL if the given module is - /// top-level, e.g. for 'std.vector' it will return the 'std' module. - CXModule clang_Module_getParent(CXModule Module) { - return _clang_Module_getParent(Module); - } - - late final _clang_Module_getParentPtr = - _lookup>( - 'clang_Module_getParent', - ); - late final _clang_Module_getParent = _clang_Module_getParentPtr - .asFunction(); - - /// Returns the name of the module, e.g. for the 'std.vector' sub-module it - /// will return "vector". - CXString clang_Module_getName(CXModule Module) { - return _clang_Module_getName(Module); - } - - late final _clang_Module_getNamePtr = - _lookup>( - 'clang_Module_getName', + late final _clang_getDiagnosticLocationPtr = + _lookup>( + 'clang_getDiagnosticLocation', ); - late final _clang_Module_getName = _clang_Module_getNamePtr - .asFunction(); + late final _clang_getDiagnosticLocation = _clang_getDiagnosticLocationPtr + .asFunction(); - /// Returns the full name of the module, e.g. "std.vector". - CXString clang_Module_getFullName(CXModule Module) { - return _clang_Module_getFullName(Module); + /// Determine the number of fix-it hints associated with the given diagnostic. + int clang_getDiagnosticNumFixIts(CXDiagnostic Diagnostic) { + return _clang_getDiagnosticNumFixIts(Diagnostic); } - late final _clang_Module_getFullNamePtr = - _lookup>( - 'clang_Module_getFullName', + late final _clang_getDiagnosticNumFixItsPtr = + _lookup>( + 'clang_getDiagnosticNumFixIts', ); - late final _clang_Module_getFullName = _clang_Module_getFullNamePtr - .asFunction(); + late final _clang_getDiagnosticNumFixIts = _clang_getDiagnosticNumFixItsPtr + .asFunction(); - /// Returns non-zero if the module is a system one. - int clang_Module_isSystem(CXModule Module) { - return _clang_Module_isSystem(Module); + /// Determine the number of source ranges associated with the given + /// diagnostic. + int clang_getDiagnosticNumRanges(CXDiagnostic arg0) { + return _clang_getDiagnosticNumRanges(arg0); } - late final _clang_Module_isSystemPtr = - _lookup>( - 'clang_Module_isSystem', + late final _clang_getDiagnosticNumRangesPtr = + _lookup>( + 'clang_getDiagnosticNumRanges', ); - late final _clang_Module_isSystem = _clang_Module_isSystemPtr - .asFunction(); + late final _clang_getDiagnosticNumRanges = _clang_getDiagnosticNumRangesPtr + .asFunction(); - /// Returns the number of top level headers associated with this module. - int clang_Module_getNumTopLevelHeaders( - CXTranslationUnit arg0, - CXModule Module, + /// Retrieve the name of the command-line option that enabled this diagnostic. + CXString clang_getDiagnosticOption( + CXDiagnostic Diag, + ffi.Pointer Disable, ) { - return _clang_Module_getNumTopLevelHeaders(arg0, Module); + return _clang_getDiagnosticOption(Diag, Disable); } - late final _clang_Module_getNumTopLevelHeadersPtr = + late final _clang_getDiagnosticOptionPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function(CXTranslationUnit, CXModule) + CXString Function(CXDiagnostic, ffi.Pointer) > - >('clang_Module_getNumTopLevelHeaders'); - late final _clang_Module_getNumTopLevelHeaders = - _clang_Module_getNumTopLevelHeadersPtr - .asFunction(); + >('clang_getDiagnosticOption'); + late final _clang_getDiagnosticOption = _clang_getDiagnosticOptionPtr + .asFunction)>(); - /// Returns the specified top level header associated with the module. - CXFile clang_Module_getTopLevelHeader( - CXTranslationUnit arg0, - CXModule Module, - int Index, - ) { - return _clang_Module_getTopLevelHeader(arg0, Module, Index); + /// Retrieve a source range associated with the diagnostic. + CXSourceRange clang_getDiagnosticRange(CXDiagnostic Diagnostic, int Range) { + return _clang_getDiagnosticRange(Diagnostic, Range); } - late final _clang_Module_getTopLevelHeaderPtr = + late final _clang_getDiagnosticRangePtr = _lookup< ffi.NativeFunction< - CXFile Function(CXTranslationUnit, CXModule, ffi.UnsignedInt) + CXSourceRange Function(CXDiagnostic, ffi.UnsignedInt) > - >('clang_Module_getTopLevelHeader'); - late final _clang_Module_getTopLevelHeader = - _clang_Module_getTopLevelHeaderPtr - .asFunction(); + >('clang_getDiagnosticRange'); + late final _clang_getDiagnosticRange = _clang_getDiagnosticRangePtr + .asFunction(); - /// Determine if a C++ constructor is a converting constructor. - int clang_CXXConstructor_isConvertingConstructor(CXCursor C) { - return _clang_CXXConstructor_isConvertingConstructor(C); + /// Retrieve the complete set of diagnostics associated with a translation + /// unit. + CXDiagnosticSet clang_getDiagnosticSetFromTU(CXTranslationUnit Unit) { + return _clang_getDiagnosticSetFromTU(Unit); } - late final _clang_CXXConstructor_isConvertingConstructorPtr = - _lookup>( - 'clang_CXXConstructor_isConvertingConstructor', + late final _clang_getDiagnosticSetFromTUPtr = + _lookup>( + 'clang_getDiagnosticSetFromTU', ); - late final _clang_CXXConstructor_isConvertingConstructor = - _clang_CXXConstructor_isConvertingConstructorPtr - .asFunction(); + late final _clang_getDiagnosticSetFromTU = _clang_getDiagnosticSetFromTUPtr + .asFunction(); - /// Determine if a C++ constructor is a copy constructor. - int clang_CXXConstructor_isCopyConstructor(CXCursor C) { - return _clang_CXXConstructor_isCopyConstructor(C); + /// Determine the severity of the given diagnostic. + CXDiagnosticSeverity clang_getDiagnosticSeverity(CXDiagnostic arg0) { + return CXDiagnosticSeverity.fromValue(_clang_getDiagnosticSeverity(arg0)); } - late final _clang_CXXConstructor_isCopyConstructorPtr = - _lookup>( - 'clang_CXXConstructor_isCopyConstructor', + late final _clang_getDiagnosticSeverityPtr = + _lookup>( + 'clang_getDiagnosticSeverity', ); - late final _clang_CXXConstructor_isCopyConstructor = - _clang_CXXConstructor_isCopyConstructorPtr - .asFunction(); + late final _clang_getDiagnosticSeverity = _clang_getDiagnosticSeverityPtr + .asFunction(); - /// Determine if a C++ constructor is the default constructor. - int clang_CXXConstructor_isDefaultConstructor(CXCursor C) { - return _clang_CXXConstructor_isDefaultConstructor(C); + /// Retrieve the text of the given diagnostic. + CXString clang_getDiagnosticSpelling(CXDiagnostic arg0) { + return _clang_getDiagnosticSpelling(arg0); } - late final _clang_CXXConstructor_isDefaultConstructorPtr = - _lookup>( - 'clang_CXXConstructor_isDefaultConstructor', + late final _clang_getDiagnosticSpellingPtr = + _lookup>( + 'clang_getDiagnosticSpelling', ); - late final _clang_CXXConstructor_isDefaultConstructor = - _clang_CXXConstructor_isDefaultConstructorPtr - .asFunction(); + late final _clang_getDiagnosticSpelling = _clang_getDiagnosticSpellingPtr + .asFunction(); - /// Determine if a C++ constructor is a move constructor. - int clang_CXXConstructor_isMoveConstructor(CXCursor C) { - return _clang_CXXConstructor_isMoveConstructor(C); + /// Return the element type of an array, complex, or vector type. + CXType clang_getElementType(CXType T) { + return _clang_getElementType(T); } - late final _clang_CXXConstructor_isMoveConstructorPtr = - _lookup>( - 'clang_CXXConstructor_isMoveConstructor', + late final _clang_getElementTypePtr = + _lookup>( + 'clang_getElementType', ); - late final _clang_CXXConstructor_isMoveConstructor = - _clang_CXXConstructor_isMoveConstructorPtr - .asFunction(); + late final _clang_getElementType = _clang_getElementTypePtr + .asFunction(); - /// Determine if a C++ field is declared 'mutable'. - int clang_CXXField_isMutable(CXCursor C) { - return _clang_CXXField_isMutable(C); + /// Retrieve the integer value of an enum constant declaration as an unsigned + /// long long. + int clang_getEnumConstantDeclUnsignedValue(CXCursor C) { + return _clang_getEnumConstantDeclUnsignedValue(C); } - late final _clang_CXXField_isMutablePtr = - _lookup>( - 'clang_CXXField_isMutable', + late final _clang_getEnumConstantDeclUnsignedValuePtr = + _lookup>( + 'clang_getEnumConstantDeclUnsignedValue', ); - late final _clang_CXXField_isMutable = _clang_CXXField_isMutablePtr - .asFunction(); + late final _clang_getEnumConstantDeclUnsignedValue = + _clang_getEnumConstantDeclUnsignedValuePtr + .asFunction(); - /// Determine if a C++ method is declared '= default'. - int clang_CXXMethod_isDefaulted(CXCursor C) { - return _clang_CXXMethod_isDefaulted(C); + /// Retrieve the integer value of an enum constant declaration as a signed + /// long long. + int clang_getEnumConstantDeclValue(CXCursor C) { + return _clang_getEnumConstantDeclValue(C); } - late final _clang_CXXMethod_isDefaultedPtr = - _lookup>( - 'clang_CXXMethod_isDefaulted', + late final _clang_getEnumConstantDeclValuePtr = + _lookup>( + 'clang_getEnumConstantDeclValue', ); - late final _clang_CXXMethod_isDefaulted = _clang_CXXMethod_isDefaultedPtr - .asFunction(); + late final _clang_getEnumConstantDeclValue = + _clang_getEnumConstantDeclValuePtr.asFunction(); - /// Determine if a C++ member function or member function template is pure - /// virtual. - int clang_CXXMethod_isPureVirtual(CXCursor C) { - return _clang_CXXMethod_isPureVirtual(C); + /// Retrieve the integer type of an enum declaration. + CXType clang_getEnumDeclIntegerType(CXCursor C) { + return _clang_getEnumDeclIntegerType(C); } - late final _clang_CXXMethod_isPureVirtualPtr = - _lookup>( - 'clang_CXXMethod_isPureVirtual', + late final _clang_getEnumDeclIntegerTypePtr = + _lookup>( + 'clang_getEnumDeclIntegerType', ); - late final _clang_CXXMethod_isPureVirtual = _clang_CXXMethod_isPureVirtualPtr - .asFunction(); + late final _clang_getEnumDeclIntegerType = _clang_getEnumDeclIntegerTypePtr + .asFunction(); - /// Determine if a C++ member function or member function template is declared - /// 'static'. - int clang_CXXMethod_isStatic(CXCursor C) { - return _clang_CXXMethod_isStatic(C); - } - - late final _clang_CXXMethod_isStaticPtr = - _lookup>( - 'clang_CXXMethod_isStatic', - ); - late final _clang_CXXMethod_isStatic = _clang_CXXMethod_isStaticPtr - .asFunction(); - - /// Determine if a C++ member function or member function template is - /// explicitly declared 'virtual' or if it overrides a virtual method from one - /// of the base classes. - int clang_CXXMethod_isVirtual(CXCursor C) { - return _clang_CXXMethod_isVirtual(C); - } - - late final _clang_CXXMethod_isVirtualPtr = - _lookup>( - 'clang_CXXMethod_isVirtual', - ); - late final _clang_CXXMethod_isVirtual = _clang_CXXMethod_isVirtualPtr - .asFunction(); - - /// Determine if a C++ record is abstract, i.e. whether a class or struct has - /// a pure virtual member function. - int clang_CXXRecord_isAbstract(CXCursor C) { - return _clang_CXXRecord_isAbstract(C); - } - - late final _clang_CXXRecord_isAbstractPtr = - _lookup>( - 'clang_CXXRecord_isAbstract', - ); - late final _clang_CXXRecord_isAbstract = _clang_CXXRecord_isAbstractPtr - .asFunction(); - - /// Determine if an enum declaration refers to a scoped enum. - int clang_EnumDecl_isScoped(CXCursor C) { - return _clang_EnumDecl_isScoped(C); + /// Retrieve the exception specification type associated with a function type. + /// This is a value of type CXCursor_ExceptionSpecificationKind. + int clang_getExceptionSpecificationType(CXType T) { + return _clang_getExceptionSpecificationType(T); } - late final _clang_EnumDecl_isScopedPtr = - _lookup>( - 'clang_EnumDecl_isScoped', + late final _clang_getExceptionSpecificationTypePtr = + _lookup>( + 'clang_getExceptionSpecificationType', ); - late final _clang_EnumDecl_isScoped = _clang_EnumDecl_isScopedPtr - .asFunction(); + late final _clang_getExceptionSpecificationType = + _clang_getExceptionSpecificationTypePtr + .asFunction(); - /// Determine if a C++ member function or member function template is declared - /// 'const'. - int clang_CXXMethod_isConst(CXCursor C) { - return _clang_CXXMethod_isConst(C); + /// Retrieve the file, line, column, and offset represented by the given + /// source location. + void clang_getExpansionLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, + ) { + return _clang_getExpansionLocation(location, file, line, column, offset); } - late final _clang_CXXMethod_isConstPtr = - _lookup>( - 'clang_CXXMethod_isConst', - ); - late final _clang_CXXMethod_isConst = _clang_CXXMethod_isConstPtr - .asFunction(); + late final _clang_getExpansionLocationPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('clang_getExpansionLocation'); + late final _clang_getExpansionLocation = _clang_getExpansionLocationPtr + .asFunction< + void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - /// Given a cursor that represents a template, determine the cursor kind of - /// the specializations would be generated by instantiating the template. - CXCursorKind clang_getTemplateCursorKind(CXCursor C) { - return CXCursorKind.fromValue(_clang_getTemplateCursorKind(C)); + /// Retrieve the bit width of a bit field declaration as an integer. + int clang_getFieldDeclBitWidth(CXCursor C) { + return _clang_getFieldDeclBitWidth(C); } - late final _clang_getTemplateCursorKindPtr = - _lookup>( - 'clang_getTemplateCursorKind', + late final _clang_getFieldDeclBitWidthPtr = + _lookup>( + 'clang_getFieldDeclBitWidth', ); - late final _clang_getTemplateCursorKind = _clang_getTemplateCursorKindPtr + late final _clang_getFieldDeclBitWidth = _clang_getFieldDeclBitWidthPtr .asFunction(); - /// Given a cursor that may represent a specialization or instantiation of a - /// template, retrieve the cursor that represents the template that it - /// specializes or from which it was instantiated. - CXCursor clang_getSpecializedCursorTemplate(CXCursor C) { - return _clang_getSpecializedCursorTemplate(C); + /// Retrieve a file handle within the given translation unit. + CXFile clang_getFile(CXTranslationUnit tu, ffi.Pointer file_name) { + return _clang_getFile(tu, file_name); } - late final _clang_getSpecializedCursorTemplatePtr = - _lookup>( - 'clang_getSpecializedCursorTemplate', - ); - late final _clang_getSpecializedCursorTemplate = - _clang_getSpecializedCursorTemplatePtr - .asFunction(); + late final _clang_getFilePtr = + _lookup< + ffi.NativeFunction< + CXFile Function(CXTranslationUnit, ffi.Pointer) + > + >('clang_getFile'); + late final _clang_getFile = _clang_getFilePtr + .asFunction)>(); - /// Given a cursor that references something else, return the source range - /// covering that reference. - CXSourceRange clang_getCursorReferenceNameRange( - CXCursor C, - int NameFlags, - int PieceIndex, + /// Retrieve the buffer associated with the given file. + ffi.Pointer clang_getFileContents( + CXTranslationUnit tu, + CXFile file, + ffi.Pointer size, ) { - return _clang_getCursorReferenceNameRange(C, NameFlags, PieceIndex); + return _clang_getFileContents(tu, file, size); } - late final _clang_getCursorReferenceNameRangePtr = + late final _clang_getFileContentsPtr = _lookup< ffi.NativeFunction< - CXSourceRange Function(CXCursor, ffi.UnsignedInt, ffi.UnsignedInt) + ffi.Pointer Function( + CXTranslationUnit, + CXFile, + ffi.Pointer, + ) > - >('clang_getCursorReferenceNameRange'); - late final _clang_getCursorReferenceNameRange = - _clang_getCursorReferenceNameRangePtr - .asFunction(); + >('clang_getFileContents'); + late final _clang_getFileContents = _clang_getFileContentsPtr + .asFunction< + ffi.Pointer Function( + CXTranslationUnit, + CXFile, + ffi.Pointer, + ) + >(); - /// Get the raw lexical token starting with the given location. - ffi.Pointer clang_getToken( - CXTranslationUnit TU, - CXSourceLocation Location, + /// Retrieve the file, line, column, and offset represented by the given + /// source location. + void clang_getFileLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, ) { - return _clang_getToken(TU, Location); + return _clang_getFileLocation(location, file, line, column, offset); } - late final _clang_getTokenPtr = + late final _clang_getFileLocationPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(CXTranslationUnit, CXSourceLocation) + ffi.Void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('clang_getToken'); - late final _clang_getToken = _clang_getTokenPtr + >('clang_getFileLocation'); + late final _clang_getFileLocation = _clang_getFileLocationPtr .asFunction< - ffi.Pointer Function(CXTranslationUnit, CXSourceLocation) + void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >(); - /// Determine the kind of the given token. - CXTokenKind clang_getTokenKind(CXToken arg0) { - return CXTokenKind.fromValue(_clang_getTokenKind(arg0)); + /// Retrieve the complete file and path name of the given file. + CXString clang_getFileName(CXFile SFile) { + return _clang_getFileName(SFile); } - late final _clang_getTokenKindPtr = - _lookup>( - 'clang_getTokenKind', + late final _clang_getFileNamePtr = + _lookup>( + 'clang_getFileName', ); - late final _clang_getTokenKind = _clang_getTokenKindPtr - .asFunction(); + late final _clang_getFileName = _clang_getFileNamePtr + .asFunction(); - /// Determine the spelling of the given token. - CXString clang_getTokenSpelling(CXTranslationUnit arg0, CXToken arg1) { - return _clang_getTokenSpelling(arg0, arg1); + /// Retrieve the last modification time of the given file. + int clang_getFileTime(CXFile SFile) { + return _clang_getFileTime(SFile); } - late final _clang_getTokenSpellingPtr = - _lookup< - ffi.NativeFunction - >('clang_getTokenSpelling'); - late final _clang_getTokenSpelling = _clang_getTokenSpellingPtr - .asFunction(); + late final _clang_getFileTimePtr = + _lookup>( + 'clang_getFileTime', + ); + late final _clang_getFileTime = _clang_getFileTimePtr + .asFunction(); - /// Retrieve the source location of the given token. - CXSourceLocation clang_getTokenLocation( - CXTranslationUnit arg0, - CXToken arg1, - ) { - return _clang_getTokenLocation(arg0, arg1); + /// Retrieve the unique ID for the given file. + int clang_getFileUniqueID(CXFile file, ffi.Pointer outID) { + return _clang_getFileUniqueID(file, outID); } - late final _clang_getTokenLocationPtr = + late final _clang_getFileUniqueIDPtr = _lookup< ffi.NativeFunction< - CXSourceLocation Function(CXTranslationUnit, CXToken) + ffi.Int Function(CXFile, ffi.Pointer) > - >('clang_getTokenLocation'); - late final _clang_getTokenLocation = _clang_getTokenLocationPtr - .asFunction(); + >('clang_getFileUniqueID'); + late final _clang_getFileUniqueID = _clang_getFileUniqueIDPtr + .asFunction)>(); - /// Retrieve a source range that covers the given token. - CXSourceRange clang_getTokenExtent(CXTranslationUnit arg0, CXToken arg1) { - return _clang_getTokenExtent(arg0, arg1); + /// Retrieve the calling convention associated with a function type. + CXCallingConv clang_getFunctionTypeCallingConv(CXType T) { + return CXCallingConv.fromValue(_clang_getFunctionTypeCallingConv(T)); } - late final _clang_getTokenExtentPtr = - _lookup< - ffi.NativeFunction - >('clang_getTokenExtent'); - late final _clang_getTokenExtent = _clang_getTokenExtentPtr - .asFunction(); + late final _clang_getFunctionTypeCallingConvPtr = + _lookup>( + 'clang_getFunctionTypeCallingConv', + ); + late final _clang_getFunctionTypeCallingConv = + _clang_getFunctionTypeCallingConvPtr.asFunction(); - /// Tokenize the source code described by the given range into raw lexical - /// tokens. - void clang_tokenize( - CXTranslationUnit TU, - CXSourceRange Range, - ffi.Pointer> Tokens, - ffi.Pointer NumTokens, - ) { - return _clang_tokenize(TU, Range, Tokens, NumTokens); + /// For cursors representing an iboutletcollection attribute, this function + /// returns the collection element type. + CXType clang_getIBOutletCollectionType(CXCursor arg0) { + return _clang_getIBOutletCollectionType(arg0); } - late final _clang_tokenizePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXTranslationUnit, - CXSourceRange, - ffi.Pointer>, - ffi.Pointer, - ) - > - >('clang_tokenize'); - late final _clang_tokenize = _clang_tokenizePtr - .asFunction< - void Function( - CXTranslationUnit, - CXSourceRange, - ffi.Pointer>, - ffi.Pointer, - ) - >(); + late final _clang_getIBOutletCollectionTypePtr = + _lookup>( + 'clang_getIBOutletCollectionType', + ); + late final _clang_getIBOutletCollectionType = + _clang_getIBOutletCollectionTypePtr + .asFunction(); - /// Annotate the given set of tokens by providing cursors for each token that - /// can be mapped to a specific entity within the abstract syntax tree. - void clang_annotateTokens( - CXTranslationUnit TU, - ffi.Pointer Tokens, - int NumTokens, - ffi.Pointer Cursors, - ) { - return _clang_annotateTokens(TU, Tokens, NumTokens, Cursors); + /// Retrieve the file that is included by the given inclusion directive + /// cursor. + CXFile clang_getIncludedFile(CXCursor cursor) { + return _clang_getIncludedFile(cursor); } - late final _clang_annotateTokensPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXTranslationUnit, - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer, - ) - > - >('clang_annotateTokens'); - late final _clang_annotateTokens = _clang_annotateTokensPtr - .asFunction< - void Function( - CXTranslationUnit, - ffi.Pointer, - int, - ffi.Pointer, - ) - >(); + late final _clang_getIncludedFilePtr = + _lookup>( + 'clang_getIncludedFile', + ); + late final _clang_getIncludedFile = _clang_getIncludedFilePtr + .asFunction(); - /// Free the given set of tokens. - void clang_disposeTokens( - CXTranslationUnit TU, - ffi.Pointer Tokens, - int NumTokens, + /// Visit the set of preprocessor inclusions in a translation unit. The + /// visitor function is called with the provided data for every included file. + /// This does not include headers included by the PCH file (unless one is + /// inspecting the inclusions in the PCH file itself). + void clang_getInclusions( + CXTranslationUnit tu, + CXInclusionVisitor visitor, + CXClientData client_data, ) { - return _clang_disposeTokens(TU, Tokens, NumTokens); + return _clang_getInclusions(tu, visitor, client_data); } - late final _clang_disposeTokensPtr = + late final _clang_getInclusionsPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - CXTranslationUnit, - ffi.Pointer, - ffi.UnsignedInt, - ) + ffi.Void Function(CXTranslationUnit, CXInclusionVisitor, CXClientData) > - >('clang_disposeTokens'); - late final _clang_disposeTokens = _clang_disposeTokensPtr + >('clang_getInclusions'); + late final _clang_getInclusions = _clang_getInclusionsPtr .asFunction< - void Function(CXTranslationUnit, ffi.Pointer, int) + void Function(CXTranslationUnit, CXInclusionVisitor, CXClientData) >(); - /// These routines are used for testing and debugging, only, and should not be - /// relied upon. - CXString clang_getCursorKindSpelling(CXCursorKind Kind) { - return _clang_getCursorKindSpelling(Kind.value); - } - - late final _clang_getCursorKindSpellingPtr = - _lookup>( - 'clang_getCursorKindSpelling', - ); - late final _clang_getCursorKindSpelling = _clang_getCursorKindSpellingPtr - .asFunction(); - - void clang_getDefinitionSpellingAndExtent( - CXCursor arg0, - ffi.Pointer> startBuf, - ffi.Pointer> endBuf, - ffi.Pointer startLine, - ffi.Pointer startColumn, - ffi.Pointer endLine, - ffi.Pointer endColumn, + /// Legacy API to retrieve the file, line, column, and offset represented by + /// the given source location. + void clang_getInstantiationLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, ) { - return _clang_getDefinitionSpellingAndExtent( - arg0, - startBuf, - endBuf, - startLine, - startColumn, - endLine, - endColumn, + return _clang_getInstantiationLocation( + location, + file, + line, + column, + offset, ); } - late final _clang_getDefinitionSpellingAndExtentPtr = + late final _clang_getInstantiationLocationPtr = _lookup< ffi.NativeFunction< ffi.Void Function( - CXCursor, - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer, + CXSourceLocation, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, ) > - >('clang_getDefinitionSpellingAndExtent'); - late final _clang_getDefinitionSpellingAndExtent = - _clang_getDefinitionSpellingAndExtentPtr + >('clang_getInstantiationLocation'); + late final _clang_getInstantiationLocation = + _clang_getInstantiationLocationPtr .asFunction< void Function( - CXCursor, - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer, + CXSourceLocation, + ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.Pointer, ) >(); - void clang_enableStackTraces() { - return _clang_enableStackTraces(); - } - - late final _clang_enableStackTracesPtr = - _lookup>( - 'clang_enableStackTraces', - ); - late final _clang_enableStackTraces = _clang_enableStackTracesPtr - .asFunction(); - - void clang_executeOnThread( - ffi.Pointer)>> - fn, - ffi.Pointer user_data, - int stack_size, + /// Retrieves the source location associated with a given file/line/column in + /// a particular translation unit. + CXSourceLocation clang_getLocation( + CXTranslationUnit tu, + CXFile file, + int line, + int column, ) { - return _clang_executeOnThread(fn, user_data, stack_size); + return _clang_getLocation(tu, file, line, column); } - late final _clang_executeOnThreadPtr = + late final _clang_getLocationPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, + CXSourceLocation Function( + CXTranslationUnit, + CXFile, + ffi.UnsignedInt, ffi.UnsignedInt, ) > - >('clang_executeOnThread'); - late final _clang_executeOnThread = _clang_executeOnThreadPtr + >('clang_getLocation'); + late final _clang_getLocation = _clang_getLocationPtr .asFunction< - void Function( - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, - int, - ) + CXSourceLocation Function(CXTranslationUnit, CXFile, int, int) >(); - /// Determine the kind of a particular chunk within a completion string. - CXCompletionChunkKind clang_getCompletionChunkKind( - CXCompletionString completion_string, - int chunk_number, + /// Retrieves the source location associated with a given character offset in + /// a particular translation unit. + CXSourceLocation clang_getLocationForOffset( + CXTranslationUnit tu, + CXFile file, + int offset, ) { - return CXCompletionChunkKind.fromValue( - _clang_getCompletionChunkKind(completion_string, chunk_number), - ); + return _clang_getLocationForOffset(tu, file, offset); } - late final _clang_getCompletionChunkKindPtr = + late final _clang_getLocationForOffsetPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function(CXCompletionString, ffi.UnsignedInt) + CXSourceLocation Function(CXTranslationUnit, CXFile, ffi.UnsignedInt) > - >('clang_getCompletionChunkKind'); - late final _clang_getCompletionChunkKind = _clang_getCompletionChunkKindPtr - .asFunction(); + >('clang_getLocationForOffset'); + late final _clang_getLocationForOffset = _clang_getLocationForOffsetPtr + .asFunction(); - /// Retrieve the text associated with a particular chunk within a completion - /// string. - CXString clang_getCompletionChunkText( - CXCompletionString completion_string, - int chunk_number, - ) { - return _clang_getCompletionChunkText(completion_string, chunk_number); + /// Given a CXFile header file, return the module that contains it, if one + /// exists. + CXModule clang_getModuleForFile(CXTranslationUnit arg0, CXFile arg1) { + return _clang_getModuleForFile(arg0, arg1); } - late final _clang_getCompletionChunkTextPtr = - _lookup< - ffi.NativeFunction< - CXString Function(CXCompletionString, ffi.UnsignedInt) - > - >('clang_getCompletionChunkText'); - late final _clang_getCompletionChunkText = _clang_getCompletionChunkTextPtr - .asFunction(); + late final _clang_getModuleForFilePtr = + _lookup>( + 'clang_getModuleForFile', + ); + late final _clang_getModuleForFile = _clang_getModuleForFilePtr + .asFunction(); - /// Retrieve the completion string associated with a particular chunk within a - /// completion string. - CXCompletionString clang_getCompletionChunkCompletionString( - CXCompletionString completion_string, - int chunk_number, - ) { - return _clang_getCompletionChunkCompletionString( - completion_string, - chunk_number, - ); + /// Retrieve the NULL cursor, which represents no entity. + CXCursor clang_getNullCursor() { + return _clang_getNullCursor(); } - late final _clang_getCompletionChunkCompletionStringPtr = - _lookup< - ffi.NativeFunction< - CXCompletionString Function(CXCompletionString, ffi.UnsignedInt) - > - >('clang_getCompletionChunkCompletionString'); - late final _clang_getCompletionChunkCompletionString = - _clang_getCompletionChunkCompletionStringPtr - .asFunction(); + late final _clang_getNullCursorPtr = + _lookup>('clang_getNullCursor'); + late final _clang_getNullCursor = _clang_getNullCursorPtr + .asFunction(); + + /// Retrieve a NULL (invalid) source location. + CXSourceLocation clang_getNullLocation() { + return _clang_getNullLocation(); + } + + late final _clang_getNullLocationPtr = + _lookup>( + 'clang_getNullLocation', + ); + late final _clang_getNullLocation = _clang_getNullLocationPtr + .asFunction(); + + /// Retrieve a NULL (invalid) source range. + CXSourceRange clang_getNullRange() { + return _clang_getNullRange(); + } + + late final _clang_getNullRangePtr = + _lookup>( + 'clang_getNullRange', + ); + late final _clang_getNullRange = _clang_getNullRangePtr + .asFunction(); + + /// Retrieve the number of non-variadic parameters associated with a function + /// type. + int clang_getNumArgTypes(CXType T) { + return _clang_getNumArgTypes(T); + } + + late final _clang_getNumArgTypesPtr = + _lookup>( + 'clang_getNumArgTypes', + ); + late final _clang_getNumArgTypes = _clang_getNumArgTypesPtr + .asFunction(); /// Retrieve the number of chunks in the given code-completion string. int clang_getNumCompletionChunks(CXCompletionString completion_string) { @@ -4284,749 +3893,828 @@ class LibClang { late final _clang_getNumCompletionChunks = _clang_getNumCompletionChunksPtr .asFunction(); - /// Determine the priority of this code completion. - int clang_getCompletionPriority(CXCompletionString completion_string) { - return _clang_getCompletionPriority(completion_string); + /// Determine the number of diagnostics produced for the given translation + /// unit. + int clang_getNumDiagnostics(CXTranslationUnit Unit) { + return _clang_getNumDiagnostics(Unit); } - late final _clang_getCompletionPriorityPtr = - _lookup>( - 'clang_getCompletionPriority', + late final _clang_getNumDiagnosticsPtr = + _lookup>( + 'clang_getNumDiagnostics', ); - late final _clang_getCompletionPriority = _clang_getCompletionPriorityPtr - .asFunction(); + late final _clang_getNumDiagnostics = _clang_getNumDiagnosticsPtr + .asFunction(); - /// Determine the availability of the entity that this code-completion string - /// refers to. - CXAvailabilityKind clang_getCompletionAvailability( - CXCompletionString completion_string, - ) { - return CXAvailabilityKind.fromValue( - _clang_getCompletionAvailability(completion_string), - ); + /// Determine the number of diagnostics in a CXDiagnosticSet. + int clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags) { + return _clang_getNumDiagnosticsInSet(Diags); } - late final _clang_getCompletionAvailabilityPtr = - _lookup>( - 'clang_getCompletionAvailability', + late final _clang_getNumDiagnosticsInSetPtr = + _lookup>( + 'clang_getNumDiagnosticsInSet', ); - late final _clang_getCompletionAvailability = - _clang_getCompletionAvailabilityPtr - .asFunction(); + late final _clang_getNumDiagnosticsInSet = _clang_getNumDiagnosticsInSetPtr + .asFunction(); - /// Retrieve the number of annotations associated with the given completion - /// string. - int clang_getCompletionNumAnnotations(CXCompletionString completion_string) { - return _clang_getCompletionNumAnnotations(completion_string); + /// Return the number of elements of an array or vector type. + int clang_getNumElements(CXType T) { + return _clang_getNumElements(T); } - late final _clang_getCompletionNumAnnotationsPtr = - _lookup>( - 'clang_getCompletionNumAnnotations', + late final _clang_getNumElementsPtr = + _lookup>( + 'clang_getNumElements', ); - late final _clang_getCompletionNumAnnotations = - _clang_getCompletionNumAnnotationsPtr - .asFunction(); + late final _clang_getNumElements = _clang_getNumElementsPtr + .asFunction(); - /// Retrieve the annotation associated with the given completion string. - CXString clang_getCompletionAnnotation( - CXCompletionString completion_string, - int annotation_number, - ) { - return _clang_getCompletionAnnotation(completion_string, annotation_number); + /// Determine the number of overloaded declarations referenced by a + /// CXCursor_OverloadedDeclRef cursor. + int clang_getNumOverloadedDecls(CXCursor cursor) { + return _clang_getNumOverloadedDecls(cursor); } - late final _clang_getCompletionAnnotationPtr = - _lookup< - ffi.NativeFunction< - CXString Function(CXCompletionString, ffi.UnsignedInt) - > - >('clang_getCompletionAnnotation'); - late final _clang_getCompletionAnnotation = _clang_getCompletionAnnotationPtr - .asFunction(); + late final _clang_getNumOverloadedDeclsPtr = + _lookup>( + 'clang_getNumOverloadedDecls', + ); + late final _clang_getNumOverloadedDecls = _clang_getNumOverloadedDeclsPtr + .asFunction(); - /// Retrieve the parent context of the given completion string. - CXString clang_getCompletionParent( - CXCompletionString completion_string, - ffi.Pointer kind, + /// Retrieve a cursor for one of the overloaded declarations referenced by a + /// CXCursor_OverloadedDeclRef cursor. + CXCursor clang_getOverloadedDecl(CXCursor cursor, int index) { + return _clang_getOverloadedDecl(cursor, index); + } + + late final _clang_getOverloadedDeclPtr = + _lookup>( + 'clang_getOverloadedDecl', + ); + late final _clang_getOverloadedDecl = _clang_getOverloadedDeclPtr + .asFunction(); + + /// Determine the set of methods that are overridden by the given method. + void clang_getOverriddenCursors( + CXCursor cursor, + ffi.Pointer> overridden, + ffi.Pointer num_overridden, ) { - return _clang_getCompletionParent(completion_string, kind); + return _clang_getOverriddenCursors(cursor, overridden, num_overridden); } - late final _clang_getCompletionParentPtr = + late final _clang_getOverriddenCursorsPtr = _lookup< ffi.NativeFunction< - CXString Function(CXCompletionString, ffi.Pointer) + ffi.Void Function( + CXCursor, + ffi.Pointer>, + ffi.Pointer, + ) > - >('clang_getCompletionParent'); - late final _clang_getCompletionParent = _clang_getCompletionParentPtr + >('clang_getOverriddenCursors'); + late final _clang_getOverriddenCursors = _clang_getOverriddenCursorsPtr .asFunction< - CXString Function(CXCompletionString, ffi.Pointer) + void Function( + CXCursor, + ffi.Pointer>, + ffi.Pointer, + ) >(); - /// Retrieve the brief documentation comment attached to the declaration that - /// corresponds to the given completion string. - CXString clang_getCompletionBriefComment( - CXCompletionString completion_string, - ) { - return _clang_getCompletionBriefComment(completion_string); + /// For pointer types, returns the type of the pointee. + CXType clang_getPointeeType(CXType T) { + return _clang_getPointeeType(T); } - late final _clang_getCompletionBriefCommentPtr = - _lookup>( - 'clang_getCompletionBriefComment', + late final _clang_getPointeeTypePtr = + _lookup>( + 'clang_getPointeeType', ); - late final _clang_getCompletionBriefComment = - _clang_getCompletionBriefCommentPtr - .asFunction(); + late final _clang_getPointeeType = _clang_getPointeeTypePtr + .asFunction(); - /// Retrieve a completion string for an arbitrary declaration or macro - /// definition cursor. - CXCompletionString clang_getCursorCompletionString(CXCursor cursor) { - return _clang_getCursorCompletionString(cursor); + /// Retrieve the file, line and column represented by the given source + /// location, as specified in a # line directive. + void clang_getPresumedLocation( + CXSourceLocation location, + ffi.Pointer filename, + ffi.Pointer line, + ffi.Pointer column, + ) { + return _clang_getPresumedLocation(location, filename, line, column); } - late final _clang_getCursorCompletionStringPtr = - _lookup>( - 'clang_getCursorCompletionString', - ); - late final _clang_getCursorCompletionString = - _clang_getCursorCompletionStringPtr - .asFunction(); - - /// Retrieve the number of fix-its for the given completion index. - int clang_getCompletionNumFixIts( - ffi.Pointer results, - int completion_index, - ) { - return _clang_getCompletionNumFixIts(results, completion_index); - } - - late final _clang_getCompletionNumFixItsPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('clang_getCompletionNumFixIts'); - late final _clang_getCompletionNumFixIts = _clang_getCompletionNumFixItsPtr - .asFunction, int)>(); - - /// Fix-its that *must* be applied before inserting the text for the - /// corresponding completion. - CXString clang_getCompletionFixIt( - ffi.Pointer results, - int completion_index, - int fixit_index, - ffi.Pointer replacement_range, - ) { - return _clang_getCompletionFixIt( - results, - completion_index, - fixit_index, - replacement_range, - ); - } - - late final _clang_getCompletionFixItPtr = + late final _clang_getPresumedLocationPtr = _lookup< ffi.NativeFunction< - CXString Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, + ffi.Void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) > - >('clang_getCompletionFixIt'); - late final _clang_getCompletionFixIt = _clang_getCompletionFixItPtr + >('clang_getPresumedLocation'); + late final _clang_getPresumedLocation = _clang_getPresumedLocationPtr .asFunction< - CXString Function( - ffi.Pointer, - int, - int, - ffi.Pointer, + void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) >(); - /// Returns a default set of code-completion options that can be passed to - /// clang_codeCompleteAt(). - int clang_defaultCodeCompleteOptions() { - return _clang_defaultCodeCompleteOptions(); - } - - late final _clang_defaultCodeCompleteOptionsPtr = - _lookup>( - 'clang_defaultCodeCompleteOptions', - ); - late final _clang_defaultCodeCompleteOptions = - _clang_defaultCodeCompleteOptionsPtr.asFunction(); - - /// Perform code completion at a given location in a translation unit. - ffi.Pointer clang_codeCompleteAt( - CXTranslationUnit TU, - ffi.Pointer complete_filename, - int complete_line, - int complete_column, - ffi.Pointer unsaved_files, - int num_unsaved_files, - int options, - ) { - return _clang_codeCompleteAt( - TU, - complete_filename, - complete_line, - complete_column, - unsaved_files, - num_unsaved_files, - options, - ); + /// Retrieve a source range given the beginning and ending source locations. + CXSourceRange clang_getRange(CXSourceLocation begin, CXSourceLocation end) { + return _clang_getRange(begin, end); } - late final _clang_codeCompleteAtPtr = + late final _clang_getRangePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - CXTranslationUnit, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ) + CXSourceRange Function(CXSourceLocation, CXSourceLocation) > - >('clang_codeCompleteAt'); - late final _clang_codeCompleteAt = _clang_codeCompleteAtPtr - .asFunction< - ffi.Pointer Function( - CXTranslationUnit, - ffi.Pointer, - int, - int, - ffi.Pointer, - int, - int, - ) - >(); + >('clang_getRange'); + late final _clang_getRange = _clang_getRangePtr + .asFunction(); - /// Sort the code-completion results in case-insensitive alphabetical order. - void clang_sortCodeCompletionResults( - ffi.Pointer Results, - int NumResults, - ) { - return _clang_sortCodeCompletionResults(Results, NumResults); + /// Retrieve a source location representing the last character within a source + /// range. + CXSourceLocation clang_getRangeEnd(CXSourceRange range) { + return _clang_getRangeEnd(range); } - late final _clang_sortCodeCompletionResultsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) - > - >('clang_sortCodeCompletionResults'); - late final _clang_sortCodeCompletionResults = - _clang_sortCodeCompletionResultsPtr - .asFunction, int)>(); + late final _clang_getRangeEndPtr = + _lookup>( + 'clang_getRangeEnd', + ); + late final _clang_getRangeEnd = _clang_getRangeEndPtr + .asFunction(); - /// Free the given set of code-completion results. - void clang_disposeCodeCompleteResults( - ffi.Pointer Results, - ) { - return _clang_disposeCodeCompleteResults(Results); + /// Retrieve a source location representing the first character within a + /// source range. + CXSourceLocation clang_getRangeStart(CXSourceRange range) { + return _clang_getRangeStart(range); } - late final _clang_disposeCodeCompleteResultsPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >('clang_disposeCodeCompleteResults'); - late final _clang_disposeCodeCompleteResults = - _clang_disposeCodeCompleteResultsPtr - .asFunction)>(); + late final _clang_getRangeStartPtr = + _lookup>( + 'clang_getRangeStart', + ); + late final _clang_getRangeStart = _clang_getRangeStartPtr + .asFunction(); - /// Determine the number of diagnostics produced prior to the location where - /// code completion was performed. - int clang_codeCompleteGetNumDiagnostics( - ffi.Pointer Results, - ) { - return _clang_codeCompleteGetNumDiagnostics(Results); + /// Retrieve a remapping. + CXRemapping clang_getRemappings(ffi.Pointer path) { + return _clang_getRemappings(path); } - late final _clang_codeCompleteGetNumDiagnosticsPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer) - > - >('clang_codeCompleteGetNumDiagnostics'); - late final _clang_codeCompleteGetNumDiagnostics = - _clang_codeCompleteGetNumDiagnosticsPtr - .asFunction)>(); + late final _clang_getRemappingsPtr = + _lookup)>>( + 'clang_getRemappings', + ); + late final _clang_getRemappings = _clang_getRemappingsPtr + .asFunction)>(); - /// Retrieve a diagnostic associated with the given code completion. - CXDiagnostic clang_codeCompleteGetDiagnostic( - ffi.Pointer Results, - int Index, + /// Retrieve a remapping. + CXRemapping clang_getRemappingsFromFileList( + ffi.Pointer> filePaths, + int numFiles, ) { - return _clang_codeCompleteGetDiagnostic(Results, Index); + return _clang_getRemappingsFromFileList(filePaths, numFiles); } - late final _clang_codeCompleteGetDiagnosticPtr = + late final _clang_getRemappingsFromFileListPtr = _lookup< ffi.NativeFunction< - CXDiagnostic Function( - ffi.Pointer, + CXRemapping Function( + ffi.Pointer>, ffi.UnsignedInt, ) > - >('clang_codeCompleteGetDiagnostic'); - late final _clang_codeCompleteGetDiagnostic = - _clang_codeCompleteGetDiagnosticPtr + >('clang_getRemappingsFromFileList'); + late final _clang_getRemappingsFromFileList = + _clang_getRemappingsFromFileListPtr .asFunction< - CXDiagnostic Function(ffi.Pointer, int) + CXRemapping Function(ffi.Pointer>, int) >(); - /// Determines what completions are appropriate for the context the given code - /// completion. - int clang_codeCompleteGetContexts( - ffi.Pointer Results, + /// Retrieve the return type associated with a function type. + CXType clang_getResultType(CXType T) { + return _clang_getResultType(T); + } + + late final _clang_getResultTypePtr = + _lookup>( + 'clang_getResultType', + ); + late final _clang_getResultType = _clang_getResultTypePtr + .asFunction(); + + /// Retrieve all ranges that were skipped by the preprocessor. + ffi.Pointer clang_getSkippedRanges( + CXTranslationUnit tu, + CXFile file, ) { - return _clang_codeCompleteGetContexts(Results); + return _clang_getSkippedRanges(tu, file); } - late final _clang_codeCompleteGetContextsPtr = + late final _clang_getSkippedRangesPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedLongLong Function(ffi.Pointer) + ffi.Pointer Function(CXTranslationUnit, CXFile) > - >('clang_codeCompleteGetContexts'); - late final _clang_codeCompleteGetContexts = _clang_codeCompleteGetContextsPtr - .asFunction)>(); + >('clang_getSkippedRanges'); + late final _clang_getSkippedRanges = _clang_getSkippedRangesPtr + .asFunction< + ffi.Pointer Function(CXTranslationUnit, CXFile) + >(); - /// Returns the cursor kind for the container for the current code completion - /// context. The container is only guaranteed to be set for contexts where a - /// container exists (i.e. member accesses or Objective-C message sends); if - /// there is not a container, this function will return CXCursor_InvalidCode. - CXCursorKind clang_codeCompleteGetContainerKind( - ffi.Pointer Results, - ffi.Pointer IsIncomplete, + /// Given a cursor that may represent a specialization or instantiation of a + /// template, retrieve the cursor that represents the template that it + /// specializes or from which it was instantiated. + CXCursor clang_getSpecializedCursorTemplate(CXCursor C) { + return _clang_getSpecializedCursorTemplate(C); + } + + late final _clang_getSpecializedCursorTemplatePtr = + _lookup>( + 'clang_getSpecializedCursorTemplate', + ); + late final _clang_getSpecializedCursorTemplate = + _clang_getSpecializedCursorTemplatePtr + .asFunction(); + + /// Retrieve the file, line, column, and offset represented by the given + /// source location. + void clang_getSpellingLocation( + CXSourceLocation location, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, ) { - return CXCursorKind.fromValue( - _clang_codeCompleteGetContainerKind(Results, IsIncomplete), - ); + return _clang_getSpellingLocation(location, file, line, column, offset); } - late final _clang_codeCompleteGetContainerKindPtr = + late final _clang_getSpellingLocationPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer, + ffi.Void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ffi.Pointer, ) > - >('clang_codeCompleteGetContainerKind'); - late final _clang_codeCompleteGetContainerKind = - _clang_codeCompleteGetContainerKindPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('clang_getSpellingLocation'); + late final _clang_getSpellingLocation = _clang_getSpellingLocationPtr + .asFunction< + void Function( + CXSourceLocation, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - /// Returns the USR for the container for the current code completion context. - /// If there is not a container for the current context, this function will - /// return the empty string. - CXString clang_codeCompleteGetContainerUSR( - ffi.Pointer Results, + /// Returns the human-readable null-terminated C string that represents the + /// name of the memory category. This string should never be freed. + ffi.Pointer clang_getTUResourceUsageName( + CXTUResourceUsageKind kind, ) { - return _clang_codeCompleteGetContainerUSR(Results); + return _clang_getTUResourceUsageName(kind.value); } - late final _clang_codeCompleteGetContainerUSRPtr = + late final _clang_getTUResourceUsageNamePtr = _lookup< - ffi.NativeFunction< - CXString Function(ffi.Pointer) - > - >('clang_codeCompleteGetContainerUSR'); - late final _clang_codeCompleteGetContainerUSR = - _clang_codeCompleteGetContainerUSRPtr - .asFunction)>(); + ffi.NativeFunction Function(ffi.UnsignedInt)> + >('clang_getTUResourceUsageName'); + late final _clang_getTUResourceUsageName = _clang_getTUResourceUsageNamePtr + .asFunction Function(int)>(); - /// Returns the currently-entered selector for an Objective-C message send, - /// formatted like "initWithFoo:bar:". Only guaranteed to return a non-empty - /// string for CXCompletionContext_ObjCInstanceMessage and - /// CXCompletionContext_ObjCClassMessage. - CXString clang_codeCompleteGetObjCSelector( - ffi.Pointer Results, + /// Given a cursor that represents a template, determine the cursor kind of + /// the specializations would be generated by instantiating the template. + CXCursorKind clang_getTemplateCursorKind(CXCursor C) { + return CXCursorKind.fromValue(_clang_getTemplateCursorKind(C)); + } + + late final _clang_getTemplateCursorKindPtr = + _lookup>( + 'clang_getTemplateCursorKind', + ); + late final _clang_getTemplateCursorKind = _clang_getTemplateCursorKindPtr + .asFunction(); + + /// Get the raw lexical token starting with the given location. + ffi.Pointer clang_getToken( + CXTranslationUnit TU, + CXSourceLocation Location, ) { - return _clang_codeCompleteGetObjCSelector(Results); + return _clang_getToken(TU, Location); } - late final _clang_codeCompleteGetObjCSelectorPtr = + late final _clang_getTokenPtr = _lookup< ffi.NativeFunction< - CXString Function(ffi.Pointer) + ffi.Pointer Function(CXTranslationUnit, CXSourceLocation) > - >('clang_codeCompleteGetObjCSelector'); - late final _clang_codeCompleteGetObjCSelector = - _clang_codeCompleteGetObjCSelectorPtr - .asFunction)>(); + >('clang_getToken'); + late final _clang_getToken = _clang_getTokenPtr + .asFunction< + ffi.Pointer Function(CXTranslationUnit, CXSourceLocation) + >(); - /// Return a version string, suitable for showing to a user, but not intended - /// to be parsed (the format is not guaranteed to be stable). - CXString clang_getClangVersion() { - return _clang_getClangVersion(); + /// Retrieve a source range that covers the given token. + CXSourceRange clang_getTokenExtent(CXTranslationUnit arg0, CXToken arg1) { + return _clang_getTokenExtent(arg0, arg1); } - late final _clang_getClangVersionPtr = - _lookup>('clang_getClangVersion'); - late final _clang_getClangVersion = _clang_getClangVersionPtr - .asFunction(); + late final _clang_getTokenExtentPtr = + _lookup< + ffi.NativeFunction + >('clang_getTokenExtent'); + late final _clang_getTokenExtent = _clang_getTokenExtentPtr + .asFunction(); - /// Enable/disable crash recovery. - void clang_toggleCrashRecovery(int isEnabled) { - return _clang_toggleCrashRecovery(isEnabled); + /// Determine the kind of the given token. + CXTokenKind clang_getTokenKind(CXToken arg0) { + return CXTokenKind.fromValue(_clang_getTokenKind(arg0)); } - late final _clang_toggleCrashRecoveryPtr = - _lookup>( - 'clang_toggleCrashRecovery', + late final _clang_getTokenKindPtr = + _lookup>( + 'clang_getTokenKind', ); - late final _clang_toggleCrashRecovery = _clang_toggleCrashRecoveryPtr - .asFunction(); + late final _clang_getTokenKind = _clang_getTokenKindPtr + .asFunction(); - /// Visit the set of preprocessor inclusions in a translation unit. The - /// visitor function is called with the provided data for every included file. - /// This does not include headers included by the PCH file (unless one is - /// inspecting the inclusions in the PCH file itself). - void clang_getInclusions( - CXTranslationUnit tu, - CXInclusionVisitor visitor, - CXClientData client_data, + /// Retrieve the source location of the given token. + CXSourceLocation clang_getTokenLocation( + CXTranslationUnit arg0, + CXToken arg1, ) { - return _clang_getInclusions(tu, visitor, client_data); + return _clang_getTokenLocation(arg0, arg1); } - late final _clang_getInclusionsPtr = + late final _clang_getTokenLocationPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(CXTranslationUnit, CXInclusionVisitor, CXClientData) + CXSourceLocation Function(CXTranslationUnit, CXToken) > - >('clang_getInclusions'); - late final _clang_getInclusions = _clang_getInclusionsPtr - .asFunction< - void Function(CXTranslationUnit, CXInclusionVisitor, CXClientData) - >(); + >('clang_getTokenLocation'); + late final _clang_getTokenLocation = _clang_getTokenLocationPtr + .asFunction(); - /// If cursor is a statement declaration tries to evaluate the statement and - /// if its variable, tries to evaluate its initializer, into its corresponding - /// type. - CXEvalResult clang_Cursor_Evaluate(CXCursor C) { - return _clang_Cursor_Evaluate(C); + /// Determine the spelling of the given token. + CXString clang_getTokenSpelling(CXTranslationUnit arg0, CXToken arg1) { + return _clang_getTokenSpelling(arg0, arg1); } - late final _clang_Cursor_EvaluatePtr = - _lookup>( - 'clang_Cursor_Evaluate', - ); - late final _clang_Cursor_Evaluate = _clang_Cursor_EvaluatePtr - .asFunction(); + late final _clang_getTokenSpellingPtr = + _lookup< + ffi.NativeFunction + >('clang_getTokenSpelling'); + late final _clang_getTokenSpelling = _clang_getTokenSpellingPtr + .asFunction(); - /// Returns the kind of the evaluated result. - CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E) { - return CXEvalResultKind.fromValue(_clang_EvalResult_getKind(E)); + /// Retrieve the cursor that represents the given translation unit. + CXCursor clang_getTranslationUnitCursor(CXTranslationUnit arg0) { + return _clang_getTranslationUnitCursor(arg0); } - late final _clang_EvalResult_getKindPtr = - _lookup>( - 'clang_EvalResult_getKind', + late final _clang_getTranslationUnitCursorPtr = + _lookup>( + 'clang_getTranslationUnitCursor', ); - late final _clang_EvalResult_getKind = _clang_EvalResult_getKindPtr - .asFunction(); + late final _clang_getTranslationUnitCursor = + _clang_getTranslationUnitCursorPtr + .asFunction(); - /// Returns the evaluation result as integer if the kind is Int. - int clang_EvalResult_getAsInt(CXEvalResult E) { - return _clang_EvalResult_getAsInt(E); + /// Get the original translation unit source file name. + CXString clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit) { + return _clang_getTranslationUnitSpelling(CTUnit); } - late final _clang_EvalResult_getAsIntPtr = - _lookup>( - 'clang_EvalResult_getAsInt', + late final _clang_getTranslationUnitSpellingPtr = + _lookup>( + 'clang_getTranslationUnitSpelling', ); - late final _clang_EvalResult_getAsInt = _clang_EvalResult_getAsIntPtr - .asFunction(); + late final _clang_getTranslationUnitSpelling = + _clang_getTranslationUnitSpellingPtr + .asFunction(); - /// Returns the evaluation result as a long long integer if the kind is Int. - /// This prevents overflows that may happen if the result is returned with - /// clang_EvalResult_getAsInt. - int clang_EvalResult_getAsLongLong(CXEvalResult E) { - return _clang_EvalResult_getAsLongLong(E); + /// Get target information for this translation unit. + CXTargetInfo clang_getTranslationUnitTargetInfo(CXTranslationUnit CTUnit) { + return _clang_getTranslationUnitTargetInfo(CTUnit); } - late final _clang_EvalResult_getAsLongLongPtr = - _lookup>( - 'clang_EvalResult_getAsLongLong', - ); - late final _clang_EvalResult_getAsLongLong = - _clang_EvalResult_getAsLongLongPtr - .asFunction(); + late final _clang_getTranslationUnitTargetInfoPtr = + _lookup>( + 'clang_getTranslationUnitTargetInfo', + ); + late final _clang_getTranslationUnitTargetInfo = + _clang_getTranslationUnitTargetInfoPtr + .asFunction(); - /// Returns a non-zero value if the kind is Int and the evaluation result - /// resulted in an unsigned integer. - int clang_EvalResult_isUnsignedInt(CXEvalResult E) { - return _clang_EvalResult_isUnsignedInt(E); + /// Return the cursor for the declaration of the given type. + CXCursor clang_getTypeDeclaration(CXType T) { + return _clang_getTypeDeclaration(T); } - late final _clang_EvalResult_isUnsignedIntPtr = - _lookup>( - 'clang_EvalResult_isUnsignedInt', + late final _clang_getTypeDeclarationPtr = + _lookup>( + 'clang_getTypeDeclaration', ); - late final _clang_EvalResult_isUnsignedInt = - _clang_EvalResult_isUnsignedIntPtr - .asFunction(); + late final _clang_getTypeDeclaration = _clang_getTypeDeclarationPtr + .asFunction(); - /// Returns the evaluation result as an unsigned integer if the kind is Int - /// and clang_EvalResult_isUnsignedInt is non-zero. - int clang_EvalResult_getAsUnsigned(CXEvalResult E) { - return _clang_EvalResult_getAsUnsigned(E); + /// Retrieve the spelling of a given CXTypeKind. + CXString clang_getTypeKindSpelling(CXTypeKind K) { + return _clang_getTypeKindSpelling(K.value); } - late final _clang_EvalResult_getAsUnsignedPtr = - _lookup>( - 'clang_EvalResult_getAsUnsigned', + late final _clang_getTypeKindSpellingPtr = + _lookup>( + 'clang_getTypeKindSpelling', ); - late final _clang_EvalResult_getAsUnsigned = - _clang_EvalResult_getAsUnsignedPtr - .asFunction(); + late final _clang_getTypeKindSpelling = _clang_getTypeKindSpellingPtr + .asFunction(); - /// Returns the evaluation result as double if the kind is double. - double clang_EvalResult_getAsDouble(CXEvalResult E) { - return _clang_EvalResult_getAsDouble(E); + /// Pretty-print the underlying type using the rules of the language of the + /// translation unit from which it came. + CXString clang_getTypeSpelling(CXType CT) { + return _clang_getTypeSpelling(CT); } - late final _clang_EvalResult_getAsDoublePtr = - _lookup>( - 'clang_EvalResult_getAsDouble', + late final _clang_getTypeSpellingPtr = + _lookup>( + 'clang_getTypeSpelling', ); - late final _clang_EvalResult_getAsDouble = _clang_EvalResult_getAsDoublePtr - .asFunction(); + late final _clang_getTypeSpelling = _clang_getTypeSpellingPtr + .asFunction(); - /// Returns the evaluation result as a constant string if the kind is other - /// than Int or float. User must not free this pointer, instead call - /// clang_EvalResult_dispose on the CXEvalResult returned by - /// clang_Cursor_Evaluate. - ffi.Pointer clang_EvalResult_getAsStr(CXEvalResult E) { - return _clang_EvalResult_getAsStr(E); + /// Retrieve the underlying type of a typedef declaration. + CXType clang_getTypedefDeclUnderlyingType(CXCursor C) { + return _clang_getTypedefDeclUnderlyingType(C); } - late final _clang_EvalResult_getAsStrPtr = - _lookup Function(CXEvalResult)>>( - 'clang_EvalResult_getAsStr', + late final _clang_getTypedefDeclUnderlyingTypePtr = + _lookup>( + 'clang_getTypedefDeclUnderlyingType', ); - late final _clang_EvalResult_getAsStr = _clang_EvalResult_getAsStrPtr - .asFunction Function(CXEvalResult)>(); + late final _clang_getTypedefDeclUnderlyingType = + _clang_getTypedefDeclUnderlyingTypePtr + .asFunction(); - /// Disposes the created Eval memory. - void clang_EvalResult_dispose(CXEvalResult E) { - return _clang_EvalResult_dispose(E); + /// Returns the typedef name of the given type. + CXString clang_getTypedefName(CXType CT) { + return _clang_getTypedefName(CT); } - late final _clang_EvalResult_disposePtr = - _lookup>( - 'clang_EvalResult_dispose', + late final _clang_getTypedefNamePtr = + _lookup>( + 'clang_getTypedefName', ); - late final _clang_EvalResult_dispose = _clang_EvalResult_disposePtr - .asFunction(); + late final _clang_getTypedefName = _clang_getTypedefNamePtr + .asFunction(); - /// Retrieve a remapping. - CXRemapping clang_getRemappings(ffi.Pointer path) { - return _clang_getRemappings(path); + /// Compute a hash value for the given cursor. + int clang_hashCursor(CXCursor arg0) { + return _clang_hashCursor(arg0); } - late final _clang_getRemappingsPtr = - _lookup)>>( - 'clang_getRemappings', + late final _clang_hashCursorPtr = + _lookup>( + 'clang_hashCursor', ); - late final _clang_getRemappings = _clang_getRemappingsPtr - .asFunction)>(); + late final _clang_hashCursor = _clang_hashCursorPtr + .asFunction(); - /// Retrieve a remapping. - CXRemapping clang_getRemappingsFromFileList( - ffi.Pointer> filePaths, - int numFiles, + /// Retrieve the CXSourceLocation represented by the given CXIdxLoc. + CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc) { + return _clang_indexLoc_getCXSourceLocation(loc); + } + + late final _clang_indexLoc_getCXSourceLocationPtr = + _lookup>( + 'clang_indexLoc_getCXSourceLocation', + ); + late final _clang_indexLoc_getCXSourceLocation = + _clang_indexLoc_getCXSourceLocationPtr + .asFunction(); + + /// Retrieve the CXIdxFile, file, line, column, and offset represented by the + /// given CXIdxLoc. + void clang_indexLoc_getFileLocation( + CXIdxLoc loc, + ffi.Pointer indexFile, + ffi.Pointer file, + ffi.Pointer line, + ffi.Pointer column, + ffi.Pointer offset, ) { - return _clang_getRemappingsFromFileList(filePaths, numFiles); + return _clang_indexLoc_getFileLocation( + loc, + indexFile, + file, + line, + column, + offset, + ); } - late final _clang_getRemappingsFromFileListPtr = + late final _clang_indexLoc_getFileLocationPtr = _lookup< ffi.NativeFunction< - CXRemapping Function( - ffi.Pointer>, - ffi.UnsignedInt, + ffi.Void Function( + CXIdxLoc, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) > - >('clang_getRemappingsFromFileList'); - late final _clang_getRemappingsFromFileList = - _clang_getRemappingsFromFileListPtr + >('clang_indexLoc_getFileLocation'); + late final _clang_indexLoc_getFileLocation = + _clang_indexLoc_getFileLocationPtr .asFunction< - CXRemapping Function(ffi.Pointer>, int) + void Function( + CXIdxLoc, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >(); - /// Determine the number of remappings. - int clang_remap_getNumFiles(CXRemapping arg0) { - return _clang_remap_getNumFiles(arg0); - } - - late final _clang_remap_getNumFilesPtr = - _lookup>( - 'clang_remap_getNumFiles', - ); - late final _clang_remap_getNumFiles = _clang_remap_getNumFilesPtr - .asFunction(); - - /// Get the original and the associated filename from the remapping. - void clang_remap_getFilenames( - CXRemapping arg0, - int index, - ffi.Pointer original, - ffi.Pointer transformed, + /// Index the given source file and the translation unit corresponding to that + /// file via callbacks implemented through #IndexerCallbacks. + int clang_indexSourceFile( + CXIndexAction arg0, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + ffi.Pointer out_TU, + int TU_options, ) { - return _clang_remap_getFilenames(arg0, index, original, transformed); + return _clang_indexSourceFile( + arg0, + client_data, + index_callbacks, + index_callbacks_size, + index_options, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + out_TU, + TU_options, + ); } - late final _clang_remap_getFilenamesPtr = + late final _clang_indexSourceFilePtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - CXRemapping, + ffi.Int Function( + CXIndexAction, + CXClientData, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer, + ffi.UnsignedInt, + ffi.Pointer, ffi.UnsignedInt, - ffi.Pointer, - ffi.Pointer, ) > - >('clang_remap_getFilenames'); - late final _clang_remap_getFilenames = _clang_remap_getFilenamesPtr + >('clang_indexSourceFile'); + late final _clang_indexSourceFile = _clang_indexSourceFilePtr .asFunction< - void Function( - CXRemapping, + int Function( + CXIndexAction, + CXClientData, + ffi.Pointer, int, - ffi.Pointer, - ffi.Pointer, - ) - >(); - - /// Dispose the remapping. - void clang_remap_dispose(CXRemapping arg0) { - return _clang_remap_dispose(arg0); - } - - late final _clang_remap_disposePtr = - _lookup>( - 'clang_remap_dispose', - ); - late final _clang_remap_dispose = _clang_remap_disposePtr - .asFunction(); + int, + ffi.Pointer, + ffi.Pointer>, + int, + ffi.Pointer, + int, + ffi.Pointer, + int, + ) + >(); - /// Find references of a declaration in a specific file. - CXResult clang_findReferencesInFile( - CXCursor cursor, - CXFile file, - CXCursorAndRangeVisitor visitor, + /// Same as clang_indexSourceFile but requires a full command line for + /// command_line_args including argv[0]. This is useful if the standard + /// library paths are relative to the binary. + int clang_indexSourceFileFullArgv( + CXIndexAction arg0, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + ffi.Pointer out_TU, + int TU_options, ) { - return CXResult.fromValue( - _clang_findReferencesInFile(cursor, file, visitor), + return _clang_indexSourceFileFullArgv( + arg0, + client_data, + index_callbacks, + index_callbacks_size, + index_options, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + out_TU, + TU_options, ); } - late final _clang_findReferencesInFilePtr = + late final _clang_indexSourceFileFullArgvPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function(CXCursor, CXFile, CXCursorAndRangeVisitor) + ffi.Int Function( + CXIndexAction, + CXClientData, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer, + ffi.UnsignedInt, + ffi.Pointer, + ffi.UnsignedInt, + ) > - >('clang_findReferencesInFile'); - late final _clang_findReferencesInFile = _clang_findReferencesInFilePtr - .asFunction(); + >('clang_indexSourceFileFullArgv'); + late final _clang_indexSourceFileFullArgv = _clang_indexSourceFileFullArgvPtr + .asFunction< + int Function( + CXIndexAction, + CXClientData, + ffi.Pointer, + int, + int, + ffi.Pointer, + ffi.Pointer>, + int, + ffi.Pointer, + int, + ffi.Pointer, + int, + ) + >(); - /// Find #import/#include directives in a specific file. - CXResult clang_findIncludesInFile( - CXTranslationUnit TU, - CXFile file, - CXCursorAndRangeVisitor visitor, + /// Index the given translation unit via callbacks implemented through + /// #IndexerCallbacks. + int clang_indexTranslationUnit( + CXIndexAction arg0, + CXClientData client_data, + ffi.Pointer index_callbacks, + int index_callbacks_size, + int index_options, + CXTranslationUnit arg5, ) { - return CXResult.fromValue(_clang_findIncludesInFile(TU, file, visitor)); + return _clang_indexTranslationUnit( + arg0, + client_data, + index_callbacks, + index_callbacks_size, + index_options, + arg5, + ); } - late final _clang_findIncludesInFilePtr = + late final _clang_indexTranslationUnitPtr = _lookup< ffi.NativeFunction< - ffi.UnsignedInt Function( + ffi.Int Function( + CXIndexAction, + CXClientData, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, CXTranslationUnit, - CXFile, - CXCursorAndRangeVisitor, ) > - >('clang_findIncludesInFile'); - late final _clang_findIncludesInFile = _clang_findIncludesInFilePtr + >('clang_indexTranslationUnit'); + late final _clang_indexTranslationUnit = _clang_indexTranslationUnitPtr .asFunction< - int Function(CXTranslationUnit, CXFile, CXCursorAndRangeVisitor) + int Function( + CXIndexAction, + CXClientData, + ffi.Pointer, + int, + int, + CXTranslationUnit, + ) >(); - int clang_index_isEntityObjCContainerKind(CXIdxEntityKind arg0) { - return _clang_index_isEntityObjCContainerKind(arg0.value); - } - - late final _clang_index_isEntityObjCContainerKindPtr = - _lookup>( - 'clang_index_isEntityObjCContainerKind', - ); - late final _clang_index_isEntityObjCContainerKind = - _clang_index_isEntityObjCContainerKindPtr.asFunction(); - - ffi.Pointer clang_index_getObjCContainerDeclInfo( + ffi.Pointer clang_index_getCXXClassDeclInfo( ffi.Pointer arg0, ) { - return _clang_index_getObjCContainerDeclInfo(arg0); + return _clang_index_getCXXClassDeclInfo(arg0); } - late final _clang_index_getObjCContainerDeclInfoPtr = + late final _clang_index_getCXXClassDeclInfoPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) > - >('clang_index_getObjCContainerDeclInfo'); - late final _clang_index_getObjCContainerDeclInfo = - _clang_index_getObjCContainerDeclInfoPtr + >('clang_index_getCXXClassDeclInfo'); + late final _clang_index_getCXXClassDeclInfo = + _clang_index_getCXXClassDeclInfoPtr .asFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) >(); - ffi.Pointer clang_index_getObjCInterfaceDeclInfo( - ffi.Pointer arg0, + /// For retrieving a custom CXIdxClientContainer attached to a container. + CXIdxClientContainer clang_index_getClientContainer( + ffi.Pointer arg0, ) { - return _clang_index_getObjCInterfaceDeclInfo(arg0); + return _clang_index_getClientContainer(arg0); } - late final _clang_index_getObjCInterfaceDeclInfoPtr = + late final _clang_index_getClientContainerPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, + CXIdxClientContainer Function(ffi.Pointer) + > + >('clang_index_getClientContainer'); + late final _clang_index_getClientContainer = + _clang_index_getClientContainerPtr + .asFunction< + CXIdxClientContainer Function(ffi.Pointer) + >(); + + /// For retrieving a custom CXIdxClientEntity attached to an entity. + CXIdxClientEntity clang_index_getClientEntity( + ffi.Pointer arg0, + ) { + return _clang_index_getClientEntity(arg0); + } + + late final _clang_index_getClientEntityPtr = + _lookup< + ffi.NativeFunction< + CXIdxClientEntity Function(ffi.Pointer) + > + >('clang_index_getClientEntity'); + late final _clang_index_getClientEntity = _clang_index_getClientEntityPtr + .asFunction)>(); + + ffi.Pointer + clang_index_getIBOutletCollectionAttrInfo(ffi.Pointer arg0) { + return _clang_index_getIBOutletCollectionAttrInfo(arg0); + } + + late final _clang_index_getIBOutletCollectionAttrInfoPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, ) > - >('clang_index_getObjCInterfaceDeclInfo'); - late final _clang_index_getObjCInterfaceDeclInfo = - _clang_index_getObjCInterfaceDeclInfoPtr + >('clang_index_getIBOutletCollectionAttrInfo'); + late final _clang_index_getIBOutletCollectionAttrInfo = + _clang_index_getIBOutletCollectionAttrInfoPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ) >(); @@ -5052,110 +4740,103 @@ class LibClang { ) >(); - ffi.Pointer - clang_index_getObjCProtocolRefListInfo(ffi.Pointer arg0) { - return _clang_index_getObjCProtocolRefListInfo(arg0); + ffi.Pointer clang_index_getObjCContainerDeclInfo( + ffi.Pointer arg0, + ) { + return _clang_index_getObjCContainerDeclInfo(arg0); } - late final _clang_index_getObjCProtocolRefListInfoPtr = + late final _clang_index_getObjCContainerDeclInfoPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) > - >('clang_index_getObjCProtocolRefListInfo'); - late final _clang_index_getObjCProtocolRefListInfo = - _clang_index_getObjCProtocolRefListInfoPtr + >('clang_index_getObjCContainerDeclInfo'); + late final _clang_index_getObjCContainerDeclInfo = + _clang_index_getObjCContainerDeclInfoPtr .asFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) >(); - ffi.Pointer clang_index_getObjCPropertyDeclInfo( + ffi.Pointer clang_index_getObjCInterfaceDeclInfo( ffi.Pointer arg0, ) { - return _clang_index_getObjCPropertyDeclInfo(arg0); + return _clang_index_getObjCInterfaceDeclInfo(arg0); } - late final _clang_index_getObjCPropertyDeclInfoPtr = + late final _clang_index_getObjCInterfaceDeclInfoPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) > - >('clang_index_getObjCPropertyDeclInfo'); - late final _clang_index_getObjCPropertyDeclInfo = - _clang_index_getObjCPropertyDeclInfoPtr + >('clang_index_getObjCInterfaceDeclInfo'); + late final _clang_index_getObjCInterfaceDeclInfo = + _clang_index_getObjCInterfaceDeclInfoPtr .asFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) >(); - ffi.Pointer - clang_index_getIBOutletCollectionAttrInfo(ffi.Pointer arg0) { - return _clang_index_getIBOutletCollectionAttrInfo(arg0); + ffi.Pointer clang_index_getObjCPropertyDeclInfo( + ffi.Pointer arg0, + ) { + return _clang_index_getObjCPropertyDeclInfo(arg0); } - late final _clang_index_getIBOutletCollectionAttrInfoPtr = + late final _clang_index_getObjCPropertyDeclInfoPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ) > - >('clang_index_getIBOutletCollectionAttrInfo'); - late final _clang_index_getIBOutletCollectionAttrInfo = - _clang_index_getIBOutletCollectionAttrInfoPtr + >('clang_index_getObjCPropertyDeclInfo'); + late final _clang_index_getObjCPropertyDeclInfo = + _clang_index_getObjCPropertyDeclInfoPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ) >(); - ffi.Pointer clang_index_getCXXClassDeclInfo( - ffi.Pointer arg0, - ) { - return _clang_index_getCXXClassDeclInfo(arg0); + ffi.Pointer + clang_index_getObjCProtocolRefListInfo(ffi.Pointer arg0) { + return _clang_index_getObjCProtocolRefListInfo(arg0); } - late final _clang_index_getCXXClassDeclInfoPtr = + late final _clang_index_getObjCProtocolRefListInfoPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) > - >('clang_index_getCXXClassDeclInfo'); - late final _clang_index_getCXXClassDeclInfo = - _clang_index_getCXXClassDeclInfoPtr + >('clang_index_getObjCProtocolRefListInfo'); + late final _clang_index_getObjCProtocolRefListInfo = + _clang_index_getObjCProtocolRefListInfoPtr .asFunction< - ffi.Pointer Function( + ffi.Pointer Function( ffi.Pointer, ) >(); - /// For retrieving a custom CXIdxClientContainer attached to a container. - CXIdxClientContainer clang_index_getClientContainer( - ffi.Pointer arg0, - ) { - return _clang_index_getClientContainer(arg0); + int clang_index_isEntityObjCContainerKind(CXIdxEntityKind arg0) { + return _clang_index_isEntityObjCContainerKind(arg0.value); } - late final _clang_index_getClientContainerPtr = - _lookup< - ffi.NativeFunction< - CXIdxClientContainer Function(ffi.Pointer) - > - >('clang_index_getClientContainer'); - late final _clang_index_getClientContainer = - _clang_index_getClientContainerPtr - .asFunction< - CXIdxClientContainer Function(ffi.Pointer) - >(); + late final _clang_index_isEntityObjCContainerKindPtr = + _lookup>( + 'clang_index_isEntityObjCContainerKind', + ); + late final _clang_index_isEntityObjCContainerKind = + _clang_index_isEntityObjCContainerKindPtr.asFunction(); /// For setting a custom CXIdxClientContainer attached to a container. void clang_index_setClientContainer( @@ -5180,22 +4861,6 @@ class LibClang { void Function(ffi.Pointer, CXIdxClientContainer) >(); - /// For retrieving a custom CXIdxClientEntity attached to an entity. - CXIdxClientEntity clang_index_getClientEntity( - ffi.Pointer arg0, - ) { - return _clang_index_getClientEntity(arg0); - } - - late final _clang_index_getClientEntityPtr = - _lookup< - ffi.NativeFunction< - CXIdxClientEntity Function(ffi.Pointer) - > - >('clang_index_getClientEntity'); - late final _clang_index_getClientEntity = _clang_index_getClientEntityPtr - .asFunction)>(); - /// For setting a custom CXIdxClientEntity attached to an entity. void clang_index_setClientEntity( ffi.Pointer arg0, @@ -5215,881 +4880,1096 @@ class LibClang { void Function(ffi.Pointer, CXIdxClientEntity) >(); - /// An indexing action/session, to be applied to one or multiple translation - /// units. - CXIndexAction clang_IndexAction_create(CXIndex CIdx) { - return _clang_IndexAction_create(CIdx); + /// Determine whether the given cursor kind represents an attribute. + int clang_isAttribute(CXCursorKind arg0) { + return _clang_isAttribute(arg0.value); } - late final _clang_IndexAction_createPtr = - _lookup>( - 'clang_IndexAction_create', + late final _clang_isAttributePtr = + _lookup>( + 'clang_isAttribute', ); - late final _clang_IndexAction_create = _clang_IndexAction_createPtr - .asFunction(); + late final _clang_isAttribute = _clang_isAttributePtr + .asFunction(); - /// Destroy the given index action. - void clang_IndexAction_dispose(CXIndexAction arg0) { - return _clang_IndexAction_dispose(arg0); + /// Determine whether a CXType has the "const" qualifier set, without looking + /// through typedefs that may have added "const" at a different level. + int clang_isConstQualifiedType(CXType T) { + return _clang_isConstQualifiedType(T); } - late final _clang_IndexAction_disposePtr = - _lookup>( - 'clang_IndexAction_dispose', + late final _clang_isConstQualifiedTypePtr = + _lookup>( + 'clang_isConstQualifiedType', ); - late final _clang_IndexAction_dispose = _clang_IndexAction_disposePtr - .asFunction(); + late final _clang_isConstQualifiedType = _clang_isConstQualifiedTypePtr + .asFunction(); - /// Index the given source file and the translation unit corresponding to that - /// file via callbacks implemented through #IndexerCallbacks. - int clang_indexSourceFile( - CXIndexAction arg0, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - ffi.Pointer out_TU, - int TU_options, - ) { - return _clang_indexSourceFile( - arg0, - client_data, - index_callbacks, - index_callbacks_size, - index_options, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - out_TU, - TU_options, - ); + /// Determine whether the declaration pointed to by this cursor is also a + /// definition of that entity. + int clang_isCursorDefinition(CXCursor arg0) { + return _clang_isCursorDefinition(arg0); } - late final _clang_indexSourceFilePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - CXIndexAction, - CXClientData, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('clang_indexSourceFile'); - late final _clang_indexSourceFile = _clang_indexSourceFilePtr - .asFunction< - int Function( - CXIndexAction, - CXClientData, - ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ) - >(); + late final _clang_isCursorDefinitionPtr = + _lookup>( + 'clang_isCursorDefinition', + ); + late final _clang_isCursorDefinition = _clang_isCursorDefinitionPtr + .asFunction(); - /// Same as clang_indexSourceFile but requires a full command line for - /// command_line_args including argv[0]. This is useful if the standard - /// library paths are relative to the binary. - int clang_indexSourceFileFullArgv( - CXIndexAction arg0, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - ffi.Pointer source_filename, - ffi.Pointer> command_line_args, - int num_command_line_args, - ffi.Pointer unsaved_files, - int num_unsaved_files, - ffi.Pointer out_TU, - int TU_options, - ) { - return _clang_indexSourceFileFullArgv( - arg0, - client_data, - index_callbacks, - index_callbacks_size, - index_options, - source_filename, - command_line_args, - num_command_line_args, - unsaved_files, - num_unsaved_files, - out_TU, - TU_options, - ); + /// Determine whether the given cursor kind represents a declaration. + int clang_isDeclaration(CXCursorKind arg0) { + return _clang_isDeclaration(arg0.value); } - late final _clang_indexSourceFileFullArgvPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - CXIndexAction, - CXClientData, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer, - ffi.UnsignedInt, - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('clang_indexSourceFileFullArgv'); - late final _clang_indexSourceFileFullArgv = _clang_indexSourceFileFullArgvPtr - .asFunction< - int Function( - CXIndexAction, - CXClientData, - ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer, - int, - ffi.Pointer, - int, - ) - >(); + late final _clang_isDeclarationPtr = + _lookup>( + 'clang_isDeclaration', + ); + late final _clang_isDeclaration = _clang_isDeclarationPtr + .asFunction(); - /// Index the given translation unit via callbacks implemented through - /// #IndexerCallbacks. - int clang_indexTranslationUnit( - CXIndexAction arg0, - CXClientData client_data, - ffi.Pointer index_callbacks, - int index_callbacks_size, - int index_options, - CXTranslationUnit arg5, - ) { - return _clang_indexTranslationUnit( - arg0, - client_data, - index_callbacks, - index_callbacks_size, - index_options, - arg5, - ); + /// Determine whether the given cursor kind represents an expression. + int clang_isExpression(CXCursorKind arg0) { + return _clang_isExpression(arg0.value); } - late final _clang_indexTranslationUnitPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - CXIndexAction, - CXClientData, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - CXTranslationUnit, - ) - > - >('clang_indexTranslationUnit'); - late final _clang_indexTranslationUnit = _clang_indexTranslationUnitPtr - .asFunction< - int Function( - CXIndexAction, - CXClientData, - ffi.Pointer, - int, - int, - CXTranslationUnit, - ) - >(); + late final _clang_isExpressionPtr = + _lookup>( + 'clang_isExpression', + ); + late final _clang_isExpression = _clang_isExpressionPtr + .asFunction(); - /// Retrieve the CXIdxFile, file, line, column, and offset represented by the - /// given CXIdxLoc. - void clang_indexLoc_getFileLocation( - CXIdxLoc loc, - ffi.Pointer indexFile, - ffi.Pointer file, - ffi.Pointer line, - ffi.Pointer column, - ffi.Pointer offset, - ) { - return _clang_indexLoc_getFileLocation( - loc, - indexFile, - file, - line, - column, - offset, - ); + /// Determine whether the given header is guarded against multiple inclusions, + /// either with the conventional #ifndef/#define/#endif macro guards or with + /// #pragma once. + int clang_isFileMultipleIncludeGuarded(CXTranslationUnit tu, CXFile file) { + return _clang_isFileMultipleIncludeGuarded(tu, file); } - late final _clang_indexLoc_getFileLocationPtr = + late final _clang_isFileMultipleIncludeGuardedPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - CXIdxLoc, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >('clang_indexLoc_getFileLocation'); - late final _clang_indexLoc_getFileLocation = - _clang_indexLoc_getFileLocationPtr - .asFunction< - void Function( - CXIdxLoc, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); + ffi.NativeFunction + >('clang_isFileMultipleIncludeGuarded'); + late final _clang_isFileMultipleIncludeGuarded = + _clang_isFileMultipleIncludeGuardedPtr + .asFunction(); - /// Retrieve the CXSourceLocation represented by the given CXIdxLoc. - CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc loc) { - return _clang_indexLoc_getCXSourceLocation(loc); + /// Return 1 if the CXType is a variadic function type, and 0 otherwise. + int clang_isFunctionTypeVariadic(CXType T) { + return _clang_isFunctionTypeVariadic(T); } - late final _clang_indexLoc_getCXSourceLocationPtr = - _lookup>( - 'clang_indexLoc_getCXSourceLocation', + late final _clang_isFunctionTypeVariadicPtr = + _lookup>( + 'clang_isFunctionTypeVariadic', ); - late final _clang_indexLoc_getCXSourceLocation = - _clang_indexLoc_getCXSourceLocationPtr - .asFunction(); + late final _clang_isFunctionTypeVariadic = _clang_isFunctionTypeVariadicPtr + .asFunction(); - /// Visit the fields of a particular type. - int clang_Type_visitFields( - CXType T, - CXFieldVisitor visitor, - CXClientData client_data, - ) { - return _clang_Type_visitFields(T, visitor, client_data); + /// Determine whether the given cursor kind represents an invalid cursor. + int clang_isInvalid(CXCursorKind arg0) { + return _clang_isInvalid(arg0.value); } - late final _clang_Type_visitFieldsPtr = - _lookup< - ffi.NativeFunction< - ffi.UnsignedInt Function(CXType, CXFieldVisitor, CXClientData) - > - >('clang_Type_visitFields'); - late final _clang_Type_visitFields = _clang_Type_visitFieldsPtr - .asFunction(); -} - -/// Error codes returned by libclang routines. -enum CXErrorCode { - /// No error. - CXError_Success(0), + late final _clang_isInvalidPtr = + _lookup>( + 'clang_isInvalid', + ); + late final _clang_isInvalid = _clang_isInvalidPtr + .asFunction(); - /// A generic error code, no further details are available. - CXError_Failure(1), + /// Determine whether the given declaration is invalid. + int clang_isInvalidDeclaration(CXCursor arg0) { + return _clang_isInvalidDeclaration(arg0); + } - /// libclang crashed while performing the requested operation. - CXError_Crashed(2), + late final _clang_isInvalidDeclarationPtr = + _lookup>( + 'clang_isInvalidDeclaration', + ); + late final _clang_isInvalidDeclaration = _clang_isInvalidDeclarationPtr + .asFunction(); - /// The function detected that the arguments violate the function contract. - CXError_InvalidArguments(3), + /// Return 1 if the CXType is a POD (plain old data) type, and 0 otherwise. + int clang_isPODType(CXType T) { + return _clang_isPODType(T); + } - /// An AST deserialization error has occurred. - CXError_ASTReadError(4); + late final _clang_isPODTypePtr = + _lookup>( + 'clang_isPODType', + ); + late final _clang_isPODType = _clang_isPODTypePtr + .asFunction(); - final int value; - const CXErrorCode(this.value); + /// * Determine whether the given cursor represents a preprocessing element, + /// such as a preprocessor directive or macro instantiation. + int clang_isPreprocessing(CXCursorKind arg0) { + return _clang_isPreprocessing(arg0.value); + } - static CXErrorCode fromValue(int value) => switch (value) { - 0 => CXError_Success, - 1 => CXError_Failure, - 2 => CXError_Crashed, - 3 => CXError_InvalidArguments, - 4 => CXError_ASTReadError, - _ => throw ArgumentError('Unknown value for CXErrorCode: $value'), - }; -} + late final _clang_isPreprocessingPtr = + _lookup>( + 'clang_isPreprocessing', + ); + late final _clang_isPreprocessing = _clang_isPreprocessingPtr + .asFunction(); -/// A character string. -final class CXString extends ffi.Struct { - external ffi.Pointer data; + /// Determine whether the given cursor kind represents a simple reference. + int clang_isReference(CXCursorKind arg0) { + return _clang_isReference(arg0.value); + } - @ffi.UnsignedInt() - external int private_flags; -} + late final _clang_isReferencePtr = + _lookup>( + 'clang_isReference', + ); + late final _clang_isReference = _clang_isReferencePtr + .asFunction(); -final class CXStringSet extends ffi.Struct { - external ffi.Pointer Strings; + /// Determine whether a CXType has the "restrict" qualifier set, without + /// looking through typedefs that may have added "restrict" at a different + /// level. + int clang_isRestrictQualifiedType(CXType T) { + return _clang_isRestrictQualifiedType(T); + } - @ffi.UnsignedInt() - external int Count; -} + late final _clang_isRestrictQualifiedTypePtr = + _lookup>( + 'clang_isRestrictQualifiedType', + ); + late final _clang_isRestrictQualifiedType = _clang_isRestrictQualifiedTypePtr + .asFunction(); -final class CXVirtualFileOverlayImpl extends ffi.Opaque {} + /// Determine whether the given cursor kind represents a statement. + int clang_isStatement(CXCursorKind arg0) { + return _clang_isStatement(arg0.value); + } -/// Object encapsulating information about overlaying virtual file/directories -/// over the real file system. -typedef CXVirtualFileOverlay = ffi.Pointer; - -final class CXModuleMapDescriptorImpl extends ffi.Opaque {} + late final _clang_isStatementPtr = + _lookup>( + 'clang_isStatement', + ); + late final _clang_isStatement = _clang_isStatementPtr + .asFunction(); -/// Object encapsulating information about a module.map file. -typedef CXModuleMapDescriptor = ffi.Pointer; + /// Determine whether the given cursor kind represents a translation unit. + int clang_isTranslationUnit(CXCursorKind arg0) { + return _clang_isTranslationUnit(arg0.value); + } -/// An "index" that consists of a set of translation units that would typically -/// be linked together into an executable or library. -typedef CXIndex = ffi.Pointer; + late final _clang_isTranslationUnitPtr = + _lookup>( + 'clang_isTranslationUnit', + ); + late final _clang_isTranslationUnit = _clang_isTranslationUnitPtr + .asFunction(); -final class CXTargetInfoImpl extends ffi.Opaque {} + /// * Determine whether the given cursor represents a currently unexposed + /// piece of the AST (e.g., CXCursor_UnexposedStmt). + int clang_isUnexposed(CXCursorKind arg0) { + return _clang_isUnexposed(arg0.value); + } -/// An opaque type representing target information for a given translation unit. -typedef CXTargetInfo = ffi.Pointer; + late final _clang_isUnexposedPtr = + _lookup>( + 'clang_isUnexposed', + ); + late final _clang_isUnexposed = _clang_isUnexposedPtr + .asFunction(); -final class CXTranslationUnitImpl extends ffi.Opaque {} + /// Returns 1 if the base class specified by the cursor with kind + /// CX_CXXBaseSpecifier is virtual. + int clang_isVirtualBase(CXCursor arg0) { + return _clang_isVirtualBase(arg0); + } -/// A single translation unit, which resides in an index. -typedef CXTranslationUnit = ffi.Pointer; + late final _clang_isVirtualBasePtr = + _lookup>( + 'clang_isVirtualBase', + ); + late final _clang_isVirtualBase = _clang_isVirtualBasePtr + .asFunction(); -/// Opaque pointer representing client data that will be passed through to -/// various callbacks and visitors. -typedef CXClientData = ffi.Pointer; + /// Determine whether a CXType has the "volatile" qualifier set, without + /// looking through typedefs that may have added "volatile" at a different + /// level. + int clang_isVolatileQualifiedType(CXType T) { + return _clang_isVolatileQualifiedType(T); + } -/// Provides the contents of a file that has not yet been saved to disk. -final class CXUnsavedFile extends ffi.Struct { - /// The file whose contents have not yet been saved. - external ffi.Pointer Filename; + late final _clang_isVolatileQualifiedTypePtr = + _lookup>( + 'clang_isVolatileQualifiedType', + ); + late final _clang_isVolatileQualifiedType = _clang_isVolatileQualifiedTypePtr + .asFunction(); - /// A buffer containing the unsaved contents of this file. - external ffi.Pointer Contents; + /// Deserialize a set of diagnostics from a Clang diagnostics bitcode file. + CXDiagnosticSet clang_loadDiagnostics( + ffi.Pointer file, + ffi.Pointer error, + ffi.Pointer errorString, + ) { + return _clang_loadDiagnostics(file, error, errorString); + } - /// The length of the unsaved contents of this buffer. - @ffi.UnsignedLong() - external int Length; -} + late final _clang_loadDiagnosticsPtr = + _lookup< + ffi.NativeFunction< + CXDiagnosticSet Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('clang_loadDiagnostics'); + late final _clang_loadDiagnostics = _clang_loadDiagnosticsPtr + .asFunction< + CXDiagnosticSet Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); -/// Describes the availability of a particular entity, which indicates whether -/// the use of this entity will result in a warning or error due to it being -/// deprecated or unavailable. -enum CXAvailabilityKind { - /// The entity is available. - CXAvailability_Available(0), + /// Same as clang_parseTranslationUnit2, but returns the CXTranslationUnit + /// instead of an error code. In case of an error this routine returns a NULL + /// CXTranslationUnit, without further detailed error codes. + CXTranslationUnit clang_parseTranslationUnit( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ) { + return _clang_parseTranslationUnit( + CIdx, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + options, + ); + } - /// The entity is available, but has been deprecated (and its use is not - /// recommended). - CXAvailability_Deprecated(1), + late final _clang_parseTranslationUnitPtr = + _lookup< + ffi.NativeFunction< + CXTranslationUnit Function( + CXIndex, + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ) + > + >('clang_parseTranslationUnit'); + late final _clang_parseTranslationUnit = _clang_parseTranslationUnitPtr + .asFunction< + CXTranslationUnit Function( + CXIndex, + ffi.Pointer, + ffi.Pointer>, + int, + ffi.Pointer, + int, + int, + ) + >(); - /// The entity is not available; any use of it will be an error. - CXAvailability_NotAvailable(2), + /// Parse the given source file and the translation unit corresponding to that + /// file. + CXErrorCode clang_parseTranslationUnit2( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ffi.Pointer out_TU, + ) { + return CXErrorCode.fromValue( + _clang_parseTranslationUnit2( + CIdx, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + options, + out_TU, + ), + ); + } - /// The entity is available, but not accessible; any use of it will be an - /// error. - CXAvailability_NotAccessible(3); + late final _clang_parseTranslationUnit2Ptr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function( + CXIndex, + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.Pointer, + ) + > + >('clang_parseTranslationUnit2'); + late final _clang_parseTranslationUnit2 = _clang_parseTranslationUnit2Ptr + .asFunction< + int Function( + CXIndex, + ffi.Pointer, + ffi.Pointer>, + int, + ffi.Pointer, + int, + int, + ffi.Pointer, + ) + >(); - final int value; - const CXAvailabilityKind(this.value); + /// Same as clang_parseTranslationUnit2 but requires a full command line for + /// command_line_args including argv[0]. This is useful if the standard + /// library paths are relative to the binary. + CXErrorCode clang_parseTranslationUnit2FullArgv( + CXIndex CIdx, + ffi.Pointer source_filename, + ffi.Pointer> command_line_args, + int num_command_line_args, + ffi.Pointer unsaved_files, + int num_unsaved_files, + int options, + ffi.Pointer out_TU, + ) { + return CXErrorCode.fromValue( + _clang_parseTranslationUnit2FullArgv( + CIdx, + source_filename, + command_line_args, + num_command_line_args, + unsaved_files, + num_unsaved_files, + options, + out_TU, + ), + ); + } - static CXAvailabilityKind fromValue(int value) => switch (value) { - 0 => CXAvailability_Available, - 1 => CXAvailability_Deprecated, - 2 => CXAvailability_NotAvailable, - 3 => CXAvailability_NotAccessible, - _ => throw ArgumentError('Unknown value for CXAvailabilityKind: $value'), - }; -} - -/// Describes a version number of the form major.minor.subminor. -final class CXVersion extends ffi.Struct { - /// The major version number, e.g., the '10' in '10.7.3'. A negative value - /// indicates that there is no version number at all. - @ffi.Int() - external int Major; - - /// The minor version number, e.g., the '7' in '10.7.3'. This value will be - /// negative if no minor version number was provided, e.g., for version '10'. - @ffi.Int() - external int Minor; - - /// The subminor version number, e.g., the '3' in '10.7.3'. This value will be - /// negative if no minor or subminor version number was provided, e.g., in - /// version '10' or '10.7'. - @ffi.Int() - external int Subminor; -} + late final _clang_parseTranslationUnit2FullArgvPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function( + CXIndex, + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ffi.Pointer, + ) + > + >('clang_parseTranslationUnit2FullArgv'); + late final _clang_parseTranslationUnit2FullArgv = + _clang_parseTranslationUnit2FullArgvPtr + .asFunction< + int Function( + CXIndex, + ffi.Pointer, + ffi.Pointer>, + int, + ffi.Pointer, + int, + int, + ffi.Pointer, + ) + >(); -/// Describes the exception specification of a cursor. -enum CXCursor_ExceptionSpecificationKind { - /// The cursor has no exception specification. - CXCursor_ExceptionSpecificationKind_None(0), + /// Dispose the remapping. + void clang_remap_dispose(CXRemapping arg0) { + return _clang_remap_dispose(arg0); + } - /// The cursor has exception specification throw() - CXCursor_ExceptionSpecificationKind_DynamicNone(1), + late final _clang_remap_disposePtr = + _lookup>( + 'clang_remap_dispose', + ); + late final _clang_remap_dispose = _clang_remap_disposePtr + .asFunction(); - /// The cursor has exception specification throw(T1, T2) - CXCursor_ExceptionSpecificationKind_Dynamic(2), + /// Get the original and the associated filename from the remapping. + void clang_remap_getFilenames( + CXRemapping arg0, + int index, + ffi.Pointer original, + ffi.Pointer transformed, + ) { + return _clang_remap_getFilenames(arg0, index, original, transformed); + } - /// The cursor has exception specification throw(...). - CXCursor_ExceptionSpecificationKind_MSAny(3), + late final _clang_remap_getFilenamesPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + CXRemapping, + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ) + > + >('clang_remap_getFilenames'); + late final _clang_remap_getFilenames = _clang_remap_getFilenamesPtr + .asFunction< + void Function( + CXRemapping, + int, + ffi.Pointer, + ffi.Pointer, + ) + >(); - /// The cursor has exception specification basic noexcept. - CXCursor_ExceptionSpecificationKind_BasicNoexcept(4), + /// Determine the number of remappings. + int clang_remap_getNumFiles(CXRemapping arg0) { + return _clang_remap_getNumFiles(arg0); + } - /// The cursor has exception specification computed noexcept. - CXCursor_ExceptionSpecificationKind_ComputedNoexcept(5), + late final _clang_remap_getNumFilesPtr = + _lookup>( + 'clang_remap_getNumFiles', + ); + late final _clang_remap_getNumFiles = _clang_remap_getNumFilesPtr + .asFunction(); - /// The exception specification has not yet been evaluated. - CXCursor_ExceptionSpecificationKind_Unevaluated(6), + /// Reparse the source files that produced this translation unit. + int clang_reparseTranslationUnit( + CXTranslationUnit TU, + int num_unsaved_files, + ffi.Pointer unsaved_files, + int options, + ) { + return _clang_reparseTranslationUnit( + TU, + num_unsaved_files, + unsaved_files, + options, + ); + } - /// The exception specification has not yet been instantiated. - CXCursor_ExceptionSpecificationKind_Uninstantiated(7), + late final _clang_reparseTranslationUnitPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + CXTranslationUnit, + ffi.UnsignedInt, + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('clang_reparseTranslationUnit'); + late final _clang_reparseTranslationUnit = _clang_reparseTranslationUnitPtr + .asFunction< + int Function(CXTranslationUnit, int, ffi.Pointer, int) + >(); - /// The exception specification has not been parsed yet. - CXCursor_ExceptionSpecificationKind_Unparsed(8), + /// Saves a translation unit into a serialized representation of that + /// translation unit on disk. + int clang_saveTranslationUnit( + CXTranslationUnit TU, + ffi.Pointer FileName, + int options, + ) { + return _clang_saveTranslationUnit(TU, FileName, options); + } - /// The cursor has a __declspec(nothrow) exception specification. - CXCursor_ExceptionSpecificationKind_NoThrow(9); + late final _clang_saveTranslationUnitPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + CXTranslationUnit, + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('clang_saveTranslationUnit'); + late final _clang_saveTranslationUnit = _clang_saveTranslationUnitPtr + .asFunction< + int Function(CXTranslationUnit, ffi.Pointer, int) + >(); - final int value; - const CXCursor_ExceptionSpecificationKind(this.value); + /// Sort the code-completion results in case-insensitive alphabetical order. + void clang_sortCodeCompletionResults( + ffi.Pointer Results, + int NumResults, + ) { + return _clang_sortCodeCompletionResults(Results, NumResults); + } - static CXCursor_ExceptionSpecificationKind fromValue(int value) => - switch (value) { - 0 => CXCursor_ExceptionSpecificationKind_None, - 1 => CXCursor_ExceptionSpecificationKind_DynamicNone, - 2 => CXCursor_ExceptionSpecificationKind_Dynamic, - 3 => CXCursor_ExceptionSpecificationKind_MSAny, - 4 => CXCursor_ExceptionSpecificationKind_BasicNoexcept, - 5 => CXCursor_ExceptionSpecificationKind_ComputedNoexcept, - 6 => CXCursor_ExceptionSpecificationKind_Unevaluated, - 7 => CXCursor_ExceptionSpecificationKind_Uninstantiated, - 8 => CXCursor_ExceptionSpecificationKind_Unparsed, - 9 => CXCursor_ExceptionSpecificationKind_NoThrow, - _ => throw ArgumentError( - 'Unknown value for CXCursor_ExceptionSpecificationKind: $value', - ), - }; -} + late final _clang_sortCodeCompletionResultsPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) + > + >('clang_sortCodeCompletionResults'); + late final _clang_sortCodeCompletionResults = + _clang_sortCodeCompletionResultsPtr + .asFunction, int)>(); -enum CXGlobalOptFlags { - /// Used to indicate that no special CXIndex options are needed. - CXGlobalOpt_None(0), + /// Suspend a translation unit in order to free memory associated with it. + int clang_suspendTranslationUnit(CXTranslationUnit arg0) { + return _clang_suspendTranslationUnit(arg0); + } - /// Used to indicate that threads that libclang creates for indexing purposes - /// should use background priority. - CXGlobalOpt_ThreadBackgroundPriorityForIndexing(1), + late final _clang_suspendTranslationUnitPtr = + _lookup>( + 'clang_suspendTranslationUnit', + ); + late final _clang_suspendTranslationUnit = _clang_suspendTranslationUnitPtr + .asFunction(); - /// Used to indicate that threads that libclang creates for editing purposes - /// should use background priority. - CXGlobalOpt_ThreadBackgroundPriorityForEditing(2), + /// Enable/disable crash recovery. + void clang_toggleCrashRecovery(int isEnabled) { + return _clang_toggleCrashRecovery(isEnabled); + } - /// Used to indicate that all threads that libclang creates should use - /// background priority. - CXGlobalOpt_ThreadBackgroundPriorityForAll(3); + late final _clang_toggleCrashRecoveryPtr = + _lookup>( + 'clang_toggleCrashRecovery', + ); + late final _clang_toggleCrashRecovery = _clang_toggleCrashRecoveryPtr + .asFunction(); - final int value; - const CXGlobalOptFlags(this.value); + /// Tokenize the source code described by the given range into raw lexical + /// tokens. + void clang_tokenize( + CXTranslationUnit TU, + CXSourceRange Range, + ffi.Pointer> Tokens, + ffi.Pointer NumTokens, + ) { + return _clang_tokenize(TU, Range, Tokens, NumTokens); + } - static CXGlobalOptFlags fromValue(int value) => switch (value) { - 0 => CXGlobalOpt_None, - 1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing, - 2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing, - 3 => CXGlobalOpt_ThreadBackgroundPriorityForAll, - _ => throw ArgumentError('Unknown value for CXGlobalOptFlags: $value'), - }; -} + late final _clang_tokenizePtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + CXTranslationUnit, + CXSourceRange, + ffi.Pointer>, + ffi.Pointer, + ) + > + >('clang_tokenize'); + late final _clang_tokenize = _clang_tokenizePtr + .asFunction< + void Function( + CXTranslationUnit, + CXSourceRange, + ffi.Pointer>, + ffi.Pointer, + ) + >(); -/// A particular source file that is part of a translation unit. -typedef CXFile = ffi.Pointer; + /// Visit the children of a particular cursor. + int clang_visitChildren( + CXCursor parent, + CXCursorVisitor visitor, + CXClientData client_data, + ) { + return _clang_visitChildren(parent, visitor, client_data); + } -/// Uniquely identifies a CXFile, that refers to the same underlying file, -/// across an indexing session. -final class CXFileUniqueID extends ffi.Struct { - @ffi.Array.multi([3]) - external ffi.Array data; + late final _clang_visitChildrenPtr = + _lookup< + ffi.NativeFunction< + ffi.UnsignedInt Function(CXCursor, CXCursorVisitor, CXClientData) + > + >('clang_visitChildren'); + late final _clang_visitChildren = _clang_visitChildrenPtr + .asFunction(); } -/// Identifies a specific source location within a translation unit. -final class CXSourceLocation extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array> ptr_data; +const int CINDEX_VERSION = 59; - @ffi.UnsignedInt() - external int int_data; -} +const int CINDEX_VERSION_MAJOR = 0; -/// Identifies a half-open character range in the source code. -final class CXSourceRange extends ffi.Struct { - @ffi.Array.multi([2]) - external ffi.Array> ptr_data; +const int CINDEX_VERSION_MINOR = 59; - @ffi.UnsignedInt() - external int begin_int_data; +const String CINDEX_VERSION_STRING = '0.59'; - @ffi.UnsignedInt() - external int end_int_data; -} +/// Describes the availability of a particular entity, which indicates whether +/// the use of this entity will result in a warning or error due to it being +/// deprecated or unavailable. +enum CXAvailabilityKind { + /// The entity is available. + CXAvailability_Available(0), -/// Identifies an array of ranges. -final class CXSourceRangeList extends ffi.Struct { - /// The number of ranges in the ranges array. - @ffi.UnsignedInt() - external int count; + /// The entity is available, but has been deprecated (and its use is not + /// recommended). + CXAvailability_Deprecated(1), - /// An array of CXSourceRanges. - external ffi.Pointer ranges; -} + /// The entity is not available; any use of it will be an error. + CXAvailability_NotAvailable(2), -/// Describes the severity of a particular diagnostic. -enum CXDiagnosticSeverity { - /// A diagnostic that has been suppressed, e.g., by a command-line option. - CXDiagnostic_Ignored(0), + /// The entity is available, but not accessible; any use of it will be an + /// error. + CXAvailability_NotAccessible(3); - /// This diagnostic is a note that should be attached to the previous - /// (non-note) diagnostic. - CXDiagnostic_Note(1), + final int value; + const CXAvailabilityKind(this.value); - /// This diagnostic indicates suspicious code that may not be wrong. - CXDiagnostic_Warning(2), + static CXAvailabilityKind fromValue(int value) => switch (value) { + 0 => CXAvailability_Available, + 1 => CXAvailability_Deprecated, + 2 => CXAvailability_NotAvailable, + 3 => CXAvailability_NotAccessible, + _ => throw ArgumentError('Unknown value for CXAvailabilityKind: $value'), + }; +} - /// This diagnostic indicates that the code is ill-formed. - CXDiagnostic_Error(3), +/// Describes the calling convention of a function type +enum CXCallingConv { + CXCallingConv_Default(0), + CXCallingConv_C(1), + CXCallingConv_X86StdCall(2), + CXCallingConv_X86FastCall(3), + CXCallingConv_X86ThisCall(4), + CXCallingConv_X86Pascal(5), + CXCallingConv_AAPCS(6), + CXCallingConv_AAPCS_VFP(7), + CXCallingConv_X86RegCall(8), + CXCallingConv_IntelOclBicc(9), + CXCallingConv_Win64(10), + CXCallingConv_X86_64SysV(11), + CXCallingConv_X86VectorCall(12), + CXCallingConv_Swift(13), + CXCallingConv_PreserveMost(14), + CXCallingConv_PreserveAll(15), + CXCallingConv_AArch64VectorCall(16), + CXCallingConv_Invalid(100), + CXCallingConv_Unexposed(200); - /// This diagnostic indicates that the code is ill-formed such that future - /// parser recovery is unlikely to produce useful results. - CXDiagnostic_Fatal(4); + static const CXCallingConv_X86_64Win64 = CXCallingConv_Win64; final int value; - const CXDiagnosticSeverity(this.value); + const CXCallingConv(this.value); - static CXDiagnosticSeverity fromValue(int value) => switch (value) { - 0 => CXDiagnostic_Ignored, - 1 => CXDiagnostic_Note, - 2 => CXDiagnostic_Warning, - 3 => CXDiagnostic_Error, - 4 => CXDiagnostic_Fatal, - _ => throw ArgumentError('Unknown value for CXDiagnosticSeverity: $value'), + static CXCallingConv fromValue(int value) => switch (value) { + 0 => CXCallingConv_Default, + 1 => CXCallingConv_C, + 2 => CXCallingConv_X86StdCall, + 3 => CXCallingConv_X86FastCall, + 4 => CXCallingConv_X86ThisCall, + 5 => CXCallingConv_X86Pascal, + 6 => CXCallingConv_AAPCS, + 7 => CXCallingConv_AAPCS_VFP, + 8 => CXCallingConv_X86RegCall, + 9 => CXCallingConv_IntelOclBicc, + 10 => CXCallingConv_Win64, + 11 => CXCallingConv_X86_64SysV, + 12 => CXCallingConv_X86VectorCall, + 13 => CXCallingConv_Swift, + 14 => CXCallingConv_PreserveMost, + 15 => CXCallingConv_PreserveAll, + 16 => CXCallingConv_AArch64VectorCall, + 100 => CXCallingConv_Invalid, + 200 => CXCallingConv_Unexposed, + _ => throw ArgumentError('Unknown value for CXCallingConv: $value'), }; -} - -/// A single diagnostic, containing the diagnostic's severity, location, text, -/// source ranges, and fix-it hints. -typedef CXDiagnostic = ffi.Pointer; -/// A group of CXDiagnostics. -typedef CXDiagnosticSet = ffi.Pointer; - -/// Describes the kind of error that occurred (if any) in a call to -/// clang_loadDiagnostics. -enum CXLoadDiag_Error { - /// Indicates that no error occurred. - CXLoadDiag_None(0), + @override + String toString() { + if (this == CXCallingConv_Win64) + return "CXCallingConv.CXCallingConv_Win64, CXCallingConv.CXCallingConv_X86_64Win64"; + return super.toString(); + } +} - /// Indicates that an unknown error occurred while attempting to deserialize - /// diagnostics. - CXLoadDiag_Unknown(1), +/// Describes how the traversal of the children of a particular cursor should +/// proceed after visiting a particular child cursor. +enum CXChildVisitResult { + /// Terminates the cursor traversal. + CXChildVisit_Break(0), - /// Indicates that the file containing the serialized diagnostics could not be - /// opened. - CXLoadDiag_CannotLoad(2), + /// Continues the cursor traversal with the next sibling of the cursor just + /// visited, without visiting its children. + CXChildVisit_Continue(1), - /// Indicates that the serialized diagnostics file is invalid or corrupt. - CXLoadDiag_InvalidFile(3); + /// Recursively traverse the children of this cursor, using the same visitor + /// and client data. + CXChildVisit_Recurse(2); final int value; - const CXLoadDiag_Error(this.value); + const CXChildVisitResult(this.value); - static CXLoadDiag_Error fromValue(int value) => switch (value) { - 0 => CXLoadDiag_None, - 1 => CXLoadDiag_Unknown, - 2 => CXLoadDiag_CannotLoad, - 3 => CXLoadDiag_InvalidFile, - _ => throw ArgumentError('Unknown value for CXLoadDiag_Error: $value'), + static CXChildVisitResult fromValue(int value) => switch (value) { + 0 => CXChildVisit_Break, + 1 => CXChildVisit_Continue, + 2 => CXChildVisit_Recurse, + _ => throw ArgumentError('Unknown value for CXChildVisitResult: $value'), }; } -/// Options to control the display of diagnostics. -enum CXDiagnosticDisplayOptions { - /// Display the source-location information where the diagnostic was located. - CXDiagnostic_DisplaySourceLocation(1), +/// Opaque pointer representing client data that will be passed through to +/// various callbacks and visitors. +typedef CXClientData = ffi.Pointer; - /// If displaying the source-location information of the diagnostic, also - /// include the column number. - CXDiagnostic_DisplayColumn(2), +/// Contains the results of code-completion. +final class CXCodeCompleteResults extends ffi.Struct { + /// The code-completion results. + external ffi.Pointer Results; - /// If displaying the source-location information of the diagnostic, also - /// include information about source ranges in a machine-parsable format. - CXDiagnostic_DisplaySourceRanges(4), + /// The number of code-completion results stored in the Results array. + @ffi.UnsignedInt() + external int NumResults; - /// Display the option name associated with this diagnostic, if any. - CXDiagnostic_DisplayOption(8), + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer Results, + required int NumResults, + }) => $allocator() + ..ref.Results = Results + ..ref.NumResults = NumResults; +} - /// Display the category number associated with this diagnostic, if any. - CXDiagnostic_DisplayCategoryId(16), +/// Flags that can be passed to clang_codeCompleteAt() to modify its behavior. +enum CXCodeComplete_Flags { + /// Whether to include macros within the set of code completions returned. + CXCodeComplete_IncludeMacros(1), - /// Display the category name associated with this diagnostic, if any. - CXDiagnostic_DisplayCategoryName(32); + /// Whether to include code patterns for language constructs within the set of + /// code completions, e.g., for loops. + CXCodeComplete_IncludeCodePatterns(2), - final int value; - const CXDiagnosticDisplayOptions(this.value); + /// Whether to include brief documentation within the set of code completions + /// returned. + CXCodeComplete_IncludeBriefComments(4), - static CXDiagnosticDisplayOptions fromValue(int value) => switch (value) { - 1 => CXDiagnostic_DisplaySourceLocation, - 2 => CXDiagnostic_DisplayColumn, - 4 => CXDiagnostic_DisplaySourceRanges, - 8 => CXDiagnostic_DisplayOption, - 16 => CXDiagnostic_DisplayCategoryId, - 32 => CXDiagnostic_DisplayCategoryName, - _ => throw ArgumentError( - 'Unknown value for CXDiagnosticDisplayOptions: $value', - ), + /// Whether to speed up completion by omitting top- or namespace-level + /// entities defined in the preamble. There's no guarantee any particular + /// entity is omitted. This may be useful if the headers are indexed + /// externally. + CXCodeComplete_SkipPreamble(8), + + /// Whether to include completions with small fix-its, e.g. change '.' to '->' + /// on member access, etc. + CXCodeComplete_IncludeCompletionsWithFixIts(16); + + final int value; + const CXCodeComplete_Flags(this.value); + + static CXCodeComplete_Flags fromValue(int value) => switch (value) { + 1 => CXCodeComplete_IncludeMacros, + 2 => CXCodeComplete_IncludeCodePatterns, + 4 => CXCodeComplete_IncludeBriefComments, + 8 => CXCodeComplete_SkipPreamble, + 16 => CXCodeComplete_IncludeCompletionsWithFixIts, + _ => throw ArgumentError('Unknown value for CXCodeComplete_Flags: $value'), }; } -/// Flags that control the creation of translation units. -enum CXTranslationUnit_Flags { - /// Used to indicate that no special translation-unit options are needed. - CXTranslationUnit_None(0), +/// Describes a single piece of text within a code-completion string. +enum CXCompletionChunkKind { + /// A code-completion string that describes "optional" text that could be a + /// part of the template (but is not required). + CXCompletionChunk_Optional(0), - /// Used to indicate that the parser should construct a "detailed" - /// preprocessing record, including all macro definitions and instantiations. - CXTranslationUnit_DetailedPreprocessingRecord(1), + /// Text that a user would be expected to type to get this code-completion + /// result. + CXCompletionChunk_TypedText(1), - /// Used to indicate that the translation unit is incomplete. - CXTranslationUnit_Incomplete(2), + /// Text that should be inserted as part of a code-completion result. + CXCompletionChunk_Text(2), - /// Used to indicate that the translation unit should be built with an - /// implicit precompiled header for the preamble. - CXTranslationUnit_PrecompiledPreamble(4), + /// Placeholder text that should be replaced by the user. + CXCompletionChunk_Placeholder(3), - /// Used to indicate that the translation unit should cache some - /// code-completion results with each reparse of the source file. - CXTranslationUnit_CacheCompletionResults(8), + /// Informative text that should be displayed but never inserted as part of + /// the template. + CXCompletionChunk_Informative(4), - /// Used to indicate that the translation unit will be serialized with - /// clang_saveTranslationUnit. - CXTranslationUnit_ForSerialization(16), + /// Text that describes the current parameter when code-completion is + /// referring to function call, message send, or template specialization. + CXCompletionChunk_CurrentParameter(5), - /// DEPRECATED: Enabled chained precompiled preambles in C++. - CXTranslationUnit_CXXChainedPCH(32), + /// A left parenthesis ('('), used to initiate a function call or signal the + /// beginning of a function parameter list. + CXCompletionChunk_LeftParen(6), - /// Used to indicate that function/method bodies should be skipped while - /// parsing. - CXTranslationUnit_SkipFunctionBodies(64), + /// A right parenthesis (')'), used to finish a function call or signal the + /// end of a function parameter list. + CXCompletionChunk_RightParen(7), - /// Used to indicate that brief documentation comments should be included into - /// the set of code completions returned from this translation unit. - CXTranslationUnit_IncludeBriefCommentsInCodeCompletion(128), + /// A left bracket ('['). + CXCompletionChunk_LeftBracket(8), - /// Used to indicate that the precompiled preamble should be created on the - /// first parse. Otherwise it will be created on the first reparse. This - /// trades runtime on the first parse (serializing the preamble takes time) - /// for reduced runtime on the second parse (can now reuse the preamble). - CXTranslationUnit_CreatePreambleOnFirstParse(256), + /// A right bracket (']'). + CXCompletionChunk_RightBracket(9), - /// Do not stop processing when fatal errors are encountered. - CXTranslationUnit_KeepGoing(512), + /// A left brace ('{'). + CXCompletionChunk_LeftBrace(10), - /// Sets the preprocessor in a mode for parsing a single file only. - CXTranslationUnit_SingleFileParse(1024), + /// A right brace ('}'). + CXCompletionChunk_RightBrace(11), - /// Used in combination with CXTranslationUnit_SkipFunctionBodies to constrain - /// the skipping of function bodies to the preamble. - CXTranslationUnit_LimitSkipFunctionBodiesToPreamble(2048), + /// A left angle bracket ('<'). + CXCompletionChunk_LeftAngle(12), - /// Used to indicate that attributed types should be included in CXType. - CXTranslationUnit_IncludeAttributedTypes(4096), + /// A right angle bracket ('>'). + CXCompletionChunk_RightAngle(13), - /// Used to indicate that implicit attributes should be visited. - CXTranslationUnit_VisitImplicitAttributes(8192), + /// A comma separator (','). + CXCompletionChunk_Comma(14), - /// Used to indicate that non-errors from included files should be ignored. - CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles(16384), + /// Text that specifies the result type of a given result. + CXCompletionChunk_ResultType(15), - /// Tells the preprocessor not to skip excluded conditional blocks. - CXTranslationUnit_RetainExcludedConditionalBlocks(32768); + /// A colon (':'). + CXCompletionChunk_Colon(16), - final int value; - const CXTranslationUnit_Flags(this.value); + /// A semicolon (';'). + CXCompletionChunk_SemiColon(17), - static CXTranslationUnit_Flags fromValue(int value) => switch (value) { - 0 => CXTranslationUnit_None, - 1 => CXTranslationUnit_DetailedPreprocessingRecord, - 2 => CXTranslationUnit_Incomplete, - 4 => CXTranslationUnit_PrecompiledPreamble, - 8 => CXTranslationUnit_CacheCompletionResults, - 16 => CXTranslationUnit_ForSerialization, - 32 => CXTranslationUnit_CXXChainedPCH, - 64 => CXTranslationUnit_SkipFunctionBodies, - 128 => CXTranslationUnit_IncludeBriefCommentsInCodeCompletion, - 256 => CXTranslationUnit_CreatePreambleOnFirstParse, - 512 => CXTranslationUnit_KeepGoing, - 1024 => CXTranslationUnit_SingleFileParse, - 2048 => CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, - 4096 => CXTranslationUnit_IncludeAttributedTypes, - 8192 => CXTranslationUnit_VisitImplicitAttributes, - 16384 => CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles, - 32768 => CXTranslationUnit_RetainExcludedConditionalBlocks, - _ => throw ArgumentError( - 'Unknown value for CXTranslationUnit_Flags: $value', - ), - }; -} + /// An '=' sign. + CXCompletionChunk_Equal(18), -/// Flags that control how translation units are saved. -enum CXSaveTranslationUnit_Flags { - /// Used to indicate that no special saving options are needed. - CXSaveTranslationUnit_None(0); + /// Horizontal space (' '). + CXCompletionChunk_HorizontalSpace(19), + + /// Vertical space ('\n'), after which it is generally a good idea to perform + /// indentation. + CXCompletionChunk_VerticalSpace(20); final int value; - const CXSaveTranslationUnit_Flags(this.value); + const CXCompletionChunkKind(this.value); - static CXSaveTranslationUnit_Flags fromValue(int value) => switch (value) { - 0 => CXSaveTranslationUnit_None, - _ => throw ArgumentError( - 'Unknown value for CXSaveTranslationUnit_Flags: $value', - ), + static CXCompletionChunkKind fromValue(int value) => switch (value) { + 0 => CXCompletionChunk_Optional, + 1 => CXCompletionChunk_TypedText, + 2 => CXCompletionChunk_Text, + 3 => CXCompletionChunk_Placeholder, + 4 => CXCompletionChunk_Informative, + 5 => CXCompletionChunk_CurrentParameter, + 6 => CXCompletionChunk_LeftParen, + 7 => CXCompletionChunk_RightParen, + 8 => CXCompletionChunk_LeftBracket, + 9 => CXCompletionChunk_RightBracket, + 10 => CXCompletionChunk_LeftBrace, + 11 => CXCompletionChunk_RightBrace, + 12 => CXCompletionChunk_LeftAngle, + 13 => CXCompletionChunk_RightAngle, + 14 => CXCompletionChunk_Comma, + 15 => CXCompletionChunk_ResultType, + 16 => CXCompletionChunk_Colon, + 17 => CXCompletionChunk_SemiColon, + 18 => CXCompletionChunk_Equal, + 19 => CXCompletionChunk_HorizontalSpace, + 20 => CXCompletionChunk_VerticalSpace, + _ => throw ArgumentError('Unknown value for CXCompletionChunkKind: $value'), }; } -/// Describes the kind of error that occurred (if any) in a call to -/// clang_saveTranslationUnit(). -enum CXSaveError { - /// Indicates that no error occurred while saving a translation unit. - CXSaveError_None(0), +/// Bits that represent the context under which completion is occurring. +enum CXCompletionContext { + /// The context for completions is unexposed, as only Clang results should be + /// included. (This is equivalent to having no context bits set.) + CXCompletionContext_Unexposed(0), - /// Indicates that an unknown error occurred while attempting to save the - /// file. - CXSaveError_Unknown(1), + /// Completions for any possible type should be included in the results. + CXCompletionContext_AnyType(1), - /// Indicates that errors during translation prevented this attempt to save - /// the translation unit. - CXSaveError_TranslationErrors(2), + /// Completions for any possible value (variables, function calls, etc.) + /// should be included in the results. + CXCompletionContext_AnyValue(2), - /// Indicates that the translation unit to be saved was somehow invalid (e.g., - /// NULL). - CXSaveError_InvalidTU(3); + /// Completions for values that resolve to an Objective-C object should be + /// included in the results. + CXCompletionContext_ObjCObjectValue(4), - final int value; - const CXSaveError(this.value); + /// Completions for values that resolve to an Objective-C selector should be + /// included in the results. + CXCompletionContext_ObjCSelectorValue(8), - static CXSaveError fromValue(int value) => switch (value) { - 0 => CXSaveError_None, - 1 => CXSaveError_Unknown, - 2 => CXSaveError_TranslationErrors, - 3 => CXSaveError_InvalidTU, - _ => throw ArgumentError('Unknown value for CXSaveError: $value'), - }; -} + /// Completions for values that resolve to a C++ class type should be included + /// in the results. + CXCompletionContext_CXXClassTypeValue(16), -/// Flags that control the reparsing of translation units. -enum CXReparse_Flags { - /// Used to indicate that no special reparsing options are needed. - CXReparse_None(0); + /// Completions for fields of the member being accessed using the dot operator + /// should be included in the results. + CXCompletionContext_DotMemberAccess(32), - final int value; - const CXReparse_Flags(this.value); + /// Completions for fields of the member being accessed using the arrow + /// operator should be included in the results. + CXCompletionContext_ArrowMemberAccess(64), - static CXReparse_Flags fromValue(int value) => switch (value) { - 0 => CXReparse_None, - _ => throw ArgumentError('Unknown value for CXReparse_Flags: $value'), - }; -} + /// Completions for properties of the Objective-C object being accessed using + /// the dot operator should be included in the results. + CXCompletionContext_ObjCPropertyAccess(128), -/// Categorizes how memory is being used by a translation unit. -enum CXTUResourceUsageKind { - CXTUResourceUsage_AST(1), - CXTUResourceUsage_Identifiers(2), - CXTUResourceUsage_Selectors(3), - CXTUResourceUsage_GlobalCompletionResults(4), - CXTUResourceUsage_SourceManagerContentCache(5), - CXTUResourceUsage_AST_SideTables(6), - CXTUResourceUsage_SourceManager_Membuffer_Malloc(7), - CXTUResourceUsage_SourceManager_Membuffer_MMap(8), - CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc(9), - CXTUResourceUsage_ExternalASTSource_Membuffer_MMap(10), - CXTUResourceUsage_Preprocessor(11), - CXTUResourceUsage_PreprocessingRecord(12), - CXTUResourceUsage_SourceManager_DataStructures(13), - CXTUResourceUsage_Preprocessor_HeaderSearch(14); + /// Completions for enum tags should be included in the results. + CXCompletionContext_EnumTag(256), - static const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST; - static const CXTUResourceUsage_MEMORY_IN_BYTES_END = - CXTUResourceUsage_Preprocessor_HeaderSearch; - static const CXTUResourceUsage_First = CXTUResourceUsage_AST; - static const CXTUResourceUsage_Last = - CXTUResourceUsage_Preprocessor_HeaderSearch; + /// Completions for union tags should be included in the results. + CXCompletionContext_UnionTag(512), + + /// Completions for struct tags should be included in the results. + CXCompletionContext_StructTag(1024), + + /// Completions for C++ class names should be included in the results. + CXCompletionContext_ClassTag(2048), + + /// Completions for C++ namespaces and namespace aliases should be included in + /// the results. + CXCompletionContext_Namespace(4096), + + /// Completions for C++ nested name specifiers should be included in the + /// results. + CXCompletionContext_NestedNameSpecifier(8192), + + /// Completions for Objective-C interfaces (classes) should be included in the + /// results. + CXCompletionContext_ObjCInterface(16384), + + /// Completions for Objective-C protocols should be included in the results. + CXCompletionContext_ObjCProtocol(32768), + + /// Completions for Objective-C categories should be included in the results. + CXCompletionContext_ObjCCategory(65536), + + /// Completions for Objective-C instance messages should be included in the + /// results. + CXCompletionContext_ObjCInstanceMessage(131072), + + /// Completions for Objective-C class messages should be included in the + /// results. + CXCompletionContext_ObjCClassMessage(262144), + + /// Completions for Objective-C selector names should be included in the + /// results. + CXCompletionContext_ObjCSelectorName(524288), + + /// Completions for preprocessor macro names should be included in the + /// results. + CXCompletionContext_MacroName(1048576), + + /// Natural language completions should be included in the results. + CXCompletionContext_NaturalLanguage(2097152), + + /// #include file completions should be included in the results. + CXCompletionContext_IncludedFile(4194304), + + /// The current context is unknown, so set all contexts. + CXCompletionContext_Unknown(8388607); final int value; - const CXTUResourceUsageKind(this.value); + const CXCompletionContext(this.value); - static CXTUResourceUsageKind fromValue(int value) => switch (value) { - 1 => CXTUResourceUsage_AST, - 2 => CXTUResourceUsage_Identifiers, - 3 => CXTUResourceUsage_Selectors, - 4 => CXTUResourceUsage_GlobalCompletionResults, - 5 => CXTUResourceUsage_SourceManagerContentCache, - 6 => CXTUResourceUsage_AST_SideTables, - 7 => CXTUResourceUsage_SourceManager_Membuffer_Malloc, - 8 => CXTUResourceUsage_SourceManager_Membuffer_MMap, - 9 => CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc, - 10 => CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, - 11 => CXTUResourceUsage_Preprocessor, - 12 => CXTUResourceUsage_PreprocessingRecord, - 13 => CXTUResourceUsage_SourceManager_DataStructures, - 14 => CXTUResourceUsage_Preprocessor_HeaderSearch, - _ => throw ArgumentError('Unknown value for CXTUResourceUsageKind: $value'), + static CXCompletionContext fromValue(int value) => switch (value) { + 0 => CXCompletionContext_Unexposed, + 1 => CXCompletionContext_AnyType, + 2 => CXCompletionContext_AnyValue, + 4 => CXCompletionContext_ObjCObjectValue, + 8 => CXCompletionContext_ObjCSelectorValue, + 16 => CXCompletionContext_CXXClassTypeValue, + 32 => CXCompletionContext_DotMemberAccess, + 64 => CXCompletionContext_ArrowMemberAccess, + 128 => CXCompletionContext_ObjCPropertyAccess, + 256 => CXCompletionContext_EnumTag, + 512 => CXCompletionContext_UnionTag, + 1024 => CXCompletionContext_StructTag, + 2048 => CXCompletionContext_ClassTag, + 4096 => CXCompletionContext_Namespace, + 8192 => CXCompletionContext_NestedNameSpecifier, + 16384 => CXCompletionContext_ObjCInterface, + 32768 => CXCompletionContext_ObjCProtocol, + 65536 => CXCompletionContext_ObjCCategory, + 131072 => CXCompletionContext_ObjCInstanceMessage, + 262144 => CXCompletionContext_ObjCClassMessage, + 524288 => CXCompletionContext_ObjCSelectorName, + 1048576 => CXCompletionContext_MacroName, + 2097152 => CXCompletionContext_NaturalLanguage, + 4194304 => CXCompletionContext_IncludedFile, + 8388607 => CXCompletionContext_Unknown, + _ => throw ArgumentError('Unknown value for CXCompletionContext: $value'), }; +} - @override - String toString() { - if (this == CXTUResourceUsage_AST) - return "CXTUResourceUsageKind.CXTUResourceUsage_AST, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN, CXTUResourceUsageKind.CXTUResourceUsage_First"; - if (this == CXTUResourceUsage_Preprocessor_HeaderSearch) - return "CXTUResourceUsageKind.CXTUResourceUsage_Preprocessor_HeaderSearch, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_END, CXTUResourceUsageKind.CXTUResourceUsage_Last"; - return super.toString(); - } +/// A single result of code completion. +final class CXCompletionResult extends ffi.Struct { + /// The kind of entity that this completion refers to. + @ffi.UnsignedInt() + external int CursorKindAsInt; + + CXCursorKind get CursorKind => CXCursorKind.fromValue(CursorKindAsInt); + set CursorKind(CXCursorKind value) => CursorKindAsInt = value.value; + + /// The code-completion string that describes how to insert this + /// code-completion result into the editing buffer. + external CXCompletionString CompletionString; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required CXCursorKind CursorKind, + required CXCompletionString CompletionString, + }) => $allocator() + ..ref.CursorKind = CursorKind + ..ref.CompletionString = CompletionString; } -final class CXTUResourceUsageEntry extends ffi.Struct { +/// A semantic string that describes a code-completion result. +typedef CXCompletionString = ffi.Pointer; + +/// A cursor representing some element in the abstract syntax tree for a +/// translation unit. +final class CXCursor extends ffi.Struct { @ffi.UnsignedInt() external int kindAsInt; - CXTUResourceUsageKind get kind => CXTUResourceUsageKind.fromValue(kindAsInt); - set kind(CXTUResourceUsageKind value) => kindAsInt = value.value; + CXCursorKind get kind => CXCursorKind.fromValue(kindAsInt); + set kind(CXCursorKind value) => kindAsInt = value.value; - @ffi.UnsignedLong() - external int amount; + @ffi.Int() + external int xdata; + + @ffi.Array.multi([3]) + external ffi.Array> data; } -/// The memory usage of a CXTranslationUnit, broken into categories. -final class CXTUResourceUsage extends ffi.Struct { - external ffi.Pointer data; +final class CXCursorAndRangeVisitor extends ffi.Struct { + external ffi.Pointer context; - @ffi.UnsignedInt() - external int numEntries; + external ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.Pointer, CXCursor, CXSourceRange) + > + > + visit; - external ffi.Pointer entries; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer context, + required ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedInt Function(ffi.Pointer, CXCursor, CXSourceRange) + > + > + visit, + }) => $allocator() + ..ref.context = context + ..ref.visit = visit; } /// Describes the kind of entity that a cursor refers to. @@ -7034,1262 +6914,1131 @@ enum CXCursorKind { } } -/// A cursor representing some element in the abstract syntax tree for a -/// translation unit. -final class CXCursor extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; +/// A fast container representing a set of CXCursors. +typedef CXCursorSet = ffi.Pointer; - CXCursorKind get kind => CXCursorKind.fromValue(kindAsInt); - set kind(CXCursorKind value) => kindAsInt = value.value; +final class CXCursorSetImpl extends ffi.Opaque {} - @ffi.Int() - external int xdata; +/// Visitor invoked for each cursor found by a traversal. +typedef CXCursorVisitor = + ffi.Pointer>; +typedef CXCursorVisitorFunction = + ffi.UnsignedInt Function( + CXCursor cursor, + CXCursor parent, + CXClientData client_data, + ); +typedef DartCXCursorVisitorFunction = + CXChildVisitResult Function( + CXCursor cursor, + CXCursor parent, + CXClientData client_data, + ); - @ffi.Array.multi([3]) - external ffi.Array> data; -} +/// Describes the exception specification of a cursor. +enum CXCursor_ExceptionSpecificationKind { + /// The cursor has no exception specification. + CXCursor_ExceptionSpecificationKind_None(0), -/// Describe the linkage of the entity referred to by a cursor. -enum CXLinkageKind { - /// This value indicates that no linkage information is available for a - /// provided CXCursor. - CXLinkage_Invalid(0), + /// The cursor has exception specification throw() + CXCursor_ExceptionSpecificationKind_DynamicNone(1), - /// This is the linkage for variables, parameters, and so on that have - /// automatic storage. This covers normal (non-extern) local variables. - CXLinkage_NoLinkage(1), + /// The cursor has exception specification throw(T1, T2) + CXCursor_ExceptionSpecificationKind_Dynamic(2), - /// This is the linkage for static variables and static functions. - CXLinkage_Internal(2), + /// The cursor has exception specification throw(...). + CXCursor_ExceptionSpecificationKind_MSAny(3), - /// This is the linkage for entities with external linkage that live in C++ - /// anonymous namespaces. - CXLinkage_UniqueExternal(3), + /// The cursor has exception specification basic noexcept. + CXCursor_ExceptionSpecificationKind_BasicNoexcept(4), - /// This is the linkage for entities with true, external linkage. - CXLinkage_External(4); + /// The cursor has exception specification computed noexcept. + CXCursor_ExceptionSpecificationKind_ComputedNoexcept(5), - final int value; - const CXLinkageKind(this.value); + /// The exception specification has not yet been evaluated. + CXCursor_ExceptionSpecificationKind_Unevaluated(6), - static CXLinkageKind fromValue(int value) => switch (value) { - 0 => CXLinkage_Invalid, - 1 => CXLinkage_NoLinkage, - 2 => CXLinkage_Internal, - 3 => CXLinkage_UniqueExternal, - 4 => CXLinkage_External, - _ => throw ArgumentError('Unknown value for CXLinkageKind: $value'), - }; -} + /// The exception specification has not yet been instantiated. + CXCursor_ExceptionSpecificationKind_Uninstantiated(7), -enum CXVisibilityKind { - /// This value indicates that no visibility information is available for a - /// provided CXCursor. - CXVisibility_Invalid(0), + /// The exception specification has not been parsed yet. + CXCursor_ExceptionSpecificationKind_Unparsed(8), - /// Symbol not seen by the linker. - CXVisibility_Hidden(1), + /// The cursor has a __declspec(nothrow) exception specification. + CXCursor_ExceptionSpecificationKind_NoThrow(9); - /// Symbol seen by the linker but resolves to a symbol inside this object. - CXVisibility_Protected(2), + final int value; + const CXCursor_ExceptionSpecificationKind(this.value); - /// Symbol seen by the linker and acts like a normal symbol. - CXVisibility_Default(3); - - final int value; - const CXVisibilityKind(this.value); - - static CXVisibilityKind fromValue(int value) => switch (value) { - 0 => CXVisibility_Invalid, - 1 => CXVisibility_Hidden, - 2 => CXVisibility_Protected, - 3 => CXVisibility_Default, - _ => throw ArgumentError('Unknown value for CXVisibilityKind: $value'), - }; + static CXCursor_ExceptionSpecificationKind fromValue(int value) => + switch (value) { + 0 => CXCursor_ExceptionSpecificationKind_None, + 1 => CXCursor_ExceptionSpecificationKind_DynamicNone, + 2 => CXCursor_ExceptionSpecificationKind_Dynamic, + 3 => CXCursor_ExceptionSpecificationKind_MSAny, + 4 => CXCursor_ExceptionSpecificationKind_BasicNoexcept, + 5 => CXCursor_ExceptionSpecificationKind_ComputedNoexcept, + 6 => CXCursor_ExceptionSpecificationKind_Unevaluated, + 7 => CXCursor_ExceptionSpecificationKind_Uninstantiated, + 8 => CXCursor_ExceptionSpecificationKind_Unparsed, + 9 => CXCursor_ExceptionSpecificationKind_NoThrow, + _ => throw ArgumentError( + 'Unknown value for CXCursor_ExceptionSpecificationKind: $value', + ), + }; } -/// Describes the availability of a given entity on a particular platform, e.g., -/// a particular class might only be available on Mac OS 10.7 or newer. -final class CXPlatformAvailability extends ffi.Struct { - /// A string that describes the platform for which this structure provides - /// availability information. - external CXString Platform; +/// A single diagnostic, containing the diagnostic's severity, location, text, +/// source ranges, and fix-it hints. +typedef CXDiagnostic = ffi.Pointer; - /// The version number in which this entity was introduced. - external CXVersion Introduced; +/// Options to control the display of diagnostics. +enum CXDiagnosticDisplayOptions { + /// Display the source-location information where the diagnostic was located. + CXDiagnostic_DisplaySourceLocation(1), - /// The version number in which this entity was deprecated (but is still - /// available). - external CXVersion Deprecated; + /// If displaying the source-location information of the diagnostic, also + /// include the column number. + CXDiagnostic_DisplayColumn(2), - /// The version number in which this entity was obsoleted, and therefore is no - /// longer available. - external CXVersion Obsoleted; + /// If displaying the source-location information of the diagnostic, also + /// include information about source ranges in a machine-parsable format. + CXDiagnostic_DisplaySourceRanges(4), - /// Whether the entity is unconditionally unavailable on this platform. - @ffi.Int() - external int Unavailable; + /// Display the option name associated with this diagnostic, if any. + CXDiagnostic_DisplayOption(8), - /// An optional message to provide to a user of this API, e.g., to suggest - /// replacement APIs. - external CXString Message; -} + /// Display the category number associated with this diagnostic, if any. + CXDiagnostic_DisplayCategoryId(16), -/// Describe the "language" of the entity referred to by a cursor. -enum CXLanguageKind { - CXLanguage_Invalid(0), - CXLanguage_C(1), - CXLanguage_ObjC(2), - CXLanguage_CPlusPlus(3); + /// Display the category name associated with this diagnostic, if any. + CXDiagnostic_DisplayCategoryName(32); final int value; - const CXLanguageKind(this.value); + const CXDiagnosticDisplayOptions(this.value); - static CXLanguageKind fromValue(int value) => switch (value) { - 0 => CXLanguage_Invalid, - 1 => CXLanguage_C, - 2 => CXLanguage_ObjC, - 3 => CXLanguage_CPlusPlus, - _ => throw ArgumentError('Unknown value for CXLanguageKind: $value'), + static CXDiagnosticDisplayOptions fromValue(int value) => switch (value) { + 1 => CXDiagnostic_DisplaySourceLocation, + 2 => CXDiagnostic_DisplayColumn, + 4 => CXDiagnostic_DisplaySourceRanges, + 8 => CXDiagnostic_DisplayOption, + 16 => CXDiagnostic_DisplayCategoryId, + 32 => CXDiagnostic_DisplayCategoryName, + _ => throw ArgumentError( + 'Unknown value for CXDiagnosticDisplayOptions: $value', + ), }; } -/// Describe the "thread-local storage (TLS) kind" of the declaration referred -/// to by a cursor. -enum CXTLSKind { - CXTLS_None(0), - CXTLS_Dynamic(1), - CXTLS_Static(2); +/// A group of CXDiagnostics. +typedef CXDiagnosticSet = ffi.Pointer; + +/// Describes the severity of a particular diagnostic. +enum CXDiagnosticSeverity { + /// A diagnostic that has been suppressed, e.g., by a command-line option. + CXDiagnostic_Ignored(0), + + /// This diagnostic is a note that should be attached to the previous + /// (non-note) diagnostic. + CXDiagnostic_Note(1), + + /// This diagnostic indicates suspicious code that may not be wrong. + CXDiagnostic_Warning(2), + + /// This diagnostic indicates that the code is ill-formed. + CXDiagnostic_Error(3), + + /// This diagnostic indicates that the code is ill-formed such that future + /// parser recovery is unlikely to produce useful results. + CXDiagnostic_Fatal(4); final int value; - const CXTLSKind(this.value); + const CXDiagnosticSeverity(this.value); - static CXTLSKind fromValue(int value) => switch (value) { - 0 => CXTLS_None, - 1 => CXTLS_Dynamic, - 2 => CXTLS_Static, - _ => throw ArgumentError('Unknown value for CXTLSKind: $value'), + static CXDiagnosticSeverity fromValue(int value) => switch (value) { + 0 => CXDiagnostic_Ignored, + 1 => CXDiagnostic_Note, + 2 => CXDiagnostic_Warning, + 3 => CXDiagnostic_Error, + 4 => CXDiagnostic_Fatal, + _ => throw ArgumentError('Unknown value for CXDiagnosticSeverity: $value'), }; } -final class CXCursorSetImpl extends ffi.Opaque {} - -/// A fast container representing a set of CXCursors. -typedef CXCursorSet = ffi.Pointer; +/// Error codes returned by libclang routines. +enum CXErrorCode { + /// No error. + CXError_Success(0), -/// Describes the kind of type -enum CXTypeKind { - /// Represents an invalid type (e.g., where no type is available). - CXType_Invalid(0), + /// A generic error code, no further details are available. + CXError_Failure(1), - /// A type whose specific kind is not exposed via this interface. - CXType_Unexposed(1), - CXType_Void(2), - CXType_Bool(3), - CXType_Char_U(4), - CXType_UChar(5), - CXType_Char16(6), - CXType_Char32(7), - CXType_UShort(8), - CXType_UInt(9), - CXType_ULong(10), - CXType_ULongLong(11), - CXType_UInt128(12), - CXType_Char_S(13), - CXType_SChar(14), - CXType_WChar(15), - CXType_Short(16), - CXType_Int(17), - CXType_Long(18), - CXType_LongLong(19), - CXType_Int128(20), - CXType_Float(21), - CXType_Double(22), - CXType_LongDouble(23), - CXType_NullPtr(24), - CXType_Overload(25), - CXType_Dependent(26), - CXType_ObjCId(27), - CXType_ObjCClass(28), - CXType_ObjCSel(29), - CXType_Float128(30), - CXType_Half(31), - CXType_Float16(32), - CXType_ShortAccum(33), - CXType_Accum(34), - CXType_LongAccum(35), - CXType_UShortAccum(36), - CXType_UAccum(37), - CXType_ULongAccum(38), - CXType_Complex(100), - CXType_Pointer(101), - CXType_BlockPointer(102), - CXType_LValueReference(103), - CXType_RValueReference(104), - CXType_Record(105), - CXType_Enum(106), - CXType_Typedef(107), - CXType_ObjCInterface(108), - CXType_ObjCObjectPointer(109), - CXType_FunctionNoProto(110), - CXType_FunctionProto(111), - CXType_ConstantArray(112), - CXType_Vector(113), - CXType_IncompleteArray(114), - CXType_VariableArray(115), - CXType_DependentSizedArray(116), - CXType_MemberPointer(117), - CXType_Auto(118), + /// libclang crashed while performing the requested operation. + CXError_Crashed(2), - /// Represents a type that was referred to using an elaborated type keyword. - CXType_Elaborated(119), - CXType_Pipe(120), - CXType_OCLImage1dRO(121), - CXType_OCLImage1dArrayRO(122), - CXType_OCLImage1dBufferRO(123), - CXType_OCLImage2dRO(124), - CXType_OCLImage2dArrayRO(125), - CXType_OCLImage2dDepthRO(126), - CXType_OCLImage2dArrayDepthRO(127), - CXType_OCLImage2dMSAARO(128), - CXType_OCLImage2dArrayMSAARO(129), - CXType_OCLImage2dMSAADepthRO(130), - CXType_OCLImage2dArrayMSAADepthRO(131), - CXType_OCLImage3dRO(132), - CXType_OCLImage1dWO(133), - CXType_OCLImage1dArrayWO(134), - CXType_OCLImage1dBufferWO(135), - CXType_OCLImage2dWO(136), - CXType_OCLImage2dArrayWO(137), - CXType_OCLImage2dDepthWO(138), - CXType_OCLImage2dArrayDepthWO(139), - CXType_OCLImage2dMSAAWO(140), - CXType_OCLImage2dArrayMSAAWO(141), - CXType_OCLImage2dMSAADepthWO(142), - CXType_OCLImage2dArrayMSAADepthWO(143), - CXType_OCLImage3dWO(144), - CXType_OCLImage1dRW(145), - CXType_OCLImage1dArrayRW(146), - CXType_OCLImage1dBufferRW(147), - CXType_OCLImage2dRW(148), - CXType_OCLImage2dArrayRW(149), - CXType_OCLImage2dDepthRW(150), - CXType_OCLImage2dArrayDepthRW(151), - CXType_OCLImage2dMSAARW(152), - CXType_OCLImage2dArrayMSAARW(153), - CXType_OCLImage2dMSAADepthRW(154), - CXType_OCLImage2dArrayMSAADepthRW(155), - CXType_OCLImage3dRW(156), - CXType_OCLSampler(157), - CXType_OCLEvent(158), - CXType_OCLQueue(159), - CXType_OCLReserveID(160), - CXType_ObjCObject(161), - CXType_ObjCTypeParam(162), - CXType_Attributed(163), - CXType_OCLIntelSubgroupAVCMcePayload(164), - CXType_OCLIntelSubgroupAVCImePayload(165), - CXType_OCLIntelSubgroupAVCRefPayload(166), - CXType_OCLIntelSubgroupAVCSicPayload(167), - CXType_OCLIntelSubgroupAVCMceResult(168), - CXType_OCLIntelSubgroupAVCImeResult(169), - CXType_OCLIntelSubgroupAVCRefResult(170), - CXType_OCLIntelSubgroupAVCSicResult(171), - CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout(172), - CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout(173), - CXType_OCLIntelSubgroupAVCImeSingleRefStreamin(174), - CXType_OCLIntelSubgroupAVCImeDualRefStreamin(175), - CXType_ExtVector(176); + /// The function detected that the arguments violate the function contract. + CXError_InvalidArguments(3), - static const CXType_FirstBuiltin = CXType_Void; - static const CXType_LastBuiltin = CXType_ULongAccum; + /// An AST deserialization error has occurred. + CXError_ASTReadError(4); final int value; - const CXTypeKind(this.value); + const CXErrorCode(this.value); - static CXTypeKind fromValue(int value) => switch (value) { - 0 => CXType_Invalid, - 1 => CXType_Unexposed, - 2 => CXType_Void, - 3 => CXType_Bool, - 4 => CXType_Char_U, - 5 => CXType_UChar, - 6 => CXType_Char16, - 7 => CXType_Char32, - 8 => CXType_UShort, - 9 => CXType_UInt, - 10 => CXType_ULong, - 11 => CXType_ULongLong, - 12 => CXType_UInt128, - 13 => CXType_Char_S, - 14 => CXType_SChar, - 15 => CXType_WChar, - 16 => CXType_Short, - 17 => CXType_Int, - 18 => CXType_Long, - 19 => CXType_LongLong, - 20 => CXType_Int128, - 21 => CXType_Float, - 22 => CXType_Double, - 23 => CXType_LongDouble, - 24 => CXType_NullPtr, - 25 => CXType_Overload, - 26 => CXType_Dependent, - 27 => CXType_ObjCId, - 28 => CXType_ObjCClass, - 29 => CXType_ObjCSel, - 30 => CXType_Float128, - 31 => CXType_Half, - 32 => CXType_Float16, - 33 => CXType_ShortAccum, - 34 => CXType_Accum, - 35 => CXType_LongAccum, - 36 => CXType_UShortAccum, - 37 => CXType_UAccum, - 38 => CXType_ULongAccum, - 100 => CXType_Complex, - 101 => CXType_Pointer, - 102 => CXType_BlockPointer, - 103 => CXType_LValueReference, - 104 => CXType_RValueReference, - 105 => CXType_Record, - 106 => CXType_Enum, - 107 => CXType_Typedef, - 108 => CXType_ObjCInterface, - 109 => CXType_ObjCObjectPointer, - 110 => CXType_FunctionNoProto, - 111 => CXType_FunctionProto, - 112 => CXType_ConstantArray, - 113 => CXType_Vector, - 114 => CXType_IncompleteArray, - 115 => CXType_VariableArray, - 116 => CXType_DependentSizedArray, - 117 => CXType_MemberPointer, - 118 => CXType_Auto, - 119 => CXType_Elaborated, - 120 => CXType_Pipe, - 121 => CXType_OCLImage1dRO, - 122 => CXType_OCLImage1dArrayRO, - 123 => CXType_OCLImage1dBufferRO, - 124 => CXType_OCLImage2dRO, - 125 => CXType_OCLImage2dArrayRO, - 126 => CXType_OCLImage2dDepthRO, - 127 => CXType_OCLImage2dArrayDepthRO, - 128 => CXType_OCLImage2dMSAARO, - 129 => CXType_OCLImage2dArrayMSAARO, - 130 => CXType_OCLImage2dMSAADepthRO, - 131 => CXType_OCLImage2dArrayMSAADepthRO, - 132 => CXType_OCLImage3dRO, - 133 => CXType_OCLImage1dWO, - 134 => CXType_OCLImage1dArrayWO, - 135 => CXType_OCLImage1dBufferWO, - 136 => CXType_OCLImage2dWO, - 137 => CXType_OCLImage2dArrayWO, - 138 => CXType_OCLImage2dDepthWO, - 139 => CXType_OCLImage2dArrayDepthWO, - 140 => CXType_OCLImage2dMSAAWO, - 141 => CXType_OCLImage2dArrayMSAAWO, - 142 => CXType_OCLImage2dMSAADepthWO, - 143 => CXType_OCLImage2dArrayMSAADepthWO, - 144 => CXType_OCLImage3dWO, - 145 => CXType_OCLImage1dRW, - 146 => CXType_OCLImage1dArrayRW, - 147 => CXType_OCLImage1dBufferRW, - 148 => CXType_OCLImage2dRW, - 149 => CXType_OCLImage2dArrayRW, - 150 => CXType_OCLImage2dDepthRW, - 151 => CXType_OCLImage2dArrayDepthRW, - 152 => CXType_OCLImage2dMSAARW, - 153 => CXType_OCLImage2dArrayMSAARW, - 154 => CXType_OCLImage2dMSAADepthRW, - 155 => CXType_OCLImage2dArrayMSAADepthRW, - 156 => CXType_OCLImage3dRW, - 157 => CXType_OCLSampler, - 158 => CXType_OCLEvent, - 159 => CXType_OCLQueue, - 160 => CXType_OCLReserveID, - 161 => CXType_ObjCObject, - 162 => CXType_ObjCTypeParam, - 163 => CXType_Attributed, - 164 => CXType_OCLIntelSubgroupAVCMcePayload, - 165 => CXType_OCLIntelSubgroupAVCImePayload, - 166 => CXType_OCLIntelSubgroupAVCRefPayload, - 167 => CXType_OCLIntelSubgroupAVCSicPayload, - 168 => CXType_OCLIntelSubgroupAVCMceResult, - 169 => CXType_OCLIntelSubgroupAVCImeResult, - 170 => CXType_OCLIntelSubgroupAVCRefResult, - 171 => CXType_OCLIntelSubgroupAVCSicResult, - 172 => CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout, - 173 => CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout, - 174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin, - 175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin, - 176 => CXType_ExtVector, - _ => throw ArgumentError('Unknown value for CXTypeKind: $value'), + static CXErrorCode fromValue(int value) => switch (value) { + 0 => CXError_Success, + 1 => CXError_Failure, + 2 => CXError_Crashed, + 3 => CXError_InvalidArguments, + 4 => CXError_ASTReadError, + _ => throw ArgumentError('Unknown value for CXErrorCode: $value'), }; - - @override - String toString() { - if (this == CXType_Void) - return "CXTypeKind.CXType_Void, CXTypeKind.CXType_FirstBuiltin"; - if (this == CXType_ULongAccum) - return "CXTypeKind.CXType_ULongAccum, CXTypeKind.CXType_LastBuiltin"; - return super.toString(); - } } -/// Describes the calling convention of a function type -enum CXCallingConv { - CXCallingConv_Default(0), - CXCallingConv_C(1), - CXCallingConv_X86StdCall(2), - CXCallingConv_X86FastCall(3), - CXCallingConv_X86ThisCall(4), - CXCallingConv_X86Pascal(5), - CXCallingConv_AAPCS(6), - CXCallingConv_AAPCS_VFP(7), - CXCallingConv_X86RegCall(8), - CXCallingConv_IntelOclBicc(9), - CXCallingConv_Win64(10), - CXCallingConv_X86_64SysV(11), - CXCallingConv_X86VectorCall(12), - CXCallingConv_Swift(13), - CXCallingConv_PreserveMost(14), - CXCallingConv_PreserveAll(15), - CXCallingConv_AArch64VectorCall(16), - CXCallingConv_Invalid(100), - CXCallingConv_Unexposed(200); +/// Evaluation result of a cursor +typedef CXEvalResult = ffi.Pointer; - static const CXCallingConv_X86_64Win64 = CXCallingConv_Win64; +enum CXEvalResultKind { + CXEval_Int(1), + CXEval_Float(2), + CXEval_ObjCStrLiteral(3), + CXEval_StrLiteral(4), + CXEval_CFStr(5), + CXEval_Other(6), + CXEval_UnExposed(0); final int value; - const CXCallingConv(this.value); + const CXEvalResultKind(this.value); - static CXCallingConv fromValue(int value) => switch (value) { - 0 => CXCallingConv_Default, - 1 => CXCallingConv_C, - 2 => CXCallingConv_X86StdCall, - 3 => CXCallingConv_X86FastCall, - 4 => CXCallingConv_X86ThisCall, - 5 => CXCallingConv_X86Pascal, - 6 => CXCallingConv_AAPCS, - 7 => CXCallingConv_AAPCS_VFP, - 8 => CXCallingConv_X86RegCall, - 9 => CXCallingConv_IntelOclBicc, - 10 => CXCallingConv_Win64, - 11 => CXCallingConv_X86_64SysV, - 12 => CXCallingConv_X86VectorCall, - 13 => CXCallingConv_Swift, - 14 => CXCallingConv_PreserveMost, - 15 => CXCallingConv_PreserveAll, - 16 => CXCallingConv_AArch64VectorCall, - 100 => CXCallingConv_Invalid, - 200 => CXCallingConv_Unexposed, - _ => throw ArgumentError('Unknown value for CXCallingConv: $value'), + static CXEvalResultKind fromValue(int value) => switch (value) { + 1 => CXEval_Int, + 2 => CXEval_Float, + 3 => CXEval_ObjCStrLiteral, + 4 => CXEval_StrLiteral, + 5 => CXEval_CFStr, + 6 => CXEval_Other, + 0 => CXEval_UnExposed, + _ => throw ArgumentError('Unknown value for CXEvalResultKind: $value'), }; +} - @override - String toString() { - if (this == CXCallingConv_Win64) - return "CXCallingConv.CXCallingConv_Win64, CXCallingConv.CXCallingConv_X86_64Win64"; - return super.toString(); - } +/// Visitor invoked for each field found by a traversal. +typedef CXFieldVisitor = + ffi.Pointer>; +typedef CXFieldVisitorFunction = + ffi.UnsignedInt Function(CXCursor C, CXClientData client_data); +typedef DartCXFieldVisitorFunction = + CXVisitorResult Function(CXCursor C, CXClientData client_data); + +/// A particular source file that is part of a translation unit. +typedef CXFile = ffi.Pointer; + +/// Uniquely identifies a CXFile, that refers to the same underlying file, +/// across an indexing session. +final class CXFileUniqueID extends ffi.Struct { + @ffi.Array.multi([3]) + external ffi.Array data; } -/// The type of an element in the abstract syntax tree. -final class CXType extends ffi.Struct { +enum CXGlobalOptFlags { + /// Used to indicate that no special CXIndex options are needed. + CXGlobalOpt_None(0), + + /// Used to indicate that threads that libclang creates for indexing purposes + /// should use background priority. + CXGlobalOpt_ThreadBackgroundPriorityForIndexing(1), + + /// Used to indicate that threads that libclang creates for editing purposes + /// should use background priority. + CXGlobalOpt_ThreadBackgroundPriorityForEditing(2), + + /// Used to indicate that all threads that libclang creates should use + /// background priority. + CXGlobalOpt_ThreadBackgroundPriorityForAll(3); + + final int value; + const CXGlobalOptFlags(this.value); + + static CXGlobalOptFlags fromValue(int value) => switch (value) { + 0 => CXGlobalOpt_None, + 1 => CXGlobalOpt_ThreadBackgroundPriorityForIndexing, + 2 => CXGlobalOpt_ThreadBackgroundPriorityForEditing, + 3 => CXGlobalOpt_ThreadBackgroundPriorityForAll, + _ => throw ArgumentError('Unknown value for CXGlobalOptFlags: $value'), + }; +} + +final class CXIdxAttrInfo extends ffi.Struct { @ffi.UnsignedInt() external int kindAsInt; - CXTypeKind get kind => CXTypeKind.fromValue(kindAsInt); - set kind(CXTypeKind value) => kindAsInt = value.value; + CXIdxAttrKind get kind => CXIdxAttrKind.fromValue(kindAsInt); + set kind(CXIdxAttrKind value) => kindAsInt = value.value; - @ffi.Array.multi([2]) - external ffi.Array> data; + external CXCursor cursor; + + external CXIdxLoc loc; } -/// Describes the kind of a template argument. -enum CXTemplateArgumentKind { - CXTemplateArgumentKind_Null(0), - CXTemplateArgumentKind_Type(1), - CXTemplateArgumentKind_Declaration(2), - CXTemplateArgumentKind_NullPtr(3), - CXTemplateArgumentKind_Integral(4), - CXTemplateArgumentKind_Template(5), - CXTemplateArgumentKind_TemplateExpansion(6), - CXTemplateArgumentKind_Expression(7), - CXTemplateArgumentKind_Pack(8), - CXTemplateArgumentKind_Invalid(9); +enum CXIdxAttrKind { + CXIdxAttr_Unexposed(0), + CXIdxAttr_IBAction(1), + CXIdxAttr_IBOutlet(2), + CXIdxAttr_IBOutletCollection(3); + + final int value; + const CXIdxAttrKind(this.value); + + static CXIdxAttrKind fromValue(int value) => switch (value) { + 0 => CXIdxAttr_Unexposed, + 1 => CXIdxAttr_IBAction, + 2 => CXIdxAttr_IBOutlet, + 3 => CXIdxAttr_IBOutletCollection, + _ => throw ArgumentError('Unknown value for CXIdxAttrKind: $value'), + }; +} + +final class CXIdxBaseClassInfo extends ffi.Struct { + external ffi.Pointer base; + + external CXCursor cursor; + + external CXIdxLoc loc; +} + +final class CXIdxCXXClassDeclInfo extends ffi.Struct { + external ffi.Pointer declInfo; + + external ffi.Pointer> bases; + + @ffi.UnsignedInt() + external int numBases; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer declInfo, + required ffi.Pointer> bases, + required int numBases, + }) => $allocator() + ..ref.declInfo = declInfo + ..ref.bases = bases + ..ref.numBases = numBases; +} + +/// The client's data object that is associated with an AST file (PCH or +/// module). +typedef CXIdxClientASTFile = ffi.Pointer; + +/// The client's data object that is associated with a semantic container of +/// entities. +typedef CXIdxClientContainer = ffi.Pointer; + +/// The client's data object that is associated with a semantic entity. +typedef CXIdxClientEntity = ffi.Pointer; + +/// The client's data object that is associated with a CXFile. +typedef CXIdxClientFile = ffi.Pointer; + +final class CXIdxContainerInfo extends ffi.Struct { + external CXCursor cursor; +} + +final class CXIdxDeclInfo extends ffi.Struct { + external ffi.Pointer entityInfo; + + external CXCursor cursor; + + external CXIdxLoc loc; + + external ffi.Pointer semanticContainer; + + /// Generally same as #semanticContainer but can be different in cases like + /// out-of-line C++ member functions. + external ffi.Pointer lexicalContainer; + + @ffi.Int() + external int isRedeclaration; + + @ffi.Int() + external int isDefinition; + + @ffi.Int() + external int isContainer; + + external ffi.Pointer declAsContainer; + + /// Whether the declaration exists in code or was created implicitly by the + /// compiler, e.g. implicit Objective-C methods for properties. + @ffi.Int() + external int isImplicit; + + external ffi.Pointer> attributes; + + @ffi.UnsignedInt() + external int numAttributes; + + @ffi.UnsignedInt() + external int flags; +} + +enum CXIdxDeclInfoFlags { + CXIdxDeclFlag_Skipped(1); + + final int value; + const CXIdxDeclInfoFlags(this.value); + + static CXIdxDeclInfoFlags fromValue(int value) => switch (value) { + 1 => CXIdxDeclFlag_Skipped, + _ => throw ArgumentError('Unknown value for CXIdxDeclInfoFlags: $value'), + }; +} + +/// Extra C++ template information for an entity. This can apply to: +/// CXIdxEntity_Function CXIdxEntity_CXXClass CXIdxEntity_CXXStaticMethod +/// CXIdxEntity_CXXInstanceMethod CXIdxEntity_CXXConstructor +/// CXIdxEntity_CXXConversionFunction CXIdxEntity_CXXTypeAlias +enum CXIdxEntityCXXTemplateKind { + CXIdxEntity_NonTemplate(0), + CXIdxEntity_Template(1), + CXIdxEntity_TemplatePartialSpecialization(2), + CXIdxEntity_TemplateSpecialization(3); final int value; - const CXTemplateArgumentKind(this.value); + const CXIdxEntityCXXTemplateKind(this.value); - static CXTemplateArgumentKind fromValue(int value) => switch (value) { - 0 => CXTemplateArgumentKind_Null, - 1 => CXTemplateArgumentKind_Type, - 2 => CXTemplateArgumentKind_Declaration, - 3 => CXTemplateArgumentKind_NullPtr, - 4 => CXTemplateArgumentKind_Integral, - 5 => CXTemplateArgumentKind_Template, - 6 => CXTemplateArgumentKind_TemplateExpansion, - 7 => CXTemplateArgumentKind_Expression, - 8 => CXTemplateArgumentKind_Pack, - 9 => CXTemplateArgumentKind_Invalid, + static CXIdxEntityCXXTemplateKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_NonTemplate, + 1 => CXIdxEntity_Template, + 2 => CXIdxEntity_TemplatePartialSpecialization, + 3 => CXIdxEntity_TemplateSpecialization, _ => throw ArgumentError( - 'Unknown value for CXTemplateArgumentKind: $value', + 'Unknown value for CXIdxEntityCXXTemplateKind: $value', ), }; } -enum CXTypeNullabilityKind { - /// Values of this type can never be null. - CXTypeNullability_NonNull(0), +final class CXIdxEntityInfo extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; - /// Values of this type can be null. - CXTypeNullability_Nullable(1), + CXIdxEntityKind get kind => CXIdxEntityKind.fromValue(kindAsInt); + set kind(CXIdxEntityKind value) => kindAsInt = value.value; - /// Whether values of this type can be null is (explicitly) unspecified. This - /// captures a (fairly rare) case where we can't conclude anything about the - /// nullability of the type even though it has been considered. - CXTypeNullability_Unspecified(2), + @ffi.UnsignedInt() + external int templateKindAsInt; - /// Nullability is not applicable to this type. - CXTypeNullability_Invalid(3); + CXIdxEntityCXXTemplateKind get templateKind => + CXIdxEntityCXXTemplateKind.fromValue(templateKindAsInt); + set templateKind(CXIdxEntityCXXTemplateKind value) => + templateKindAsInt = value.value; - final int value; - const CXTypeNullabilityKind(this.value); + @ffi.UnsignedInt() + external int langAsInt; - static CXTypeNullabilityKind fromValue(int value) => switch (value) { - 0 => CXTypeNullability_NonNull, - 1 => CXTypeNullability_Nullable, - 2 => CXTypeNullability_Unspecified, - 3 => CXTypeNullability_Invalid, - _ => throw ArgumentError('Unknown value for CXTypeNullabilityKind: $value'), - }; -} + CXIdxEntityLanguage get lang => CXIdxEntityLanguage.fromValue(langAsInt); + set lang(CXIdxEntityLanguage value) => langAsInt = value.value; -/// List the possible error codes for clang_Type_getSizeOf, -/// clang_Type_getAlignOf, clang_Type_getOffsetOf and clang_Cursor_getOffsetOf. -enum CXTypeLayoutError { - /// Type is of kind CXType_Invalid. - CXTypeLayoutError_Invalid(-1), + external ffi.Pointer name; - /// The type is an incomplete Type. - CXTypeLayoutError_Incomplete(-2), + external ffi.Pointer USR; - /// The type is a dependent Type. - CXTypeLayoutError_Dependent(-3), + external CXCursor cursor; - /// The type is not a constant size type. - CXTypeLayoutError_NotConstantSize(-4), + external ffi.Pointer> attributes; - /// The Field name is not valid for this record. - CXTypeLayoutError_InvalidFieldName(-5), + @ffi.UnsignedInt() + external int numAttributes; +} - /// The type is undeduced. - CXTypeLayoutError_Undeduced(-6); +enum CXIdxEntityKind { + CXIdxEntity_Unexposed(0), + CXIdxEntity_Typedef(1), + CXIdxEntity_Function(2), + CXIdxEntity_Variable(3), + CXIdxEntity_Field(4), + CXIdxEntity_EnumConstant(5), + CXIdxEntity_ObjCClass(6), + CXIdxEntity_ObjCProtocol(7), + CXIdxEntity_ObjCCategory(8), + CXIdxEntity_ObjCInstanceMethod(9), + CXIdxEntity_ObjCClassMethod(10), + CXIdxEntity_ObjCProperty(11), + CXIdxEntity_ObjCIvar(12), + CXIdxEntity_Enum(13), + CXIdxEntity_Struct(14), + CXIdxEntity_Union(15), + CXIdxEntity_CXXClass(16), + CXIdxEntity_CXXNamespace(17), + CXIdxEntity_CXXNamespaceAlias(18), + CXIdxEntity_CXXStaticVariable(19), + CXIdxEntity_CXXStaticMethod(20), + CXIdxEntity_CXXInstanceMethod(21), + CXIdxEntity_CXXConstructor(22), + CXIdxEntity_CXXDestructor(23), + CXIdxEntity_CXXConversionFunction(24), + CXIdxEntity_CXXTypeAlias(25), + CXIdxEntity_CXXInterface(26); final int value; - const CXTypeLayoutError(this.value); + const CXIdxEntityKind(this.value); - static CXTypeLayoutError fromValue(int value) => switch (value) { - -1 => CXTypeLayoutError_Invalid, - -2 => CXTypeLayoutError_Incomplete, - -3 => CXTypeLayoutError_Dependent, - -4 => CXTypeLayoutError_NotConstantSize, - -5 => CXTypeLayoutError_InvalidFieldName, - -6 => CXTypeLayoutError_Undeduced, - _ => throw ArgumentError('Unknown value for CXTypeLayoutError: $value'), + static CXIdxEntityKind fromValue(int value) => switch (value) { + 0 => CXIdxEntity_Unexposed, + 1 => CXIdxEntity_Typedef, + 2 => CXIdxEntity_Function, + 3 => CXIdxEntity_Variable, + 4 => CXIdxEntity_Field, + 5 => CXIdxEntity_EnumConstant, + 6 => CXIdxEntity_ObjCClass, + 7 => CXIdxEntity_ObjCProtocol, + 8 => CXIdxEntity_ObjCCategory, + 9 => CXIdxEntity_ObjCInstanceMethod, + 10 => CXIdxEntity_ObjCClassMethod, + 11 => CXIdxEntity_ObjCProperty, + 12 => CXIdxEntity_ObjCIvar, + 13 => CXIdxEntity_Enum, + 14 => CXIdxEntity_Struct, + 15 => CXIdxEntity_Union, + 16 => CXIdxEntity_CXXClass, + 17 => CXIdxEntity_CXXNamespace, + 18 => CXIdxEntity_CXXNamespaceAlias, + 19 => CXIdxEntity_CXXStaticVariable, + 20 => CXIdxEntity_CXXStaticMethod, + 21 => CXIdxEntity_CXXInstanceMethod, + 22 => CXIdxEntity_CXXConstructor, + 23 => CXIdxEntity_CXXDestructor, + 24 => CXIdxEntity_CXXConversionFunction, + 25 => CXIdxEntity_CXXTypeAlias, + 26 => CXIdxEntity_CXXInterface, + _ => throw ArgumentError('Unknown value for CXIdxEntityKind: $value'), }; } -enum CXRefQualifierKind { - /// No ref-qualifier was provided. - CXRefQualifier_None(0), - - /// An lvalue ref-qualifier was provided ( &). - CXRefQualifier_LValue(1), - - /// An rvalue ref-qualifier was provided ( &&). - CXRefQualifier_RValue(2); +enum CXIdxEntityLanguage { + CXIdxEntityLang_None(0), + CXIdxEntityLang_C(1), + CXIdxEntityLang_ObjC(2), + CXIdxEntityLang_CXX(3), + CXIdxEntityLang_Swift(4); final int value; - const CXRefQualifierKind(this.value); + const CXIdxEntityLanguage(this.value); - static CXRefQualifierKind fromValue(int value) => switch (value) { - 0 => CXRefQualifier_None, - 1 => CXRefQualifier_LValue, - 2 => CXRefQualifier_RValue, - _ => throw ArgumentError('Unknown value for CXRefQualifierKind: $value'), + static CXIdxEntityLanguage fromValue(int value) => switch (value) { + 0 => CXIdxEntityLang_None, + 1 => CXIdxEntityLang_C, + 2 => CXIdxEntityLang_ObjC, + 3 => CXIdxEntityLang_CXX, + 4 => CXIdxEntityLang_Swift, + _ => throw ArgumentError('Unknown value for CXIdxEntityLanguage: $value'), }; } -/// Represents the C++ access control level to a base class for a cursor with -/// kind CX_CXXBaseSpecifier. -enum CX_CXXAccessSpecifier { - CX_CXXInvalidAccessSpecifier(0), - CX_CXXPublic(1), - CX_CXXProtected(2), - CX_CXXPrivate(3); +/// Data for IndexerCallbacks#indexEntityReference. +final class CXIdxEntityRefInfo extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; - final int value; - const CX_CXXAccessSpecifier(this.value); + CXIdxEntityRefKind get kind => CXIdxEntityRefKind.fromValue(kindAsInt); + set kind(CXIdxEntityRefKind value) => kindAsInt = value.value; - static CX_CXXAccessSpecifier fromValue(int value) => switch (value) { - 0 => CX_CXXInvalidAccessSpecifier, - 1 => CX_CXXPublic, - 2 => CX_CXXProtected, - 3 => CX_CXXPrivate, - _ => throw ArgumentError('Unknown value for CX_CXXAccessSpecifier: $value'), - }; -} + /// Reference cursor. + external CXCursor cursor; -/// Represents the storage classes as declared in the source. CX_SC_Invalid was -/// added for the case that the passed cursor in not a declaration. -enum CX_StorageClass { - CX_SC_Invalid(0), - CX_SC_None(1), - CX_SC_Extern(2), - CX_SC_Static(3), - CX_SC_PrivateExtern(4), - CX_SC_OpenCLWorkGroupLocal(5), - CX_SC_Auto(6), - CX_SC_Register(7); + external CXIdxLoc loc; - final int value; - const CX_StorageClass(this.value); + /// The entity that gets referenced. + external ffi.Pointer referencedEntity; - static CX_StorageClass fromValue(int value) => switch (value) { - 0 => CX_SC_Invalid, - 1 => CX_SC_None, - 2 => CX_SC_Extern, - 3 => CX_SC_Static, - 4 => CX_SC_PrivateExtern, - 5 => CX_SC_OpenCLWorkGroupLocal, - 6 => CX_SC_Auto, - 7 => CX_SC_Register, - _ => throw ArgumentError('Unknown value for CX_StorageClass: $value'), - }; -} + /// Immediate "parent" of the reference. For example: + external ffi.Pointer parentEntity; -/// Describes how the traversal of the children of a particular cursor should -/// proceed after visiting a particular child cursor. -enum CXChildVisitResult { - /// Terminates the cursor traversal. - CXChildVisit_Break(0), + /// Lexical container context of the reference. + external ffi.Pointer container; - /// Continues the cursor traversal with the next sibling of the cursor just - /// visited, without visiting its children. - CXChildVisit_Continue(1), + /// Sets of symbol roles of the reference. + @ffi.UnsignedInt() + external int roleAsInt; + + CXSymbolRole get role => CXSymbolRole.fromValue(roleAsInt); + set role(CXSymbolRole value) => roleAsInt = value.value; +} + +/// Data for IndexerCallbacks#indexEntityReference. +enum CXIdxEntityRefKind { + /// The entity is referenced directly in user's code. + CXIdxEntityRef_Direct(1), - /// Recursively traverse the children of this cursor, using the same visitor - /// and client data. - CXChildVisit_Recurse(2); + /// An implicit reference, e.g. a reference of an Objective-C method via the + /// dot syntax. + CXIdxEntityRef_Implicit(2); final int value; - const CXChildVisitResult(this.value); + const CXIdxEntityRefKind(this.value); - static CXChildVisitResult fromValue(int value) => switch (value) { - 0 => CXChildVisit_Break, - 1 => CXChildVisit_Continue, - 2 => CXChildVisit_Recurse, - _ => throw ArgumentError('Unknown value for CXChildVisitResult: $value'), + static CXIdxEntityRefKind fromValue(int value) => switch (value) { + 1 => CXIdxEntityRef_Direct, + 2 => CXIdxEntityRef_Implicit, + _ => throw ArgumentError('Unknown value for CXIdxEntityRefKind: $value'), }; } -typedef CXCursorVisitorFunction = - ffi.UnsignedInt Function( - CXCursor cursor, - CXCursor parent, - CXClientData client_data, - ); -typedef DartCXCursorVisitorFunction = - CXChildVisitResult Function( - CXCursor cursor, - CXCursor parent, - CXClientData client_data, - ); +final class CXIdxIBOutletCollectionAttrInfo extends ffi.Struct { + external ffi.Pointer attrInfo; -/// Visitor invoked for each cursor found by a traversal. -typedef CXCursorVisitor = - ffi.Pointer>; + external ffi.Pointer objcClass; -/// Opaque pointer representing a policy that controls pretty printing for -/// clang_getCursorPrettyPrinted. -typedef CXPrintingPolicy = ffi.Pointer; + external CXCursor classCursor; -/// Properties for the printing policy. -enum CXPrintingPolicyProperty { - CXPrintingPolicy_Indentation(0), - CXPrintingPolicy_SuppressSpecifiers(1), - CXPrintingPolicy_SuppressTagKeyword(2), - CXPrintingPolicy_IncludeTagDefinition(3), - CXPrintingPolicy_SuppressScope(4), - CXPrintingPolicy_SuppressUnwrittenScope(5), - CXPrintingPolicy_SuppressInitializers(6), - CXPrintingPolicy_ConstantArraySizeAsWritten(7), - CXPrintingPolicy_AnonymousTagLocations(8), - CXPrintingPolicy_SuppressStrongLifetime(9), - CXPrintingPolicy_SuppressLifetimeQualifiers(10), - CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors(11), - CXPrintingPolicy_Bool(12), - CXPrintingPolicy_Restrict(13), - CXPrintingPolicy_Alignof(14), - CXPrintingPolicy_UnderscoreAlignof(15), - CXPrintingPolicy_UseVoidForZeroParams(16), - CXPrintingPolicy_TerseOutput(17), - CXPrintingPolicy_PolishForDeclaration(18), - CXPrintingPolicy_Half(19), - CXPrintingPolicy_MSWChar(20), - CXPrintingPolicy_IncludeNewlines(21), - CXPrintingPolicy_MSVCFormatting(22), - CXPrintingPolicy_ConstantsAsWritten(23), - CXPrintingPolicy_SuppressImplicitBase(24), - CXPrintingPolicy_FullyQualifiedName(25); + external CXIdxLoc classLoc; +} - static const CXPrintingPolicy_LastProperty = - CXPrintingPolicy_FullyQualifiedName; +/// Data for IndexerCallbacks#importedASTFile. +final class CXIdxImportedASTFileInfo extends ffi.Struct { + /// Top level AST file containing the imported PCH, module or submodule. + external CXFile file; - final int value; - const CXPrintingPolicyProperty(this.value); + /// The imported module or NULL if the AST file is a PCH. + external CXModule module; - static CXPrintingPolicyProperty fromValue(int value) => switch (value) { - 0 => CXPrintingPolicy_Indentation, - 1 => CXPrintingPolicy_SuppressSpecifiers, - 2 => CXPrintingPolicy_SuppressTagKeyword, - 3 => CXPrintingPolicy_IncludeTagDefinition, - 4 => CXPrintingPolicy_SuppressScope, - 5 => CXPrintingPolicy_SuppressUnwrittenScope, - 6 => CXPrintingPolicy_SuppressInitializers, - 7 => CXPrintingPolicy_ConstantArraySizeAsWritten, - 8 => CXPrintingPolicy_AnonymousTagLocations, - 9 => CXPrintingPolicy_SuppressStrongLifetime, - 10 => CXPrintingPolicy_SuppressLifetimeQualifiers, - 11 => CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, - 12 => CXPrintingPolicy_Bool, - 13 => CXPrintingPolicy_Restrict, - 14 => CXPrintingPolicy_Alignof, - 15 => CXPrintingPolicy_UnderscoreAlignof, - 16 => CXPrintingPolicy_UseVoidForZeroParams, - 17 => CXPrintingPolicy_TerseOutput, - 18 => CXPrintingPolicy_PolishForDeclaration, - 19 => CXPrintingPolicy_Half, - 20 => CXPrintingPolicy_MSWChar, - 21 => CXPrintingPolicy_IncludeNewlines, - 22 => CXPrintingPolicy_MSVCFormatting, - 23 => CXPrintingPolicy_ConstantsAsWritten, - 24 => CXPrintingPolicy_SuppressImplicitBase, - 25 => CXPrintingPolicy_FullyQualifiedName, - _ => throw ArgumentError( - 'Unknown value for CXPrintingPolicyProperty: $value', - ), - }; + /// Location where the file is imported. Applicable only for modules. + external CXIdxLoc loc; - @override - String toString() { - if (this == CXPrintingPolicy_FullyQualifiedName) - return "CXPrintingPolicyProperty.CXPrintingPolicy_FullyQualifiedName, CXPrintingPolicyProperty.CXPrintingPolicy_LastProperty"; - return super.toString(); - } + /// Non-zero if an inclusion directive was automatically turned into a module + /// import. Applicable only for modules. + @ffi.Int() + external int isImplicit; } -/// Property attributes for a CXCursor_ObjCPropertyDecl. -enum CXObjCPropertyAttrKind { - CXObjCPropertyAttr_noattr(0), - CXObjCPropertyAttr_readonly(1), - CXObjCPropertyAttr_getter(2), - CXObjCPropertyAttr_assign(4), - CXObjCPropertyAttr_readwrite(8), - CXObjCPropertyAttr_retain(16), - CXObjCPropertyAttr_copy(32), - CXObjCPropertyAttr_nonatomic(64), - CXObjCPropertyAttr_setter(128), - CXObjCPropertyAttr_atomic(256), - CXObjCPropertyAttr_weak(512), - CXObjCPropertyAttr_strong(1024), - CXObjCPropertyAttr_unsafe_unretained(2048), - CXObjCPropertyAttr_class(4096); +/// Data for ppIncludedFile callback. +final class CXIdxIncludedFileInfo extends ffi.Struct { + /// Location of '#' in the #include/#import directive. + external CXIdxLoc hashLoc; - final int value; - const CXObjCPropertyAttrKind(this.value); + /// Filename as written in the #include/#import directive. + external ffi.Pointer filename; - static CXObjCPropertyAttrKind fromValue(int value) => switch (value) { - 0 => CXObjCPropertyAttr_noattr, - 1 => CXObjCPropertyAttr_readonly, - 2 => CXObjCPropertyAttr_getter, - 4 => CXObjCPropertyAttr_assign, - 8 => CXObjCPropertyAttr_readwrite, - 16 => CXObjCPropertyAttr_retain, - 32 => CXObjCPropertyAttr_copy, - 64 => CXObjCPropertyAttr_nonatomic, - 128 => CXObjCPropertyAttr_setter, - 256 => CXObjCPropertyAttr_atomic, - 512 => CXObjCPropertyAttr_weak, - 1024 => CXObjCPropertyAttr_strong, - 2048 => CXObjCPropertyAttr_unsafe_unretained, - 4096 => CXObjCPropertyAttr_class, - _ => throw ArgumentError( - 'Unknown value for CXObjCPropertyAttrKind: $value', - ), - }; -} + /// The actual file that the #include/#import directive resolved to. + external CXFile file; -/// 'Qualifiers' written next to the return and parameter types in Objective-C -/// method declarations. -enum CXObjCDeclQualifierKind { - CXObjCDeclQualifier_None(0), - CXObjCDeclQualifier_In(1), - CXObjCDeclQualifier_Inout(2), - CXObjCDeclQualifier_Out(4), - CXObjCDeclQualifier_Bycopy(8), - CXObjCDeclQualifier_Byref(16), - CXObjCDeclQualifier_Oneway(32); + @ffi.Int() + external int isImport; - final int value; - const CXObjCDeclQualifierKind(this.value); + @ffi.Int() + external int isAngled; - static CXObjCDeclQualifierKind fromValue(int value) => switch (value) { - 0 => CXObjCDeclQualifier_None, - 1 => CXObjCDeclQualifier_In, - 2 => CXObjCDeclQualifier_Inout, - 4 => CXObjCDeclQualifier_Out, - 8 => CXObjCDeclQualifier_Bycopy, - 16 => CXObjCDeclQualifier_Byref, - 32 => CXObjCDeclQualifier_Oneway, - _ => throw ArgumentError( - 'Unknown value for CXObjCDeclQualifierKind: $value', - ), - }; + /// Non-zero if the directive was automatically turned into a module import. + @ffi.Int() + external int isModuleImport; } -/// The functions in this group provide access to information about modules. -typedef CXModule = ffi.Pointer; +/// Source location passed to index callbacks. +final class CXIdxLoc extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array> ptr_data; -enum CXNameRefFlags { - /// Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the range. - CXNameRange_WantQualifier(1), + @ffi.UnsignedInt() + external int int_data; +} - /// Include the explicit template arguments, e.g. in x.f, in the - /// range. - CXNameRange_WantTemplateArgs(2), +final class CXIdxObjCCategoryDeclInfo extends ffi.Struct { + external ffi.Pointer containerInfo; - /// If the name is non-contiguous, return the full spanning range. - CXNameRange_WantSinglePiece(4); + external ffi.Pointer objcClass; - final int value; - const CXNameRefFlags(this.value); + external CXCursor classCursor; - static CXNameRefFlags fromValue(int value) => switch (value) { - 1 => CXNameRange_WantQualifier, - 2 => CXNameRange_WantTemplateArgs, - 4 => CXNameRange_WantSinglePiece, - _ => throw ArgumentError('Unknown value for CXNameRefFlags: $value'), - }; + external CXIdxLoc classLoc; + + external ffi.Pointer protocols; } -/// Describes a kind of token. -enum CXTokenKind { - /// A token that contains some kind of punctuation. - CXToken_Punctuation(0), +final class CXIdxObjCContainerDeclInfo extends ffi.Struct { + external ffi.Pointer declInfo; - /// A language keyword. - CXToken_Keyword(1), + @ffi.UnsignedInt() + external int kindAsInt; - /// An identifier (that is not a keyword). - CXToken_Identifier(2), + CXIdxObjCContainerKind get kind => + CXIdxObjCContainerKind.fromValue(kindAsInt); + set kind(CXIdxObjCContainerKind value) => kindAsInt = value.value; - /// A numeric, string, or character literal. - CXToken_Literal(3), + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer declInfo, + required CXIdxObjCContainerKind kind, + }) => $allocator() + ..ref.declInfo = declInfo + ..ref.kind = kind; +} - /// A comment. - CXToken_Comment(4); +enum CXIdxObjCContainerKind { + CXIdxObjCContainer_ForwardRef(0), + CXIdxObjCContainer_Interface(1), + CXIdxObjCContainer_Implementation(2); final int value; - const CXTokenKind(this.value); + const CXIdxObjCContainerKind(this.value); - static CXTokenKind fromValue(int value) => switch (value) { - 0 => CXToken_Punctuation, - 1 => CXToken_Keyword, - 2 => CXToken_Identifier, - 3 => CXToken_Literal, - 4 => CXToken_Comment, - _ => throw ArgumentError('Unknown value for CXTokenKind: $value'), + static CXIdxObjCContainerKind fromValue(int value) => switch (value) { + 0 => CXIdxObjCContainer_ForwardRef, + 1 => CXIdxObjCContainer_Interface, + 2 => CXIdxObjCContainer_Implementation, + _ => throw ArgumentError( + 'Unknown value for CXIdxObjCContainerKind: $value', + ), }; } -/// Describes a single preprocessing token. -final class CXToken extends ffi.Struct { - @ffi.Array.multi([4]) - external ffi.Array int_data; - - external ffi.Pointer ptr_data; -} - -/// A semantic string that describes a code-completion result. -typedef CXCompletionString = ffi.Pointer; +final class CXIdxObjCInterfaceDeclInfo extends ffi.Struct { + external ffi.Pointer containerInfo; -/// A single result of code completion. -final class CXCompletionResult extends ffi.Struct { - /// The kind of entity that this completion refers to. - @ffi.UnsignedInt() - external int CursorKindAsInt; + external ffi.Pointer superInfo; - CXCursorKind get CursorKind => CXCursorKind.fromValue(CursorKindAsInt); - set CursorKind(CXCursorKind value) => CursorKindAsInt = value.value; + external ffi.Pointer protocols; - /// The code-completion string that describes how to insert this - /// code-completion result into the editing buffer. - external CXCompletionString CompletionString; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer containerInfo, + required ffi.Pointer superInfo, + required ffi.Pointer protocols, + }) => $allocator() + ..ref.containerInfo = containerInfo + ..ref.superInfo = superInfo + ..ref.protocols = protocols; } -/// Describes a single piece of text within a code-completion string. -enum CXCompletionChunkKind { - /// A code-completion string that describes "optional" text that could be a - /// part of the template (but is not required). - CXCompletionChunk_Optional(0), - - /// Text that a user would be expected to type to get this code-completion - /// result. - CXCompletionChunk_TypedText(1), - - /// Text that should be inserted as part of a code-completion result. - CXCompletionChunk_Text(2), +final class CXIdxObjCPropertyDeclInfo extends ffi.Struct { + external ffi.Pointer declInfo; - /// Placeholder text that should be replaced by the user. - CXCompletionChunk_Placeholder(3), + external ffi.Pointer getter; - /// Informative text that should be displayed but never inserted as part of - /// the template. - CXCompletionChunk_Informative(4), + external ffi.Pointer setter; - /// Text that describes the current parameter when code-completion is - /// referring to function call, message send, or template specialization. - CXCompletionChunk_CurrentParameter(5), + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer declInfo, + required ffi.Pointer getter, + required ffi.Pointer setter, + }) => $allocator() + ..ref.declInfo = declInfo + ..ref.getter = getter + ..ref.setter = setter; +} - /// A left parenthesis ('('), used to initiate a function call or signal the - /// beginning of a function parameter list. - CXCompletionChunk_LeftParen(6), +final class CXIdxObjCProtocolRefInfo extends ffi.Struct { + external ffi.Pointer protocol; - /// A right parenthesis (')'), used to finish a function call or signal the - /// end of a function parameter list. - CXCompletionChunk_RightParen(7), + external CXCursor cursor; - /// A left bracket ('['). - CXCompletionChunk_LeftBracket(8), + external CXIdxLoc loc; +} - /// A right bracket (']'). - CXCompletionChunk_RightBracket(9), +final class CXIdxObjCProtocolRefListInfo extends ffi.Struct { + external ffi.Pointer> protocols; - /// A left brace ('{'). - CXCompletionChunk_LeftBrace(10), + @ffi.UnsignedInt() + external int numProtocols; - /// A right brace ('}'). - CXCompletionChunk_RightBrace(11), + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer> protocols, + required int numProtocols, + }) => $allocator() + ..ref.protocols = protocols + ..ref.numProtocols = numProtocols; +} - /// A left angle bracket ('<'). - CXCompletionChunk_LeftAngle(12), +/// Visitor invoked for each file in a translation unit (used with +/// clang_getInclusions()). +typedef CXInclusionVisitor = + ffi.Pointer>; +typedef CXInclusionVisitorFunction = + ffi.Void Function( + CXFile included_file, + ffi.Pointer inclusion_stack, + ffi.UnsignedInt include_len, + CXClientData client_data, + ); +typedef DartCXInclusionVisitorFunction = + void Function( + CXFile included_file, + ffi.Pointer inclusion_stack, + int include_len, + CXClientData client_data, + ); - /// A right angle bracket ('>'). - CXCompletionChunk_RightAngle(13), +/// An "index" that consists of a set of translation units that would typically +/// be linked together into an executable or library. +typedef CXIndex = ffi.Pointer; - /// A comma separator (','). - CXCompletionChunk_Comma(14), +/// An indexing action/session, to be applied to one or multiple translation +/// units. +typedef CXIndexAction = ffi.Pointer; - /// Text that specifies the result type of a given result. - CXCompletionChunk_ResultType(15), +enum CXIndexOptFlags { + /// Used to indicate that no special indexing options are needed. + CXIndexOpt_None(0), - /// A colon (':'). - CXCompletionChunk_Colon(16), + /// Used to indicate that IndexerCallbacks#indexEntityReference should be + /// invoked for only one reference of an entity per source file that does not + /// also include a declaration/definition of the entity. + CXIndexOpt_SuppressRedundantRefs(1), - /// A semicolon (';'). - CXCompletionChunk_SemiColon(17), + /// Function-local symbols should be indexed. If this is not set + /// function-local symbols will be ignored. + CXIndexOpt_IndexFunctionLocalSymbols(2), - /// An '=' sign. - CXCompletionChunk_Equal(18), + /// Implicit function/class template instantiations should be indexed. If this + /// is not set, implicit instantiations will be ignored. + CXIndexOpt_IndexImplicitTemplateInstantiations(4), - /// Horizontal space (' '). - CXCompletionChunk_HorizontalSpace(19), + /// Suppress all compiler warnings when parsing for indexing. + CXIndexOpt_SuppressWarnings(8), - /// Vertical space ('\n'), after which it is generally a good idea to perform - /// indentation. - CXCompletionChunk_VerticalSpace(20); + /// Skip a function/method body that was already parsed during an indexing + /// session associated with a CXIndexAction object. Bodies in system headers + /// are always skipped. + CXIndexOpt_SkipParsedBodiesInSession(16); final int value; - const CXCompletionChunkKind(this.value); + const CXIndexOptFlags(this.value); - static CXCompletionChunkKind fromValue(int value) => switch (value) { - 0 => CXCompletionChunk_Optional, - 1 => CXCompletionChunk_TypedText, - 2 => CXCompletionChunk_Text, - 3 => CXCompletionChunk_Placeholder, - 4 => CXCompletionChunk_Informative, - 5 => CXCompletionChunk_CurrentParameter, - 6 => CXCompletionChunk_LeftParen, - 7 => CXCompletionChunk_RightParen, - 8 => CXCompletionChunk_LeftBracket, - 9 => CXCompletionChunk_RightBracket, - 10 => CXCompletionChunk_LeftBrace, - 11 => CXCompletionChunk_RightBrace, - 12 => CXCompletionChunk_LeftAngle, - 13 => CXCompletionChunk_RightAngle, - 14 => CXCompletionChunk_Comma, - 15 => CXCompletionChunk_ResultType, - 16 => CXCompletionChunk_Colon, - 17 => CXCompletionChunk_SemiColon, - 18 => CXCompletionChunk_Equal, - 19 => CXCompletionChunk_HorizontalSpace, - 20 => CXCompletionChunk_VerticalSpace, - _ => throw ArgumentError('Unknown value for CXCompletionChunkKind: $value'), + static CXIndexOptFlags fromValue(int value) => switch (value) { + 0 => CXIndexOpt_None, + 1 => CXIndexOpt_SuppressRedundantRefs, + 2 => CXIndexOpt_IndexFunctionLocalSymbols, + 4 => CXIndexOpt_IndexImplicitTemplateInstantiations, + 8 => CXIndexOpt_SuppressWarnings, + 16 => CXIndexOpt_SkipParsedBodiesInSession, + _ => throw ArgumentError('Unknown value for CXIndexOptFlags: $value'), }; } -/// Contains the results of code-completion. -final class CXCodeCompleteResults extends ffi.Struct { - /// The code-completion results. - external ffi.Pointer Results; +/// Describe the "language" of the entity referred to by a cursor. +enum CXLanguageKind { + CXLanguage_Invalid(0), + CXLanguage_C(1), + CXLanguage_ObjC(2), + CXLanguage_CPlusPlus(3); - /// The number of code-completion results stored in the Results array. - @ffi.UnsignedInt() - external int NumResults; + final int value; + const CXLanguageKind(this.value); + + static CXLanguageKind fromValue(int value) => switch (value) { + 0 => CXLanguage_Invalid, + 1 => CXLanguage_C, + 2 => CXLanguage_ObjC, + 3 => CXLanguage_CPlusPlus, + _ => throw ArgumentError('Unknown value for CXLanguageKind: $value'), + }; } -/// Flags that can be passed to clang_codeCompleteAt() to modify its behavior. -enum CXCodeComplete_Flags { - /// Whether to include macros within the set of code completions returned. - CXCodeComplete_IncludeMacros(1), +/// Describe the linkage of the entity referred to by a cursor. +enum CXLinkageKind { + /// This value indicates that no linkage information is available for a + /// provided CXCursor. + CXLinkage_Invalid(0), - /// Whether to include code patterns for language constructs within the set of - /// code completions, e.g., for loops. - CXCodeComplete_IncludeCodePatterns(2), + /// This is the linkage for variables, parameters, and so on that have + /// automatic storage. This covers normal (non-extern) local variables. + CXLinkage_NoLinkage(1), - /// Whether to include brief documentation within the set of code completions - /// returned. - CXCodeComplete_IncludeBriefComments(4), + /// This is the linkage for static variables and static functions. + CXLinkage_Internal(2), - /// Whether to speed up completion by omitting top- or namespace-level - /// entities defined in the preamble. There's no guarantee any particular - /// entity is omitted. This may be useful if the headers are indexed - /// externally. - CXCodeComplete_SkipPreamble(8), + /// This is the linkage for entities with external linkage that live in C++ + /// anonymous namespaces. + CXLinkage_UniqueExternal(3), - /// Whether to include completions with small fix-its, e.g. change '.' to '->' - /// on member access, etc. - CXCodeComplete_IncludeCompletionsWithFixIts(16); + /// This is the linkage for entities with true, external linkage. + CXLinkage_External(4); final int value; - const CXCodeComplete_Flags(this.value); + const CXLinkageKind(this.value); - static CXCodeComplete_Flags fromValue(int value) => switch (value) { - 1 => CXCodeComplete_IncludeMacros, - 2 => CXCodeComplete_IncludeCodePatterns, - 4 => CXCodeComplete_IncludeBriefComments, - 8 => CXCodeComplete_SkipPreamble, - 16 => CXCodeComplete_IncludeCompletionsWithFixIts, - _ => throw ArgumentError('Unknown value for CXCodeComplete_Flags: $value'), + static CXLinkageKind fromValue(int value) => switch (value) { + 0 => CXLinkage_Invalid, + 1 => CXLinkage_NoLinkage, + 2 => CXLinkage_Internal, + 3 => CXLinkage_UniqueExternal, + 4 => CXLinkage_External, + _ => throw ArgumentError('Unknown value for CXLinkageKind: $value'), }; } -/// Bits that represent the context under which completion is occurring. -enum CXCompletionContext { - /// The context for completions is unexposed, as only Clang results should be - /// included. (This is equivalent to having no context bits set.) - CXCompletionContext_Unexposed(0), +/// Describes the kind of error that occurred (if any) in a call to +/// clang_loadDiagnostics. +enum CXLoadDiag_Error { + /// Indicates that no error occurred. + CXLoadDiag_None(0), - /// Completions for any possible type should be included in the results. - CXCompletionContext_AnyType(1), + /// Indicates that an unknown error occurred while attempting to deserialize + /// diagnostics. + CXLoadDiag_Unknown(1), - /// Completions for any possible value (variables, function calls, etc.) - /// should be included in the results. - CXCompletionContext_AnyValue(2), + /// Indicates that the file containing the serialized diagnostics could not be + /// opened. + CXLoadDiag_CannotLoad(2), - /// Completions for values that resolve to an Objective-C object should be - /// included in the results. - CXCompletionContext_ObjCObjectValue(4), + /// Indicates that the serialized diagnostics file is invalid or corrupt. + CXLoadDiag_InvalidFile(3); - /// Completions for values that resolve to an Objective-C selector should be - /// included in the results. - CXCompletionContext_ObjCSelectorValue(8), + final int value; + const CXLoadDiag_Error(this.value); - /// Completions for values that resolve to a C++ class type should be included - /// in the results. - CXCompletionContext_CXXClassTypeValue(16), + static CXLoadDiag_Error fromValue(int value) => switch (value) { + 0 => CXLoadDiag_None, + 1 => CXLoadDiag_Unknown, + 2 => CXLoadDiag_CannotLoad, + 3 => CXLoadDiag_InvalidFile, + _ => throw ArgumentError('Unknown value for CXLoadDiag_Error: $value'), + }; +} - /// Completions for fields of the member being accessed using the dot operator - /// should be included in the results. - CXCompletionContext_DotMemberAccess(32), +/// The functions in this group provide access to information about modules. +typedef CXModule = ffi.Pointer; - /// Completions for fields of the member being accessed using the arrow - /// operator should be included in the results. - CXCompletionContext_ArrowMemberAccess(64), +/// Object encapsulating information about a module.map file. +typedef CXModuleMapDescriptor = ffi.Pointer; - /// Completions for properties of the Objective-C object being accessed using - /// the dot operator should be included in the results. - CXCompletionContext_ObjCPropertyAccess(128), +final class CXModuleMapDescriptorImpl extends ffi.Opaque {} - /// Completions for enum tags should be included in the results. - CXCompletionContext_EnumTag(256), +enum CXNameRefFlags { + /// Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the range. + CXNameRange_WantQualifier(1), - /// Completions for union tags should be included in the results. - CXCompletionContext_UnionTag(512), + /// Include the explicit template arguments, e.g. in x.f, in the + /// range. + CXNameRange_WantTemplateArgs(2), - /// Completions for struct tags should be included in the results. - CXCompletionContext_StructTag(1024), + /// If the name is non-contiguous, return the full spanning range. + CXNameRange_WantSinglePiece(4); - /// Completions for C++ class names should be included in the results. - CXCompletionContext_ClassTag(2048), + final int value; + const CXNameRefFlags(this.value); - /// Completions for C++ namespaces and namespace aliases should be included in - /// the results. - CXCompletionContext_Namespace(4096), + static CXNameRefFlags fromValue(int value) => switch (value) { + 1 => CXNameRange_WantQualifier, + 2 => CXNameRange_WantTemplateArgs, + 4 => CXNameRange_WantSinglePiece, + _ => throw ArgumentError('Unknown value for CXNameRefFlags: $value'), + }; +} - /// Completions for C++ nested name specifiers should be included in the - /// results. - CXCompletionContext_NestedNameSpecifier(8192), +/// 'Qualifiers' written next to the return and parameter types in Objective-C +/// method declarations. +enum CXObjCDeclQualifierKind { + CXObjCDeclQualifier_None(0), + CXObjCDeclQualifier_In(1), + CXObjCDeclQualifier_Inout(2), + CXObjCDeclQualifier_Out(4), + CXObjCDeclQualifier_Bycopy(8), + CXObjCDeclQualifier_Byref(16), + CXObjCDeclQualifier_Oneway(32); - /// Completions for Objective-C interfaces (classes) should be included in the - /// results. - CXCompletionContext_ObjCInterface(16384), + final int value; + const CXObjCDeclQualifierKind(this.value); - /// Completions for Objective-C protocols should be included in the results. - CXCompletionContext_ObjCProtocol(32768), + static CXObjCDeclQualifierKind fromValue(int value) => switch (value) { + 0 => CXObjCDeclQualifier_None, + 1 => CXObjCDeclQualifier_In, + 2 => CXObjCDeclQualifier_Inout, + 4 => CXObjCDeclQualifier_Out, + 8 => CXObjCDeclQualifier_Bycopy, + 16 => CXObjCDeclQualifier_Byref, + 32 => CXObjCDeclQualifier_Oneway, + _ => throw ArgumentError( + 'Unknown value for CXObjCDeclQualifierKind: $value', + ), + }; +} - /// Completions for Objective-C categories should be included in the results. - CXCompletionContext_ObjCCategory(65536), +/// Property attributes for a CXCursor_ObjCPropertyDecl. +enum CXObjCPropertyAttrKind { + CXObjCPropertyAttr_noattr(0), + CXObjCPropertyAttr_readonly(1), + CXObjCPropertyAttr_getter(2), + CXObjCPropertyAttr_assign(4), + CXObjCPropertyAttr_readwrite(8), + CXObjCPropertyAttr_retain(16), + CXObjCPropertyAttr_copy(32), + CXObjCPropertyAttr_nonatomic(64), + CXObjCPropertyAttr_setter(128), + CXObjCPropertyAttr_atomic(256), + CXObjCPropertyAttr_weak(512), + CXObjCPropertyAttr_strong(1024), + CXObjCPropertyAttr_unsafe_unretained(2048), + CXObjCPropertyAttr_class(4096); - /// Completions for Objective-C instance messages should be included in the - /// results. - CXCompletionContext_ObjCInstanceMessage(131072), + final int value; + const CXObjCPropertyAttrKind(this.value); - /// Completions for Objective-C class messages should be included in the - /// results. - CXCompletionContext_ObjCClassMessage(262144), + static CXObjCPropertyAttrKind fromValue(int value) => switch (value) { + 0 => CXObjCPropertyAttr_noattr, + 1 => CXObjCPropertyAttr_readonly, + 2 => CXObjCPropertyAttr_getter, + 4 => CXObjCPropertyAttr_assign, + 8 => CXObjCPropertyAttr_readwrite, + 16 => CXObjCPropertyAttr_retain, + 32 => CXObjCPropertyAttr_copy, + 64 => CXObjCPropertyAttr_nonatomic, + 128 => CXObjCPropertyAttr_setter, + 256 => CXObjCPropertyAttr_atomic, + 512 => CXObjCPropertyAttr_weak, + 1024 => CXObjCPropertyAttr_strong, + 2048 => CXObjCPropertyAttr_unsafe_unretained, + 4096 => CXObjCPropertyAttr_class, + _ => throw ArgumentError( + 'Unknown value for CXObjCPropertyAttrKind: $value', + ), + }; +} - /// Completions for Objective-C selector names should be included in the - /// results. - CXCompletionContext_ObjCSelectorName(524288), +/// Describes the availability of a given entity on a particular platform, e.g., +/// a particular class might only be available on Mac OS 10.7 or newer. +final class CXPlatformAvailability extends ffi.Struct { + /// A string that describes the platform for which this structure provides + /// availability information. + external CXString Platform; - /// Completions for preprocessor macro names should be included in the - /// results. - CXCompletionContext_MacroName(1048576), + /// The version number in which this entity was introduced. + external CXVersion Introduced; - /// Natural language completions should be included in the results. - CXCompletionContext_NaturalLanguage(2097152), + /// The version number in which this entity was deprecated (but is still + /// available). + external CXVersion Deprecated; - /// #include file completions should be included in the results. - CXCompletionContext_IncludedFile(4194304), + /// The version number in which this entity was obsoleted, and therefore is no + /// longer available. + external CXVersion Obsoleted; - /// The current context is unknown, so set all contexts. - CXCompletionContext_Unknown(8388607); + /// Whether the entity is unconditionally unavailable on this platform. + @ffi.Int() + external int Unavailable; - final int value; - const CXCompletionContext(this.value); + /// An optional message to provide to a user of this API, e.g., to suggest + /// replacement APIs. + external CXString Message; +} - static CXCompletionContext fromValue(int value) => switch (value) { - 0 => CXCompletionContext_Unexposed, - 1 => CXCompletionContext_AnyType, - 2 => CXCompletionContext_AnyValue, - 4 => CXCompletionContext_ObjCObjectValue, - 8 => CXCompletionContext_ObjCSelectorValue, - 16 => CXCompletionContext_CXXClassTypeValue, - 32 => CXCompletionContext_DotMemberAccess, - 64 => CXCompletionContext_ArrowMemberAccess, - 128 => CXCompletionContext_ObjCPropertyAccess, - 256 => CXCompletionContext_EnumTag, - 512 => CXCompletionContext_UnionTag, - 1024 => CXCompletionContext_StructTag, - 2048 => CXCompletionContext_ClassTag, - 4096 => CXCompletionContext_Namespace, - 8192 => CXCompletionContext_NestedNameSpecifier, - 16384 => CXCompletionContext_ObjCInterface, - 32768 => CXCompletionContext_ObjCProtocol, - 65536 => CXCompletionContext_ObjCCategory, - 131072 => CXCompletionContext_ObjCInstanceMessage, - 262144 => CXCompletionContext_ObjCClassMessage, - 524288 => CXCompletionContext_ObjCSelectorName, - 1048576 => CXCompletionContext_MacroName, - 2097152 => CXCompletionContext_NaturalLanguage, - 4194304 => CXCompletionContext_IncludedFile, - 8388607 => CXCompletionContext_Unknown, - _ => throw ArgumentError('Unknown value for CXCompletionContext: $value'), +/// Opaque pointer representing a policy that controls pretty printing for +/// clang_getCursorPrettyPrinted. +typedef CXPrintingPolicy = ffi.Pointer; + +/// Properties for the printing policy. +enum CXPrintingPolicyProperty { + CXPrintingPolicy_Indentation(0), + CXPrintingPolicy_SuppressSpecifiers(1), + CXPrintingPolicy_SuppressTagKeyword(2), + CXPrintingPolicy_IncludeTagDefinition(3), + CXPrintingPolicy_SuppressScope(4), + CXPrintingPolicy_SuppressUnwrittenScope(5), + CXPrintingPolicy_SuppressInitializers(6), + CXPrintingPolicy_ConstantArraySizeAsWritten(7), + CXPrintingPolicy_AnonymousTagLocations(8), + CXPrintingPolicy_SuppressStrongLifetime(9), + CXPrintingPolicy_SuppressLifetimeQualifiers(10), + CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors(11), + CXPrintingPolicy_Bool(12), + CXPrintingPolicy_Restrict(13), + CXPrintingPolicy_Alignof(14), + CXPrintingPolicy_UnderscoreAlignof(15), + CXPrintingPolicy_UseVoidForZeroParams(16), + CXPrintingPolicy_TerseOutput(17), + CXPrintingPolicy_PolishForDeclaration(18), + CXPrintingPolicy_Half(19), + CXPrintingPolicy_MSWChar(20), + CXPrintingPolicy_IncludeNewlines(21), + CXPrintingPolicy_MSVCFormatting(22), + CXPrintingPolicy_ConstantsAsWritten(23), + CXPrintingPolicy_SuppressImplicitBase(24), + CXPrintingPolicy_FullyQualifiedName(25); + + static const CXPrintingPolicy_LastProperty = + CXPrintingPolicy_FullyQualifiedName; + + final int value; + const CXPrintingPolicyProperty(this.value); + + static CXPrintingPolicyProperty fromValue(int value) => switch (value) { + 0 => CXPrintingPolicy_Indentation, + 1 => CXPrintingPolicy_SuppressSpecifiers, + 2 => CXPrintingPolicy_SuppressTagKeyword, + 3 => CXPrintingPolicy_IncludeTagDefinition, + 4 => CXPrintingPolicy_SuppressScope, + 5 => CXPrintingPolicy_SuppressUnwrittenScope, + 6 => CXPrintingPolicy_SuppressInitializers, + 7 => CXPrintingPolicy_ConstantArraySizeAsWritten, + 8 => CXPrintingPolicy_AnonymousTagLocations, + 9 => CXPrintingPolicy_SuppressStrongLifetime, + 10 => CXPrintingPolicy_SuppressLifetimeQualifiers, + 11 => CXPrintingPolicy_SuppressTemplateArgsInCXXConstructors, + 12 => CXPrintingPolicy_Bool, + 13 => CXPrintingPolicy_Restrict, + 14 => CXPrintingPolicy_Alignof, + 15 => CXPrintingPolicy_UnderscoreAlignof, + 16 => CXPrintingPolicy_UseVoidForZeroParams, + 17 => CXPrintingPolicy_TerseOutput, + 18 => CXPrintingPolicy_PolishForDeclaration, + 19 => CXPrintingPolicy_Half, + 20 => CXPrintingPolicy_MSWChar, + 21 => CXPrintingPolicy_IncludeNewlines, + 22 => CXPrintingPolicy_MSVCFormatting, + 23 => CXPrintingPolicy_ConstantsAsWritten, + 24 => CXPrintingPolicy_SuppressImplicitBase, + 25 => CXPrintingPolicy_FullyQualifiedName, + _ => throw ArgumentError( + 'Unknown value for CXPrintingPolicyProperty: $value', + ), }; + + @override + String toString() { + if (this == CXPrintingPolicy_FullyQualifiedName) + return "CXPrintingPolicyProperty.CXPrintingPolicy_FullyQualifiedName, CXPrintingPolicyProperty.CXPrintingPolicy_LastProperty"; + return super.toString(); + } } -typedef CXInclusionVisitorFunction = - ffi.Void Function( - CXFile included_file, - ffi.Pointer inclusion_stack, - ffi.UnsignedInt include_len, - CXClientData client_data, - ); -typedef DartCXInclusionVisitorFunction = - void Function( - CXFile included_file, - ffi.Pointer inclusion_stack, - int include_len, - CXClientData client_data, - ); +enum CXRefQualifierKind { + /// No ref-qualifier was provided. + CXRefQualifier_None(0), -/// Visitor invoked for each file in a translation unit (used with -/// clang_getInclusions()). -typedef CXInclusionVisitor = - ffi.Pointer>; + /// An lvalue ref-qualifier was provided ( &). + CXRefQualifier_LValue(1), -enum CXEvalResultKind { - CXEval_Int(1), - CXEval_Float(2), - CXEval_ObjCStrLiteral(3), - CXEval_StrLiteral(4), - CXEval_CFStr(5), - CXEval_Other(6), - CXEval_UnExposed(0); + /// An rvalue ref-qualifier was provided ( &&). + CXRefQualifier_RValue(2); final int value; - const CXEvalResultKind(this.value); + const CXRefQualifierKind(this.value); - static CXEvalResultKind fromValue(int value) => switch (value) { - 1 => CXEval_Int, - 2 => CXEval_Float, - 3 => CXEval_ObjCStrLiteral, - 4 => CXEval_StrLiteral, - 5 => CXEval_CFStr, - 6 => CXEval_Other, - 0 => CXEval_UnExposed, - _ => throw ArgumentError('Unknown value for CXEvalResultKind: $value'), + static CXRefQualifierKind fromValue(int value) => switch (value) { + 0 => CXRefQualifier_None, + 1 => CXRefQualifier_LValue, + 2 => CXRefQualifier_RValue, + _ => throw ArgumentError('Unknown value for CXRefQualifierKind: $value'), }; } -/// Evaluation result of a cursor -typedef CXEvalResult = ffi.Pointer; - /// A remapping of original source files and their translated files. typedef CXRemapping = ffi.Pointer; -/// @{ -enum CXVisitorResult { - CXVisit_Break(0), - CXVisit_Continue(1); +/// Flags that control the reparsing of translation units. +enum CXReparse_Flags { + /// Used to indicate that no special reparsing options are needed. + CXReparse_None(0); final int value; - const CXVisitorResult(this.value); + const CXReparse_Flags(this.value); - static CXVisitorResult fromValue(int value) => switch (value) { - 0 => CXVisit_Break, - 1 => CXVisit_Continue, - _ => throw ArgumentError('Unknown value for CXVisitorResult: $value'), + static CXReparse_Flags fromValue(int value) => switch (value) { + 0 => CXReparse_None, + _ => throw ArgumentError('Unknown value for CXReparse_Flags: $value'), }; } -final class CXCursorAndRangeVisitor extends ffi.Struct { - external ffi.Pointer context; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.UnsignedInt Function(ffi.Pointer, CXCursor, CXSourceRange) - > - > - visit; -} - enum CXResult { /// Function returned successfully. CXResult_Success(0), @@ -8311,22 +8060,54 @@ enum CXResult { }; } -/// The client's data object that is associated with a CXFile. -typedef CXIdxClientFile = ffi.Pointer; +/// Describes the kind of error that occurred (if any) in a call to +/// clang_saveTranslationUnit(). +enum CXSaveError { + /// Indicates that no error occurred while saving a translation unit. + CXSaveError_None(0), -/// The client's data object that is associated with a semantic entity. -typedef CXIdxClientEntity = ffi.Pointer; + /// Indicates that an unknown error occurred while attempting to save the + /// file. + CXSaveError_Unknown(1), -/// The client's data object that is associated with a semantic container of -/// entities. -typedef CXIdxClientContainer = ffi.Pointer; + /// Indicates that errors during translation prevented this attempt to save + /// the translation unit. + CXSaveError_TranslationErrors(2), -/// The client's data object that is associated with an AST file (PCH or -/// module). -typedef CXIdxClientASTFile = ffi.Pointer; + /// Indicates that the translation unit to be saved was somehow invalid (e.g., + /// NULL). + CXSaveError_InvalidTU(3); -/// Source location passed to index callbacks. -final class CXIdxLoc extends ffi.Struct { + final int value; + const CXSaveError(this.value); + + static CXSaveError fromValue(int value) => switch (value) { + 0 => CXSaveError_None, + 1 => CXSaveError_Unknown, + 2 => CXSaveError_TranslationErrors, + 3 => CXSaveError_InvalidTU, + _ => throw ArgumentError('Unknown value for CXSaveError: $value'), + }; +} + +/// Flags that control how translation units are saved. +enum CXSaveTranslationUnit_Flags { + /// Used to indicate that no special saving options are needed. + CXSaveTranslationUnit_None(0); + + final int value; + const CXSaveTranslationUnit_Flags(this.value); + + static CXSaveTranslationUnit_Flags fromValue(int value) => switch (value) { + 0 => CXSaveTranslationUnit_None, + _ => throw ArgumentError( + 'Unknown value for CXSaveTranslationUnit_Flags: $value', + ), + }; +} + +/// Identifies a specific source location within a translation unit. +final class CXSourceLocation extends ffi.Struct { @ffi.Array.multi([2]) external ffi.Array> ptr_data; @@ -8334,447 +8115,860 @@ final class CXIdxLoc extends ffi.Struct { external int int_data; } -/// Data for ppIncludedFile callback. -final class CXIdxIncludedFileInfo extends ffi.Struct { - /// Location of '#' in the #include/#import directive. - external CXIdxLoc hashLoc; +/// Identifies a half-open character range in the source code. +final class CXSourceRange extends ffi.Struct { + @ffi.Array.multi([2]) + external ffi.Array> ptr_data; + + @ffi.UnsignedInt() + external int begin_int_data; + + @ffi.UnsignedInt() + external int end_int_data; +} + +/// Identifies an array of ranges. +final class CXSourceRangeList extends ffi.Struct { + /// The number of ranges in the ranges array. + @ffi.UnsignedInt() + external int count; + + /// An array of CXSourceRanges. + external ffi.Pointer ranges; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int count, + required ffi.Pointer ranges, + }) => $allocator() + ..ref.count = count + ..ref.ranges = ranges; +} + +/// A character string. +final class CXString extends ffi.Struct { + external ffi.Pointer data; + + @ffi.UnsignedInt() + external int private_flags; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer data, + required int private_flags, + }) => $allocator() + ..ref.data = data + ..ref.private_flags = private_flags; +} + +final class CXStringSet extends ffi.Struct { + external ffi.Pointer Strings; + + @ffi.UnsignedInt() + external int Count; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer Strings, + required int Count, + }) => $allocator() + ..ref.Strings = Strings + ..ref.Count = Count; +} + +/// Roles that are attributed to symbol occurrences. +enum CXSymbolRole { + CXSymbolRole_None(0), + CXSymbolRole_Declaration(1), + CXSymbolRole_Definition(2), + CXSymbolRole_Reference(4), + CXSymbolRole_Read(8), + CXSymbolRole_Write(16), + CXSymbolRole_Call(32), + CXSymbolRole_Dynamic(64), + CXSymbolRole_AddressOf(128), + CXSymbolRole_Implicit(256); + + final int value; + const CXSymbolRole(this.value); + + static CXSymbolRole fromValue(int value) => switch (value) { + 0 => CXSymbolRole_None, + 1 => CXSymbolRole_Declaration, + 2 => CXSymbolRole_Definition, + 4 => CXSymbolRole_Reference, + 8 => CXSymbolRole_Read, + 16 => CXSymbolRole_Write, + 32 => CXSymbolRole_Call, + 64 => CXSymbolRole_Dynamic, + 128 => CXSymbolRole_AddressOf, + 256 => CXSymbolRole_Implicit, + _ => throw ArgumentError('Unknown value for CXSymbolRole: $value'), + }; +} + +/// Describe the "thread-local storage (TLS) kind" of the declaration referred +/// to by a cursor. +enum CXTLSKind { + CXTLS_None(0), + CXTLS_Dynamic(1), + CXTLS_Static(2); + + final int value; + const CXTLSKind(this.value); - /// Filename as written in the #include/#import directive. - external ffi.Pointer filename; + static CXTLSKind fromValue(int value) => switch (value) { + 0 => CXTLS_None, + 1 => CXTLS_Dynamic, + 2 => CXTLS_Static, + _ => throw ArgumentError('Unknown value for CXTLSKind: $value'), + }; +} - /// The actual file that the #include/#import directive resolved to. - external CXFile file; +/// The memory usage of a CXTranslationUnit, broken into categories. +final class CXTUResourceUsage extends ffi.Struct { + external ffi.Pointer data; - @ffi.Int() - external int isImport; + @ffi.UnsignedInt() + external int numEntries; - @ffi.Int() - external int isAngled; + external ffi.Pointer entries; - /// Non-zero if the directive was automatically turned into a module import. - @ffi.Int() - external int isModuleImport; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer data, + required int numEntries, + required ffi.Pointer entries, + }) => $allocator() + ..ref.data = data + ..ref.numEntries = numEntries + ..ref.entries = entries; } -/// Data for IndexerCallbacks#importedASTFile. -final class CXIdxImportedASTFileInfo extends ffi.Struct { - /// Top level AST file containing the imported PCH, module or submodule. - external CXFile file; +final class CXTUResourceUsageEntry extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; - /// The imported module or NULL if the AST file is a PCH. - external CXModule module; + CXTUResourceUsageKind get kind => CXTUResourceUsageKind.fromValue(kindAsInt); + set kind(CXTUResourceUsageKind value) => kindAsInt = value.value; - /// Location where the file is imported. Applicable only for modules. - external CXIdxLoc loc; + @ffi.UnsignedLong() + external int amount; - /// Non-zero if an inclusion directive was automatically turned into a module - /// import. Applicable only for modules. - @ffi.Int() - external int isImplicit; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required CXTUResourceUsageKind kind, + required int amount, + }) => $allocator() + ..ref.kind = kind + ..ref.amount = amount; } -enum CXIdxEntityKind { - CXIdxEntity_Unexposed(0), - CXIdxEntity_Typedef(1), - CXIdxEntity_Function(2), - CXIdxEntity_Variable(3), - CXIdxEntity_Field(4), - CXIdxEntity_EnumConstant(5), - CXIdxEntity_ObjCClass(6), - CXIdxEntity_ObjCProtocol(7), - CXIdxEntity_ObjCCategory(8), - CXIdxEntity_ObjCInstanceMethod(9), - CXIdxEntity_ObjCClassMethod(10), - CXIdxEntity_ObjCProperty(11), - CXIdxEntity_ObjCIvar(12), - CXIdxEntity_Enum(13), - CXIdxEntity_Struct(14), - CXIdxEntity_Union(15), - CXIdxEntity_CXXClass(16), - CXIdxEntity_CXXNamespace(17), - CXIdxEntity_CXXNamespaceAlias(18), - CXIdxEntity_CXXStaticVariable(19), - CXIdxEntity_CXXStaticMethod(20), - CXIdxEntity_CXXInstanceMethod(21), - CXIdxEntity_CXXConstructor(22), - CXIdxEntity_CXXDestructor(23), - CXIdxEntity_CXXConversionFunction(24), - CXIdxEntity_CXXTypeAlias(25), - CXIdxEntity_CXXInterface(26); +/// Categorizes how memory is being used by a translation unit. +enum CXTUResourceUsageKind { + CXTUResourceUsage_AST(1), + CXTUResourceUsage_Identifiers(2), + CXTUResourceUsage_Selectors(3), + CXTUResourceUsage_GlobalCompletionResults(4), + CXTUResourceUsage_SourceManagerContentCache(5), + CXTUResourceUsage_AST_SideTables(6), + CXTUResourceUsage_SourceManager_Membuffer_Malloc(7), + CXTUResourceUsage_SourceManager_Membuffer_MMap(8), + CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc(9), + CXTUResourceUsage_ExternalASTSource_Membuffer_MMap(10), + CXTUResourceUsage_Preprocessor(11), + CXTUResourceUsage_PreprocessingRecord(12), + CXTUResourceUsage_SourceManager_DataStructures(13), + CXTUResourceUsage_Preprocessor_HeaderSearch(14); + + static const CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN = CXTUResourceUsage_AST; + static const CXTUResourceUsage_MEMORY_IN_BYTES_END = + CXTUResourceUsage_Preprocessor_HeaderSearch; + static const CXTUResourceUsage_First = CXTUResourceUsage_AST; + static const CXTUResourceUsage_Last = + CXTUResourceUsage_Preprocessor_HeaderSearch; final int value; - const CXIdxEntityKind(this.value); + const CXTUResourceUsageKind(this.value); - static CXIdxEntityKind fromValue(int value) => switch (value) { - 0 => CXIdxEntity_Unexposed, - 1 => CXIdxEntity_Typedef, - 2 => CXIdxEntity_Function, - 3 => CXIdxEntity_Variable, - 4 => CXIdxEntity_Field, - 5 => CXIdxEntity_EnumConstant, - 6 => CXIdxEntity_ObjCClass, - 7 => CXIdxEntity_ObjCProtocol, - 8 => CXIdxEntity_ObjCCategory, - 9 => CXIdxEntity_ObjCInstanceMethod, - 10 => CXIdxEntity_ObjCClassMethod, - 11 => CXIdxEntity_ObjCProperty, - 12 => CXIdxEntity_ObjCIvar, - 13 => CXIdxEntity_Enum, - 14 => CXIdxEntity_Struct, - 15 => CXIdxEntity_Union, - 16 => CXIdxEntity_CXXClass, - 17 => CXIdxEntity_CXXNamespace, - 18 => CXIdxEntity_CXXNamespaceAlias, - 19 => CXIdxEntity_CXXStaticVariable, - 20 => CXIdxEntity_CXXStaticMethod, - 21 => CXIdxEntity_CXXInstanceMethod, - 22 => CXIdxEntity_CXXConstructor, - 23 => CXIdxEntity_CXXDestructor, - 24 => CXIdxEntity_CXXConversionFunction, - 25 => CXIdxEntity_CXXTypeAlias, - 26 => CXIdxEntity_CXXInterface, - _ => throw ArgumentError('Unknown value for CXIdxEntityKind: $value'), + static CXTUResourceUsageKind fromValue(int value) => switch (value) { + 1 => CXTUResourceUsage_AST, + 2 => CXTUResourceUsage_Identifiers, + 3 => CXTUResourceUsage_Selectors, + 4 => CXTUResourceUsage_GlobalCompletionResults, + 5 => CXTUResourceUsage_SourceManagerContentCache, + 6 => CXTUResourceUsage_AST_SideTables, + 7 => CXTUResourceUsage_SourceManager_Membuffer_Malloc, + 8 => CXTUResourceUsage_SourceManager_Membuffer_MMap, + 9 => CXTUResourceUsage_ExternalASTSource_Membuffer_Malloc, + 10 => CXTUResourceUsage_ExternalASTSource_Membuffer_MMap, + 11 => CXTUResourceUsage_Preprocessor, + 12 => CXTUResourceUsage_PreprocessingRecord, + 13 => CXTUResourceUsage_SourceManager_DataStructures, + 14 => CXTUResourceUsage_Preprocessor_HeaderSearch, + _ => throw ArgumentError('Unknown value for CXTUResourceUsageKind: $value'), }; + + @override + String toString() { + if (this == CXTUResourceUsage_AST) + return "CXTUResourceUsageKind.CXTUResourceUsage_AST, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_BEGIN, CXTUResourceUsageKind.CXTUResourceUsage_First"; + if (this == CXTUResourceUsage_Preprocessor_HeaderSearch) + return "CXTUResourceUsageKind.CXTUResourceUsage_Preprocessor_HeaderSearch, CXTUResourceUsageKind.CXTUResourceUsage_MEMORY_IN_BYTES_END, CXTUResourceUsageKind.CXTUResourceUsage_Last"; + return super.toString(); + } } -enum CXIdxEntityLanguage { - CXIdxEntityLang_None(0), - CXIdxEntityLang_C(1), - CXIdxEntityLang_ObjC(2), - CXIdxEntityLang_CXX(3), - CXIdxEntityLang_Swift(4); +/// An opaque type representing target information for a given translation unit. +typedef CXTargetInfo = ffi.Pointer; + +final class CXTargetInfoImpl extends ffi.Opaque {} + +/// Describes the kind of a template argument. +enum CXTemplateArgumentKind { + CXTemplateArgumentKind_Null(0), + CXTemplateArgumentKind_Type(1), + CXTemplateArgumentKind_Declaration(2), + CXTemplateArgumentKind_NullPtr(3), + CXTemplateArgumentKind_Integral(4), + CXTemplateArgumentKind_Template(5), + CXTemplateArgumentKind_TemplateExpansion(6), + CXTemplateArgumentKind_Expression(7), + CXTemplateArgumentKind_Pack(8), + CXTemplateArgumentKind_Invalid(9); final int value; - const CXIdxEntityLanguage(this.value); + const CXTemplateArgumentKind(this.value); - static CXIdxEntityLanguage fromValue(int value) => switch (value) { - 0 => CXIdxEntityLang_None, - 1 => CXIdxEntityLang_C, - 2 => CXIdxEntityLang_ObjC, - 3 => CXIdxEntityLang_CXX, - 4 => CXIdxEntityLang_Swift, - _ => throw ArgumentError('Unknown value for CXIdxEntityLanguage: $value'), + static CXTemplateArgumentKind fromValue(int value) => switch (value) { + 0 => CXTemplateArgumentKind_Null, + 1 => CXTemplateArgumentKind_Type, + 2 => CXTemplateArgumentKind_Declaration, + 3 => CXTemplateArgumentKind_NullPtr, + 4 => CXTemplateArgumentKind_Integral, + 5 => CXTemplateArgumentKind_Template, + 6 => CXTemplateArgumentKind_TemplateExpansion, + 7 => CXTemplateArgumentKind_Expression, + 8 => CXTemplateArgumentKind_Pack, + 9 => CXTemplateArgumentKind_Invalid, + _ => throw ArgumentError( + 'Unknown value for CXTemplateArgumentKind: $value', + ), }; } -/// Extra C++ template information for an entity. This can apply to: -/// CXIdxEntity_Function CXIdxEntity_CXXClass CXIdxEntity_CXXStaticMethod -/// CXIdxEntity_CXXInstanceMethod CXIdxEntity_CXXConstructor -/// CXIdxEntity_CXXConversionFunction CXIdxEntity_CXXTypeAlias -enum CXIdxEntityCXXTemplateKind { - CXIdxEntity_NonTemplate(0), - CXIdxEntity_Template(1), - CXIdxEntity_TemplatePartialSpecialization(2), - CXIdxEntity_TemplateSpecialization(3); +/// Describes a single preprocessing token. +final class CXToken extends ffi.Struct { + @ffi.Array.multi([4]) + external ffi.Array int_data; + + external ffi.Pointer ptr_data; +} + +/// Describes a kind of token. +enum CXTokenKind { + /// A token that contains some kind of punctuation. + CXToken_Punctuation(0), + + /// A language keyword. + CXToken_Keyword(1), + + /// An identifier (that is not a keyword). + CXToken_Identifier(2), + + /// A numeric, string, or character literal. + CXToken_Literal(3), + + /// A comment. + CXToken_Comment(4); final int value; - const CXIdxEntityCXXTemplateKind(this.value); + const CXTokenKind(this.value); - static CXIdxEntityCXXTemplateKind fromValue(int value) => switch (value) { - 0 => CXIdxEntity_NonTemplate, - 1 => CXIdxEntity_Template, - 2 => CXIdxEntity_TemplatePartialSpecialization, - 3 => CXIdxEntity_TemplateSpecialization, - _ => throw ArgumentError( - 'Unknown value for CXIdxEntityCXXTemplateKind: $value', - ), + static CXTokenKind fromValue(int value) => switch (value) { + 0 => CXToken_Punctuation, + 1 => CXToken_Keyword, + 2 => CXToken_Identifier, + 3 => CXToken_Literal, + 4 => CXToken_Comment, + _ => throw ArgumentError('Unknown value for CXTokenKind: $value'), }; } -enum CXIdxAttrKind { - CXIdxAttr_Unexposed(0), - CXIdxAttr_IBAction(1), - CXIdxAttr_IBOutlet(2), - CXIdxAttr_IBOutletCollection(3); +/// A single translation unit, which resides in an index. +typedef CXTranslationUnit = ffi.Pointer; - final int value; - const CXIdxAttrKind(this.value); +final class CXTranslationUnitImpl extends ffi.Opaque {} - static CXIdxAttrKind fromValue(int value) => switch (value) { - 0 => CXIdxAttr_Unexposed, - 1 => CXIdxAttr_IBAction, - 2 => CXIdxAttr_IBOutlet, - 3 => CXIdxAttr_IBOutletCollection, - _ => throw ArgumentError('Unknown value for CXIdxAttrKind: $value'), - }; -} +/// Flags that control the creation of translation units. +enum CXTranslationUnit_Flags { + /// Used to indicate that no special translation-unit options are needed. + CXTranslationUnit_None(0), -final class CXIdxAttrInfo extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; + /// Used to indicate that the parser should construct a "detailed" + /// preprocessing record, including all macro definitions and instantiations. + CXTranslationUnit_DetailedPreprocessingRecord(1), - CXIdxAttrKind get kind => CXIdxAttrKind.fromValue(kindAsInt); - set kind(CXIdxAttrKind value) => kindAsInt = value.value; + /// Used to indicate that the translation unit is incomplete. + CXTranslationUnit_Incomplete(2), - external CXCursor cursor; + /// Used to indicate that the translation unit should be built with an + /// implicit precompiled header for the preamble. + CXTranslationUnit_PrecompiledPreamble(4), - external CXIdxLoc loc; -} + /// Used to indicate that the translation unit should cache some + /// code-completion results with each reparse of the source file. + CXTranslationUnit_CacheCompletionResults(8), -final class CXIdxEntityInfo extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; + /// Used to indicate that the translation unit will be serialized with + /// clang_saveTranslationUnit. + CXTranslationUnit_ForSerialization(16), - CXIdxEntityKind get kind => CXIdxEntityKind.fromValue(kindAsInt); - set kind(CXIdxEntityKind value) => kindAsInt = value.value; + /// DEPRECATED: Enabled chained precompiled preambles in C++. + CXTranslationUnit_CXXChainedPCH(32), - @ffi.UnsignedInt() - external int templateKindAsInt; + /// Used to indicate that function/method bodies should be skipped while + /// parsing. + CXTranslationUnit_SkipFunctionBodies(64), - CXIdxEntityCXXTemplateKind get templateKind => - CXIdxEntityCXXTemplateKind.fromValue(templateKindAsInt); - set templateKind(CXIdxEntityCXXTemplateKind value) => - templateKindAsInt = value.value; + /// Used to indicate that brief documentation comments should be included into + /// the set of code completions returned from this translation unit. + CXTranslationUnit_IncludeBriefCommentsInCodeCompletion(128), - @ffi.UnsignedInt() - external int langAsInt; + /// Used to indicate that the precompiled preamble should be created on the + /// first parse. Otherwise it will be created on the first reparse. This + /// trades runtime on the first parse (serializing the preamble takes time) + /// for reduced runtime on the second parse (can now reuse the preamble). + CXTranslationUnit_CreatePreambleOnFirstParse(256), - CXIdxEntityLanguage get lang => CXIdxEntityLanguage.fromValue(langAsInt); - set lang(CXIdxEntityLanguage value) => langAsInt = value.value; + /// Do not stop processing when fatal errors are encountered. + CXTranslationUnit_KeepGoing(512), - external ffi.Pointer name; + /// Sets the preprocessor in a mode for parsing a single file only. + CXTranslationUnit_SingleFileParse(1024), - external ffi.Pointer USR; + /// Used in combination with CXTranslationUnit_SkipFunctionBodies to constrain + /// the skipping of function bodies to the preamble. + CXTranslationUnit_LimitSkipFunctionBodiesToPreamble(2048), - external CXCursor cursor; + /// Used to indicate that attributed types should be included in CXType. + CXTranslationUnit_IncludeAttributedTypes(4096), - external ffi.Pointer> attributes; + /// Used to indicate that implicit attributes should be visited. + CXTranslationUnit_VisitImplicitAttributes(8192), - @ffi.UnsignedInt() - external int numAttributes; -} + /// Used to indicate that non-errors from included files should be ignored. + CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles(16384), -final class CXIdxContainerInfo extends ffi.Struct { - external CXCursor cursor; -} + /// Tells the preprocessor not to skip excluded conditional blocks. + CXTranslationUnit_RetainExcludedConditionalBlocks(32768); -final class CXIdxIBOutletCollectionAttrInfo extends ffi.Struct { - external ffi.Pointer attrInfo; + final int value; + const CXTranslationUnit_Flags(this.value); - external ffi.Pointer objcClass; + static CXTranslationUnit_Flags fromValue(int value) => switch (value) { + 0 => CXTranslationUnit_None, + 1 => CXTranslationUnit_DetailedPreprocessingRecord, + 2 => CXTranslationUnit_Incomplete, + 4 => CXTranslationUnit_PrecompiledPreamble, + 8 => CXTranslationUnit_CacheCompletionResults, + 16 => CXTranslationUnit_ForSerialization, + 32 => CXTranslationUnit_CXXChainedPCH, + 64 => CXTranslationUnit_SkipFunctionBodies, + 128 => CXTranslationUnit_IncludeBriefCommentsInCodeCompletion, + 256 => CXTranslationUnit_CreatePreambleOnFirstParse, + 512 => CXTranslationUnit_KeepGoing, + 1024 => CXTranslationUnit_SingleFileParse, + 2048 => CXTranslationUnit_LimitSkipFunctionBodiesToPreamble, + 4096 => CXTranslationUnit_IncludeAttributedTypes, + 8192 => CXTranslationUnit_VisitImplicitAttributes, + 16384 => CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles, + 32768 => CXTranslationUnit_RetainExcludedConditionalBlocks, + _ => throw ArgumentError( + 'Unknown value for CXTranslationUnit_Flags: $value', + ), + }; +} - external CXCursor classCursor; +/// The type of an element in the abstract syntax tree. +final class CXType extends ffi.Struct { + @ffi.UnsignedInt() + external int kindAsInt; - external CXIdxLoc classLoc; + CXTypeKind get kind => CXTypeKind.fromValue(kindAsInt); + set kind(CXTypeKind value) => kindAsInt = value.value; + + @ffi.Array.multi([2]) + external ffi.Array> data; } -enum CXIdxDeclInfoFlags { - CXIdxDeclFlag_Skipped(1); +/// Describes the kind of type +enum CXTypeKind { + /// Represents an invalid type (e.g., where no type is available). + CXType_Invalid(0), + + /// A type whose specific kind is not exposed via this interface. + CXType_Unexposed(1), + CXType_Void(2), + CXType_Bool(3), + CXType_Char_U(4), + CXType_UChar(5), + CXType_Char16(6), + CXType_Char32(7), + CXType_UShort(8), + CXType_UInt(9), + CXType_ULong(10), + CXType_ULongLong(11), + CXType_UInt128(12), + CXType_Char_S(13), + CXType_SChar(14), + CXType_WChar(15), + CXType_Short(16), + CXType_Int(17), + CXType_Long(18), + CXType_LongLong(19), + CXType_Int128(20), + CXType_Float(21), + CXType_Double(22), + CXType_LongDouble(23), + CXType_NullPtr(24), + CXType_Overload(25), + CXType_Dependent(26), + CXType_ObjCId(27), + CXType_ObjCClass(28), + CXType_ObjCSel(29), + CXType_Float128(30), + CXType_Half(31), + CXType_Float16(32), + CXType_ShortAccum(33), + CXType_Accum(34), + CXType_LongAccum(35), + CXType_UShortAccum(36), + CXType_UAccum(37), + CXType_ULongAccum(38), + CXType_Complex(100), + CXType_Pointer(101), + CXType_BlockPointer(102), + CXType_LValueReference(103), + CXType_RValueReference(104), + CXType_Record(105), + CXType_Enum(106), + CXType_Typedef(107), + CXType_ObjCInterface(108), + CXType_ObjCObjectPointer(109), + CXType_FunctionNoProto(110), + CXType_FunctionProto(111), + CXType_ConstantArray(112), + CXType_Vector(113), + CXType_IncompleteArray(114), + CXType_VariableArray(115), + CXType_DependentSizedArray(116), + CXType_MemberPointer(117), + CXType_Auto(118), + + /// Represents a type that was referred to using an elaborated type keyword. + CXType_Elaborated(119), + CXType_Pipe(120), + CXType_OCLImage1dRO(121), + CXType_OCLImage1dArrayRO(122), + CXType_OCLImage1dBufferRO(123), + CXType_OCLImage2dRO(124), + CXType_OCLImage2dArrayRO(125), + CXType_OCLImage2dDepthRO(126), + CXType_OCLImage2dArrayDepthRO(127), + CXType_OCLImage2dMSAARO(128), + CXType_OCLImage2dArrayMSAARO(129), + CXType_OCLImage2dMSAADepthRO(130), + CXType_OCLImage2dArrayMSAADepthRO(131), + CXType_OCLImage3dRO(132), + CXType_OCLImage1dWO(133), + CXType_OCLImage1dArrayWO(134), + CXType_OCLImage1dBufferWO(135), + CXType_OCLImage2dWO(136), + CXType_OCLImage2dArrayWO(137), + CXType_OCLImage2dDepthWO(138), + CXType_OCLImage2dArrayDepthWO(139), + CXType_OCLImage2dMSAAWO(140), + CXType_OCLImage2dArrayMSAAWO(141), + CXType_OCLImage2dMSAADepthWO(142), + CXType_OCLImage2dArrayMSAADepthWO(143), + CXType_OCLImage3dWO(144), + CXType_OCLImage1dRW(145), + CXType_OCLImage1dArrayRW(146), + CXType_OCLImage1dBufferRW(147), + CXType_OCLImage2dRW(148), + CXType_OCLImage2dArrayRW(149), + CXType_OCLImage2dDepthRW(150), + CXType_OCLImage2dArrayDepthRW(151), + CXType_OCLImage2dMSAARW(152), + CXType_OCLImage2dArrayMSAARW(153), + CXType_OCLImage2dMSAADepthRW(154), + CXType_OCLImage2dArrayMSAADepthRW(155), + CXType_OCLImage3dRW(156), + CXType_OCLSampler(157), + CXType_OCLEvent(158), + CXType_OCLQueue(159), + CXType_OCLReserveID(160), + CXType_ObjCObject(161), + CXType_ObjCTypeParam(162), + CXType_Attributed(163), + CXType_OCLIntelSubgroupAVCMcePayload(164), + CXType_OCLIntelSubgroupAVCImePayload(165), + CXType_OCLIntelSubgroupAVCRefPayload(166), + CXType_OCLIntelSubgroupAVCSicPayload(167), + CXType_OCLIntelSubgroupAVCMceResult(168), + CXType_OCLIntelSubgroupAVCImeResult(169), + CXType_OCLIntelSubgroupAVCRefResult(170), + CXType_OCLIntelSubgroupAVCSicResult(171), + CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout(172), + CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout(173), + CXType_OCLIntelSubgroupAVCImeSingleRefStreamin(174), + CXType_OCLIntelSubgroupAVCImeDualRefStreamin(175), + CXType_ExtVector(176); + + static const CXType_FirstBuiltin = CXType_Void; + static const CXType_LastBuiltin = CXType_ULongAccum; final int value; - const CXIdxDeclInfoFlags(this.value); + const CXTypeKind(this.value); - static CXIdxDeclInfoFlags fromValue(int value) => switch (value) { - 1 => CXIdxDeclFlag_Skipped, - _ => throw ArgumentError('Unknown value for CXIdxDeclInfoFlags: $value'), + static CXTypeKind fromValue(int value) => switch (value) { + 0 => CXType_Invalid, + 1 => CXType_Unexposed, + 2 => CXType_Void, + 3 => CXType_Bool, + 4 => CXType_Char_U, + 5 => CXType_UChar, + 6 => CXType_Char16, + 7 => CXType_Char32, + 8 => CXType_UShort, + 9 => CXType_UInt, + 10 => CXType_ULong, + 11 => CXType_ULongLong, + 12 => CXType_UInt128, + 13 => CXType_Char_S, + 14 => CXType_SChar, + 15 => CXType_WChar, + 16 => CXType_Short, + 17 => CXType_Int, + 18 => CXType_Long, + 19 => CXType_LongLong, + 20 => CXType_Int128, + 21 => CXType_Float, + 22 => CXType_Double, + 23 => CXType_LongDouble, + 24 => CXType_NullPtr, + 25 => CXType_Overload, + 26 => CXType_Dependent, + 27 => CXType_ObjCId, + 28 => CXType_ObjCClass, + 29 => CXType_ObjCSel, + 30 => CXType_Float128, + 31 => CXType_Half, + 32 => CXType_Float16, + 33 => CXType_ShortAccum, + 34 => CXType_Accum, + 35 => CXType_LongAccum, + 36 => CXType_UShortAccum, + 37 => CXType_UAccum, + 38 => CXType_ULongAccum, + 100 => CXType_Complex, + 101 => CXType_Pointer, + 102 => CXType_BlockPointer, + 103 => CXType_LValueReference, + 104 => CXType_RValueReference, + 105 => CXType_Record, + 106 => CXType_Enum, + 107 => CXType_Typedef, + 108 => CXType_ObjCInterface, + 109 => CXType_ObjCObjectPointer, + 110 => CXType_FunctionNoProto, + 111 => CXType_FunctionProto, + 112 => CXType_ConstantArray, + 113 => CXType_Vector, + 114 => CXType_IncompleteArray, + 115 => CXType_VariableArray, + 116 => CXType_DependentSizedArray, + 117 => CXType_MemberPointer, + 118 => CXType_Auto, + 119 => CXType_Elaborated, + 120 => CXType_Pipe, + 121 => CXType_OCLImage1dRO, + 122 => CXType_OCLImage1dArrayRO, + 123 => CXType_OCLImage1dBufferRO, + 124 => CXType_OCLImage2dRO, + 125 => CXType_OCLImage2dArrayRO, + 126 => CXType_OCLImage2dDepthRO, + 127 => CXType_OCLImage2dArrayDepthRO, + 128 => CXType_OCLImage2dMSAARO, + 129 => CXType_OCLImage2dArrayMSAARO, + 130 => CXType_OCLImage2dMSAADepthRO, + 131 => CXType_OCLImage2dArrayMSAADepthRO, + 132 => CXType_OCLImage3dRO, + 133 => CXType_OCLImage1dWO, + 134 => CXType_OCLImage1dArrayWO, + 135 => CXType_OCLImage1dBufferWO, + 136 => CXType_OCLImage2dWO, + 137 => CXType_OCLImage2dArrayWO, + 138 => CXType_OCLImage2dDepthWO, + 139 => CXType_OCLImage2dArrayDepthWO, + 140 => CXType_OCLImage2dMSAAWO, + 141 => CXType_OCLImage2dArrayMSAAWO, + 142 => CXType_OCLImage2dMSAADepthWO, + 143 => CXType_OCLImage2dArrayMSAADepthWO, + 144 => CXType_OCLImage3dWO, + 145 => CXType_OCLImage1dRW, + 146 => CXType_OCLImage1dArrayRW, + 147 => CXType_OCLImage1dBufferRW, + 148 => CXType_OCLImage2dRW, + 149 => CXType_OCLImage2dArrayRW, + 150 => CXType_OCLImage2dDepthRW, + 151 => CXType_OCLImage2dArrayDepthRW, + 152 => CXType_OCLImage2dMSAARW, + 153 => CXType_OCLImage2dArrayMSAARW, + 154 => CXType_OCLImage2dMSAADepthRW, + 155 => CXType_OCLImage2dArrayMSAADepthRW, + 156 => CXType_OCLImage3dRW, + 157 => CXType_OCLSampler, + 158 => CXType_OCLEvent, + 159 => CXType_OCLQueue, + 160 => CXType_OCLReserveID, + 161 => CXType_ObjCObject, + 162 => CXType_ObjCTypeParam, + 163 => CXType_Attributed, + 164 => CXType_OCLIntelSubgroupAVCMcePayload, + 165 => CXType_OCLIntelSubgroupAVCImePayload, + 166 => CXType_OCLIntelSubgroupAVCRefPayload, + 167 => CXType_OCLIntelSubgroupAVCSicPayload, + 168 => CXType_OCLIntelSubgroupAVCMceResult, + 169 => CXType_OCLIntelSubgroupAVCImeResult, + 170 => CXType_OCLIntelSubgroupAVCRefResult, + 171 => CXType_OCLIntelSubgroupAVCSicResult, + 172 => CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout, + 173 => CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout, + 174 => CXType_OCLIntelSubgroupAVCImeSingleRefStreamin, + 175 => CXType_OCLIntelSubgroupAVCImeDualRefStreamin, + 176 => CXType_ExtVector, + _ => throw ArgumentError('Unknown value for CXTypeKind: $value'), }; -} - -final class CXIdxDeclInfo extends ffi.Struct { - external ffi.Pointer entityInfo; - - external CXCursor cursor; - - external CXIdxLoc loc; - - external ffi.Pointer semanticContainer; - - /// Generally same as #semanticContainer but can be different in cases like - /// out-of-line C++ member functions. - external ffi.Pointer lexicalContainer; - - @ffi.Int() - external int isRedeclaration; - @ffi.Int() - external int isDefinition; - - @ffi.Int() - external int isContainer; + @override + String toString() { + if (this == CXType_Void) + return "CXTypeKind.CXType_Void, CXTypeKind.CXType_FirstBuiltin"; + if (this == CXType_ULongAccum) + return "CXTypeKind.CXType_ULongAccum, CXTypeKind.CXType_LastBuiltin"; + return super.toString(); + } +} - external ffi.Pointer declAsContainer; +/// List the possible error codes for clang_Type_getSizeOf, +/// clang_Type_getAlignOf, clang_Type_getOffsetOf and clang_Cursor_getOffsetOf. +enum CXTypeLayoutError { + /// Type is of kind CXType_Invalid. + CXTypeLayoutError_Invalid(-1), - /// Whether the declaration exists in code or was created implicitly by the - /// compiler, e.g. implicit Objective-C methods for properties. - @ffi.Int() - external int isImplicit; + /// The type is an incomplete Type. + CXTypeLayoutError_Incomplete(-2), - external ffi.Pointer> attributes; + /// The type is a dependent Type. + CXTypeLayoutError_Dependent(-3), - @ffi.UnsignedInt() - external int numAttributes; + /// The type is not a constant size type. + CXTypeLayoutError_NotConstantSize(-4), - @ffi.UnsignedInt() - external int flags; -} + /// The Field name is not valid for this record. + CXTypeLayoutError_InvalidFieldName(-5), -enum CXIdxObjCContainerKind { - CXIdxObjCContainer_ForwardRef(0), - CXIdxObjCContainer_Interface(1), - CXIdxObjCContainer_Implementation(2); + /// The type is undeduced. + CXTypeLayoutError_Undeduced(-6); final int value; - const CXIdxObjCContainerKind(this.value); + const CXTypeLayoutError(this.value); - static CXIdxObjCContainerKind fromValue(int value) => switch (value) { - 0 => CXIdxObjCContainer_ForwardRef, - 1 => CXIdxObjCContainer_Interface, - 2 => CXIdxObjCContainer_Implementation, - _ => throw ArgumentError( - 'Unknown value for CXIdxObjCContainerKind: $value', - ), + static CXTypeLayoutError fromValue(int value) => switch (value) { + -1 => CXTypeLayoutError_Invalid, + -2 => CXTypeLayoutError_Incomplete, + -3 => CXTypeLayoutError_Dependent, + -4 => CXTypeLayoutError_NotConstantSize, + -5 => CXTypeLayoutError_InvalidFieldName, + -6 => CXTypeLayoutError_Undeduced, + _ => throw ArgumentError('Unknown value for CXTypeLayoutError: $value'), }; } -final class CXIdxObjCContainerDeclInfo extends ffi.Struct { - external ffi.Pointer declInfo; - - @ffi.UnsignedInt() - external int kindAsInt; - - CXIdxObjCContainerKind get kind => - CXIdxObjCContainerKind.fromValue(kindAsInt); - set kind(CXIdxObjCContainerKind value) => kindAsInt = value.value; -} - -final class CXIdxBaseClassInfo extends ffi.Struct { - external ffi.Pointer base; - - external CXCursor cursor; - - external CXIdxLoc loc; -} - -final class CXIdxObjCProtocolRefInfo extends ffi.Struct { - external ffi.Pointer protocol; - - external CXCursor cursor; - - external CXIdxLoc loc; -} +enum CXTypeNullabilityKind { + /// Values of this type can never be null. + CXTypeNullability_NonNull(0), -final class CXIdxObjCProtocolRefListInfo extends ffi.Struct { - external ffi.Pointer> protocols; + /// Values of this type can be null. + CXTypeNullability_Nullable(1), - @ffi.UnsignedInt() - external int numProtocols; -} + /// Whether values of this type can be null is (explicitly) unspecified. This + /// captures a (fairly rare) case where we can't conclude anything about the + /// nullability of the type even though it has been considered. + CXTypeNullability_Unspecified(2), -final class CXIdxObjCInterfaceDeclInfo extends ffi.Struct { - external ffi.Pointer containerInfo; + /// Nullability is not applicable to this type. + CXTypeNullability_Invalid(3); - external ffi.Pointer superInfo; + final int value; + const CXTypeNullabilityKind(this.value); - external ffi.Pointer protocols; + static CXTypeNullabilityKind fromValue(int value) => switch (value) { + 0 => CXTypeNullability_NonNull, + 1 => CXTypeNullability_Nullable, + 2 => CXTypeNullability_Unspecified, + 3 => CXTypeNullability_Invalid, + _ => throw ArgumentError('Unknown value for CXTypeNullabilityKind: $value'), + }; } -final class CXIdxObjCCategoryDeclInfo extends ffi.Struct { - external ffi.Pointer containerInfo; - - external ffi.Pointer objcClass; +/// Provides the contents of a file that has not yet been saved to disk. +final class CXUnsavedFile extends ffi.Struct { + /// The file whose contents have not yet been saved. + external ffi.Pointer Filename; - external CXCursor classCursor; + /// A buffer containing the unsaved contents of this file. + external ffi.Pointer Contents; - external CXIdxLoc classLoc; + /// The length of the unsaved contents of this buffer. + @ffi.UnsignedLong() + external int Length; - external ffi.Pointer protocols; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer Filename, + required ffi.Pointer Contents, + required int Length, + }) => $allocator() + ..ref.Filename = Filename + ..ref.Contents = Contents + ..ref.Length = Length; } -final class CXIdxObjCPropertyDeclInfo extends ffi.Struct { - external ffi.Pointer declInfo; +/// Describes a version number of the form major.minor.subminor. +final class CXVersion extends ffi.Struct { + /// The major version number, e.g., the '10' in '10.7.3'. A negative value + /// indicates that there is no version number at all. + @ffi.Int() + external int Major; - external ffi.Pointer getter; + /// The minor version number, e.g., the '7' in '10.7.3'. This value will be + /// negative if no minor version number was provided, e.g., for version '10'. + @ffi.Int() + external int Minor; - external ffi.Pointer setter; + /// The subminor version number, e.g., the '3' in '10.7.3'. This value will be + /// negative if no minor or subminor version number was provided, e.g., in + /// version '10' or '10.7'. + @ffi.Int() + external int Subminor; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int Major, + required int Minor, + required int Subminor, + }) => $allocator() + ..ref.Major = Major + ..ref.Minor = Minor + ..ref.Subminor = Subminor; } -final class CXIdxCXXClassDeclInfo extends ffi.Struct { - external ffi.Pointer declInfo; +/// Object encapsulating information about overlaying virtual file/directories +/// over the real file system. +typedef CXVirtualFileOverlay = ffi.Pointer; - external ffi.Pointer> bases; +final class CXVirtualFileOverlayImpl extends ffi.Opaque {} - @ffi.UnsignedInt() - external int numBases; -} +enum CXVisibilityKind { + /// This value indicates that no visibility information is available for a + /// provided CXCursor. + CXVisibility_Invalid(0), -/// Data for IndexerCallbacks#indexEntityReference. -enum CXIdxEntityRefKind { - /// The entity is referenced directly in user's code. - CXIdxEntityRef_Direct(1), + /// Symbol not seen by the linker. + CXVisibility_Hidden(1), - /// An implicit reference, e.g. a reference of an Objective-C method via the - /// dot syntax. - CXIdxEntityRef_Implicit(2); + /// Symbol seen by the linker but resolves to a symbol inside this object. + CXVisibility_Protected(2), + + /// Symbol seen by the linker and acts like a normal symbol. + CXVisibility_Default(3); final int value; - const CXIdxEntityRefKind(this.value); + const CXVisibilityKind(this.value); - static CXIdxEntityRefKind fromValue(int value) => switch (value) { - 1 => CXIdxEntityRef_Direct, - 2 => CXIdxEntityRef_Implicit, - _ => throw ArgumentError('Unknown value for CXIdxEntityRefKind: $value'), + static CXVisibilityKind fromValue(int value) => switch (value) { + 0 => CXVisibility_Invalid, + 1 => CXVisibility_Hidden, + 2 => CXVisibility_Protected, + 3 => CXVisibility_Default, + _ => throw ArgumentError('Unknown value for CXVisibilityKind: $value'), }; } -/// Roles that are attributed to symbol occurrences. -enum CXSymbolRole { - CXSymbolRole_None(0), - CXSymbolRole_Declaration(1), - CXSymbolRole_Definition(2), - CXSymbolRole_Reference(4), - CXSymbolRole_Read(8), - CXSymbolRole_Write(16), - CXSymbolRole_Call(32), - CXSymbolRole_Dynamic(64), - CXSymbolRole_AddressOf(128), - CXSymbolRole_Implicit(256); +/// @{ +enum CXVisitorResult { + CXVisit_Break(0), + CXVisit_Continue(1); final int value; - const CXSymbolRole(this.value); + const CXVisitorResult(this.value); - static CXSymbolRole fromValue(int value) => switch (value) { - 0 => CXSymbolRole_None, - 1 => CXSymbolRole_Declaration, - 2 => CXSymbolRole_Definition, - 4 => CXSymbolRole_Reference, - 8 => CXSymbolRole_Read, - 16 => CXSymbolRole_Write, - 32 => CXSymbolRole_Call, - 64 => CXSymbolRole_Dynamic, - 128 => CXSymbolRole_AddressOf, - 256 => CXSymbolRole_Implicit, - _ => throw ArgumentError('Unknown value for CXSymbolRole: $value'), + static CXVisitorResult fromValue(int value) => switch (value) { + 0 => CXVisit_Break, + 1 => CXVisit_Continue, + _ => throw ArgumentError('Unknown value for CXVisitorResult: $value'), }; } -/// Data for IndexerCallbacks#indexEntityReference. -final class CXIdxEntityRefInfo extends ffi.Struct { - @ffi.UnsignedInt() - external int kindAsInt; - - CXIdxEntityRefKind get kind => CXIdxEntityRefKind.fromValue(kindAsInt); - set kind(CXIdxEntityRefKind value) => kindAsInt = value.value; - - /// Reference cursor. - external CXCursor cursor; - - external CXIdxLoc loc; +/// Represents the C++ access control level to a base class for a cursor with +/// kind CX_CXXBaseSpecifier. +enum CX_CXXAccessSpecifier { + CX_CXXInvalidAccessSpecifier(0), + CX_CXXPublic(1), + CX_CXXProtected(2), + CX_CXXPrivate(3); - /// The entity that gets referenced. - external ffi.Pointer referencedEntity; + final int value; + const CX_CXXAccessSpecifier(this.value); - /// Immediate "parent" of the reference. For example: - external ffi.Pointer parentEntity; + static CX_CXXAccessSpecifier fromValue(int value) => switch (value) { + 0 => CX_CXXInvalidAccessSpecifier, + 1 => CX_CXXPublic, + 2 => CX_CXXProtected, + 3 => CX_CXXPrivate, + _ => throw ArgumentError('Unknown value for CX_CXXAccessSpecifier: $value'), + }; +} - /// Lexical container context of the reference. - external ffi.Pointer container; +/// Represents the storage classes as declared in the source. CX_SC_Invalid was +/// added for the case that the passed cursor in not a declaration. +enum CX_StorageClass { + CX_SC_Invalid(0), + CX_SC_None(1), + CX_SC_Extern(2), + CX_SC_Static(3), + CX_SC_PrivateExtern(4), + CX_SC_OpenCLWorkGroupLocal(5), + CX_SC_Auto(6), + CX_SC_Register(7); - /// Sets of symbol roles of the reference. - @ffi.UnsignedInt() - external int roleAsInt; + final int value; + const CX_StorageClass(this.value); - CXSymbolRole get role => CXSymbolRole.fromValue(roleAsInt); - set role(CXSymbolRole value) => roleAsInt = value.value; + static CX_StorageClass fromValue(int value) => switch (value) { + 0 => CX_SC_Invalid, + 1 => CX_SC_None, + 2 => CX_SC_Extern, + 3 => CX_SC_Static, + 4 => CX_SC_PrivateExtern, + 5 => CX_SC_OpenCLWorkGroupLocal, + 6 => CX_SC_Auto, + 7 => CX_SC_Register, + _ => throw ArgumentError('Unknown value for CX_StorageClass: $value'), + }; } /// A group of callbacks used by #clang_indexSourceFile and @@ -8852,64 +9046,80 @@ final class IndexerCallbacks extends ffi.Struct { > > indexEntityReference; -} - -/// An indexing action/session, to be applied to one or multiple translation -/// units. -typedef CXIndexAction = ffi.Pointer; - -enum CXIndexOptFlags { - /// Used to indicate that no special indexing options are needed. - CXIndexOpt_None(0), - - /// Used to indicate that IndexerCallbacks#indexEntityReference should be - /// invoked for only one reference of an entity per source file that does not - /// also include a declaration/definition of the entity. - CXIndexOpt_SuppressRedundantRefs(1), - - /// Function-local symbols should be indexed. If this is not set - /// function-local symbols will be ignored. - CXIndexOpt_IndexFunctionLocalSymbols(2), - - /// Implicit function/class template instantiations should be indexed. If this - /// is not set, implicit instantiations will be ignored. - CXIndexOpt_IndexImplicitTemplateInstantiations(4), - - /// Suppress all compiler warnings when parsing for indexing. - CXIndexOpt_SuppressWarnings(8), - - /// Skip a function/method body that was already parsed during an indexing - /// session associated with a CXIndexAction object. Bodies in system headers - /// are always skipped. - CXIndexOpt_SkipParsedBodiesInSession(16); - final int value; - const CXIndexOptFlags(this.value); - - static CXIndexOptFlags fromValue(int value) => switch (value) { - 0 => CXIndexOpt_None, - 1 => CXIndexOpt_SuppressRedundantRefs, - 2 => CXIndexOpt_IndexFunctionLocalSymbols, - 4 => CXIndexOpt_IndexImplicitTemplateInstantiations, - 8 => CXIndexOpt_SuppressWarnings, - 16 => CXIndexOpt_SkipParsedBodiesInSession, - _ => throw ArgumentError('Unknown value for CXIndexOptFlags: $value'), - }; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + CXClientData client_data, + ffi.Pointer reserved, + ) + > + > + abortQuery, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(CXClientData, CXDiagnosticSet, ffi.Pointer) + > + > + diagnostic, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientFile Function( + CXClientData client_data, + CXFile mainFile, + ffi.Pointer reserved, + ) + > + > + enteredMainFile, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientFile Function( + CXClientData, + ffi.Pointer, + ) + > + > + ppIncludedFile, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientASTFile Function( + CXClientData, + ffi.Pointer, + ) + > + > + importedASTFile, + required ffi.Pointer< + ffi.NativeFunction< + CXIdxClientContainer Function( + CXClientData client_data, + ffi.Pointer reserved, + ) + > + > + startedTranslationUnit, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(CXClientData, ffi.Pointer) + > + > + indexDeclaration, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(CXClientData, ffi.Pointer) + > + > + indexEntityReference, + }) => $allocator() + ..ref.abortQuery = abortQuery + ..ref.diagnostic = diagnostic + ..ref.enteredMainFile = enteredMainFile + ..ref.ppIncludedFile = ppIncludedFile + ..ref.importedASTFile = importedASTFile + ..ref.startedTranslationUnit = startedTranslationUnit + ..ref.indexDeclaration = indexDeclaration + ..ref.indexEntityReference = indexEntityReference; } - -typedef CXFieldVisitorFunction = - ffi.UnsignedInt Function(CXCursor C, CXClientData client_data); -typedef DartCXFieldVisitorFunction = - CXVisitorResult Function(CXCursor C, CXClientData client_data); - -/// Visitor invoked for each field found by a traversal. -typedef CXFieldVisitor = - ffi.Pointer>; - -const int CINDEX_VERSION_MAJOR = 0; - -const int CINDEX_VERSION_MINOR = 59; - -const int CINDEX_VERSION = 59; - -const String CINDEX_VERSION_STRING = '0.59'; diff --git a/pkgs/ffigen/test/large_integration_tests/_expected_sqlite_bindings.dart b/pkgs/ffigen/test/large_integration_tests/_expected_sqlite_bindings.dart index d277571c91..95c91a0821 100644 --- a/pkgs/ffigen/test/large_integration_tests/_expected_sqlite_bindings.dart +++ b/pkgs/ffigen/test/large_integration_tests/_expected_sqlite_bindings.dart @@ -18,4020 +18,3629 @@ class SQLite { ffi.Pointer Function(String symbolName) lookup, ) : _lookup = lookup; - /// CAPI3REF: Run-Time Library Version Numbers - /// KEYWORDS: sqlite3_version sqlite3_sourceid + /// CAPI3REF: Obtain Aggregate Function Context + /// METHOD: sqlite3_context /// - /// These interfaces provide the same information as the [SQLITE_VERSION], - /// [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros - /// but are associated with the library instead of the header file. ^(Cautious - /// programmers might include assert() statements in their application to - /// verify that values returned by these interfaces match the macros in - /// the header, and thus ensure that the application is - /// compiled with matching library and header files. + /// Implementations of aggregate SQL functions use this + /// routine to allocate memory for storing their state. /// - ///
-  /// assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
-  /// assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
-  /// assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
-  /// 
)^ + /// ^The first time the sqlite3_aggregate_context(C,N) routine is called + /// for a particular aggregate function, SQLite allocates + /// N bytes of memory, zeroes out that memory, and returns a pointer + /// to the new memory. ^On second and subsequent calls to + /// sqlite3_aggregate_context() for the same aggregate function instance, + /// the same buffer is returned. Sqlite3_aggregate_context() is normally + /// called once for each invocation of the xStep callback and then one + /// last time when the xFinal callback is invoked. ^(When no rows match + /// an aggregate query, the xStep() callback of the aggregate function + /// implementation is never called and xFinal() is called exactly once. + /// In those cases, sqlite3_aggregate_context() might be called for the + /// first time from within xFinal().)^ /// - /// ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] - /// macro. ^The sqlite3_libversion() function returns a pointer to the - /// to the sqlite3_version[] string constant. The sqlite3_libversion() - /// function is provided for use in DLLs since DLL users usually do not have - /// direct access to string constants within the DLL. ^The - /// sqlite3_libversion_number() function returns an integer equal to - /// [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns - /// a pointer to a string constant whose value is the same as the - /// [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built - /// using an edited copy of [the amalgamation], then the last four characters - /// of the hash might be different from [SQLITE_SOURCE_ID].)^ + /// ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer + /// when first called if N is less than or equal to zero or if a memory + /// allocate error occurs. /// - /// See also: [sqlite_version()] and [sqlite_source_id()]. - late final ffi.Pointer> _sqlite3_version = - _lookup>('sqlite3_version'); - - ffi.Pointer get sqlite3_version => _sqlite3_version.value; - - set sqlite3_version(ffi.Pointer value) => - _sqlite3_version.value = value; - - ffi.Pointer sqlite3_libversion() { - return _sqlite3_libversion(); - } - - late final _sqlite3_libversionPtr = - _lookup Function()>>( - 'sqlite3_libversion', - ); - late final _sqlite3_libversion = _sqlite3_libversionPtr - .asFunction Function()>(); - - ffi.Pointer sqlite3_sourceid() { - return _sqlite3_sourceid(); + /// ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is + /// determined by the N parameter on first successful call. Changing the + /// value of N in any subsequent call to sqlite3_aggregate_context() within + /// the same aggregate function instance will not resize the memory + /// allocation.)^ Within the xFinal callback, it is customary to set + /// N=0 in calls to sqlite3_aggregate_context(C,N) so that no + /// pointless memory allocations occur. + /// + /// ^SQLite automatically frees the memory allocated by + /// sqlite3_aggregate_context() when the aggregate query concludes. + /// + /// The first parameter must be a copy of the + /// [sqlite3_context | SQL function context] that is the first parameter + /// to the xStep or xFinal callback routine that implements the aggregate + /// function. + /// + /// This routine must be called from the same thread in which + /// the aggregate SQL function is running. + ffi.Pointer sqlite3_aggregate_context( + ffi.Pointer arg0, + int nBytes, + ) { + return _sqlite3_aggregate_context(arg0, nBytes); } - late final _sqlite3_sourceidPtr = - _lookup Function()>>( - 'sqlite3_sourceid', - ); - late final _sqlite3_sourceid = _sqlite3_sourceidPtr - .asFunction Function()>(); + late final _sqlite3_aggregate_contextPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_aggregate_context'); + late final _sqlite3_aggregate_context = _sqlite3_aggregate_contextPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - int sqlite3_libversion_number() { - return _sqlite3_libversion_number(); + int sqlite3_aggregate_count(ffi.Pointer arg0) { + return _sqlite3_aggregate_count(arg0); } - late final _sqlite3_libversion_numberPtr = - _lookup>( - 'sqlite3_libversion_number', - ); - late final _sqlite3_libversion_number = _sqlite3_libversion_numberPtr - .asFunction(); + late final _sqlite3_aggregate_countPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_aggregate_count'); + late final _sqlite3_aggregate_count = _sqlite3_aggregate_countPtr + .asFunction)>(); - int sqlite3_compileoption_used(ffi.Pointer zOptName) { - return _sqlite3_compileoption_used(zOptName); + /// CAPI3REF: Automatically Load Statically Linked Extensions + /// + /// ^This interface causes the xEntryPoint() function to be invoked for + /// each new [database connection] that is created. The idea here is that + /// xEntryPoint() is the entry point for a statically linked [SQLite extension] + /// that is to be automatically loaded into all new database connections. + /// + /// ^(Even though the function prototype shows that xEntryPoint() takes + /// no arguments and returns void, SQLite invokes xEntryPoint() with three + /// arguments and expects an integer result as if the signature of the + /// entry point where as follows: + /// + ///
+  ///    int xEntryPoint(
+  ///      sqlite3 *db,
+  ///      const char **pzErrMsg,
+  ///      const struct sqlite3_api_routines *pThunk
+  ///    );
+  /// 
)^ + /// + /// If the xEntryPoint routine encounters an error, it should make *pzErrMsg + /// point to an appropriate error message (obtained from [sqlite3_mprintf()]) + /// and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg + /// is NULL before calling the xEntryPoint(). ^SQLite will invoke + /// [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any + /// xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], + /// or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. + /// + /// ^Calling sqlite3_auto_extension(X) with an entry point X that is already + /// on the list of automatic extensions is a harmless no-op. ^No entry point + /// will be called more than once for each database connection that is opened. + /// + /// See also: [sqlite3_reset_auto_extension()] + /// and [sqlite3_cancel_auto_extension()] + int sqlite3_auto_extension( + ffi.Pointer> xEntryPoint, + ) { + return _sqlite3_auto_extension(xEntryPoint); } - late final _sqlite3_compileoption_usedPtr = - _lookup)>>( - 'sqlite3_compileoption_used', - ); - late final _sqlite3_compileoption_used = _sqlite3_compileoption_usedPtr - .asFunction)>(); + late final _sqlite3_auto_extensionPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer>) + > + >('sqlite3_auto_extension'); + late final _sqlite3_auto_extension = _sqlite3_auto_extensionPtr + .asFunction< + int Function(ffi.Pointer>) + >(); - ffi.Pointer sqlite3_compileoption_get(int N) { - return _sqlite3_compileoption_get(N); + int sqlite3_backup_finish(ffi.Pointer p) { + return _sqlite3_backup_finish(p); } - late final _sqlite3_compileoption_getPtr = - _lookup Function(ffi.Int)>>( - 'sqlite3_compileoption_get', - ); - late final _sqlite3_compileoption_get = _sqlite3_compileoption_getPtr - .asFunction Function(int)>(); + late final _sqlite3_backup_finishPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_backup_finish'); + late final _sqlite3_backup_finish = _sqlite3_backup_finishPtr + .asFunction)>(); - /// CAPI3REF: Test To See If The Library Is Threadsafe + /// CAPI3REF: Online Backup API. /// - /// ^The sqlite3_threadsafe() function returns zero if and only if - /// SQLite was compiled with mutexing code omitted due to the - /// [SQLITE_THREADSAFE] compile-time option being set to 0. + /// The backup API copies the content of one database into another. + /// It is useful either for creating backups of databases or + /// for copying in-memory databases to or from persistent files. /// - /// SQLite can be compiled with or without mutexes. When - /// the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes - /// are enabled and SQLite is threadsafe. When the - /// [SQLITE_THREADSAFE] macro is 0, - /// the mutexes are omitted. Without the mutexes, it is not safe - /// to use SQLite concurrently from more than one thread. + /// See Also: [Using the SQLite Online Backup API] /// - /// Enabling mutexes incurs a measurable performance penalty. - /// So if speed is of utmost importance, it makes sense to disable - /// the mutexes. But for maximum safety, mutexes should be enabled. - /// ^The default behavior is for mutexes to be enabled. + /// ^SQLite holds a write transaction open on the destination database file + /// for the duration of the backup operation. + /// ^The source database is read-locked only while it is being read; + /// it is not locked continuously for the entire backup operation. + /// ^Thus, the backup may be performed on a live source database without + /// preventing other database connections from + /// reading or writing to the source database while the backup is underway. /// - /// This interface can be used by an application to make sure that the - /// version of SQLite that it is linking against was compiled with - /// the desired setting of the [SQLITE_THREADSAFE] macro. + /// ^(To perform a backup operation: + ///
    + ///
  1. sqlite3_backup_init() is called once to initialize the + /// backup, + ///
  2. sqlite3_backup_step() is called one or more times to transfer + /// the data between the two databases, and finally + ///
  3. sqlite3_backup_finish() is called to release all resources + /// associated with the backup operation. + ///
)^ + /// There should be exactly one call to sqlite3_backup_finish() for each + /// successful call to sqlite3_backup_init(). /// - /// This interface only reports on the compile-time mutex setting - /// of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with - /// SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but - /// can be fully or partially disabled using a call to [sqlite3_config()] - /// with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], - /// or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the - /// sqlite3_threadsafe() function shows only the compile-time setting of - /// thread safety, not any run-time changes to that setting made by - /// sqlite3_config(). In other words, the return value from sqlite3_threadsafe() - /// is unchanged by calls to sqlite3_config().)^ + /// [[sqlite3_backup_init()]] sqlite3_backup_init() /// - /// See the [threading mode] documentation for additional information. - int sqlite3_threadsafe() { - return _sqlite3_threadsafe(); - } - - late final _sqlite3_threadsafePtr = - _lookup>('sqlite3_threadsafe'); - late final _sqlite3_threadsafe = _sqlite3_threadsafePtr - .asFunction(); - - /// CAPI3REF: Closing A Database Connection - /// DESTRUCTOR: sqlite3 + /// ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the + /// [database connection] associated with the destination database + /// and the database name, respectively. + /// ^The database name is "main" for the main database, "temp" for the + /// temporary database, or the name specified after the AS keyword in + /// an [ATTACH] statement for an attached database. + /// ^The S and M arguments passed to + /// sqlite3_backup_init(D,N,S,M) identify the [database connection] + /// and database name of the source database, respectively. + /// ^The source and destination [database connections] (parameters S and D) + /// must be different or else sqlite3_backup_init(D,N,S,M) will fail with + /// an error. /// - /// ^The sqlite3_close() and sqlite3_close_v2() routines are destructors - /// for the [sqlite3] object. - /// ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if - /// the [sqlite3] object is successfully destroyed and all associated - /// resources are deallocated. + /// ^A call to sqlite3_backup_init() will fail, returning NULL, if + /// there is already a read or read-write transaction open on the + /// destination database. /// - /// Ideally, applications should [sqlite3_finalize | finalize] all - /// [prepared statements], [sqlite3_blob_close | close] all [BLOB handles], and - /// [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated - /// with the [sqlite3] object prior to attempting to close the object. - /// ^If the database connection is associated with unfinalized prepared - /// statements, BLOB handlers, and/or unfinished sqlite3_backup objects then - /// sqlite3_close() will leave the database connection open and return - /// [SQLITE_BUSY]. ^If sqlite3_close_v2() is called with unfinalized prepared - /// statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups, - /// it returns [SQLITE_OK] regardless, but instead of deallocating the database - /// connection immediately, it marks the database connection as an unusable - /// "zombie" and makes arrangements to automatically deallocate the database - /// connection after all prepared statements are finalized, all BLOB handles - /// are closed, and all backups have finished. The sqlite3_close_v2() interface - /// is intended for use with host languages that are garbage collected, and - /// where the order in which destructors are called is arbitrary. + /// ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is + /// returned and an error code and error message are stored in the + /// destination [database connection] D. + /// ^The error code and message for the failed call to sqlite3_backup_init() + /// can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or + /// [sqlite3_errmsg16()] functions. + /// ^A successful call to sqlite3_backup_init() returns a pointer to an + /// [sqlite3_backup] object. + /// ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and + /// sqlite3_backup_finish() functions to perform the specified backup + /// operation. /// - /// ^If an [sqlite3] object is destroyed while a transaction is open, - /// the transaction is automatically rolled back. + /// [[sqlite3_backup_step()]] sqlite3_backup_step() /// - /// The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] - /// must be either a NULL - /// pointer or an [sqlite3] object pointer obtained - /// from [sqlite3_open()], [sqlite3_open16()], or - /// [sqlite3_open_v2()], and not previously closed. - /// ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer - /// argument is a harmless no-op. - int sqlite3_close(ffi.Pointer arg0) { - return _sqlite3_close(arg0); - } - - late final _sqlite3_closePtr = - _lookup)>>( - 'sqlite3_close', - ); - late final _sqlite3_close = _sqlite3_closePtr - .asFunction)>(); - - int sqlite3_close_v2(ffi.Pointer arg0) { - return _sqlite3_close_v2(arg0); - } - - late final _sqlite3_close_v2Ptr = - _lookup)>>( - 'sqlite3_close_v2', - ); - late final _sqlite3_close_v2 = _sqlite3_close_v2Ptr - .asFunction)>(); - - /// CAPI3REF: One-Step Query Execution Interface - /// METHOD: sqlite3 + /// ^Function sqlite3_backup_step(B,N) will copy up to N pages between + /// the source and destination databases specified by [sqlite3_backup] object B. + /// ^If N is negative, all remaining source pages are copied. + /// ^If sqlite3_backup_step(B,N) successfully copies N pages and there + /// are still more pages to be copied, then the function returns [SQLITE_OK]. + /// ^If sqlite3_backup_step(B,N) successfully finishes copying all pages + /// from source to destination, then it returns [SQLITE_DONE]. + /// ^If an error occurs while running sqlite3_backup_step(B,N), + /// then an [error code] is returned. ^As well as [SQLITE_OK] and + /// [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], + /// [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an + /// [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. /// - /// The sqlite3_exec() interface is a convenience wrapper around - /// [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], - /// that allows an application to run multiple statements of SQL - /// without having to use a lot of C code. + /// ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if + ///
    + ///
  1. the destination database was opened read-only, or + ///
  2. the destination database is using write-ahead-log journaling + /// and the destination and source page sizes differ, or + ///
  3. the destination database is an in-memory database and the + /// destination and source page sizes differ. + ///
)^ /// - /// ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, - /// semicolon-separate SQL statements passed into its 2nd argument, - /// in the context of the [database connection] passed in as its 1st - /// argument. ^If the callback function of the 3rd argument to - /// sqlite3_exec() is not NULL, then it is invoked for each result row - /// coming out of the evaluated SQL statements. ^The 4th argument to - /// sqlite3_exec() is relayed through to the 1st argument of each - /// callback invocation. ^If the callback pointer to sqlite3_exec() - /// is NULL, then no callback is ever invoked and result rows are - /// ignored. + /// ^If sqlite3_backup_step() cannot obtain a required file-system lock, then + /// the [sqlite3_busy_handler | busy-handler function] + /// is invoked (if one is specified). ^If the + /// busy-handler returns non-zero before the lock is available, then + /// [SQLITE_BUSY] is returned to the caller. ^In this case the call to + /// sqlite3_backup_step() can be retried later. ^If the source + /// [database connection] + /// is being used to write to the source database when sqlite3_backup_step() + /// is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this + /// case the call to sqlite3_backup_step() can be retried later on. ^(If + /// [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or + /// [SQLITE_READONLY] is returned, then + /// there is no point in retrying the call to sqlite3_backup_step(). These + /// errors are considered fatal.)^ The application must accept + /// that the backup operation has failed and pass the backup operation handle + /// to the sqlite3_backup_finish() to release associated resources. /// - /// ^If an error occurs while evaluating the SQL statements passed into - /// sqlite3_exec(), then execution of the current statement stops and - /// subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() - /// is not NULL then any error message is written into memory obtained - /// from [sqlite3_malloc()] and passed back through the 5th parameter. - /// To avoid memory leaks, the application should invoke [sqlite3_free()] - /// on error message strings returned through the 5th parameter of - /// sqlite3_exec() after the error message string is no longer needed. - /// ^If the 5th parameter to sqlite3_exec() is not NULL and no errors - /// occur, then sqlite3_exec() sets the pointer in its 5th parameter to - /// NULL before returning. + /// ^The first call to sqlite3_backup_step() obtains an exclusive lock + /// on the destination file. ^The exclusive lock is not released until either + /// sqlite3_backup_finish() is called or the backup operation is complete + /// and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to + /// sqlite3_backup_step() obtains a [shared lock] on the source database that + /// lasts for the duration of the sqlite3_backup_step() call. + /// ^Because the source database is not locked between calls to + /// sqlite3_backup_step(), the source database may be modified mid-way + /// through the backup process. ^If the source database is modified by an + /// external process or via a database connection other than the one being + /// used by the backup operation, then the backup will be automatically + /// restarted by the next call to sqlite3_backup_step(). ^If the source + /// database is modified by the using the same database connection as is used + /// by the backup operation, then the backup database is automatically + /// updated at the same time. /// - /// ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() - /// routine returns SQLITE_ABORT without invoking the callback again and - /// without running any subsequent SQL statements. + /// [[sqlite3_backup_finish()]] sqlite3_backup_finish() /// - /// ^The 2nd argument to the sqlite3_exec() callback function is the - /// number of columns in the result. ^The 3rd argument to the sqlite3_exec() - /// callback is an array of pointers to strings obtained as if from - /// [sqlite3_column_text()], one for each column. ^If an element of a - /// result row is NULL then the corresponding string pointer for the - /// sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the - /// sqlite3_exec() callback is an array of pointers to strings where each - /// entry represents the name of corresponding result column as obtained - /// from [sqlite3_column_name()]. + /// When sqlite3_backup_step() has returned [SQLITE_DONE], or when the + /// application wishes to abandon the backup operation, the application + /// should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). + /// ^The sqlite3_backup_finish() interfaces releases all + /// resources associated with the [sqlite3_backup] object. + /// ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any + /// active write-transaction on the destination database is rolled back. + /// The [sqlite3_backup] object is invalid + /// and may not be used following a call to sqlite3_backup_finish(). /// - /// ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer - /// to an empty string, or a pointer that contains only whitespace and/or - /// SQL comments, then no SQL statements are evaluated and the database - /// is not changed. + /// ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no + /// sqlite3_backup_step() errors occurred, regardless or whether or not + /// sqlite3_backup_step() completed. + /// ^If an out-of-memory condition or IO error occurred during any prior + /// sqlite3_backup_step() call on the same [sqlite3_backup] object, then + /// sqlite3_backup_finish() returns the corresponding [error code]. /// - /// Restrictions: + /// ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() + /// is not a permanent error and does not affect the return value of + /// sqlite3_backup_finish(). /// - ///
    - ///
  • The application must ensure that the 1st parameter to sqlite3_exec() - /// is a valid and open [database connection]. - ///
  • The application must not close the [database connection] specified by - /// the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. - ///
  • The application must not modify the SQL statement text passed into - /// the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. - ///
- int sqlite3_exec( - ffi.Pointer arg0, - ffi.Pointer sql, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) - > - > - callback, - ffi.Pointer arg3, - ffi.Pointer> errmsg, - ) { - return _sqlite3_exec(arg0, sql, callback, arg3, errmsg); - } - - late final _sqlite3_execPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) - > - >, - ffi.Pointer, - ffi.Pointer>, - ) - > - >('sqlite3_exec'); - late final _sqlite3_exec = _sqlite3_execPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) - > - >, - ffi.Pointer, - ffi.Pointer>, - ) - >(); - - /// CAPI3REF: Initialize The SQLite Library - /// - /// ^The sqlite3_initialize() routine initializes the - /// SQLite library. ^The sqlite3_shutdown() routine - /// deallocates any resources that were allocated by sqlite3_initialize(). - /// These routines are designed to aid in process initialization and - /// shutdown on embedded systems. Workstation applications using - /// SQLite normally do not need to invoke either of these routines. - /// - /// A call to sqlite3_initialize() is an "effective" call if it is - /// the first time sqlite3_initialize() is invoked during the lifetime of - /// the process, or if it is the first time sqlite3_initialize() is invoked - /// following a call to sqlite3_shutdown(). ^(Only an effective call - /// of sqlite3_initialize() does any initialization. All other calls - /// are harmless no-ops.)^ - /// - /// A call to sqlite3_shutdown() is an "effective" call if it is the first - /// call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only - /// an effective call to sqlite3_shutdown() does any deinitialization. - /// All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ + /// [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]] + /// sqlite3_backup_remaining() and sqlite3_backup_pagecount() /// - /// The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() - /// is not. The sqlite3_shutdown() interface must only be called from a - /// single thread. All open [database connections] must be closed and all - /// other SQLite resources must be deallocated prior to invoking - /// sqlite3_shutdown(). + /// ^The sqlite3_backup_remaining() routine returns the number of pages still + /// to be backed up at the conclusion of the most recent sqlite3_backup_step(). + /// ^The sqlite3_backup_pagecount() routine returns the total number of pages + /// in the source database at the conclusion of the most recent + /// sqlite3_backup_step(). + /// ^(The values returned by these functions are only updated by + /// sqlite3_backup_step(). If the source database is modified in a way that + /// changes the size of the source database or the number of pages remaining, + /// those changes are not reflected in the output of sqlite3_backup_pagecount() + /// and sqlite3_backup_remaining() until after the next + /// sqlite3_backup_step().)^ /// - /// Among other things, ^sqlite3_initialize() will invoke - /// sqlite3_os_init(). Similarly, ^sqlite3_shutdown() - /// will invoke sqlite3_os_end(). + /// Concurrent Usage of Database Handles /// - /// ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. - /// ^If for some reason, sqlite3_initialize() is unable to initialize - /// the library (perhaps it is unable to allocate a needed resource such - /// as a mutex) it returns an [error code] other than [SQLITE_OK]. + /// ^The source [database connection] may be used by the application for other + /// purposes while a backup operation is underway or being initialized. + /// ^If SQLite is compiled and configured to support threadsafe database + /// connections, then the source database connection may be used concurrently + /// from within other threads. /// - /// ^The sqlite3_initialize() routine is called internally by many other - /// SQLite interfaces so that an application usually does not need to - /// invoke sqlite3_initialize() directly. For example, [sqlite3_open()] - /// calls sqlite3_initialize() so the SQLite library will be automatically - /// initialized when [sqlite3_open()] is called if it has not be initialized - /// already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] - /// compile-time option, then the automatic calls to sqlite3_initialize() - /// are omitted and the application must call sqlite3_initialize() directly - /// prior to using any other SQLite interface. For maximum portability, - /// it is recommended that applications always invoke sqlite3_initialize() - /// directly prior to using any other SQLite interface. Future releases - /// of SQLite may require this. In other words, the behavior exhibited - /// when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the - /// default behavior in some future release of SQLite. + /// However, the application must guarantee that the destination + /// [database connection] is not passed to any other API (by any thread) after + /// sqlite3_backup_init() is called and before the corresponding call to + /// sqlite3_backup_finish(). SQLite does not currently check to see + /// if the application incorrectly accesses the destination [database connection] + /// and so no error code is reported, but the operations may malfunction + /// nevertheless. Use of the destination database connection while a + /// backup is in progress might also also cause a mutex deadlock. /// - /// The sqlite3_os_init() routine does operating-system specific - /// initialization of the SQLite library. The sqlite3_os_end() - /// routine undoes the effect of sqlite3_os_init(). Typical tasks - /// performed by these routines include allocation or deallocation - /// of static resources, initialization of global variables, - /// setting up a default [sqlite3_vfs] module, or setting up - /// a default configuration using [sqlite3_config()]. + /// If running in [shared cache mode], the application must + /// guarantee that the shared cache used by the destination database + /// is not accessed while the backup is running. In practice this means + /// that the application must guarantee that the disk file being + /// backed up to is not accessed by any connection within the process, + /// not just the specific connection that was passed to sqlite3_backup_init(). /// - /// The application should never invoke either sqlite3_os_init() - /// or sqlite3_os_end() directly. The application should only invoke - /// sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() - /// interface is called automatically by sqlite3_initialize() and - /// sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate - /// implementations for sqlite3_os_init() and sqlite3_os_end() - /// are built into SQLite when it is compiled for Unix, Windows, or OS/2. - /// When [custom builds | built for other platforms] - /// (using the [SQLITE_OS_OTHER=1] compile-time - /// option) the application must supply a suitable implementation for - /// sqlite3_os_init() and sqlite3_os_end(). An application-supplied - /// implementation of sqlite3_os_init() or sqlite3_os_end() - /// must return [SQLITE_OK] on success and some other [error code] upon - /// failure. - int sqlite3_initialize() { - return _sqlite3_initialize(); + /// The [sqlite3_backup] object itself is partially threadsafe. Multiple + /// threads may safely make multiple concurrent calls to sqlite3_backup_step(). + /// However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() + /// APIs are not strictly speaking threadsafe. If they are invoked at the + /// same time as another thread is invoking sqlite3_backup_step() it is + /// possible that they return invalid values. + ffi.Pointer sqlite3_backup_init( + ffi.Pointer pDest, + ffi.Pointer zDestName, + ffi.Pointer pSource, + ffi.Pointer zSourceName, + ) { + return _sqlite3_backup_init(pDest, zDestName, pSource, zSourceName); } - late final _sqlite3_initializePtr = - _lookup>('sqlite3_initialize'); - late final _sqlite3_initialize = _sqlite3_initializePtr - .asFunction(); + late final _sqlite3_backup_initPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >('sqlite3_backup_init'); + late final _sqlite3_backup_init = _sqlite3_backup_initPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); - int sqlite3_shutdown() { - return _sqlite3_shutdown(); + int sqlite3_backup_pagecount(ffi.Pointer p) { + return _sqlite3_backup_pagecount(p); } - late final _sqlite3_shutdownPtr = - _lookup>('sqlite3_shutdown'); - late final _sqlite3_shutdown = _sqlite3_shutdownPtr - .asFunction(); + late final _sqlite3_backup_pagecountPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_backup_pagecount'); + late final _sqlite3_backup_pagecount = _sqlite3_backup_pagecountPtr + .asFunction)>(); - int sqlite3_os_init() { - return _sqlite3_os_init(); + int sqlite3_backup_remaining(ffi.Pointer p) { + return _sqlite3_backup_remaining(p); } - late final _sqlite3_os_initPtr = - _lookup>('sqlite3_os_init'); - late final _sqlite3_os_init = _sqlite3_os_initPtr - .asFunction(); + late final _sqlite3_backup_remainingPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_backup_remaining'); + late final _sqlite3_backup_remaining = _sqlite3_backup_remainingPtr + .asFunction)>(); - int sqlite3_os_end() { - return _sqlite3_os_end(); + int sqlite3_backup_step(ffi.Pointer p, int nPage) { + return _sqlite3_backup_step(p, nPage); } - late final _sqlite3_os_endPtr = - _lookup>('sqlite3_os_end'); - late final _sqlite3_os_end = _sqlite3_os_endPtr.asFunction(); + late final _sqlite3_backup_stepPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_backup_step'); + late final _sqlite3_backup_step = _sqlite3_backup_stepPtr + .asFunction, int)>(); - /// CAPI3REF: Configuring The SQLite Library + /// CAPI3REF: Binding Values To Prepared Statements + /// KEYWORDS: {host parameter} {host parameters} {host parameter name} + /// KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} + /// METHOD: sqlite3_stmt /// - /// The sqlite3_config() interface is used to make global configuration - /// changes to SQLite in order to tune SQLite to the specific needs of - /// the application. The default configuration is recommended for most - /// applications and so this routine is usually not necessary. It is - /// provided to support rare applications with unusual needs. + /// ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, + /// literals may be replaced by a [parameter] that matches one of following + /// templates: /// - /// The sqlite3_config() interface is not threadsafe. The application - /// must ensure that no other SQLite interfaces are invoked by other - /// threads while sqlite3_config() is running. + ///
    + ///
  • ? + ///
  • ?NNN + ///
  • :VVV + ///
  • @VVV + ///
  • $VVV + ///
/// - /// The sqlite3_config() interface - /// may only be invoked prior to library initialization using - /// [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. - /// ^If sqlite3_config() is called after [sqlite3_initialize()] and before - /// [sqlite3_shutdown()] then it will return SQLITE_MISUSE. - /// Note, however, that ^sqlite3_config() can be called as part of the - /// implementation of an application-defined [sqlite3_os_init()]. + /// In the templates above, NNN represents an integer literal, + /// and VVV represents an alphanumeric identifier.)^ ^The values of these + /// parameters (also called "host parameter names" or "SQL parameters") + /// can be set using the sqlite3_bind_*() routines defined here. /// - /// The first argument to sqlite3_config() is an integer - /// [configuration option] that determines - /// what property of SQLite is to be configured. Subsequent arguments - /// vary depending on the [configuration option] - /// in the first argument. + /// ^The first argument to the sqlite3_bind_*() routines is always + /// a pointer to the [sqlite3_stmt] object returned from + /// [sqlite3_prepare_v2()] or its variants. /// - /// ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. - /// ^If the option is unknown or SQLite is unable to set the option - /// then this routine returns a non-zero [error code]. - int sqlite3_config(int arg0) { - return _sqlite3_config(arg0); - } - - late final _sqlite3_configPtr = - _lookup>('sqlite3_config'); - late final _sqlite3_config = _sqlite3_configPtr - .asFunction(); - - /// CAPI3REF: Configure database connections - /// METHOD: sqlite3 + /// ^The second argument is the index of the SQL parameter to be set. + /// ^The leftmost SQL parameter has an index of 1. ^When the same named + /// SQL parameter is used more than once, second and subsequent + /// occurrences have the same index as the first occurrence. + /// ^The index for named parameters can be looked up using the + /// [sqlite3_bind_parameter_index()] API if desired. ^The index + /// for "?NNN" parameters is the value of NNN. + /// ^The NNN value must be between 1 and the [sqlite3_limit()] + /// parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 32766). /// - /// The sqlite3_db_config() interface is used to make configuration - /// changes to a [database connection]. The interface is similar to - /// [sqlite3_config()] except that the changes apply to a single - /// [database connection] (specified in the first argument). - /// - /// The second argument to sqlite3_db_config(D,V,...) is the - /// [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code - /// that indicates what aspect of the [database connection] is being configured. - /// Subsequent arguments vary depending on the configuration verb. - /// - /// ^Calls to sqlite3_db_config() return SQLITE_OK if and only if - /// the call is considered successful. - int sqlite3_db_config(ffi.Pointer arg0, int op) { - return _sqlite3_db_config(arg0, op); - } - - late final _sqlite3_db_configPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_db_config'); - late final _sqlite3_db_config = _sqlite3_db_configPtr - .asFunction, int)>(); - - /// CAPI3REF: Enable Or Disable Extended Result Codes - /// METHOD: sqlite3 + /// ^The third argument is the value to bind to the parameter. + /// ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16() + /// or sqlite3_bind_blob() is a NULL pointer then the fourth parameter + /// is ignored and the end result is the same as sqlite3_bind_null(). + /// ^If the third parameter to sqlite3_bind_text() is not NULL, then + /// it should be a pointer to well-formed UTF8 text. + /// ^If the third parameter to sqlite3_bind_text16() is not NULL, then + /// it should be a pointer to well-formed UTF16 text. + /// ^If the third parameter to sqlite3_bind_text64() is not NULL, then + /// it should be a pointer to a well-formed unicode string that is + /// either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16 + /// otherwise. /// - /// ^The sqlite3_extended_result_codes() routine enables or disables the - /// [extended result codes] feature of SQLite. ^The extended result - /// codes are disabled by default for historical compatibility. - int sqlite3_extended_result_codes(ffi.Pointer arg0, int onoff) { - return _sqlite3_extended_result_codes(arg0, onoff); - } - - late final _sqlite3_extended_result_codesPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_extended_result_codes'); - late final _sqlite3_extended_result_codes = _sqlite3_extended_result_codesPtr - .asFunction, int)>(); - - /// CAPI3REF: Last Insert Rowid - /// METHOD: sqlite3 + /// [[byte-order determination rules]] ^The byte-order of + /// UTF16 input text is determined by the byte-order mark (BOM, U+FEFF) + /// found in first character, which is removed, or in the absence of a BOM + /// the byte order is the native byte order of the host + /// machine for sqlite3_bind_text16() or the byte order specified in + /// the 6th parameter for sqlite3_bind_text64().)^ + /// ^If UTF16 input text contains invalid unicode + /// characters, then SQLite might change those invalid characters + /// into the unicode replacement character: U+FFFD. /// - /// ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) - /// has a unique 64-bit signed - /// integer key called the [ROWID | "rowid"]. ^The rowid is always available - /// as an undeclared column named ROWID, OID, or _ROWID_ as long as those - /// names are not also used by explicitly declared columns. ^If - /// the table has a column of type [INTEGER PRIMARY KEY] then that column - /// is another alias for the rowid. + /// ^(In those routines that have a fourth argument, its value is the + /// number of bytes in the parameter. To be clear: the value is the + /// number of bytes in the value, not the number of characters.)^ + /// ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() + /// is negative, then the length of the string is + /// the number of bytes up to the first zero terminator. + /// If the fourth parameter to sqlite3_bind_blob() is negative, then + /// the behavior is undefined. + /// If a non-negative fourth parameter is provided to sqlite3_bind_text() + /// or sqlite3_bind_text16() or sqlite3_bind_text64() then + /// that parameter must be the byte offset + /// where the NUL terminator would occur assuming the string were NUL + /// terminated. If any NUL characters occurs at byte offsets less than + /// the value of the fourth parameter then the resulting string value will + /// contain embedded NULs. The result of expressions involving strings + /// with embedded NULs is undefined. /// - /// ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of - /// the most recent successful [INSERT] into a rowid table or [virtual table] - /// on database connection D. ^Inserts into [WITHOUT ROWID] tables are not - /// recorded. ^If no successful [INSERT]s into rowid tables have ever occurred - /// on the database connection D, then sqlite3_last_insert_rowid(D) returns - /// zero. + /// ^The fifth argument to the BLOB and string binding interfaces + /// is a destructor used to dispose of the BLOB or + /// string after SQLite has finished with it. ^The destructor is called + /// to dispose of the BLOB or string even if the call to the bind API fails, + /// except the destructor is not called if the third parameter is a NULL + /// pointer or the fourth parameter is negative. + /// ^If the fifth argument is + /// the special value [SQLITE_STATIC], then SQLite assumes that the + /// information is in static, unmanaged space and does not need to be freed. + /// ^If the fifth argument has the value [SQLITE_TRANSIENT], then + /// SQLite makes its own private copy of the data immediately, before + /// the sqlite3_bind_*() routine returns. /// - /// As well as being set automatically as rows are inserted into database - /// tables, the value returned by this function may be set explicitly by - /// [sqlite3_set_last_insert_rowid()] + /// ^The sixth argument to sqlite3_bind_text64() must be one of + /// [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] + /// to specify the encoding of the text in the third parameter. If + /// the sixth argument to sqlite3_bind_text64() is not one of the + /// allowed values shown above, or if the text encoding is different + /// from the encoding specified by the sixth parameter, then the behavior + /// is undefined. /// - /// Some virtual table implementations may INSERT rows into rowid tables as - /// part of committing a transaction (e.g. to flush data accumulated in memory - /// to disk). In this case subsequent calls to this function return the rowid - /// associated with these internal INSERT operations, which leads to - /// unintuitive results. Virtual table implementations that do write to rowid - /// tables in this way can avoid this problem by restoring the original - /// rowid value using [sqlite3_set_last_insert_rowid()] before returning - /// control to the user. + /// ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that + /// is filled with zeroes. ^A zeroblob uses a fixed amount of memory + /// (just an integer to hold its size) while it is being processed. + /// Zeroblobs are intended to serve as placeholders for BLOBs whose + /// content is later written using + /// [sqlite3_blob_open | incremental BLOB I/O] routines. + /// ^A negative value for the zeroblob results in a zero-length BLOB. /// - /// ^(If an [INSERT] occurs within a trigger then this routine will - /// return the [rowid] of the inserted row as long as the trigger is - /// running. Once the trigger program ends, the value returned - /// by this routine reverts to what it was before the trigger was fired.)^ + /// ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in + /// [prepared statement] S to have an SQL value of NULL, but to also be + /// associated with the pointer P of type T. ^D is either a NULL pointer or + /// a pointer to a destructor function for P. ^SQLite will invoke the + /// destructor D with a single argument of P when it is finished using + /// P. The T parameter should be a static string, preferably a string + /// literal. The sqlite3_bind_pointer() routine is part of the + /// [pointer passing interface] added for SQLite 3.20.0. /// - /// ^An [INSERT] that fails due to a constraint violation is not a - /// successful [INSERT] and does not change the value returned by this - /// routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, - /// and INSERT OR ABORT make no changes to the return value of this - /// routine when their insertion fails. ^(When INSERT OR REPLACE - /// encounters a constraint violation, it does not fail. The - /// INSERT continues to completion after deleting rows that caused - /// the constraint problem so INSERT OR REPLACE will always change - /// the return value of this interface.)^ + /// ^If any of the sqlite3_bind_*() routines are called with a NULL pointer + /// for the [prepared statement] or with a prepared statement for which + /// [sqlite3_step()] has been called more recently than [sqlite3_reset()], + /// then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() + /// routine is passed a [prepared statement] that has been finalized, the + /// result is undefined and probably harmful. /// - /// ^For the purposes of this routine, an [INSERT] is considered to - /// be successful even if it is subsequently rolled back. + /// ^Bindings are not cleared by the [sqlite3_reset()] routine. + /// ^Unbound parameters are interpreted as NULL. /// - /// This function is accessible to SQL statements via the - /// [last_insert_rowid() SQL function]. + /// ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an + /// [error code] if anything goes wrong. + /// ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB + /// exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or + /// [SQLITE_MAX_LENGTH]. + /// ^[SQLITE_RANGE] is returned if the parameter + /// index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. /// - /// If a separate thread performs a new [INSERT] on the same - /// database connection while the [sqlite3_last_insert_rowid()] - /// function is running and thus changes the last insert [rowid], - /// then the value returned by [sqlite3_last_insert_rowid()] is - /// unpredictable and might not equal either the old or the new - /// last insert [rowid]. - int sqlite3_last_insert_rowid(ffi.Pointer arg0) { - return _sqlite3_last_insert_rowid(arg0); + /// See also: [sqlite3_bind_parameter_count()], + /// [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. + int sqlite3_bind_blob( + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2, + int n, + ffi.Pointer)>> + arg4, + ) { + return _sqlite3_bind_blob(arg0, arg1, arg2, n, arg4); } - late final _sqlite3_last_insert_rowidPtr = - _lookup)>>( - 'sqlite3_last_insert_rowid', - ); - late final _sqlite3_last_insert_rowid = _sqlite3_last_insert_rowidPtr - .asFunction)>(); + late final _sqlite3_bind_blobPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_bind_blob'); + late final _sqlite3_bind_blob = _sqlite3_bind_blobPtr + .asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); - /// CAPI3REF: Set the Last Insert Rowid value. - /// METHOD: sqlite3 - /// - /// The sqlite3_set_last_insert_rowid(D, R) method allows the application to - /// set the value returned by calling sqlite3_last_insert_rowid(D) to R - /// without inserting a row into the database. - void sqlite3_set_last_insert_rowid(ffi.Pointer arg0, int arg1) { - return _sqlite3_set_last_insert_rowid(arg0, arg1); + int sqlite3_bind_blob64( + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer)>> + arg4, + ) { + return _sqlite3_bind_blob64(arg0, arg1, arg2, arg3, arg4); } - late final _sqlite3_set_last_insert_rowidPtr = + late final _sqlite3_bind_blob64Ptr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, sqlite3_int64) + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + sqlite3_uint64, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) > - >('sqlite3_set_last_insert_rowid'); - late final _sqlite3_set_last_insert_rowid = _sqlite3_set_last_insert_rowidPtr - .asFunction, int)>(); - - /// CAPI3REF: Count The Number Of Rows Modified - /// METHOD: sqlite3 - /// - /// ^This function returns the number of rows modified, inserted or - /// deleted by the most recently completed INSERT, UPDATE or DELETE - /// statement on the database connection specified by the only parameter. - /// ^Executing any other type of SQL statement does not modify the value - /// returned by this function. - /// - /// ^Only changes made directly by the INSERT, UPDATE or DELETE statement are - /// considered - auxiliary changes caused by [CREATE TRIGGER | triggers], - /// [foreign key actions] or [REPLACE] constraint resolution are not counted. - /// - /// Changes to a view that are intercepted by - /// [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value - /// returned by sqlite3_changes() immediately after an INSERT, UPDATE or - /// DELETE statement run on a view is always zero. Only changes made to real - /// tables are counted. - /// - /// Things are more complicated if the sqlite3_changes() function is - /// executed while a trigger program is running. This may happen if the - /// program uses the [changes() SQL function], or if some other callback - /// function invokes sqlite3_changes() directly. Essentially: - /// - ///
    - ///
  • ^(Before entering a trigger program the value returned by - /// sqlite3_changes() function is saved. After the trigger program - /// has finished, the original value is restored.)^ - /// - ///
  • ^(Within a trigger program each INSERT, UPDATE and DELETE - /// statement sets the value returned by sqlite3_changes() - /// upon completion as normal. Of course, this value will not include - /// any changes performed by sub-triggers, as the sqlite3_changes() - /// value will be saved and restored after each sub-trigger has run.)^ - ///
- /// - /// ^This means that if the changes() SQL function (or similar) is used - /// by the first INSERT, UPDATE or DELETE statement within a trigger, it - /// returns the value as set when the calling statement began executing. - /// ^If it is used by the second or subsequent such statement within a trigger - /// program, the value returned reflects the number of rows modified by the - /// previous INSERT, UPDATE or DELETE statement within the same trigger. - /// - /// If a separate thread makes changes on the same database connection - /// while [sqlite3_changes()] is running then the value returned - /// is unpredictable and not meaningful. - /// - /// See also: - ///
    - ///
  • the [sqlite3_total_changes()] interface - ///
  • the [count_changes pragma] - ///
  • the [changes() SQL function] - ///
  • the [data_version pragma] - ///
- int sqlite3_changes(ffi.Pointer arg0) { - return _sqlite3_changes(arg0); + >('sqlite3_bind_blob64'); + late final _sqlite3_bind_blob64 = _sqlite3_bind_blob64Ptr + .asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); + + int sqlite3_bind_double( + ffi.Pointer arg0, + int arg1, + double arg2, + ) { + return _sqlite3_bind_double(arg0, arg1, arg2); } - late final _sqlite3_changesPtr = - _lookup)>>( - 'sqlite3_changes', - ); - late final _sqlite3_changes = _sqlite3_changesPtr - .asFunction)>(); + late final _sqlite3_bind_doublePtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Double) + > + >('sqlite3_bind_double'); + late final _sqlite3_bind_double = _sqlite3_bind_doublePtr + .asFunction, int, double)>(); - /// CAPI3REF: Total Number Of Rows Modified - /// METHOD: sqlite3 - /// - /// ^This function returns the total number of rows inserted, modified or - /// deleted by all [INSERT], [UPDATE] or [DELETE] statements completed - /// since the database connection was opened, including those executed as - /// part of trigger programs. ^Executing any other type of SQL statement - /// does not affect the value returned by sqlite3_total_changes(). - /// - /// ^Changes made as part of [foreign key actions] are included in the - /// count, but those made as part of REPLACE constraint resolution are - /// not. ^Changes to a view that are intercepted by INSTEAD OF triggers - /// are not counted. - /// - /// The [sqlite3_total_changes(D)] interface only reports the number - /// of rows that changed due to SQL statement run against database - /// connection D. Any changes by other database connections are ignored. - /// To detect changes against a database file from other database - /// connections use the [PRAGMA data_version] command or the - /// [SQLITE_FCNTL_DATA_VERSION] [file control]. - /// - /// If a separate thread makes changes on the same database connection - /// while [sqlite3_total_changes()] is running then the value - /// returned is unpredictable and not meaningful. - /// - /// See also: - ///
    - ///
  • the [sqlite3_changes()] interface - ///
  • the [count_changes pragma] - ///
  • the [changes() SQL function] - ///
  • the [data_version pragma] - ///
  • the [SQLITE_FCNTL_DATA_VERSION] [file control] - ///
- int sqlite3_total_changes(ffi.Pointer arg0) { - return _sqlite3_total_changes(arg0); + int sqlite3_bind_int(ffi.Pointer arg0, int arg1, int arg2) { + return _sqlite3_bind_int(arg0, arg1, arg2); } - late final _sqlite3_total_changesPtr = - _lookup)>>( - 'sqlite3_total_changes', - ); - late final _sqlite3_total_changes = _sqlite3_total_changesPtr - .asFunction)>(); + late final _sqlite3_bind_intPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) + > + >('sqlite3_bind_int'); + late final _sqlite3_bind_int = _sqlite3_bind_intPtr + .asFunction, int, int)>(); - /// CAPI3REF: Interrupt A Long-Running Query - /// METHOD: sqlite3 - /// - /// ^This function causes any pending database operation to abort and - /// return at its earliest opportunity. This routine is typically - /// called in response to a user action such as pressing "Cancel" - /// or Ctrl-C where the user wants a long query operation to halt - /// immediately. - /// - /// ^It is safe to call this routine from a thread different from the - /// thread that is currently running the database operation. But it - /// is not safe to call this routine with a [database connection] that - /// is closed or might close before sqlite3_interrupt() returns. - /// - /// ^If an SQL operation is very nearly finished at the time when - /// sqlite3_interrupt() is called, then it might not have an opportunity - /// to be interrupted and might continue to completion. - /// - /// ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. - /// ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE - /// that is inside an explicit transaction, then the entire transaction - /// will be rolled back automatically. - /// - /// ^The sqlite3_interrupt(D) call is in effect until all currently running - /// SQL statements on [database connection] D complete. ^Any new SQL statements - /// that are started after the sqlite3_interrupt() call and before the - /// running statement count reaches zero are interrupted as if they had been - /// running prior to the sqlite3_interrupt() call. ^New SQL statements - /// that are started after the running statement count reaches zero are - /// not effected by the sqlite3_interrupt(). - /// ^A call to sqlite3_interrupt(D) that occurs when there are no running - /// SQL statements is a no-op and has no effect on SQL statements - /// that are started after the sqlite3_interrupt() call returns. - void sqlite3_interrupt(ffi.Pointer arg0) { - return _sqlite3_interrupt(arg0); + int sqlite3_bind_int64(ffi.Pointer arg0, int arg1, int arg2) { + return _sqlite3_bind_int64(arg0, arg1, arg2); } - late final _sqlite3_interruptPtr = - _lookup)>>( - 'sqlite3_interrupt', - ); - late final _sqlite3_interrupt = _sqlite3_interruptPtr - .asFunction)>(); + late final _sqlite3_bind_int64Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int, sqlite3_int64) + > + >('sqlite3_bind_int64'); + late final _sqlite3_bind_int64 = _sqlite3_bind_int64Ptr + .asFunction, int, int)>(); - /// CAPI3REF: Determine If An SQL Statement Is Complete - /// - /// These routines are useful during command-line input to determine if the - /// currently entered text seems to form a complete SQL statement or - /// if additional input is needed before sending the text into - /// SQLite for parsing. ^These routines return 1 if the input string - /// appears to be a complete SQL statement. ^A statement is judged to be - /// complete if it ends with a semicolon token and is not a prefix of a - /// well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within - /// string literals or quoted identifier names or comments are not - /// independent tokens (they are part of the token in which they are - /// embedded) and thus do not count as a statement terminator. ^Whitespace - /// and comments that follow the final semicolon are ignored. - /// - /// ^These routines return 0 if the statement is incomplete. ^If a - /// memory allocation fails, then SQLITE_NOMEM is returned. - /// - /// ^These routines do not parse the SQL statements thus - /// will not detect syntactically incorrect SQL. + int sqlite3_bind_null(ffi.Pointer arg0, int arg1) { + return _sqlite3_bind_null(arg0, arg1); + } + + late final _sqlite3_bind_nullPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_bind_null'); + late final _sqlite3_bind_null = _sqlite3_bind_nullPtr + .asFunction, int)>(); + + /// CAPI3REF: Number Of SQL Parameters + /// METHOD: sqlite3_stmt /// - /// ^(If SQLite has not been initialized using [sqlite3_initialize()] prior - /// to invoking sqlite3_complete16() then sqlite3_initialize() is invoked - /// automatically by sqlite3_complete16(). If that initialization fails, - /// then the return value from sqlite3_complete16() will be non-zero - /// regardless of whether or not the input SQL is complete.)^ + /// ^This routine can be used to find the number of [SQL parameters] + /// in a [prepared statement]. SQL parameters are tokens of the + /// form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as + /// placeholders for values that are [sqlite3_bind_blob | bound] + /// to the parameters at a later time. /// - /// The input to [sqlite3_complete()] must be a zero-terminated - /// UTF-8 string. + /// ^(This routine actually returns the index of the largest (rightmost) + /// parameter. For all forms except ?NNN, this will correspond to the + /// number of unique parameters. If parameters of the ?NNN form are used, + /// there may be gaps in the list.)^ /// - /// The input to [sqlite3_complete16()] must be a zero-terminated - /// UTF-16 string in native byte order. - int sqlite3_complete(ffi.Pointer sql) { - return _sqlite3_complete(sql); + /// See also: [sqlite3_bind_blob|sqlite3_bind()], + /// [sqlite3_bind_parameter_name()], and + /// [sqlite3_bind_parameter_index()]. + int sqlite3_bind_parameter_count(ffi.Pointer arg0) { + return _sqlite3_bind_parameter_count(arg0); } - late final _sqlite3_completePtr = - _lookup)>>( - 'sqlite3_complete', + late final _sqlite3_bind_parameter_countPtr = + _lookup)>>( + 'sqlite3_bind_parameter_count', ); - late final _sqlite3_complete = _sqlite3_completePtr - .asFunction)>(); - - int sqlite3_complete16(ffi.Pointer sql) { - return _sqlite3_complete16(sql); - } + late final _sqlite3_bind_parameter_count = _sqlite3_bind_parameter_countPtr + .asFunction)>(); - late final _sqlite3_complete16Ptr = - _lookup)>>( - 'sqlite3_complete16', - ); - late final _sqlite3_complete16 = _sqlite3_complete16Ptr - .asFunction)>(); - - /// CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors - /// KEYWORDS: {busy-handler callback} {busy handler} - /// METHOD: sqlite3 - /// - /// ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X - /// that might be invoked with argument P whenever - /// an attempt is made to access a database table associated with - /// [database connection] D when another thread - /// or process has the table locked. - /// The sqlite3_busy_handler() interface is used to implement - /// [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. - /// - /// ^If the busy callback is NULL, then [SQLITE_BUSY] - /// is returned immediately upon encountering the lock. ^If the busy callback - /// is not NULL, then the callback might be invoked with two arguments. + /// CAPI3REF: Index Of A Parameter With A Given Name + /// METHOD: sqlite3_stmt /// - /// ^The first argument to the busy handler is a copy of the void* pointer which - /// is the third argument to sqlite3_busy_handler(). ^The second argument to - /// the busy handler callback is the number of times that the busy handler has - /// been invoked previously for the same locking event. ^If the - /// busy callback returns 0, then no additional attempts are made to - /// access the database and [SQLITE_BUSY] is returned - /// to the application. - /// ^If the callback returns non-zero, then another attempt - /// is made to access the database and the cycle repeats. + /// ^Return the index of an SQL parameter given its name. ^The + /// index value returned is suitable for use as the second + /// parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero + /// is returned if no matching parameter is found. ^The parameter + /// name must be given in UTF-8 even if the original statement + /// was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or + /// [sqlite3_prepare16_v3()]. /// - /// The presence of a busy handler does not guarantee that it will be invoked - /// when there is lock contention. ^If SQLite determines that invoking the busy - /// handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] - /// to the application instead of invoking the - /// busy handler. - /// Consider a scenario where one process is holding a read lock that - /// it is trying to promote to a reserved lock and - /// a second process is holding a reserved lock that it is trying - /// to promote to an exclusive lock. The first process cannot proceed - /// because it is blocked by the second and the second process cannot - /// proceed because it is blocked by the first. If both processes - /// invoke the busy handlers, neither will make any progress. Therefore, - /// SQLite returns [SQLITE_BUSY] for the first process, hoping that this - /// will induce the first process to release its read lock and allow - /// the second process to proceed. + /// See also: [sqlite3_bind_blob|sqlite3_bind()], + /// [sqlite3_bind_parameter_count()], and + /// [sqlite3_bind_parameter_name()]. + int sqlite3_bind_parameter_index( + ffi.Pointer arg0, + ffi.Pointer zName, + ) { + return _sqlite3_bind_parameter_index(arg0, zName); + } + + late final _sqlite3_bind_parameter_indexPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + >('sqlite3_bind_parameter_index'); + late final _sqlite3_bind_parameter_index = _sqlite3_bind_parameter_indexPtr + .asFunction< + int Function(ffi.Pointer, ffi.Pointer) + >(); + + /// CAPI3REF: Name Of A Host Parameter + /// METHOD: sqlite3_stmt /// - /// ^The default busy callback is NULL. + /// ^The sqlite3_bind_parameter_name(P,N) interface returns + /// the name of the N-th [SQL parameter] in the [prepared statement] P. + /// ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" + /// have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" + /// respectively. + /// In other words, the initial ":" or "$" or "@" or "?" + /// is included as part of the name.)^ + /// ^Parameters of the form "?" without a following integer have no name + /// and are referred to as "nameless" or "anonymous parameters". /// - /// ^(There can only be a single busy handler defined for each - /// [database connection]. Setting a new busy handler clears any - /// previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] - /// or evaluating [PRAGMA busy_timeout=N] will change the - /// busy handler and thus clear any previously set busy handler. + /// ^The first host parameter has an index of 1, not 0. /// - /// The busy callback should not take any actions which modify the - /// database connection that invoked the busy handler. In other words, - /// the busy handler is not reentrant. Any such actions - /// result in undefined behavior. + /// ^If the value N is out of range or if the N-th parameter is + /// nameless, then NULL is returned. ^The returned string is + /// always in UTF-8 encoding even if the named parameter was + /// originally specified as UTF-16 in [sqlite3_prepare16()], + /// [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. /// - /// A busy handler must not close the database connection - /// or [prepared statement] that invoked the busy handler. - int sqlite3_busy_handler( - ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction, ffi.Int)> - > - arg1, + /// See also: [sqlite3_bind_blob|sqlite3_bind()], + /// [sqlite3_bind_parameter_count()], and + /// [sqlite3_bind_parameter_index()]. + ffi.Pointer sqlite3_bind_parameter_name( + ffi.Pointer arg0, + int arg1, + ) { + return _sqlite3_bind_parameter_name(arg0, arg1); + } + + late final _sqlite3_bind_parameter_namePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_bind_parameter_name'); + late final _sqlite3_bind_parameter_name = _sqlite3_bind_parameter_namePtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); + + int sqlite3_bind_pointer( + ffi.Pointer arg0, + int arg1, ffi.Pointer arg2, + ffi.Pointer arg3, + ffi.Pointer)>> + arg4, ) { - return _sqlite3_busy_handler(arg0, arg1, arg2); + return _sqlite3_bind_pointer(arg0, arg1, arg2, arg3, arg4); } - late final _sqlite3_busy_handlerPtr = + late final _sqlite3_bind_pointerPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int) - > + ffi.NativeFunction)> >, - ffi.Pointer, ) > - >('sqlite3_busy_handler'); - late final _sqlite3_busy_handler = _sqlite3_busy_handlerPtr + >('sqlite3_bind_pointer'); + late final _sqlite3_bind_pointer = _sqlite3_bind_pointerPtr .asFunction< int Function( - ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, ffi.Pointer< - ffi.NativeFunction, ffi.Int)> + ffi.NativeFunction)> >, - ffi.Pointer, ) >(); - /// CAPI3REF: Set A Busy Timeout - /// METHOD: sqlite3 - /// - /// ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps - /// for a specified amount of time when a table is locked. ^The handler - /// will sleep multiple times until at least "ms" milliseconds of sleeping - /// have accumulated. ^After at least "ms" milliseconds of sleeping, - /// the handler returns 0 which causes [sqlite3_step()] to return - /// [SQLITE_BUSY]. - /// - /// ^Calling this routine with an argument less than or equal to zero - /// turns off all busy handlers. - /// - /// ^(There can only be a single busy handler for a particular - /// [database connection] at any given moment. If another busy handler - /// was defined (using [sqlite3_busy_handler()]) prior to calling - /// this routine, that other busy handler is cleared.)^ - /// - /// See also: [PRAGMA busy_timeout] - int sqlite3_busy_timeout(ffi.Pointer arg0, int ms) { - return _sqlite3_busy_timeout(arg0, ms); + int sqlite3_bind_text( + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer)>> + arg4, + ) { + return _sqlite3_bind_text(arg0, arg1, arg2, arg3, arg4); } - late final _sqlite3_busy_timeoutPtr = + late final _sqlite3_bind_textPtr = _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_busy_timeout'); - late final _sqlite3_busy_timeout = _sqlite3_busy_timeoutPtr - .asFunction, int)>(); + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_bind_text'); + late final _sqlite3_bind_text = _sqlite3_bind_textPtr + .asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); - /// CAPI3REF: Convenience Routines For Running Queries - /// METHOD: sqlite3 - /// - /// This is a legacy interface that is preserved for backwards compatibility. - /// Use of this interface is not recommended. - /// - /// Definition: A result table is memory data structure created by the - /// [sqlite3_get_table()] interface. A result table records the - /// complete query results from one or more queries. - /// - /// The table conceptually has a number of rows and columns. But - /// these numbers are not part of the result table itself. These - /// numbers are obtained separately. Let N be the number of rows - /// and M be the number of columns. - /// - /// A result table is an array of pointers to zero-terminated UTF-8 strings. - /// There are (N+1)*M elements in the array. The first M pointers point - /// to zero-terminated strings that contain the names of the columns. - /// The remaining entries all point to query results. NULL values result - /// in NULL pointers. All other values are in their UTF-8 zero-terminated - /// string representation as returned by [sqlite3_column_text()]. - /// - /// A result table might consist of one or more memory allocations. - /// It is not safe to pass a result table directly to [sqlite3_free()]. - /// A result table should be deallocated using [sqlite3_free_table()]. - /// - /// ^(As an example of the result table format, suppose a query result - /// is as follows: - /// - ///
-  /// Name        | Age
-  /// -----------------------
-  /// Alice       | 43
-  /// Bob         | 28
-  /// Cindy       | 21
-  /// 
- /// - /// There are two columns (M==2) and three rows (N==3). Thus the - /// result table has 8 entries. Suppose the result table is stored - /// in an array named azResult. Then azResult holds this content: - /// - ///
-  /// azResult[0] = "Name";
-  /// azResult[1] = "Age";
-  /// azResult[2] = "Alice";
-  /// azResult[3] = "43";
-  /// azResult[4] = "Bob";
-  /// azResult[5] = "28";
-  /// azResult[6] = "Cindy";
-  /// azResult[7] = "21";
-  /// 
)^ - /// - /// ^The sqlite3_get_table() function evaluates one or more - /// semicolon-separated SQL statements in the zero-terminated UTF-8 - /// string of its 2nd parameter and returns a result table to the - /// pointer given in its 3rd parameter. - /// - /// After the application has finished with the result from sqlite3_get_table(), - /// it must pass the result table pointer to sqlite3_free_table() in order to - /// release the memory that was malloced. Because of the way the - /// [sqlite3_malloc()] happens within sqlite3_get_table(), the calling - /// function must not try to call [sqlite3_free()] directly. Only - /// [sqlite3_free_table()] is able to release the memory properly and safely. - /// - /// The sqlite3_get_table() interface is implemented as a wrapper around - /// [sqlite3_exec()]. The sqlite3_get_table() routine does not have access - /// to any internal data structures of SQLite. It uses only the public - /// interface defined here. As a consequence, errors that occur in the - /// wrapper layer outside of the internal [sqlite3_exec()] call are not - /// reflected in subsequent calls to [sqlite3_errcode()] or - /// [sqlite3_errmsg()]. - int sqlite3_get_table( - ffi.Pointer db, - ffi.Pointer zSql, - ffi.Pointer>> pazResult, - ffi.Pointer pnRow, - ffi.Pointer pnColumn, - ffi.Pointer> pzErrmsg, + int sqlite3_bind_text16( + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer)>> + arg4, ) { - return _sqlite3_get_table(db, zSql, pazResult, pnRow, pnColumn, pzErrmsg); + return _sqlite3_bind_text16(arg0, arg1, arg2, arg3, arg4); } - late final _sqlite3_get_tablePtr = + late final _sqlite3_bind_text16Ptr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_bind_text16'); + late final _sqlite3_bind_text16 = _sqlite3_bind_text16Ptr + .asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); + + int sqlite3_bind_text64( + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2, + int arg3, + ffi.Pointer)>> + arg4, + int encoding, + ) { + return _sqlite3_bind_text64(arg0, arg1, arg2, arg3, arg4, encoding); + } + + late final _sqlite3_bind_text64Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, ffi.Pointer, - ffi.Pointer>>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + sqlite3_uint64, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.UnsignedChar, ) > - >('sqlite3_get_table'); - late final _sqlite3_get_table = _sqlite3_get_tablePtr + >('sqlite3_bind_text64'); + late final _sqlite3_bind_text64 = _sqlite3_bind_text64Ptr .asFunction< int Function( - ffi.Pointer, + ffi.Pointer, + int, ffi.Pointer, - ffi.Pointer>>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + int, ) >(); - void sqlite3_free_table(ffi.Pointer> result) { - return _sqlite3_free_table(result); + int sqlite3_bind_value( + ffi.Pointer arg0, + int arg1, + ffi.Pointer arg2, + ) { + return _sqlite3_bind_value(arg0, arg1, arg2); } - late final _sqlite3_free_tablePtr = + late final _sqlite3_bind_valuePtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer>) + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) > - >('sqlite3_free_table'); - late final _sqlite3_free_table = _sqlite3_free_tablePtr - .asFunction>)>(); + >('sqlite3_bind_value'); + late final _sqlite3_bind_value = _sqlite3_bind_valuePtr + .asFunction< + int Function(ffi.Pointer, int, ffi.Pointer) + >(); - /// CAPI3REF: Formatted String Printing Functions - /// - /// These routines are work-alikes of the "printf()" family of functions - /// from the standard C library. - /// These routines understand most of the common formatting options from - /// the standard library printf() - /// plus some additional non-standard formats ([%q], [%Q], [%w], and [%z]). - /// See the [built-in printf()] documentation for details. - /// - /// ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their - /// results into memory obtained from [sqlite3_malloc64()]. - /// The strings returned by these two routines should be - /// released by [sqlite3_free()]. ^Both routines return a - /// NULL pointer if [sqlite3_malloc64()] is unable to allocate enough - /// memory to hold the resulting string. - /// - /// ^(The sqlite3_snprintf() routine is similar to "snprintf()" from - /// the standard C library. The result is written into the - /// buffer supplied as the second parameter whose size is given by - /// the first parameter. Note that the order of the - /// first two parameters is reversed from snprintf().)^ This is an - /// historical accident that cannot be fixed without breaking - /// backwards compatibility. ^(Note also that sqlite3_snprintf() - /// returns a pointer to its buffer instead of the number of - /// characters actually written into the buffer.)^ We admit that - /// the number of characters written would be a more useful return - /// value but we cannot change the implementation of sqlite3_snprintf() - /// now without breaking compatibility. - /// - /// ^As long as the buffer size is greater than zero, sqlite3_snprintf() - /// guarantees that the buffer is always zero-terminated. ^The first - /// parameter "n" is the total size of the buffer, including space for - /// the zero terminator. So the longest string that can be completely - /// written will be n-1 characters. - /// - /// ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). - /// - /// See also: [built-in printf()], [printf() SQL function] - ffi.Pointer sqlite3_mprintf(ffi.Pointer arg0) { - return _sqlite3_mprintf(arg0); + int sqlite3_bind_zeroblob(ffi.Pointer arg0, int arg1, int n) { + return _sqlite3_bind_zeroblob(arg0, arg1, n); } - late final _sqlite3_mprintfPtr = + late final _sqlite3_bind_zeroblobPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) > - >('sqlite3_mprintf'); - late final _sqlite3_mprintf = _sqlite3_mprintfPtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_bind_zeroblob'); + late final _sqlite3_bind_zeroblob = _sqlite3_bind_zeroblobPtr + .asFunction, int, int)>(); - ffi.Pointer sqlite3_snprintf( - int arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, + int sqlite3_bind_zeroblob64( + ffi.Pointer arg0, + int arg1, + int arg2, ) { - return _sqlite3_snprintf(arg0, arg1, arg2); + return _sqlite3_bind_zeroblob64(arg0, arg1, arg2); } - late final _sqlite3_snprintfPtr = + late final _sqlite3_bind_zeroblob64Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Int Function(ffi.Pointer, ffi.Int, sqlite3_uint64) > - >('sqlite3_snprintf'); - late final _sqlite3_snprintf = _sqlite3_snprintfPtr - .asFunction< - ffi.Pointer Function( - int, - ffi.Pointer, - ffi.Pointer, - ) - >(); + >('sqlite3_bind_zeroblob64'); + late final _sqlite3_bind_zeroblob64 = _sqlite3_bind_zeroblob64Ptr + .asFunction, int, int)>(); - /// CAPI3REF: Memory Allocation Subsystem - /// - /// The SQLite core uses these three routines for all of its own - /// internal memory allocation needs. "Core" in the previous sentence - /// does not include operating-system specific [VFS] implementation. The - /// Windows VFS uses native malloc() and free() for some operations. - /// - /// ^The sqlite3_malloc() routine returns a pointer to a block - /// of memory at least N bytes in length, where N is the parameter. - /// ^If sqlite3_malloc() is unable to obtain sufficient free - /// memory, it returns a NULL pointer. ^If the parameter N to - /// sqlite3_malloc() is zero or negative then sqlite3_malloc() returns - /// a NULL pointer. + /// CAPI3REF: Return The Size Of An Open BLOB + /// METHOD: sqlite3_blob /// - /// ^The sqlite3_malloc64(N) routine works just like - /// sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead - /// of a signed 32-bit integer. + /// ^Returns the size in bytes of the BLOB accessible via the + /// successfully opened [BLOB handle] in its only argument. ^The + /// incremental blob I/O routines can only read or overwriting existing + /// blob content; they cannot change the size of a blob. /// - /// ^Calling sqlite3_free() with a pointer previously returned - /// by sqlite3_malloc() or sqlite3_realloc() releases that memory so - /// that it might be reused. ^The sqlite3_free() routine is - /// a no-op if is called with a NULL pointer. Passing a NULL pointer - /// to sqlite3_free() is harmless. After being freed, memory - /// should neither be read nor written. Even reading previously freed - /// memory might result in a segmentation fault or other severe error. - /// Memory corruption, a segmentation fault, or other severe error - /// might result if sqlite3_free() is called with a non-NULL pointer that - /// was not obtained from sqlite3_malloc() or sqlite3_realloc(). - /// - /// ^The sqlite3_realloc(X,N) interface attempts to resize a - /// prior memory allocation X to be at least N bytes. - /// ^If the X parameter to sqlite3_realloc(X,N) - /// is a NULL pointer then its behavior is identical to calling - /// sqlite3_malloc(N). - /// ^If the N parameter to sqlite3_realloc(X,N) is zero or - /// negative then the behavior is exactly the same as calling - /// sqlite3_free(X). - /// ^sqlite3_realloc(X,N) returns a pointer to a memory allocation - /// of at least N bytes in size or NULL if insufficient memory is available. - /// ^If M is the size of the prior allocation, then min(N,M) bytes - /// of the prior allocation are copied into the beginning of buffer returned - /// by sqlite3_realloc(X,N) and the prior allocation is freed. - /// ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the - /// prior allocation is not freed. - /// - /// ^The sqlite3_realloc64(X,N) interfaces works the same as - /// sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead - /// of a 32-bit signed integer. - /// - /// ^If X is a memory allocation previously obtained from sqlite3_malloc(), - /// sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then - /// sqlite3_msize(X) returns the size of that memory allocation in bytes. - /// ^The value returned by sqlite3_msize(X) might be larger than the number - /// of bytes requested when X was allocated. ^If X is a NULL pointer then - /// sqlite3_msize(X) returns zero. If X points to something that is not - /// the beginning of memory allocation, or if it points to a formerly - /// valid memory allocation that has now been freed, then the behavior - /// of sqlite3_msize(X) is undefined and possibly harmful. - /// - /// ^The memory returned by sqlite3_malloc(), sqlite3_realloc(), - /// sqlite3_malloc64(), and sqlite3_realloc64() - /// is always aligned to at least an 8 byte boundary, or to a - /// 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time - /// option is used. - /// - /// The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] - /// must be either NULL or else pointers obtained from a prior - /// invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have - /// not yet been released. - /// - /// The application must not read or write any part of - /// a block of memory after it has been released using - /// [sqlite3_free()] or [sqlite3_realloc()]. - ffi.Pointer sqlite3_malloc(int arg0) { - return _sqlite3_malloc(arg0); - } - - late final _sqlite3_mallocPtr = - _lookup Function(ffi.Int)>>( - 'sqlite3_malloc', - ); - late final _sqlite3_malloc = _sqlite3_mallocPtr - .asFunction Function(int)>(); - - ffi.Pointer sqlite3_malloc64(int arg0) { - return _sqlite3_malloc64(arg0); - } - - late final _sqlite3_malloc64Ptr = - _lookup< - ffi.NativeFunction Function(sqlite3_uint64)> - >('sqlite3_malloc64'); - late final _sqlite3_malloc64 = _sqlite3_malloc64Ptr - .asFunction Function(int)>(); - - ffi.Pointer sqlite3_realloc(ffi.Pointer arg0, int arg1) { - return _sqlite3_realloc(arg0, arg1); - } - - late final _sqlite3_reallocPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_realloc'); - late final _sqlite3_realloc = _sqlite3_reallocPtr - .asFunction Function(ffi.Pointer, int)>(); - - ffi.Pointer sqlite3_realloc64( - ffi.Pointer arg0, - int arg1, - ) { - return _sqlite3_realloc64(arg0, arg1); - } - - late final _sqlite3_realloc64Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, sqlite3_uint64) - > - >('sqlite3_realloc64'); - late final _sqlite3_realloc64 = _sqlite3_realloc64Ptr - .asFunction Function(ffi.Pointer, int)>(); - - void sqlite3_free(ffi.Pointer arg0) { - return _sqlite3_free(arg0); + /// This routine only works on a [BLOB handle] which has been created + /// by a prior successful call to [sqlite3_blob_open()] and which has not + /// been closed by [sqlite3_blob_close()]. Passing any other pointer in + /// to this routine results in undefined and probably undesirable behavior. + int sqlite3_blob_bytes(ffi.Pointer arg0) { + return _sqlite3_blob_bytes(arg0); } - late final _sqlite3_freePtr = - _lookup)>>( - 'sqlite3_free', + late final _sqlite3_blob_bytesPtr = + _lookup)>>( + 'sqlite3_blob_bytes', ); - late final _sqlite3_free = _sqlite3_freePtr - .asFunction)>(); - - int sqlite3_msize(ffi.Pointer arg0) { - return _sqlite3_msize(arg0); - } - - late final _sqlite3_msizePtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_msize'); - late final _sqlite3_msize = _sqlite3_msizePtr - .asFunction)>(); + late final _sqlite3_blob_bytes = _sqlite3_blob_bytesPtr + .asFunction)>(); - /// CAPI3REF: Memory Allocator Statistics + /// CAPI3REF: Close A BLOB Handle + /// DESTRUCTOR: sqlite3_blob /// - /// SQLite provides these two interfaces for reporting on the status - /// of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] - /// routines, which form the built-in memory allocation subsystem. + /// ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed + /// unconditionally. Even if this routine returns an error code, the + /// handle is still closed.)^ /// - /// ^The [sqlite3_memory_used()] routine returns the number of bytes - /// of memory currently outstanding (malloced but not freed). - /// ^The [sqlite3_memory_highwater()] routine returns the maximum - /// value of [sqlite3_memory_used()] since the high-water mark - /// was last reset. ^The values returned by [sqlite3_memory_used()] and - /// [sqlite3_memory_highwater()] include any overhead - /// added by SQLite in its implementation of [sqlite3_malloc()], - /// but not overhead added by the any underlying system library - /// routines that [sqlite3_malloc()] may call. + /// ^If the blob handle being closed was opened for read-write access, and if + /// the database is in auto-commit mode and there are no other open read-write + /// blob handles or active write statements, the current transaction is + /// committed. ^If an error occurs while committing the transaction, an error + /// code is returned and the transaction rolled back. /// - /// ^The memory high-water mark is reset to the current value of - /// [sqlite3_memory_used()] if and only if the parameter to - /// [sqlite3_memory_highwater()] is true. ^The value returned - /// by [sqlite3_memory_highwater(1)] is the high-water mark - /// prior to the reset. - int sqlite3_memory_used() { - return _sqlite3_memory_used(); - } - - late final _sqlite3_memory_usedPtr = - _lookup>( - 'sqlite3_memory_used', - ); - late final _sqlite3_memory_used = _sqlite3_memory_usedPtr - .asFunction(); - - int sqlite3_memory_highwater(int resetFlag) { - return _sqlite3_memory_highwater(resetFlag); + /// Calling this function with an argument that is not a NULL pointer or an + /// open blob handle results in undefined behaviour. ^Calling this routine + /// with a null pointer (such as would be returned by a failed call to + /// [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function + /// is passed a valid open blob handle, the values returned by the + /// sqlite3_errcode() and sqlite3_errmsg() functions are set before returning. + int sqlite3_blob_close(ffi.Pointer arg0) { + return _sqlite3_blob_close(arg0); } - late final _sqlite3_memory_highwaterPtr = - _lookup>( - 'sqlite3_memory_highwater', + late final _sqlite3_blob_closePtr = + _lookup)>>( + 'sqlite3_blob_close', ); - late final _sqlite3_memory_highwater = _sqlite3_memory_highwaterPtr - .asFunction(); + late final _sqlite3_blob_close = _sqlite3_blob_closePtr + .asFunction)>(); - /// CAPI3REF: Pseudo-Random Number Generator + /// CAPI3REF: Open A BLOB For Incremental I/O + /// METHOD: sqlite3 + /// CONSTRUCTOR: sqlite3_blob /// - /// SQLite contains a high-quality pseudo-random number generator (PRNG) used to - /// select random [ROWID | ROWIDs] when inserting new records into a table that - /// already uses the largest possible [ROWID]. The PRNG is also used for - /// the built-in random() and randomblob() SQL functions. This interface allows - /// applications to access the same PRNG for other purposes. + /// ^(This interfaces opens a [BLOB handle | handle] to the BLOB located + /// in row iRow, column zColumn, table zTable in database zDb; + /// in other words, the same BLOB that would be selected by: /// - /// ^A call to this routine stores N bytes of randomness into buffer P. - /// ^The P parameter can be a NULL pointer. + ///
+  /// SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
+  /// 
)^ /// - /// ^If this routine has not been previously called or if the previous - /// call had N less than one or a NULL pointer for P, then the PRNG is - /// seeded using randomness obtained from the xRandomness method of - /// the default [sqlite3_vfs] object. - /// ^If the previous call to this routine had an N of 1 or more and a - /// non-NULL P then the pseudo-randomness is generated - /// internally and without recourse to the [sqlite3_vfs] xRandomness - /// method. - void sqlite3_randomness(int N, ffi.Pointer P) { - return _sqlite3_randomness(N, P); - } - - late final _sqlite3_randomnessPtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_randomness'); - late final _sqlite3_randomness = _sqlite3_randomnessPtr - .asFunction)>(); - - /// CAPI3REF: Compile-Time Authorization Callbacks - /// METHOD: sqlite3 - /// KEYWORDS: {authorizer callback} + /// ^(Parameter zDb is not the filename that contains the database, but + /// rather the symbolic name of the database. For attached databases, this is + /// the name that appears after the AS keyword in the [ATTACH] statement. + /// For the main database file, the database name is "main". For TEMP + /// tables, the database name is "temp".)^ /// - /// ^This routine registers an authorizer callback with a particular - /// [database connection], supplied in the first argument. - /// ^The authorizer callback is invoked as SQL statements are being compiled - /// by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], - /// [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()], - /// and [sqlite3_prepare16_v3()]. ^At various - /// points during the compilation process, as logic is being created - /// to perform various actions, the authorizer callback is invoked to - /// see if those actions are allowed. ^The authorizer callback should - /// return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the - /// specific action but allow the SQL statement to continue to be - /// compiled, or [SQLITE_DENY] to cause the entire SQL statement to be - /// rejected with an error. ^If the authorizer callback returns - /// any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] - /// then the [sqlite3_prepare_v2()] or equivalent call that triggered - /// the authorizer will fail with an error message. + /// ^If the flags parameter is non-zero, then the BLOB is opened for read + /// and write access. ^If the flags parameter is zero, the BLOB is opened for + /// read-only access. /// - /// When the callback returns [SQLITE_OK], that means the operation - /// requested is ok. ^When the callback returns [SQLITE_DENY], the - /// [sqlite3_prepare_v2()] or equivalent call that triggered the - /// authorizer will fail with an error message explaining that - /// access is denied. + /// ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored + /// in *ppBlob. Otherwise an [error code] is returned and, unless the error + /// code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided + /// the API is not misused, it is always safe to call [sqlite3_blob_close()] + /// on *ppBlob after this function it returns. /// - /// ^The first parameter to the authorizer callback is a copy of the third - /// parameter to the sqlite3_set_authorizer() interface. ^The second parameter - /// to the callback is an integer [SQLITE_COPY | action code] that specifies - /// the particular action to be authorized. ^The third through sixth parameters - /// to the callback are either NULL pointers or zero-terminated strings - /// that contain additional details about the action to be authorized. - /// Applications must always be prepared to encounter a NULL pointer in any - /// of the third through the sixth parameters of the authorization callback. + /// This function fails with SQLITE_ERROR if any of the following are true: + ///
    + ///
  • ^(Database zDb does not exist)^, + ///
  • ^(Table zTable does not exist within database zDb)^, + ///
  • ^(Table zTable is a WITHOUT ROWID table)^, + ///
  • ^(Column zColumn does not exist)^, + ///
  • ^(Row iRow is not present in the table)^, + ///
  • ^(The specified column of row iRow contains a value that is not + /// a TEXT or BLOB value)^, + ///
  • ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE + /// constraint and the blob is being opened for read/write access)^, + ///
  • ^([foreign key constraints | Foreign key constraints] are enabled, + /// column zColumn is part of a [child key] definition and the blob is + /// being opened for read/write access)^. + ///
/// - /// ^If the action code is [SQLITE_READ] - /// and the callback returns [SQLITE_IGNORE] then the - /// [prepared statement] statement is constructed to substitute - /// a NULL value in place of the table column that would have - /// been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] - /// return can be used to deny an untrusted user access to individual - /// columns of a table. - /// ^When a table is referenced by a [SELECT] but no column values are - /// extracted from that table (for example in a query like - /// "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback - /// is invoked once for that table with a column name that is an empty string. - /// ^If the action code is [SQLITE_DELETE] and the callback returns - /// [SQLITE_IGNORE] then the [DELETE] operation proceeds but the - /// [truncate optimization] is disabled and all rows are deleted individually. + /// ^Unless it returns SQLITE_MISUSE, this function sets the + /// [database connection] error code and message accessible via + /// [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. /// - /// An authorizer is used when [sqlite3_prepare | preparing] - /// SQL statements from an untrusted source, to ensure that the SQL statements - /// do not try to access data they are not allowed to see, or that they do not - /// try to execute malicious statements that damage the database. For - /// example, an application may allow a user to enter arbitrary - /// SQL queries for evaluation by a database. But the application does - /// not want the user to be able to make arbitrary changes to the - /// database. An authorizer could then be put in place while the - /// user-entered SQL is being [sqlite3_prepare | prepared] that - /// disallows everything except [SELECT] statements. + /// A BLOB referenced by sqlite3_blob_open() may be read using the + /// [sqlite3_blob_read()] interface and modified by using + /// [sqlite3_blob_write()]. The [BLOB handle] can be moved to a + /// different row of the same table using the [sqlite3_blob_reopen()] + /// interface. However, the column, table, or database of a [BLOB handle] + /// cannot be changed after the [BLOB handle] is opened. /// - /// Applications that need to process SQL from untrusted sources - /// might also consider lowering resource limits using [sqlite3_limit()] - /// and limiting database size using the [max_page_count] [PRAGMA] - /// in addition to using an authorizer. + /// ^(If the row that a BLOB handle points to is modified by an + /// [UPDATE], [DELETE], or by [ON CONFLICT] side-effects + /// then the BLOB handle is marked as "expired". + /// This is true if any column of the row is changed, even a column + /// other than the one the BLOB handle is open on.)^ + /// ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for + /// an expired BLOB handle fail with a return code of [SQLITE_ABORT]. + /// ^(Changes written into a BLOB prior to the BLOB expiring are not + /// rolled back by the expiration of the BLOB. Such changes will eventually + /// commit if the transaction continues to completion.)^ /// - /// ^(Only a single authorizer can be in place on a database connection - /// at a time. Each call to sqlite3_set_authorizer overrides the - /// previous call.)^ ^Disable the authorizer by installing a NULL callback. - /// The authorizer is disabled by default. + /// ^Use the [sqlite3_blob_bytes()] interface to determine the size of + /// the opened blob. ^The size of a blob may not be changed by this + /// interface. Use the [UPDATE] SQL command to change the size of a + /// blob. /// - /// The authorizer callback must not do anything that will modify - /// the database connection that invoked the authorizer callback. - /// Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - /// database connections for the meaning of "modify" in this paragraph. + /// ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces + /// and the built-in [zeroblob] SQL function may be used to create a + /// zero-filled blob to read or write using the incremental-blob interface. /// - /// ^When [sqlite3_prepare_v2()] is used to prepare a statement, the - /// statement might be re-prepared during [sqlite3_step()] due to a - /// schema change. Hence, the application should ensure that the - /// correct authorizer callback remains in place during the [sqlite3_step()]. + /// To avoid a resource leak, every open [BLOB handle] should eventually + /// be released by a call to [sqlite3_blob_close()]. /// - /// ^Note that the authorizer callback is invoked only during - /// [sqlite3_prepare()] or its variants. Authorization is not - /// performed during statement evaluation in [sqlite3_step()], unless - /// as stated in the previous paragraph, sqlite3_step() invokes - /// sqlite3_prepare_v2() to reprepare a statement after a schema change. - int sqlite3_set_authorizer( + /// See also: [sqlite3_blob_close()], + /// [sqlite3_blob_reopen()], [sqlite3_blob_read()], + /// [sqlite3_blob_bytes()], [sqlite3_blob_write()]. + int sqlite3_blob_open( ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xAuth, - ffi.Pointer pUserData, + ffi.Pointer zDb, + ffi.Pointer zTable, + ffi.Pointer zColumn, + int iRow, + int flags, + ffi.Pointer> ppBlob, ) { - return _sqlite3_set_authorizer(arg0, xAuth, pUserData); + return _sqlite3_blob_open(arg0, zDb, zTable, zColumn, iRow, flags, ppBlob); } - late final _sqlite3_set_authorizerPtr = + late final _sqlite3_blob_openPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + sqlite3_int64, + ffi.Int, + ffi.Pointer>, ) > - >('sqlite3_set_authorizer'); - late final _sqlite3_set_authorizer = _sqlite3_set_authorizerPtr + >('sqlite3_blob_open'); + late final _sqlite3_blob_open = _sqlite3_blob_openPtr .asFunction< int Function( ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer>, ) >(); - /// CAPI3REF: Tracing And Profiling Functions - /// METHOD: sqlite3 + /// CAPI3REF: Read Data From A BLOB Incrementally + /// METHOD: sqlite3_blob /// - /// These routines are deprecated. Use the [sqlite3_trace_v2()] interface - /// instead of the routines described here. + /// ^(This function is used to read data from an open [BLOB handle] into a + /// caller-supplied buffer. N bytes of data are copied into buffer Z + /// from the open BLOB, starting at offset iOffset.)^ /// - /// These routines register callback functions that can be used for - /// tracing and profiling the execution of SQL statements. + /// ^If offset iOffset is less than N bytes from the end of the BLOB, + /// [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is + /// less than zero, [SQLITE_ERROR] is returned and no data is read. + /// ^The size of the blob (and hence the maximum value of N+iOffset) + /// can be determined using the [sqlite3_blob_bytes()] interface. /// - /// ^The callback function registered by sqlite3_trace() is invoked at - /// various times when an SQL statement is being run by [sqlite3_step()]. - /// ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the - /// SQL statement text as the statement first begins executing. - /// ^(Additional sqlite3_trace() callbacks might occur - /// as each triggered subprogram is entered. The callbacks for triggers - /// contain a UTF-8 SQL comment that identifies the trigger.)^ + /// ^An attempt to read from an expired [BLOB handle] fails with an + /// error code of [SQLITE_ABORT]. /// - /// The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit - /// the length of [bound parameter] expansion in the output of sqlite3_trace(). + /// ^(On success, sqlite3_blob_read() returns SQLITE_OK. + /// Otherwise, an [error code] or an [extended error code] is returned.)^ /// - /// ^The callback function registered by sqlite3_profile() is invoked - /// as each SQL statement finishes. ^The profile callback contains - /// the original statement text and an estimate of wall-clock time - /// of how long that statement took to run. ^The profile callback - /// time is in units of nanoseconds, however the current implementation - /// is only capable of millisecond resolution so the six least significant - /// digits in the time are meaningless. Future versions of SQLite - /// might provide greater resolution on the profiler callback. Invoking - /// either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the - /// profile callback. - ffi.Pointer sqlite3_trace( - ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - > - xTrace, - ffi.Pointer arg2, + /// This routine only works on a [BLOB handle] which has been created + /// by a prior successful call to [sqlite3_blob_open()] and which has not + /// been closed by [sqlite3_blob_close()]. Passing any other pointer in + /// to this routine results in undefined and probably undesirable behavior. + /// + /// See also: [sqlite3_blob_write()]. + int sqlite3_blob_read( + ffi.Pointer arg0, + ffi.Pointer Z, + int N, + int iOffset, ) { - return _sqlite3_trace(arg0, xTrace, arg2); + return _sqlite3_blob_read(arg0, Z, N, iOffset); } - late final _sqlite3_tracePtr = + late final _sqlite3_blob_readPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >, + ffi.Int Function( + ffi.Pointer, ffi.Pointer, + ffi.Int, + ffi.Int, ) > - >('sqlite3_trace'); - late final _sqlite3_trace = _sqlite3_tracePtr + >('sqlite3_blob_read'); + late final _sqlite3_blob_read = _sqlite3_blob_readPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - >, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer, int, int) >(); - ffi.Pointer sqlite3_profile( - ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_uint64, - ) - > - > - xProfile, - ffi.Pointer arg2, + /// CAPI3REF: Move a BLOB Handle to a New Row + /// METHOD: sqlite3_blob + /// + /// ^This function is used to move an existing [BLOB handle] so that it points + /// to a different row of the same database table. ^The new row is identified + /// by the rowid value passed as the second argument. Only the row can be + /// changed. ^The database, table and column on which the blob handle is open + /// remain the same. Moving an existing [BLOB handle] to a new row is + /// faster than closing the existing handle and opening a new one. + /// + /// ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - + /// it must exist and there must be either a blob or text value stored in + /// the nominated column.)^ ^If the new row is not present in the table, or if + /// it does not contain a blob or text value, or if another error occurs, an + /// SQLite error code is returned and the blob handle is considered aborted. + /// ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or + /// [sqlite3_blob_reopen()] on an aborted blob handle immediately return + /// SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle + /// always returns zero. + /// + /// ^This function sets the database handle error code and message. + int sqlite3_blob_reopen(ffi.Pointer arg0, int arg1) { + return _sqlite3_blob_reopen(arg0, arg1); + } + + late final _sqlite3_blob_reopenPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, sqlite3_int64) + > + >('sqlite3_blob_reopen'); + late final _sqlite3_blob_reopen = _sqlite3_blob_reopenPtr + .asFunction, int)>(); + + /// CAPI3REF: Write Data Into A BLOB Incrementally + /// METHOD: sqlite3_blob + /// + /// ^(This function is used to write data into an open [BLOB handle] from a + /// caller-supplied buffer. N bytes of data are copied from the buffer Z + /// into the open BLOB, starting at offset iOffset.)^ + /// + /// ^(On success, sqlite3_blob_write() returns SQLITE_OK. + /// Otherwise, an [error code] or an [extended error code] is returned.)^ + /// ^Unless SQLITE_MISUSE is returned, this function sets the + /// [database connection] error code and message accessible via + /// [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. + /// + /// ^If the [BLOB handle] passed as the first argument was not opened for + /// writing (the flags parameter to [sqlite3_blob_open()] was zero), + /// this function returns [SQLITE_READONLY]. + /// + /// This function may only modify the contents of the BLOB; it is + /// not possible to increase the size of a BLOB using this API. + /// ^If offset iOffset is less than N bytes from the end of the BLOB, + /// [SQLITE_ERROR] is returned and no data is written. The size of the + /// BLOB (and hence the maximum value of N+iOffset) can be determined + /// using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less + /// than zero [SQLITE_ERROR] is returned and no data is written. + /// + /// ^An attempt to write to an expired [BLOB handle] fails with an + /// error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred + /// before the [BLOB handle] expired are not rolled back by the + /// expiration of the handle, though of course those changes might + /// have been overwritten by the statement that expired the BLOB handle + /// or by other independent statements. + /// + /// This routine only works on a [BLOB handle] which has been created + /// by a prior successful call to [sqlite3_blob_open()] and which has not + /// been closed by [sqlite3_blob_close()]. Passing any other pointer in + /// to this routine results in undefined and probably undesirable behavior. + /// + /// See also: [sqlite3_blob_read()]. + int sqlite3_blob_write( + ffi.Pointer arg0, + ffi.Pointer z, + int n, + int iOffset, ) { - return _sqlite3_profile(arg0, xProfile, arg2); + return _sqlite3_blob_write(arg0, z, n, iOffset); } - late final _sqlite3_profilePtr = + late final _sqlite3_blob_writePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_uint64, - ) - > - >, + ffi.Int Function( + ffi.Pointer, ffi.Pointer, + ffi.Int, + ffi.Int, ) > - >('sqlite3_profile'); - late final _sqlite3_profile = _sqlite3_profilePtr + >('sqlite3_blob_write'); + late final _sqlite3_blob_write = _sqlite3_blob_writePtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_uint64, - ) - > - >, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer, int, int) >(); - /// CAPI3REF: SQL Trace Hook + /// CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors + /// KEYWORDS: {busy-handler callback} {busy handler} /// METHOD: sqlite3 /// - /// ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback - /// function X against [database connection] D, using property mask M - /// and context pointer P. ^If the X callback is - /// NULL or if the M mask is zero, then tracing is disabled. The - /// M argument should be the bitwise OR-ed combination of - /// zero or more [SQLITE_TRACE] constants. + /// ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X + /// that might be invoked with argument P whenever + /// an attempt is made to access a database table associated with + /// [database connection] D when another thread + /// or process has the table locked. + /// The sqlite3_busy_handler() interface is used to implement + /// [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. /// - /// ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides - /// (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). + /// ^If the busy callback is NULL, then [SQLITE_BUSY] + /// is returned immediately upon encountering the lock. ^If the busy callback + /// is not NULL, then the callback might be invoked with two arguments. /// - /// ^The X callback is invoked whenever any of the events identified by - /// mask M occur. ^The integer return value from the callback is currently - /// ignored, though this may change in future releases. Callback - /// implementations should return zero to ensure future compatibility. + /// ^The first argument to the busy handler is a copy of the void* pointer which + /// is the third argument to sqlite3_busy_handler(). ^The second argument to + /// the busy handler callback is the number of times that the busy handler has + /// been invoked previously for the same locking event. ^If the + /// busy callback returns 0, then no additional attempts are made to + /// access the database and [SQLITE_BUSY] is returned + /// to the application. + /// ^If the callback returns non-zero, then another attempt + /// is made to access the database and the cycle repeats. /// - /// ^A trace callback is invoked with four arguments: callback(T,C,P,X). - /// ^The T argument is one of the [SQLITE_TRACE] - /// constants to indicate why the callback was invoked. - /// ^The C argument is a copy of the context pointer. - /// The P and X arguments are pointers whose meanings depend on T. + /// The presence of a busy handler does not guarantee that it will be invoked + /// when there is lock contention. ^If SQLite determines that invoking the busy + /// handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] + /// to the application instead of invoking the + /// busy handler. + /// Consider a scenario where one process is holding a read lock that + /// it is trying to promote to a reserved lock and + /// a second process is holding a reserved lock that it is trying + /// to promote to an exclusive lock. The first process cannot proceed + /// because it is blocked by the second and the second process cannot + /// proceed because it is blocked by the first. If both processes + /// invoke the busy handlers, neither will make any progress. Therefore, + /// SQLite returns [SQLITE_BUSY] for the first process, hoping that this + /// will induce the first process to release its read lock and allow + /// the second process to proceed. /// - /// The sqlite3_trace_v2() interface is intended to replace the legacy - /// interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which - /// are deprecated. - int sqlite3_trace_v2( + /// ^The default busy callback is NULL. + /// + /// ^(There can only be a single busy handler defined for each + /// [database connection]. Setting a new busy handler clears any + /// previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] + /// or evaluating [PRAGMA busy_timeout=N] will change the + /// busy handler and thus clear any previously set busy handler. + /// + /// The busy callback should not take any actions which modify the + /// database connection that invoked the busy handler. In other words, + /// the busy handler is not reentrant. Any such actions + /// result in undefined behavior. + /// + /// A busy handler must not close the database connection + /// or [prepared statement] that invoked the busy handler. + int sqlite3_busy_handler( ffi.Pointer arg0, - int uMask, ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.UnsignedInt, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > + ffi.NativeFunction, ffi.Int)> > - xCallback, - ffi.Pointer pCtx, + arg1, + ffi.Pointer arg2, ) { - return _sqlite3_trace_v2(arg0, uMask, xCallback, pCtx); + return _sqlite3_busy_handler(arg0, arg1, arg2); } - late final _sqlite3_trace_v2Ptr = + late final _sqlite3_busy_handlerPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, - ffi.UnsignedInt, ffi.Pointer< ffi.NativeFunction< - ffi.Int Function( - ffi.UnsignedInt, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + ffi.Int Function(ffi.Pointer, ffi.Int) > >, ffi.Pointer, ) > - >('sqlite3_trace_v2'); - late final _sqlite3_trace_v2 = _sqlite3_trace_v2Ptr + >('sqlite3_busy_handler'); + late final _sqlite3_busy_handler = _sqlite3_busy_handlerPtr .asFunction< int Function( ffi.Pointer, - int, ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.UnsignedInt, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > + ffi.NativeFunction, ffi.Int)> >, ffi.Pointer, ) >(); - /// CAPI3REF: Query Progress Callbacks + /// CAPI3REF: Set A Busy Timeout /// METHOD: sqlite3 /// - /// ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback - /// function X to be invoked periodically during long running calls to - /// [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for - /// database connection D. An example use for this - /// interface is to keep a GUI updated during a large query. - /// - /// ^The parameter P is passed through as the only parameter to the - /// callback function X. ^The parameter N is the approximate number of - /// [virtual machine instructions] that are evaluated between successive - /// invocations of the callback X. ^If N is less than one then the progress - /// handler is disabled. + /// ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps + /// for a specified amount of time when a table is locked. ^The handler + /// will sleep multiple times until at least "ms" milliseconds of sleeping + /// have accumulated. ^After at least "ms" milliseconds of sleeping, + /// the handler returns 0 which causes [sqlite3_step()] to return + /// [SQLITE_BUSY]. /// - /// ^Only a single progress handler may be defined at one time per - /// [database connection]; setting a new progress handler cancels the - /// old one. ^Setting parameter X to NULL disables the progress handler. - /// ^The progress handler is also disabled by setting N to a value less - /// than 1. + /// ^Calling this routine with an argument less than or equal to zero + /// turns off all busy handlers. /// - /// ^If the progress callback returns non-zero, the operation is - /// interrupted. This feature can be used to implement a - /// "Cancel" button on a GUI progress dialog box. + /// ^(There can only be a single busy handler for a particular + /// [database connection] at any given moment. If another busy handler + /// was defined (using [sqlite3_busy_handler()]) prior to calling + /// this routine, that other busy handler is cleared.)^ /// - /// The progress handler callback must not do anything that will modify - /// the database connection that invoked the progress handler. - /// Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - /// database connections for the meaning of "modify" in this paragraph. - void sqlite3_progress_handler( - ffi.Pointer arg0, - int arg1, - ffi.Pointer)>> - arg2, - ffi.Pointer arg3, + /// See also: [PRAGMA busy_timeout] + int sqlite3_busy_timeout(ffi.Pointer arg0, int ms) { + return _sqlite3_busy_timeout(arg0, ms); + } + + late final _sqlite3_busy_timeoutPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_busy_timeout'); + late final _sqlite3_busy_timeout = _sqlite3_busy_timeoutPtr + .asFunction, int)>(); + + /// CAPI3REF: Cancel Automatic Extension Loading + /// + /// ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the + /// initialization routine X that was registered using a prior call to + /// [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] + /// routine returns 1 if initialization routine X was successfully + /// unregistered and it returns 0 if X was not on the list of initialization + /// routines. + int sqlite3_cancel_auto_extension( + ffi.Pointer> xEntryPoint, ) { - return _sqlite3_progress_handler(arg0, arg1, arg2, arg3); + return _sqlite3_cancel_auto_extension(xEntryPoint); } - late final _sqlite3_progress_handlerPtr = + late final _sqlite3_cancel_auto_extensionPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, - ) + ffi.Int Function(ffi.Pointer>) > - >('sqlite3_progress_handler'); - late final _sqlite3_progress_handler = _sqlite3_progress_handlerPtr + >('sqlite3_cancel_auto_extension'); + late final _sqlite3_cancel_auto_extension = _sqlite3_cancel_auto_extensionPtr .asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, - ) + int Function(ffi.Pointer>) >(); - /// CAPI3REF: Opening A New Database Connection - /// CONSTRUCTOR: sqlite3 - /// - /// ^These routines open an SQLite database file as specified by the - /// filename argument. ^The filename argument is interpreted as UTF-8 for - /// sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte - /// order for sqlite3_open16(). ^(A [database connection] handle is usually - /// returned in *ppDb, even if an error occurs. The only exception is that - /// if SQLite is unable to allocate memory to hold the [sqlite3] object, - /// a NULL will be written into *ppDb instead of a pointer to the [sqlite3] - /// object.)^ ^(If the database is opened (and/or created) successfully, then - /// [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The - /// [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain - /// an English language description of the error following a failure of any - /// of the sqlite3_open() routines. - /// - /// ^The default encoding will be UTF-8 for databases created using - /// sqlite3_open() or sqlite3_open_v2(). ^The default encoding for databases - /// created using sqlite3_open16() will be UTF-16 in the native byte order. - /// - /// Whether or not an error occurs when it is opened, resources - /// associated with the [database connection] handle should be released by - /// passing it to [sqlite3_close()] when it is no longer required. + /// CAPI3REF: Count The Number Of Rows Modified + /// METHOD: sqlite3 /// - /// The sqlite3_open_v2() interface works like sqlite3_open() - /// except that it accepts two additional parameters for additional control - /// over the new database connection. ^(The flags parameter to - /// sqlite3_open_v2() must include, at a minimum, one of the following - /// three flag combinations:)^ + /// ^This function returns the number of rows modified, inserted or + /// deleted by the most recently completed INSERT, UPDATE or DELETE + /// statement on the database connection specified by the only parameter. + /// ^Executing any other type of SQL statement does not modify the value + /// returned by this function. /// - ///
- /// ^(
[SQLITE_OPEN_READONLY]
- ///
The database is opened in read-only mode. If the database does not - /// already exist, an error is returned.
)^ + /// ^Only changes made directly by the INSERT, UPDATE or DELETE statement are + /// considered - auxiliary changes caused by [CREATE TRIGGER | triggers], + /// [foreign key actions] or [REPLACE] constraint resolution are not counted. /// - /// ^(
[SQLITE_OPEN_READWRITE]
- ///
The database is opened for reading and writing if possible, or reading - /// only if the file is write protected by the operating system. In either - /// case the database must already exist, otherwise an error is returned.
)^ + /// Changes to a view that are intercepted by + /// [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value + /// returned by sqlite3_changes() immediately after an INSERT, UPDATE or + /// DELETE statement run on a view is always zero. Only changes made to real + /// tables are counted. /// - /// ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
- ///
The database is opened for reading and writing, and is created if - /// it does not already exist. This is the behavior that is always used for - /// sqlite3_open() and sqlite3_open16().
)^ - ///
+ /// Things are more complicated if the sqlite3_changes() function is + /// executed while a trigger program is running. This may happen if the + /// program uses the [changes() SQL function], or if some other callback + /// function invokes sqlite3_changes() directly. Essentially: /// - /// In addition to the required flags, the following optional flags are - /// also supported: + ///
    + ///
  • ^(Before entering a trigger program the value returned by + /// sqlite3_changes() function is saved. After the trigger program + /// has finished, the original value is restored.)^ /// - ///
    - /// ^(
    [SQLITE_OPEN_URI]
    - ///
    The filename can be interpreted as a URI if this flag is set.
    )^ + ///
  • ^(Within a trigger program each INSERT, UPDATE and DELETE + /// statement sets the value returned by sqlite3_changes() + /// upon completion as normal. Of course, this value will not include + /// any changes performed by sub-triggers, as the sqlite3_changes() + /// value will be saved and restored after each sub-trigger has run.)^ + ///
/// - /// ^(
[SQLITE_OPEN_MEMORY]
- ///
The database will be opened as an in-memory database. The database - /// is named by the "filename" argument for the purposes of cache-sharing, - /// if shared cache mode is enabled, but the "filename" is otherwise ignored. - ///
)^ + /// ^This means that if the changes() SQL function (or similar) is used + /// by the first INSERT, UPDATE or DELETE statement within a trigger, it + /// returns the value as set when the calling statement began executing. + /// ^If it is used by the second or subsequent such statement within a trigger + /// program, the value returned reflects the number of rows modified by the + /// previous INSERT, UPDATE or DELETE statement within the same trigger. /// - /// ^(
[SQLITE_OPEN_NOMUTEX]
- ///
The new database connection will use the "multi-thread" - /// [threading mode].)^ This means that separate threads are allowed - /// to use SQLite at the same time, as long as each thread is using - /// a different [database connection]. + /// If a separate thread makes changes on the same database connection + /// while [sqlite3_changes()] is running then the value returned + /// is unpredictable and not meaningful. /// - /// ^(
[SQLITE_OPEN_FULLMUTEX]
- ///
The new database connection will use the "serialized" - /// [threading mode].)^ This means the multiple threads can safely - /// attempt to use the same database connection at the same time. - /// (Mutexes will block any actual concurrency, but in this mode - /// there is no harm in trying.) + /// See also: + ///
    + ///
  • the [sqlite3_total_changes()] interface + ///
  • the [count_changes pragma] + ///
  • the [changes() SQL function] + ///
  • the [data_version pragma] + ///
+ int sqlite3_changes(ffi.Pointer arg0) { + return _sqlite3_changes(arg0); + } + + late final _sqlite3_changesPtr = + _lookup)>>( + 'sqlite3_changes', + ); + late final _sqlite3_changes = _sqlite3_changesPtr + .asFunction)>(); + + /// CAPI3REF: Reset All Bindings On A Prepared Statement + /// METHOD: sqlite3_stmt /// - /// ^(
[SQLITE_OPEN_SHAREDCACHE]
- ///
The database is opened [shared cache] enabled, overriding - /// the default shared cache setting provided by - /// [sqlite3_enable_shared_cache()].)^ + /// ^Contrary to the intuition of many, [sqlite3_reset()] does not reset + /// the [sqlite3_bind_blob | bindings] on a [prepared statement]. + /// ^Use this routine to reset all host parameters to NULL. + int sqlite3_clear_bindings(ffi.Pointer arg0) { + return _sqlite3_clear_bindings(arg0); + } + + late final _sqlite3_clear_bindingsPtr = + _lookup)>>( + 'sqlite3_clear_bindings', + ); + late final _sqlite3_clear_bindings = _sqlite3_clear_bindingsPtr + .asFunction)>(); + + /// CAPI3REF: Closing A Database Connection + /// DESTRUCTOR: sqlite3 /// - /// ^(
[SQLITE_OPEN_PRIVATECACHE]
- ///
The database is opened [shared cache] disabled, overriding - /// the default shared cache setting provided by - /// [sqlite3_enable_shared_cache()].)^ + /// ^The sqlite3_close() and sqlite3_close_v2() routines are destructors + /// for the [sqlite3] object. + /// ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if + /// the [sqlite3] object is successfully destroyed and all associated + /// resources are deallocated. /// - /// [[OPEN_NOFOLLOW]] ^(
[SQLITE_OPEN_NOFOLLOW]
- ///
The database filename is not allowed to be a symbolic link
- /// )^ + /// Ideally, applications should [sqlite3_finalize | finalize] all + /// [prepared statements], [sqlite3_blob_close | close] all [BLOB handles], and + /// [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated + /// with the [sqlite3] object prior to attempting to close the object. + /// ^If the database connection is associated with unfinalized prepared + /// statements, BLOB handlers, and/or unfinished sqlite3_backup objects then + /// sqlite3_close() will leave the database connection open and return + /// [SQLITE_BUSY]. ^If sqlite3_close_v2() is called with unfinalized prepared + /// statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups, + /// it returns [SQLITE_OK] regardless, but instead of deallocating the database + /// connection immediately, it marks the database connection as an unusable + /// "zombie" and makes arrangements to automatically deallocate the database + /// connection after all prepared statements are finalized, all BLOB handles + /// are closed, and all backups have finished. The sqlite3_close_v2() interface + /// is intended for use with host languages that are garbage collected, and + /// where the order in which destructors are called is arbitrary. /// - /// If the 3rd parameter to sqlite3_open_v2() is not one of the - /// required combinations shown above optionally combined with other - /// [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] - /// then the behavior is undefined. + /// ^If an [sqlite3] object is destroyed while a transaction is open, + /// the transaction is automatically rolled back. /// - /// ^The fourth parameter to sqlite3_open_v2() is the name of the - /// [sqlite3_vfs] object that defines the operating system interface that - /// the new database connection should use. ^If the fourth parameter is - /// a NULL pointer then the default [sqlite3_vfs] object is used. - /// - /// ^If the filename is ":memory:", then a private, temporary in-memory database - /// is created for the connection. ^This in-memory database will vanish when - /// the database connection is closed. Future versions of SQLite might - /// make use of additional special filenames that begin with the ":" character. - /// It is recommended that when a database filename actually does begin with - /// a ":" character you should prefix the filename with a pathname such as - /// "./" to avoid ambiguity. - /// - /// ^If the filename is an empty string, then a private, temporary - /// on-disk database will be created. ^This private database will be - /// automatically deleted as soon as the database connection is closed. - /// - /// [[URI filenames in sqlite3_open()]]

URI Filenames

- /// - /// ^If [URI filename] interpretation is enabled, and the filename argument - /// begins with "file:", then the filename is interpreted as a URI. ^URI - /// filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is - /// set in the third argument to sqlite3_open_v2(), or if it has - /// been enabled globally using the [SQLITE_CONFIG_URI] option with the - /// [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. - /// URI filename interpretation is turned off - /// by default, but future releases of SQLite might enable URI filename - /// interpretation by default. See "[URI filenames]" for additional - /// information. - /// - /// URI filenames are parsed according to RFC 3986. ^If the URI contains an - /// authority, then it must be either an empty string or the string - /// "localhost". ^If the authority is not an empty string or "localhost", an - /// error is returned to the caller. ^The fragment component of a URI, if - /// present, is ignored. - /// - /// ^SQLite uses the path component of the URI as the name of the disk file - /// which contains the database. ^If the path begins with a '/' character, - /// then it is interpreted as an absolute path. ^If the path does not begin - /// with a '/' (meaning that the authority section is omitted from the URI) - /// then the path is interpreted as a relative path. - /// ^(On windows, the first component of an absolute path - /// is a drive specification (e.g. "C:").)^ - /// - /// [[core URI query parameters]] - /// The query component of a URI may contain parameters that are interpreted - /// either by SQLite itself, or by a [VFS | custom VFS implementation]. - /// SQLite and its built-in [VFSes] interpret the - /// following query parameters: - /// - ///
    - ///
  • vfs: ^The "vfs" parameter may be used to specify the name of - /// a VFS object that provides the operating system interface that should - /// be used to access the database file on disk. ^If this option is set to - /// an empty string the default VFS object is used. ^Specifying an unknown - /// VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is - /// present, then the VFS specified by the option takes precedence over - /// the value passed as the fourth parameter to sqlite3_open_v2(). - /// - ///
  • mode: ^(The mode parameter may be set to either "ro", "rw", - /// "rwc", or "memory". Attempting to set it to any other value is - /// an error)^. - /// ^If "ro" is specified, then the database is opened for read-only - /// access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the - /// third argument to sqlite3_open_v2(). ^If the mode option is set to - /// "rw", then the database is opened for read-write (but not create) - /// access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had - /// been set. ^Value "rwc" is equivalent to setting both - /// SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is - /// set to "memory" then a pure [in-memory database] that never reads - /// or writes from disk is used. ^It is an error to specify a value for - /// the mode parameter that is less restrictive than that specified by - /// the flags passed in the third parameter to sqlite3_open_v2(). - /// - ///
  • cache: ^The cache parameter may be set to either "shared" or - /// "private". ^Setting it to "shared" is equivalent to setting the - /// SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to - /// sqlite3_open_v2(). ^Setting the cache parameter to "private" is - /// equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. - /// ^If sqlite3_open_v2() is used and the "cache" parameter is present in - /// a URI filename, its value overrides any behavior requested by setting - /// SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. - /// - ///
  • psow: ^The psow parameter indicates whether or not the - /// [powersafe overwrite] property does or does not apply to the - /// storage media on which the database file resides. - /// - ///
  • nolock: ^The nolock parameter is a boolean query parameter - /// which if set disables file locking in rollback journal modes. This - /// is useful for accessing a database on a filesystem that does not - /// support locking. Caution: Database corruption might result if two - /// or more processes write to the same database and any one of those - /// processes uses nolock=1. - /// - ///
  • immutable: ^The immutable parameter is a boolean query - /// parameter that indicates that the database file is stored on - /// read-only media. ^When immutable is set, SQLite assumes that the - /// database file cannot be changed, even by a process with higher - /// privilege, and so the database is opened read-only and all locking - /// and change detection is disabled. Caution: Setting the immutable - /// property on a database file that does in fact change can result - /// in incorrect query results and/or [SQLITE_CORRUPT] errors. - /// See also: [SQLITE_IOCAP_IMMUTABLE]. - /// - ///
- /// - /// ^Specifying an unknown parameter in the query component of a URI is not an - /// error. Future versions of SQLite might understand additional query - /// parameters. See "[query parameters with special meaning to SQLite]" for - /// additional information. - /// - /// [[URI filename examples]]

URI filename examples

- /// - /// - ///
URI filenames Results - ///
file:data.db - /// Open the file "data.db" in the current directory. - ///
file:/home/fred/data.db
- /// file:///home/fred/data.db
- /// file://localhost/home/fred/data.db
- /// Open the database file "/home/fred/data.db". - ///
file://darkstar/home/fred/data.db - /// An error. "darkstar" is not a recognized authority. - ///
- /// file:///C:/Documents%20and%20Settings/fred/Desktop/data.db - /// Windows only: Open the file "data.db" on fred's desktop on drive - /// C:. Note that the %20 escaping in this example is not strictly - /// necessary - space characters can be used literally - /// in URI filenames. - ///
file:data.db?mode=ro&cache=private - /// Open file "data.db" in the current directory for read-only access. - /// Regardless of whether or not shared-cache mode is enabled by - /// default, use a private cache. - ///
file:/home/fred/data.db?vfs=unix-dotfile - /// Open file "/home/fred/data.db". Use the special VFS "unix-dotfile" - /// that uses dot-files in place of posix advisory locking. - ///
file:data.db?mode=readonly - /// An error. "readonly" is not a valid option for the "mode" parameter. - ///
+ /// The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] + /// must be either a NULL + /// pointer or an [sqlite3] object pointer obtained + /// from [sqlite3_open()], [sqlite3_open16()], or + /// [sqlite3_open_v2()], and not previously closed. + /// ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer + /// argument is a harmless no-op. + int sqlite3_close(ffi.Pointer arg0) { + return _sqlite3_close(arg0); + } + + late final _sqlite3_closePtr = + _lookup)>>( + 'sqlite3_close', + ); + late final _sqlite3_close = _sqlite3_closePtr + .asFunction)>(); + + int sqlite3_close_v2(ffi.Pointer arg0) { + return _sqlite3_close_v2(arg0); + } + + late final _sqlite3_close_v2Ptr = + _lookup)>>( + 'sqlite3_close_v2', + ); + late final _sqlite3_close_v2 = _sqlite3_close_v2Ptr + .asFunction)>(); + + /// CAPI3REF: Collation Needed Callbacks + /// METHOD: sqlite3 /// - /// ^URI hexadecimal escape sequences (%HH) are supported within the path and - /// query components of a URI. A hexadecimal escape sequence consists of a - /// percent sign - "%" - followed by exactly two hexadecimal digits - /// specifying an octet value. ^Before the path or query components of a - /// URI filename are interpreted, they are encoded using UTF-8 and all - /// hexadecimal escape sequences replaced by a single byte containing the - /// corresponding octet. If this process generates an invalid UTF-8 encoding, - /// the results are undefined. + /// ^To avoid having to register all collation sequences before a database + /// can be used, a single callback function may be registered with the + /// [database connection] to be invoked whenever an undefined collation + /// sequence is required. /// - /// Note to Windows users: The encoding used for the filename argument - /// of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever - /// codepage is currently defined. Filenames containing international - /// characters must be converted to UTF-8 prior to passing them into - /// sqlite3_open() or sqlite3_open_v2(). + /// ^If the function is registered using the sqlite3_collation_needed() API, + /// then it is passed the names of undefined collation sequences as strings + /// encoded in UTF-8. ^If sqlite3_collation_needed16() is used, + /// the names are passed as UTF-16 in machine native byte order. + /// ^A call to either function replaces the existing collation-needed callback. /// - /// Note to Windows Runtime users: The temporary directory must be set - /// prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various - /// features that require the use of temporary files may fail. + /// ^(When the callback is invoked, the first argument passed is a copy + /// of the second argument to sqlite3_collation_needed() or + /// sqlite3_collation_needed16(). The second argument is the database + /// connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], + /// or [SQLITE_UTF16LE], indicating the most desirable form of the collation + /// sequence function required. The fourth parameter is the name of the + /// required collation sequence.)^ /// - /// See also: [sqlite3_temp_directory] - int sqlite3_open( - ffi.Pointer filename, - ffi.Pointer> ppDb, + /// The callback function should register the desired collation using + /// [sqlite3_create_collation()], [sqlite3_create_collation16()], or + /// [sqlite3_create_collation_v2()]. + int sqlite3_collation_needed( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + arg2, ) { - return _sqlite3_open(filename, ppDb); + return _sqlite3_collation_needed(arg0, arg1, arg2); } - late final _sqlite3_openPtr = + late final _sqlite3_collation_neededPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + >, ) > - >('sqlite3_open'); - late final _sqlite3_open = _sqlite3_openPtr + >('sqlite3_collation_needed'); + late final _sqlite3_collation_needed = _sqlite3_collation_neededPtr .asFunction< - int Function(ffi.Pointer, ffi.Pointer>) - >(); - - int sqlite3_open16( - ffi.Pointer filename, - ffi.Pointer> ppDb, - ) { - return _sqlite3_open16(filename, ppDb); - } - - late final _sqlite3_open16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, - ) - > - >('sqlite3_open16'); - late final _sqlite3_open16 = _sqlite3_open16Ptr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer>) + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + >, + ) >(); - int sqlite3_open_v2( - ffi.Pointer filename, - ffi.Pointer> ppDb, - int flags, - ffi.Pointer zVfs, + int sqlite3_collation_needed16( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + arg2, ) { - return _sqlite3_open_v2(filename, ppDb, flags, zVfs); + return _sqlite3_collation_needed16(arg0, arg1, arg2); } - late final _sqlite3_open_v2Ptr = + late final _sqlite3_collation_needed16Ptr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + >, ) > - >('sqlite3_open_v2'); - late final _sqlite3_open_v2 = _sqlite3_open_v2Ptr + >('sqlite3_collation_needed16'); + late final _sqlite3_collation_needed16 = _sqlite3_collation_needed16Ptr .asFunction< int Function( - ffi.Pointer, - ffi.Pointer>, - int, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + >, ) >(); - /// CAPI3REF: Obtain Values For URI Parameters + /// CAPI3REF: Result Values From A Query + /// KEYWORDS: {column access functions} + /// METHOD: sqlite3_stmt /// - /// These are utility routines, useful to [VFS|custom VFS implementations], - /// that check if a database file was a URI that contained a specific query - /// parameter, and if so obtains the value of that query parameter. + /// Summary: + ///
+ ///
sqlite3_column_blobBLOB result + ///
sqlite3_column_doubleREAL result + ///
sqlite3_column_int32-bit INTEGER result + ///
sqlite3_column_int6464-bit INTEGER result + ///
sqlite3_column_textUTF-8 TEXT result + ///
sqlite3_column_text16UTF-16 TEXT result + ///
sqlite3_column_valueThe result as an + /// [sqlite3_value|unprotected sqlite3_value] object. + ///
    + ///
sqlite3_column_bytesSize of a BLOB + /// or a UTF-8 TEXT result in bytes + ///
sqlite3_column_bytes16   + /// →  Size of UTF-16 + /// TEXT in bytes + ///
sqlite3_column_typeDefault + /// datatype of the result + ///
/// - /// The first parameter to these interfaces (hereafter referred to - /// as F) must be one of: - ///
    - ///
  • A database filename pointer created by the SQLite core and - /// passed into the xOpen() method of a VFS implemention, or - ///
  • A filename obtained from [sqlite3_db_filename()], or - ///
  • A new filename constructed using [sqlite3_create_filename()]. - ///
- /// If the F parameter is not one of the above, then the behavior is - /// undefined and probably undesirable. Older versions of SQLite were - /// more tolerant of invalid F parameters than newer versions. + /// Details: /// - /// If F is a suitable filename (as described in the previous paragraph) - /// and if P is the name of the query parameter, then - /// sqlite3_uri_parameter(F,P) returns the value of the P - /// parameter if it exists or a NULL pointer if P does not appear as a - /// query parameter on F. If P is a query parameter of F and it - /// has no explicit value, then sqlite3_uri_parameter(F,P) returns - /// a pointer to an empty string. + /// ^These routines return information about a single column of the current + /// result row of a query. ^In every case the first argument is a pointer + /// to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] + /// that was returned from [sqlite3_prepare_v2()] or one of its variants) + /// and the second argument is the index of the column for which information + /// should be returned. ^The leftmost column of the result set has the index 0. + /// ^The number of columns in the result can be determined using + /// [sqlite3_column_count()]. /// - /// The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean - /// parameter and returns true (1) or false (0) according to the value - /// of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the - /// value of query parameter P is one of "yes", "true", or "on" in any - /// case or if the value begins with a non-zero number. The - /// sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of - /// query parameter P is one of "no", "false", or "off" in any case or - /// if the value begins with a numeric zero. If P is not a query - /// parameter on F or if the value of P does not match any of the - /// above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). + /// If the SQL statement does not currently point to a valid row, or if the + /// column index is out of range, the result is undefined. + /// These routines may only be called when the most recent call to + /// [sqlite3_step()] has returned [SQLITE_ROW] and neither + /// [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. + /// If any of these routines are called after [sqlite3_reset()] or + /// [sqlite3_finalize()] or after [sqlite3_step()] has returned + /// something other than [SQLITE_ROW], the results are undefined. + /// If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] + /// are called from a different thread while any of these routines + /// are pending, then the results are undefined. /// - /// The sqlite3_uri_int64(F,P,D) routine converts the value of P into a - /// 64-bit signed integer and returns that integer, or D if P does not - /// exist. If the value of P is something other than an integer, then - /// zero is returned. + /// The first six interfaces (_blob, _double, _int, _int64, _text, and _text16) + /// each return the value of a result column in a specific data format. If + /// the result column is not initially in the requested format (for example, + /// if the query returns an integer but the sqlite3_column_text() interface + /// is used to extract the value) then an automatic type conversion is performed. /// - /// The sqlite3_uri_key(F,N) returns a pointer to the name (not - /// the value) of the N-th query parameter for filename F, or a NULL - /// pointer if N is less than zero or greater than the number of query - /// parameters minus 1. The N value is zero-based so N should be 0 to obtain - /// the name of the first query parameter, 1 for the second parameter, and - /// so forth. + /// ^The sqlite3_column_type() routine returns the + /// [SQLITE_INTEGER | datatype code] for the initial data type + /// of the result column. ^The returned value is one of [SQLITE_INTEGER], + /// [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. + /// The return value of sqlite3_column_type() can be used to decide which + /// of the first six interface should be used to extract the column value. + /// The value returned by sqlite3_column_type() is only meaningful if no + /// automatic type conversions have occurred for the value in question. + /// After a type conversion, the result of calling sqlite3_column_type() + /// is undefined, though harmless. Future + /// versions of SQLite may change the behavior of sqlite3_column_type() + /// following a type conversion. /// - /// If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and - /// sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and - /// is not a database file pathname pointer that the SQLite core passed - /// into the xOpen VFS method, then the behavior of this routine is undefined - /// and probably undesirable. + /// If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes() + /// or sqlite3_column_bytes16() interfaces can be used to determine the size + /// of that BLOB or string. /// - /// Beginning with SQLite [version 3.31.0] ([dateof:3.31.0]) the input F - /// parameter can also be the name of a rollback journal file or WAL file - /// in addition to the main database file. Prior to version 3.31.0, these - /// routines would only work if F was the name of the main database file. - /// When the F parameter is the name of the rollback journal or WAL file, - /// it has access to all the same query parameters as were found on the - /// main database file. + /// ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() + /// routine returns the number of bytes in that BLOB or string. + /// ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts + /// the string to UTF-8 and then returns the number of bytes. + /// ^If the result is a numeric value then sqlite3_column_bytes() uses + /// [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns + /// the number of bytes in that string. + /// ^If the result is NULL, then sqlite3_column_bytes() returns zero. /// - /// See the [URI filename] documentation for additional information. - ffi.Pointer sqlite3_uri_parameter( - ffi.Pointer zFilename, - ffi.Pointer zParam, - ) { - return _sqlite3_uri_parameter(zFilename, zParam); - } - - late final _sqlite3_uri_parameterPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('sqlite3_uri_parameter'); - late final _sqlite3_uri_parameter = _sqlite3_uri_parameterPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - int sqlite3_uri_boolean( - ffi.Pointer zFile, - ffi.Pointer zParam, - int bDefault, - ) { - return _sqlite3_uri_boolean(zFile, zParam, bDefault); - } - - late final _sqlite3_uri_booleanPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('sqlite3_uri_boolean'); - late final _sqlite3_uri_boolean = _sqlite3_uri_booleanPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - int sqlite3_uri_int64( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _sqlite3_uri_int64(arg0, arg1, arg2); - } - - late final _sqlite3_uri_int64Ptr = - _lookup< - ffi.NativeFunction< - sqlite3_int64 Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_int64, - ) - > - >('sqlite3_uri_int64'); - late final _sqlite3_uri_int64 = _sqlite3_uri_int64Ptr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); - - ffi.Pointer sqlite3_uri_key( - ffi.Pointer zFilename, - int N, - ) { - return _sqlite3_uri_key(zFilename, N); - } - - late final _sqlite3_uri_keyPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_uri_key'); - late final _sqlite3_uri_key = _sqlite3_uri_keyPtr - .asFunction Function(ffi.Pointer, int)>(); - - /// CAPI3REF: Translate filenames + /// ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() + /// routine returns the number of bytes in that BLOB or string. + /// ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts + /// the string to UTF-16 and then returns the number of bytes. + /// ^If the result is a numeric value then sqlite3_column_bytes16() uses + /// [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns + /// the number of bytes in that string. + /// ^If the result is NULL, then sqlite3_column_bytes16() returns zero. /// - /// These routines are available to [VFS|custom VFS implementations] for - /// translating filenames between the main database file, the journal file, - /// and the WAL file. + /// ^The values returned by [sqlite3_column_bytes()] and + /// [sqlite3_column_bytes16()] do not include the zero terminators at the end + /// of the string. ^For clarity: the values returned by + /// [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of + /// bytes in the string, not the number of characters. /// - /// If F is the name of an sqlite database file, journal file, or WAL file - /// passed by the SQLite core into the VFS, then sqlite3_filename_database(F) - /// returns the name of the corresponding database file. + /// ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), + /// even empty strings, are always zero-terminated. ^The return + /// value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. /// - /// If F is the name of an sqlite database file, journal file, or WAL file - /// passed by the SQLite core into the VFS, or if F is a database filename - /// obtained from [sqlite3_db_filename()], then sqlite3_filename_journal(F) - /// returns the name of the corresponding rollback journal file. + /// Warning: ^The object returned by [sqlite3_column_value()] is an + /// [unprotected sqlite3_value] object. In a multithreaded environment, + /// an unprotected sqlite3_value object may only be used safely with + /// [sqlite3_bind_value()] and [sqlite3_result_value()]. + /// If the [unprotected sqlite3_value] object returned by + /// [sqlite3_column_value()] is used in any other way, including calls + /// to routines like [sqlite3_value_int()], [sqlite3_value_text()], + /// or [sqlite3_value_bytes()], the behavior is not threadsafe. + /// Hence, the sqlite3_column_value() interface + /// is normally only useful within the implementation of + /// [application-defined SQL functions] or [virtual tables], not within + /// top-level application code. /// - /// If F is the name of an sqlite database file, journal file, or WAL file - /// that was passed by the SQLite core into the VFS, or if F is a database - /// filename obtained from [sqlite3_db_filename()], then - /// sqlite3_filename_wal(F) returns the name of the corresponding - /// WAL file. + /// The these routines may attempt to convert the datatype of the result. + /// ^For example, if the internal representation is FLOAT and a text result + /// is requested, [sqlite3_snprintf()] is used internally to perform the + /// conversion automatically. ^(The following table details the conversions + /// that are applied: /// - /// In all of the above, if F is not the name of a database, journal or WAL - /// filename passed into the VFS from the SQLite core and F is not the - /// return value from [sqlite3_db_filename()], then the result is - /// undefined and is likely a memory access violation. - ffi.Pointer sqlite3_filename_database(ffi.Pointer arg0) { - return _sqlite3_filename_database(arg0); + ///
+ /// + ///
Internal
Type
Requested
Type
Conversion + /// + ///
NULL INTEGER Result is 0 + ///
NULL FLOAT Result is 0.0 + ///
NULL TEXT Result is a NULL pointer + ///
NULL BLOB Result is a NULL pointer + ///
INTEGER FLOAT Convert from integer to float + ///
INTEGER TEXT ASCII rendering of the integer + ///
INTEGER BLOB Same as INTEGER->TEXT + ///
FLOAT INTEGER [CAST] to INTEGER + ///
FLOAT TEXT ASCII rendering of the float + ///
FLOAT BLOB [CAST] to BLOB + ///
TEXT INTEGER [CAST] to INTEGER + ///
TEXT FLOAT [CAST] to REAL + ///
TEXT BLOB No change + ///
BLOB INTEGER [CAST] to INTEGER + ///
BLOB FLOAT [CAST] to REAL + ///
BLOB TEXT Add a zero terminator if needed + ///
+ ///
)^ + /// + /// Note that when type conversions occur, pointers returned by prior + /// calls to sqlite3_column_blob(), sqlite3_column_text(), and/or + /// sqlite3_column_text16() may be invalidated. + /// Type conversions and pointer invalidations might occur + /// in the following cases: + /// + ///
    + ///
  • The initial content is a BLOB and sqlite3_column_text() or + /// sqlite3_column_text16() is called. A zero-terminator might + /// need to be added to the string.
  • + ///
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or + /// sqlite3_column_text16() is called. The content must be converted + /// to UTF-16.
  • + ///
  • The initial content is UTF-16 text and sqlite3_column_bytes() or + /// sqlite3_column_text() is called. The content must be converted + /// to UTF-8.
  • + ///
+ /// + /// ^Conversions between UTF-16be and UTF-16le are always done in place and do + /// not invalidate a prior pointer, though of course the content of the buffer + /// that the prior pointer references will have been modified. Other kinds + /// of conversion are done in place when it is possible, but sometimes they + /// are not possible and in those cases prior pointers are invalidated. + /// + /// The safest policy is to invoke these routines + /// in one of the following ways: + /// + ///
    + ///
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • + ///
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • + ///
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • + ///
+ /// + /// In other words, you should call sqlite3_column_text(), + /// sqlite3_column_blob(), or sqlite3_column_text16() first to force the result + /// into the desired format, then invoke sqlite3_column_bytes() or + /// sqlite3_column_bytes16() to find the size of the result. Do not mix calls + /// to sqlite3_column_text() or sqlite3_column_blob() with calls to + /// sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() + /// with calls to sqlite3_column_bytes(). + /// + /// ^The pointers returned are valid until a type conversion occurs as + /// described above, or until [sqlite3_step()] or [sqlite3_reset()] or + /// [sqlite3_finalize()] is called. ^The memory space used to hold strings + /// and BLOBs is freed automatically. Do not pass the pointers returned + /// from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into + /// [sqlite3_free()]. + /// + /// As long as the input parameters are correct, these routines will only + /// fail if an out-of-memory error occurs during a format conversion. + /// Only the following subset of interfaces are subject to out-of-memory + /// errors: + /// + ///
    + ///
  • sqlite3_column_blob() + ///
  • sqlite3_column_text() + ///
  • sqlite3_column_text16() + ///
  • sqlite3_column_bytes() + ///
  • sqlite3_column_bytes16() + ///
+ /// + /// If an out-of-memory error occurs, then the return value from these + /// routines is the same as if the column had contained an SQL NULL value. + /// Valid SQL NULL returns can be distinguished from out-of-memory errors + /// by invoking the [sqlite3_errcode()] immediately after the suspect + /// return value is obtained and before any + /// other SQLite interface is called on the same [database connection]. + ffi.Pointer sqlite3_column_blob( + ffi.Pointer arg0, + int iCol, + ) { + return _sqlite3_column_blob(arg0, iCol); } - late final _sqlite3_filename_databasePtr = + late final _sqlite3_column_blobPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_filename_database'); - late final _sqlite3_filename_database = _sqlite3_filename_databasePtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_column_blob'); + late final _sqlite3_column_blob = _sqlite3_column_blobPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - ffi.Pointer sqlite3_filename_journal(ffi.Pointer arg0) { - return _sqlite3_filename_journal(arg0); + int sqlite3_column_bytes(ffi.Pointer arg0, int iCol) { + return _sqlite3_column_bytes(arg0, iCol); } - late final _sqlite3_filename_journalPtr = + late final _sqlite3_column_bytesPtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_filename_journal'); - late final _sqlite3_filename_journal = _sqlite3_filename_journalPtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction, ffi.Int)> + >('sqlite3_column_bytes'); + late final _sqlite3_column_bytes = _sqlite3_column_bytesPtr + .asFunction, int)>(); - ffi.Pointer sqlite3_filename_wal(ffi.Pointer arg0) { - return _sqlite3_filename_wal(arg0); + int sqlite3_column_bytes16(ffi.Pointer arg0, int iCol) { + return _sqlite3_column_bytes16(arg0, iCol); } - late final _sqlite3_filename_walPtr = + late final _sqlite3_column_bytes16Ptr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_filename_wal'); - late final _sqlite3_filename_wal = _sqlite3_filename_walPtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction, ffi.Int)> + >('sqlite3_column_bytes16'); + late final _sqlite3_column_bytes16 = _sqlite3_column_bytes16Ptr + .asFunction, int)>(); - /// CAPI3REF: Database File Corresponding To A Journal + /// CAPI3REF: Number Of Columns In A Result Set + /// METHOD: sqlite3_stmt /// - /// ^If X is the name of a rollback or WAL-mode journal file that is - /// passed into the xOpen method of [sqlite3_vfs], then - /// sqlite3_database_file_object(X) returns a pointer to the [sqlite3_file] - /// object that represents the main database file. + /// ^Return the number of columns in the result set returned by the + /// [prepared statement]. ^If this routine returns 0, that means the + /// [prepared statement] returns no data (for example an [UPDATE]). + /// ^However, just because this routine returns a positive number does not + /// mean that one or more rows of data will be returned. ^A SELECT statement + /// will always have a positive sqlite3_column_count() but depending on the + /// WHERE clause constraints and the table content, it might return no rows. /// - /// This routine is intended for use in custom [VFS] implementations - /// only. It is not a general-purpose interface. - /// The argument sqlite3_file_object(X) must be a filename pointer that - /// has been passed into [sqlite3_vfs].xOpen method where the - /// flags parameter to xOpen contains one of the bits - /// [SQLITE_OPEN_MAIN_JOURNAL] or [SQLITE_OPEN_WAL]. Any other use - /// of this routine results in undefined and probably undesirable - /// behavior. - ffi.Pointer sqlite3_database_file_object( - ffi.Pointer arg0, - ) { - return _sqlite3_database_file_object(arg0); + /// See also: [sqlite3_data_count()] + int sqlite3_column_count(ffi.Pointer pStmt) { + return _sqlite3_column_count(pStmt); } - late final _sqlite3_database_file_objectPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_database_file_object'); - late final _sqlite3_database_file_object = _sqlite3_database_file_objectPtr - .asFunction Function(ffi.Pointer)>(); + late final _sqlite3_column_countPtr = + _lookup)>>( + 'sqlite3_column_count', + ); + late final _sqlite3_column_count = _sqlite3_column_countPtr + .asFunction)>(); - /// CAPI3REF: Create and Destroy VFS Filenames + /// CAPI3REF: Source Of Data In A Query Result + /// METHOD: sqlite3_stmt /// - /// These interfces are provided for use by [VFS shim] implementations and - /// are not useful outside of that context. + /// ^These routines provide a means to determine the database, table, and + /// table column that is the origin of a particular result column in + /// [SELECT] statement. + /// ^The name of the database or table or column can be returned as + /// either a UTF-8 or UTF-16 string. ^The _database_ routines return + /// the database name, the _table_ routines return the table name, and + /// the origin_ routines return the column name. + /// ^The returned string is valid until the [prepared statement] is destroyed + /// using [sqlite3_finalize()] or until the statement is automatically + /// reprepared by the first call to [sqlite3_step()] for a particular run + /// or until the same information is requested + /// again in a different encoding. /// - /// The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of - /// database filename D with corresponding journal file J and WAL file W and - /// with N URI parameters key/values pairs in the array P. The result from - /// sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that - /// is safe to pass to routines like: - ///
    - ///
  • [sqlite3_uri_parameter()], - ///
  • [sqlite3_uri_boolean()], - ///
  • [sqlite3_uri_int64()], - ///
  • [sqlite3_uri_key()], - ///
  • [sqlite3_filename_database()], - ///
  • [sqlite3_filename_journal()], or - ///
  • [sqlite3_filename_wal()]. - ///
- /// If a memory allocation error occurs, sqlite3_create_filename() might - /// return a NULL pointer. The memory obtained from sqlite3_create_filename(X) - /// must be released by a corresponding call to sqlite3_free_filename(Y). + /// ^The names returned are the original un-aliased names of the + /// database, table, and column. /// - /// The P parameter in sqlite3_create_filename(D,J,W,N,P) should be an array - /// of 2*N pointers to strings. Each pair of pointers in this array corresponds - /// to a key and value for a query parameter. The P parameter may be a NULL - /// pointer if N is zero. None of the 2*N pointers in the P array may be - /// NULL pointers and key pointers should not be empty strings. - /// None of the D, J, or W parameters to sqlite3_create_filename(D,J,W,N,P) may - /// be NULL pointers, though they can be empty strings. + /// ^The first argument to these interfaces is a [prepared statement]. + /// ^These functions return information about the Nth result column returned by + /// the statement, where N is the second function argument. + /// ^The left-most column is column 0 for these routines. /// - /// The sqlite3_free_filename(Y) routine releases a memory allocation - /// previously obtained from sqlite3_create_filename(). Invoking - /// sqlite3_free_filename(Y) where Y is a NULL pointer is a harmless no-op. + /// ^If the Nth column returned by the statement is an expression or + /// subquery and is not a column value, then all of these functions return + /// NULL. ^These routines might also return NULL if a memory allocation error + /// occurs. ^Otherwise, they return the name of the attached database, table, + /// or column that query result column was extracted from. /// - /// If the Y parameter to sqlite3_free_filename(Y) is anything other - /// than a NULL pointer or a pointer previously acquired from - /// sqlite3_create_filename(), then bad things such as heap - /// corruption or segfaults may occur. The value Y should be - /// used again after sqlite3_free_filename(Y) has been called. This means - /// that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, - /// then the corresponding [sqlite3_module.xClose() method should also be - /// invoked prior to calling sqlite3_free_filename(Y). - ffi.Pointer sqlite3_create_filename( - ffi.Pointer zDatabase, - ffi.Pointer zJournal, - ffi.Pointer zWal, - int nParam, - ffi.Pointer> azParam, + /// ^As with all other SQLite APIs, those whose names end with "16" return + /// UTF-16 encoded strings and the other functions return UTF-8. + /// + /// ^These APIs are only available if the library was compiled with the + /// [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. + /// + /// If two or more threads call one or more + /// [sqlite3_column_database_name | column metadata interfaces] + /// for the same [prepared statement] and result column + /// at the same time then the results are undefined. + ffi.Pointer sqlite3_column_database_name( + ffi.Pointer arg0, + int arg1, ) { - return _sqlite3_create_filename(zDatabase, zJournal, zWal, nParam, azParam); + return _sqlite3_column_database_name(arg0, arg1); } - late final _sqlite3_create_filenamePtr = + late final _sqlite3_column_database_namePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_create_filename'); - late final _sqlite3_create_filename = _sqlite3_create_filenamePtr + >('sqlite3_column_database_name'); + late final _sqlite3_column_database_name = _sqlite3_column_database_namePtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - void sqlite3_free_filename(ffi.Pointer arg0) { - return _sqlite3_free_filename(arg0); + ffi.Pointer sqlite3_column_database_name16( + ffi.Pointer arg0, + int arg1, + ) { + return _sqlite3_column_database_name16(arg0, arg1); } - late final _sqlite3_free_filenamePtr = - _lookup)>>( - 'sqlite3_free_filename', - ); - late final _sqlite3_free_filename = _sqlite3_free_filenamePtr - .asFunction)>(); + late final _sqlite3_column_database_name16Ptr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_column_database_name16'); + late final _sqlite3_column_database_name16 = + _sqlite3_column_database_name16Ptr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - /// CAPI3REF: Error Codes And Messages - /// METHOD: sqlite3 + /// CAPI3REF: Declared Datatype Of A Query Result + /// METHOD: sqlite3_stmt /// - /// ^If the most recent sqlite3_* API call associated with - /// [database connection] D failed, then the sqlite3_errcode(D) interface - /// returns the numeric [result code] or [extended result code] for that - /// API call. - /// ^The sqlite3_extended_errcode() - /// interface is the same except that it always returns the - /// [extended result code] even when extended result codes are - /// disabled. + /// ^(The first parameter is a [prepared statement]. + /// If this statement is a [SELECT] statement and the Nth column of the + /// returned result set of that [SELECT] is a table column (not an + /// expression or subquery) then the declared type of the table + /// column is returned.)^ ^If the Nth column of the result set is an + /// expression or subquery, then a NULL pointer is returned. + /// ^The returned string is always UTF-8 encoded. /// - /// The values returned by sqlite3_errcode() and/or - /// sqlite3_extended_errcode() might change with each API call. - /// Except, there are some interfaces that are guaranteed to never - /// change the value of the error code. The error-code preserving - /// interfaces are: + /// ^(For example, given the database schema: /// - ///
    - ///
  • sqlite3_errcode() - ///
  • sqlite3_extended_errcode() - ///
  • sqlite3_errmsg() - ///
  • sqlite3_errmsg16() - ///
+ /// CREATE TABLE t1(c1 VARIANT); /// - /// ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language - /// text that describes the error, as either UTF-8 or UTF-16 respectively. - /// ^(Memory to hold the error message string is managed internally. - /// The application does not need to worry about freeing the result. - /// However, the error string might be overwritten or deallocated by - /// subsequent calls to other SQLite interface functions.)^ + /// and the following statement to be compiled: /// - /// ^The sqlite3_errstr() interface returns the English-language text - /// that describes the [result code], as UTF-8. - /// ^(Memory to hold the error message string is managed internally - /// and must not be freed by the application)^. + /// SELECT c1 + 1, c1 FROM t1; /// - /// When the serialized [threading mode] is in use, it might be the - /// case that a second error occurs on a separate thread in between - /// the time of the first error and the call to these interfaces. - /// When that happens, the second error will be reported since these - /// interfaces always report the most recent result. To avoid - /// this, each thread can obtain exclusive use of the [database connection] D - /// by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning - /// to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after - /// all calls to the interfaces listed here are completed. + /// this routine would return the string "VARIANT" for the second result + /// column (i==1), and a NULL pointer for the first result column (i==0).)^ /// - /// If an interface fails with SQLITE_MISUSE, that means the interface - /// was invoked incorrectly by the application. In that case, the - /// error code and message may or may not be set. - int sqlite3_errcode(ffi.Pointer db) { - return _sqlite3_errcode(db); - } - - late final _sqlite3_errcodePtr = - _lookup)>>( - 'sqlite3_errcode', - ); - late final _sqlite3_errcode = _sqlite3_errcodePtr - .asFunction)>(); - - int sqlite3_extended_errcode(ffi.Pointer db) { - return _sqlite3_extended_errcode(db); + /// ^SQLite uses dynamic run-time typing. ^So just because a column + /// is declared to contain a particular type does not mean that the + /// data stored in that column is of the declared type. SQLite is + /// strongly typed, but the typing is dynamic not static. ^Type + /// is associated with individual values, not with the containers + /// used to hold those values. + ffi.Pointer sqlite3_column_decltype( + ffi.Pointer arg0, + int arg1, + ) { + return _sqlite3_column_decltype(arg0, arg1); } - late final _sqlite3_extended_errcodePtr = - _lookup)>>( - 'sqlite3_extended_errcode', - ); - late final _sqlite3_extended_errcode = _sqlite3_extended_errcodePtr - .asFunction)>(); + late final _sqlite3_column_decltypePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_column_decltype'); + late final _sqlite3_column_decltype = _sqlite3_column_decltypePtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - ffi.Pointer sqlite3_errmsg(ffi.Pointer arg0) { - return _sqlite3_errmsg(arg0); + ffi.Pointer sqlite3_column_decltype16( + ffi.Pointer arg0, + int arg1, + ) { + return _sqlite3_column_decltype16(arg0, arg1); } - late final _sqlite3_errmsgPtr = + late final _sqlite3_column_decltype16Ptr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('sqlite3_errmsg'); - late final _sqlite3_errmsg = _sqlite3_errmsgPtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_column_decltype16'); + late final _sqlite3_column_decltype16 = _sqlite3_column_decltype16Ptr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - ffi.Pointer sqlite3_errmsg16(ffi.Pointer arg0) { - return _sqlite3_errmsg16(arg0); + double sqlite3_column_double(ffi.Pointer arg0, int iCol) { + return _sqlite3_column_double(arg0, iCol); } - late final _sqlite3_errmsg16Ptr = + late final _sqlite3_column_doublePtr = _lookup< - ffi.NativeFunction Function(ffi.Pointer)> - >('sqlite3_errmsg16'); - late final _sqlite3_errmsg16 = _sqlite3_errmsg16Ptr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction< + ffi.Double Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_column_double'); + late final _sqlite3_column_double = _sqlite3_column_doublePtr + .asFunction, int)>(); - ffi.Pointer sqlite3_errstr(int arg0) { - return _sqlite3_errstr(arg0); + int sqlite3_column_int(ffi.Pointer arg0, int iCol) { + return _sqlite3_column_int(arg0, iCol); } - late final _sqlite3_errstrPtr = - _lookup Function(ffi.Int)>>( - 'sqlite3_errstr', - ); - late final _sqlite3_errstr = _sqlite3_errstrPtr - .asFunction Function(int)>(); + late final _sqlite3_column_intPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_column_int'); + late final _sqlite3_column_int = _sqlite3_column_intPtr + .asFunction, int)>(); - /// CAPI3REF: Run-time Limits - /// METHOD: sqlite3 - /// - /// ^(This interface allows the size of various constructs to be limited - /// on a connection by connection basis. The first parameter is the - /// [database connection] whose limit is to be set or queried. The - /// second parameter is one of the [limit categories] that define a - /// class of constructs to be size limited. The third parameter is the - /// new limit for that construct.)^ - /// - /// ^If the new limit is a negative number, the limit is unchanged. - /// ^(For each limit category SQLITE_LIMIT_NAME there is a - /// [limits | hard upper bound] - /// set at compile-time by a C preprocessor macro called - /// [limits | SQLITE_MAX_NAME]. - /// (The "_LIMIT_" in the name is changed to "_MAX_".))^ - /// ^Attempts to increase a limit above its hard upper bound are - /// silently truncated to the hard upper bound. - /// - /// ^Regardless of whether or not the limit was changed, the - /// [sqlite3_limit()] interface returns the prior value of the limit. - /// ^Hence, to find the current value of a limit without changing it, - /// simply invoke this interface with the third parameter set to -1. - /// - /// Run-time limits are intended for use in applications that manage - /// both their own internal database and also databases that are controlled - /// by untrusted external sources. An example application might be a - /// web browser that has its own databases for storing history and - /// separate databases controlled by JavaScript applications downloaded - /// off the Internet. The internal databases can be given the - /// large, default limits. Databases managed by external sources can - /// be given much smaller limits designed to prevent a denial of service - /// attack. Developers might also want to use the [sqlite3_set_authorizer()] - /// interface to further control untrusted SQL. The size of the database - /// created by an untrusted script can be contained using the - /// [max_page_count] [PRAGMA]. - /// - /// New run-time limit categories may be added in future releases. - int sqlite3_limit(ffi.Pointer arg0, int id, int newVal) { - return _sqlite3_limit(arg0, id, newVal); + int sqlite3_column_int64(ffi.Pointer arg0, int iCol) { + return _sqlite3_column_int64(arg0, iCol); } - late final _sqlite3_limitPtr = + late final _sqlite3_column_int64Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) + sqlite3_int64 Function(ffi.Pointer, ffi.Int) > - >('sqlite3_limit'); - late final _sqlite3_limit = _sqlite3_limitPtr - .asFunction, int, int)>(); + >('sqlite3_column_int64'); + late final _sqlite3_column_int64 = _sqlite3_column_int64Ptr + .asFunction, int)>(); - /// CAPI3REF: Compiling An SQL Statement - /// KEYWORDS: {SQL statement compiler} - /// METHOD: sqlite3 - /// CONSTRUCTOR: sqlite3_stmt - /// - /// To execute an SQL statement, it must first be compiled into a byte-code - /// program using one of these routines. Or, in other words, these routines - /// are constructors for the [prepared statement] object. - /// - /// The preferred routine to use is [sqlite3_prepare_v2()]. The - /// [sqlite3_prepare()] interface is legacy and should be avoided. - /// [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used - /// for special purposes. - /// - /// The use of the UTF-8 interfaces is preferred, as SQLite currently - /// does all parsing using UTF-8. The UTF-16 interfaces are provided - /// as a convenience. The UTF-16 interfaces work by converting the - /// input text into UTF-8, then invoking the corresponding UTF-8 interface. - /// - /// The first argument, "db", is a [database connection] obtained from a - /// prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or - /// [sqlite3_open16()]. The database connection must not have been closed. - /// - /// The second argument, "zSql", is the statement to be compiled, encoded - /// as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(), - /// and sqlite3_prepare_v3() - /// interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(), - /// and sqlite3_prepare16_v3() use UTF-16. - /// - /// ^If the nByte argument is negative, then zSql is read up to the - /// first zero terminator. ^If nByte is positive, then it is the - /// number of bytes read from zSql. ^If nByte is zero, then no prepared - /// statement is generated. - /// If the caller knows that the supplied string is nul-terminated, then - /// there is a small performance advantage to passing an nByte parameter that - /// is the number of bytes in the input string including - /// the nul-terminator. - /// - /// ^If pzTail is not NULL then *pzTail is made to point to the first byte - /// past the end of the first SQL statement in zSql. These routines only - /// compile the first statement in zSql, so *pzTail is left pointing to - /// what remains uncompiled. - /// - /// ^*ppStmt is left pointing to a compiled [prepared statement] that can be - /// executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set - /// to NULL. ^If the input text contains no SQL (if the input is an empty - /// string or a comment) then *ppStmt is set to NULL. - /// The calling procedure is responsible for deleting the compiled - /// SQL statement using [sqlite3_finalize()] after it has finished with it. - /// ppStmt may not be NULL. - /// - /// ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; - /// otherwise an [error code] is returned. - /// - /// The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(), - /// and sqlite3_prepare16_v3() interfaces are recommended for all new programs. - /// The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) - /// are retained for backwards compatibility, but their use is discouraged. - /// ^In the "vX" interfaces, the prepared statement - /// that is returned (the [sqlite3_stmt] object) contains a copy of the - /// original SQL text. This causes the [sqlite3_step()] interface to - /// behave differently in three ways: + /// CAPI3REF: Column Names In A Result Set + /// METHOD: sqlite3_stmt /// - ///
    - ///
  1. - /// ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it - /// always used to do, [sqlite3_step()] will automatically recompile the SQL - /// statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY] - /// retries will occur before sqlite3_step() gives up and returns an error. - ///
  2. + /// ^These routines return the name assigned to a particular column + /// in the result set of a [SELECT] statement. ^The sqlite3_column_name() + /// interface returns a pointer to a zero-terminated UTF-8 string + /// and sqlite3_column_name16() returns a pointer to a zero-terminated + /// UTF-16 string. ^The first parameter is the [prepared statement] + /// that implements the [SELECT] statement. ^The second parameter is the + /// column number. ^The leftmost column is number 0. /// - ///
  3. - /// ^When an error occurs, [sqlite3_step()] will return one of the detailed - /// [error codes] or [extended error codes]. ^The legacy behavior was that - /// [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code - /// and the application would have to make a second call to [sqlite3_reset()] - /// in order to find the underlying cause of the problem. With the "v2" prepare - /// interfaces, the underlying reason for the error is returned immediately. - ///
  4. + /// ^The returned string pointer is valid until either the [prepared statement] + /// is destroyed by [sqlite3_finalize()] or until the statement is automatically + /// reprepared by the first call to [sqlite3_step()] for a particular run + /// or until the next call to + /// sqlite3_column_name() or sqlite3_column_name16() on the same column. /// - ///
  5. - /// ^If the specific value bound to a [parameter | host parameter] in the - /// WHERE clause might influence the choice of query plan for a statement, - /// then the statement will be automatically recompiled, as if there had been - /// a schema change, on the first [sqlite3_step()] call following any change - /// to the [sqlite3_bind_text | bindings] of that [parameter]. - /// ^The specific value of a WHERE-clause [parameter] might influence the - /// choice of query plan if the parameter is the left-hand side of a [LIKE] - /// or [GLOB] operator or if the parameter is compared to an indexed column - /// and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. - ///
  6. - ///
+ /// ^If sqlite3_malloc() fails during the processing of either routine + /// (for example during a conversion from UTF-8 to UTF-16) then a + /// NULL pointer is returned. /// - ///

^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having - /// the extra prepFlags parameter, which is a bit array consisting of zero or - /// more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The - /// sqlite3_prepare_v2() interface works exactly the same as - /// sqlite3_prepare_v3() with a zero prepFlags parameter. - int sqlite3_prepare( - ffi.Pointer db, - ffi.Pointer zSql, - int nByte, - ffi.Pointer> ppStmt, - ffi.Pointer> pzTail, + /// ^The name of a result column is the value of the "AS" clause for + /// that column, if there is an AS clause. If there is no AS clause + /// then the name of the column is unspecified and may change from + /// one release of SQLite to the next. + ffi.Pointer sqlite3_column_name( + ffi.Pointer arg0, + int N, ) { - return _sqlite3_prepare(db, zSql, nByte, ppStmt, pzTail); + return _sqlite3_column_name(arg0, N); } - late final _sqlite3_preparePtr = + late final _sqlite3_column_namePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_prepare'); - late final _sqlite3_prepare = _sqlite3_preparePtr + >('sqlite3_column_name'); + late final _sqlite3_column_name = _sqlite3_column_namePtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - int sqlite3_prepare_v2( - ffi.Pointer db, - ffi.Pointer zSql, - int nByte, - ffi.Pointer> ppStmt, - ffi.Pointer> pzTail, + ffi.Pointer sqlite3_column_name16( + ffi.Pointer arg0, + int N, ) { - return _sqlite3_prepare_v2(db, zSql, nByte, ppStmt, pzTail); + return _sqlite3_column_name16(arg0, N); } - late final _sqlite3_prepare_v2Ptr = + late final _sqlite3_column_name16Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_prepare_v2'); - late final _sqlite3_prepare_v2 = _sqlite3_prepare_v2Ptr + >('sqlite3_column_name16'); + late final _sqlite3_column_name16 = _sqlite3_column_name16Ptr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - int sqlite3_prepare_v3( - ffi.Pointer db, - ffi.Pointer zSql, - int nByte, - int prepFlags, - ffi.Pointer> ppStmt, - ffi.Pointer> pzTail, + ffi.Pointer sqlite3_column_origin_name( + ffi.Pointer arg0, + int arg1, ) { - return _sqlite3_prepare_v3(db, zSql, nByte, prepFlags, ppStmt, pzTail); + return _sqlite3_column_origin_name(arg0, arg1); } - late final _sqlite3_prepare_v3Ptr = + late final _sqlite3_column_origin_namePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.UnsignedInt, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_prepare_v3'); - late final _sqlite3_prepare_v3 = _sqlite3_prepare_v3Ptr + >('sqlite3_column_origin_name'); + late final _sqlite3_column_origin_name = _sqlite3_column_origin_namePtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - int sqlite3_prepare16( - ffi.Pointer db, - ffi.Pointer zSql, - int nByte, - ffi.Pointer> ppStmt, - ffi.Pointer> pzTail, + ffi.Pointer sqlite3_column_origin_name16( + ffi.Pointer arg0, + int arg1, ) { - return _sqlite3_prepare16(db, zSql, nByte, ppStmt, pzTail); + return _sqlite3_column_origin_name16(arg0, arg1); } - late final _sqlite3_prepare16Ptr = + late final _sqlite3_column_origin_name16Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_prepare16'); - late final _sqlite3_prepare16 = _sqlite3_prepare16Ptr + >('sqlite3_column_origin_name16'); + late final _sqlite3_column_origin_name16 = _sqlite3_column_origin_name16Ptr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - int sqlite3_prepare16_v2( - ffi.Pointer db, - ffi.Pointer zSql, - int nByte, - ffi.Pointer> ppStmt, - ffi.Pointer> pzTail, + ffi.Pointer sqlite3_column_table_name( + ffi.Pointer arg0, + int arg1, ) { - return _sqlite3_prepare16_v2(db, zSql, nByte, ppStmt, pzTail); + return _sqlite3_column_table_name(arg0, arg1); } - late final _sqlite3_prepare16_v2Ptr = + late final _sqlite3_column_table_namePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_prepare16_v2'); - late final _sqlite3_prepare16_v2 = _sqlite3_prepare16_v2Ptr + >('sqlite3_column_table_name'); + late final _sqlite3_column_table_name = _sqlite3_column_table_namePtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - int sqlite3_prepare16_v3( - ffi.Pointer db, - ffi.Pointer zSql, - int nByte, - int prepFlags, - ffi.Pointer> ppStmt, - ffi.Pointer> pzTail, + ffi.Pointer sqlite3_column_table_name16( + ffi.Pointer arg0, + int arg1, ) { - return _sqlite3_prepare16_v3(db, zSql, nByte, prepFlags, ppStmt, pzTail); + return _sqlite3_column_table_name16(arg0, arg1); } - late final _sqlite3_prepare16_v3Ptr = + late final _sqlite3_column_table_name16Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.UnsignedInt, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_prepare16_v3'); - late final _sqlite3_prepare16_v3 = _sqlite3_prepare16_v3Ptr + >('sqlite3_column_table_name16'); + late final _sqlite3_column_table_name16 = _sqlite3_column_table_name16Ptr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer>, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, int) >(); - /// CAPI3REF: Retrieving Statement SQL - /// METHOD: sqlite3_stmt - /// - /// ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 - /// SQL text used to create [prepared statement] P if P was - /// created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], - /// [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. - /// ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 - /// string containing the SQL text of prepared statement P with - /// [bound parameters] expanded. - /// ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8 - /// string containing the normalized SQL text of prepared statement P. The - /// semantics used to normalize a SQL statement are unspecified and subject - /// to change. At a minimum, literal values will be replaced with suitable - /// placeholders. - /// - /// ^(For example, if a prepared statement is created using the SQL - /// text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 - /// and parameter :xyz is unbound, then sqlite3_sql() will return - /// the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() - /// will return "SELECT 2345,NULL".)^ - /// - /// ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory - /// is available to hold the result, or if the result would exceed the - /// the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. - /// - /// ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of - /// bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time - /// option causes sqlite3_expanded_sql() to always return NULL. - /// - /// ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P) - /// are managed by SQLite and are automatically freed when the prepared - /// statement is finalized. - /// ^The string returned by sqlite3_expanded_sql(P), on the other hand, - /// is obtained from [sqlite3_malloc()] and must be free by the application - /// by passing it to [sqlite3_free()]. - ffi.Pointer sqlite3_sql(ffi.Pointer pStmt) { - return _sqlite3_sql(pStmt); + ffi.Pointer sqlite3_column_text( + ffi.Pointer arg0, + int iCol, + ) { + return _sqlite3_column_text(arg0, iCol); } - late final _sqlite3_sqlPtr = + late final _sqlite3_column_textPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function( + ffi.Pointer, + ffi.Int, + ) > - >('sqlite3_sql'); - late final _sqlite3_sql = _sqlite3_sqlPtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_column_text'); + late final _sqlite3_column_text = _sqlite3_column_textPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - ffi.Pointer sqlite3_expanded_sql(ffi.Pointer pStmt) { - return _sqlite3_expanded_sql(pStmt); + ffi.Pointer sqlite3_column_text16( + ffi.Pointer arg0, + int iCol, + ) { + return _sqlite3_column_text16(arg0, iCol); } - late final _sqlite3_expanded_sqlPtr = + late final _sqlite3_column_text16Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_expanded_sql'); - late final _sqlite3_expanded_sql = _sqlite3_expanded_sqlPtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_column_text16'); + late final _sqlite3_column_text16 = _sqlite3_column_text16Ptr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - ffi.Pointer sqlite3_normalized_sql( - ffi.Pointer pStmt, - ) { - return _sqlite3_normalized_sql(pStmt); + int sqlite3_column_type(ffi.Pointer arg0, int iCol) { + return _sqlite3_column_type(arg0, iCol); } - late final _sqlite3_normalized_sqlPtr = + late final _sqlite3_column_typePtr = _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_normalized_sql'); - late final _sqlite3_normalized_sql = _sqlite3_normalized_sqlPtr - .asFunction Function(ffi.Pointer)>(); + ffi.NativeFunction, ffi.Int)> + >('sqlite3_column_type'); + late final _sqlite3_column_type = _sqlite3_column_typePtr + .asFunction, int)>(); - /// CAPI3REF: Determine If An SQL Statement Writes The Database - /// METHOD: sqlite3_stmt + ffi.Pointer sqlite3_column_value( + ffi.Pointer arg0, + int iCol, + ) { + return _sqlite3_column_value(arg0, iCol); + } + + late final _sqlite3_column_valuePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Int, + ) + > + >('sqlite3_column_value'); + late final _sqlite3_column_value = _sqlite3_column_valuePtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); + + /// CAPI3REF: Commit And Rollback Notification Callbacks + /// METHOD: sqlite3 /// - /// ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if - /// and only if the [prepared statement] X makes no direct changes to - /// the content of the database file. + /// ^The sqlite3_commit_hook() interface registers a callback + /// function to be invoked whenever a transaction is [COMMIT | committed]. + /// ^Any callback set by a previous call to sqlite3_commit_hook() + /// for the same database connection is overridden. + /// ^The sqlite3_rollback_hook() interface registers a callback + /// function to be invoked whenever a transaction is [ROLLBACK | rolled back]. + /// ^Any callback set by a previous call to sqlite3_rollback_hook() + /// for the same database connection is overridden. + /// ^The pArg argument is passed through to the callback. + /// ^If the callback on a commit hook function returns non-zero, + /// then the commit is converted into a rollback. /// - /// Note that [application-defined SQL functions] or - /// [virtual tables] might change the database indirectly as a side effect. - /// ^(For example, if an application defines a function "eval()" that - /// calls [sqlite3_exec()], then the following SQL statement would - /// change the database file through side-effects: + /// ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions + /// return the P argument from the previous call of the same function + /// on the same [database connection] D, or NULL for + /// the first call for each function on D. /// - ///

-  /// SELECT eval('DELETE FROM t1') FROM t2;
-  /// 
+ /// The commit and rollback hook callbacks are not reentrant. + /// The callback implementation must not do anything that will modify + /// the database connection that invoked the callback. Any actions + /// to modify the database connection must be deferred until after the + /// completion of the [sqlite3_step()] call that triggered the commit + /// or rollback hook in the first place. + /// Note that running any other SQL statements, including SELECT statements, + /// or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify + /// the database connections for the meaning of "modify" in this paragraph. /// - /// But because the [SELECT] statement does not change the database file - /// directly, sqlite3_stmt_readonly() would still return true.)^ + /// ^Registering a NULL function disables the callback. /// - /// ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], - /// [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, - /// since the statements themselves do not actually modify the database but - /// rather they control the timing of when other statements modify the - /// database. ^The [ATTACH] and [DETACH] statements also cause - /// sqlite3_stmt_readonly() to return true since, while those statements - /// change the configuration of a database connection, they do not make - /// changes to the content of the database files on disk. - /// ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since - /// [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and - /// [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so - /// sqlite3_stmt_readonly() returns false for those commands. - int sqlite3_stmt_readonly(ffi.Pointer pStmt) { - return _sqlite3_stmt_readonly(pStmt); + /// ^When the commit hook callback routine returns zero, the [COMMIT] + /// operation is allowed to continue normally. ^If the commit hook + /// returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. + /// ^The rollback hook is invoked on a rollback that results from a commit + /// hook returning non-zero, just as it would be with any other rollback. + /// + /// ^For the purposes of this API, a transaction is said to have been + /// rolled back if an explicit "ROLLBACK" statement is executed, or + /// an error or constraint causes an implicit rollback to occur. + /// ^The rollback callback is not invoked if a transaction is + /// automatically rolled back because the database connection is closed. + /// + /// See also the [sqlite3_update_hook()] interface. + ffi.Pointer sqlite3_commit_hook( + ffi.Pointer arg0, + ffi.Pointer)>> + arg1, + ffi.Pointer arg2, + ) { + return _sqlite3_commit_hook(arg0, arg1, arg2); } - late final _sqlite3_stmt_readonlyPtr = - _lookup)>>( - 'sqlite3_stmt_readonly', - ); - late final _sqlite3_stmt_readonly = _sqlite3_stmt_readonlyPtr - .asFunction)>(); + late final _sqlite3_commit_hookPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ) + > + >('sqlite3_commit_hook'); + late final _sqlite3_commit_hook = _sqlite3_commit_hookPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ) + >(); - /// CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement - /// METHOD: sqlite3_stmt - /// - /// ^The sqlite3_stmt_isexplain(S) interface returns 1 if the - /// prepared statement S is an EXPLAIN statement, or 2 if the - /// statement S is an EXPLAIN QUERY PLAN. - /// ^The sqlite3_stmt_isexplain(S) interface returns 0 if S is - /// an ordinary statement or a NULL pointer. - int sqlite3_stmt_isexplain(ffi.Pointer pStmt) { - return _sqlite3_stmt_isexplain(pStmt); + ffi.Pointer sqlite3_compileoption_get(int N) { + return _sqlite3_compileoption_get(N); } - late final _sqlite3_stmt_isexplainPtr = - _lookup)>>( - 'sqlite3_stmt_isexplain', + late final _sqlite3_compileoption_getPtr = + _lookup Function(ffi.Int)>>( + 'sqlite3_compileoption_get', ); - late final _sqlite3_stmt_isexplain = _sqlite3_stmt_isexplainPtr - .asFunction)>(); + late final _sqlite3_compileoption_get = _sqlite3_compileoption_getPtr + .asFunction Function(int)>(); - /// CAPI3REF: Determine If A Prepared Statement Has Been Reset - /// METHOD: sqlite3_stmt - /// - /// ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the - /// [prepared statement] S has been stepped at least once using - /// [sqlite3_step(S)] but has neither run to completion (returned - /// [SQLITE_DONE] from [sqlite3_step(S)]) nor - /// been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) - /// interface returns false if S is a NULL pointer. If S is not a - /// NULL pointer and is not a pointer to a valid [prepared statement] - /// object, then the behavior is undefined and probably undesirable. - /// - /// This interface can be used in combination [sqlite3_next_stmt()] - /// to locate all prepared statements associated with a database - /// connection that are in need of being reset. This can be used, - /// for example, in diagnostic routines to search for prepared - /// statements that are holding a transaction open. - int sqlite3_stmt_busy(ffi.Pointer arg0) { - return _sqlite3_stmt_busy(arg0); + int sqlite3_compileoption_used(ffi.Pointer zOptName) { + return _sqlite3_compileoption_used(zOptName); } - late final _sqlite3_stmt_busyPtr = - _lookup)>>( - 'sqlite3_stmt_busy', + late final _sqlite3_compileoption_usedPtr = + _lookup)>>( + 'sqlite3_compileoption_used', ); - late final _sqlite3_stmt_busy = _sqlite3_stmt_busyPtr - .asFunction)>(); + late final _sqlite3_compileoption_used = _sqlite3_compileoption_usedPtr + .asFunction)>(); - /// CAPI3REF: Binding Values To Prepared Statements - /// KEYWORDS: {host parameter} {host parameters} {host parameter name} - /// KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} - /// METHOD: sqlite3_stmt - /// - /// ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, - /// literals may be replaced by a [parameter] that matches one of following - /// templates: - /// - ///
    - ///
  • ? - ///
  • ?NNN - ///
  • :VVV - ///
  • @VVV - ///
  • $VVV - ///
+ /// CAPI3REF: Determine If An SQL Statement Is Complete /// - /// In the templates above, NNN represents an integer literal, - /// and VVV represents an alphanumeric identifier.)^ ^The values of these - /// parameters (also called "host parameter names" or "SQL parameters") - /// can be set using the sqlite3_bind_*() routines defined here. + /// These routines are useful during command-line input to determine if the + /// currently entered text seems to form a complete SQL statement or + /// if additional input is needed before sending the text into + /// SQLite for parsing. ^These routines return 1 if the input string + /// appears to be a complete SQL statement. ^A statement is judged to be + /// complete if it ends with a semicolon token and is not a prefix of a + /// well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within + /// string literals or quoted identifier names or comments are not + /// independent tokens (they are part of the token in which they are + /// embedded) and thus do not count as a statement terminator. ^Whitespace + /// and comments that follow the final semicolon are ignored. /// - /// ^The first argument to the sqlite3_bind_*() routines is always - /// a pointer to the [sqlite3_stmt] object returned from - /// [sqlite3_prepare_v2()] or its variants. + /// ^These routines return 0 if the statement is incomplete. ^If a + /// memory allocation fails, then SQLITE_NOMEM is returned. /// - /// ^The second argument is the index of the SQL parameter to be set. - /// ^The leftmost SQL parameter has an index of 1. ^When the same named - /// SQL parameter is used more than once, second and subsequent - /// occurrences have the same index as the first occurrence. - /// ^The index for named parameters can be looked up using the - /// [sqlite3_bind_parameter_index()] API if desired. ^The index - /// for "?NNN" parameters is the value of NNN. - /// ^The NNN value must be between 1 and the [sqlite3_limit()] - /// parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 32766). + /// ^These routines do not parse the SQL statements thus + /// will not detect syntactically incorrect SQL. /// - /// ^The third argument is the value to bind to the parameter. - /// ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16() - /// or sqlite3_bind_blob() is a NULL pointer then the fourth parameter - /// is ignored and the end result is the same as sqlite3_bind_null(). - /// ^If the third parameter to sqlite3_bind_text() is not NULL, then - /// it should be a pointer to well-formed UTF8 text. - /// ^If the third parameter to sqlite3_bind_text16() is not NULL, then - /// it should be a pointer to well-formed UTF16 text. - /// ^If the third parameter to sqlite3_bind_text64() is not NULL, then - /// it should be a pointer to a well-formed unicode string that is - /// either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16 - /// otherwise. + /// ^(If SQLite has not been initialized using [sqlite3_initialize()] prior + /// to invoking sqlite3_complete16() then sqlite3_initialize() is invoked + /// automatically by sqlite3_complete16(). If that initialization fails, + /// then the return value from sqlite3_complete16() will be non-zero + /// regardless of whether or not the input SQL is complete.)^ /// - /// [[byte-order determination rules]] ^The byte-order of - /// UTF16 input text is determined by the byte-order mark (BOM, U+FEFF) - /// found in first character, which is removed, or in the absence of a BOM - /// the byte order is the native byte order of the host - /// machine for sqlite3_bind_text16() or the byte order specified in - /// the 6th parameter for sqlite3_bind_text64().)^ - /// ^If UTF16 input text contains invalid unicode - /// characters, then SQLite might change those invalid characters - /// into the unicode replacement character: U+FFFD. + /// The input to [sqlite3_complete()] must be a zero-terminated + /// UTF-8 string. /// - /// ^(In those routines that have a fourth argument, its value is the - /// number of bytes in the parameter. To be clear: the value is the - /// number of bytes in the value, not the number of characters.)^ - /// ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() - /// is negative, then the length of the string is - /// the number of bytes up to the first zero terminator. - /// If the fourth parameter to sqlite3_bind_blob() is negative, then - /// the behavior is undefined. - /// If a non-negative fourth parameter is provided to sqlite3_bind_text() - /// or sqlite3_bind_text16() or sqlite3_bind_text64() then - /// that parameter must be the byte offset - /// where the NUL terminator would occur assuming the string were NUL - /// terminated. If any NUL characters occurs at byte offsets less than - /// the value of the fourth parameter then the resulting string value will - /// contain embedded NULs. The result of expressions involving strings - /// with embedded NULs is undefined. - /// - /// ^The fifth argument to the BLOB and string binding interfaces - /// is a destructor used to dispose of the BLOB or - /// string after SQLite has finished with it. ^The destructor is called - /// to dispose of the BLOB or string even if the call to the bind API fails, - /// except the destructor is not called if the third parameter is a NULL - /// pointer or the fourth parameter is negative. - /// ^If the fifth argument is - /// the special value [SQLITE_STATIC], then SQLite assumes that the - /// information is in static, unmanaged space and does not need to be freed. - /// ^If the fifth argument has the value [SQLITE_TRANSIENT], then - /// SQLite makes its own private copy of the data immediately, before - /// the sqlite3_bind_*() routine returns. - /// - /// ^The sixth argument to sqlite3_bind_text64() must be one of - /// [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] - /// to specify the encoding of the text in the third parameter. If - /// the sixth argument to sqlite3_bind_text64() is not one of the - /// allowed values shown above, or if the text encoding is different - /// from the encoding specified by the sixth parameter, then the behavior - /// is undefined. - /// - /// ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that - /// is filled with zeroes. ^A zeroblob uses a fixed amount of memory - /// (just an integer to hold its size) while it is being processed. - /// Zeroblobs are intended to serve as placeholders for BLOBs whose - /// content is later written using - /// [sqlite3_blob_open | incremental BLOB I/O] routines. - /// ^A negative value for the zeroblob results in a zero-length BLOB. + /// The input to [sqlite3_complete16()] must be a zero-terminated + /// UTF-16 string in native byte order. + int sqlite3_complete(ffi.Pointer sql) { + return _sqlite3_complete(sql); + } + + late final _sqlite3_completePtr = + _lookup)>>( + 'sqlite3_complete', + ); + late final _sqlite3_complete = _sqlite3_completePtr + .asFunction)>(); + + int sqlite3_complete16(ffi.Pointer sql) { + return _sqlite3_complete16(sql); + } + + late final _sqlite3_complete16Ptr = + _lookup)>>( + 'sqlite3_complete16', + ); + late final _sqlite3_complete16 = _sqlite3_complete16Ptr + .asFunction)>(); + + /// CAPI3REF: Configuring The SQLite Library /// - /// ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in - /// [prepared statement] S to have an SQL value of NULL, but to also be - /// associated with the pointer P of type T. ^D is either a NULL pointer or - /// a pointer to a destructor function for P. ^SQLite will invoke the - /// destructor D with a single argument of P when it is finished using - /// P. The T parameter should be a static string, preferably a string - /// literal. The sqlite3_bind_pointer() routine is part of the - /// [pointer passing interface] added for SQLite 3.20.0. + /// The sqlite3_config() interface is used to make global configuration + /// changes to SQLite in order to tune SQLite to the specific needs of + /// the application. The default configuration is recommended for most + /// applications and so this routine is usually not necessary. It is + /// provided to support rare applications with unusual needs. /// - /// ^If any of the sqlite3_bind_*() routines are called with a NULL pointer - /// for the [prepared statement] or with a prepared statement for which - /// [sqlite3_step()] has been called more recently than [sqlite3_reset()], - /// then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() - /// routine is passed a [prepared statement] that has been finalized, the - /// result is undefined and probably harmful. + /// The sqlite3_config() interface is not threadsafe. The application + /// must ensure that no other SQLite interfaces are invoked by other + /// threads while sqlite3_config() is running. /// - /// ^Bindings are not cleared by the [sqlite3_reset()] routine. - /// ^Unbound parameters are interpreted as NULL. + /// The sqlite3_config() interface + /// may only be invoked prior to library initialization using + /// [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. + /// ^If sqlite3_config() is called after [sqlite3_initialize()] and before + /// [sqlite3_shutdown()] then it will return SQLITE_MISUSE. + /// Note, however, that ^sqlite3_config() can be called as part of the + /// implementation of an application-defined [sqlite3_os_init()]. /// - /// ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an - /// [error code] if anything goes wrong. - /// ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB - /// exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or - /// [SQLITE_MAX_LENGTH]. - /// ^[SQLITE_RANGE] is returned if the parameter - /// index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. + /// The first argument to sqlite3_config() is an integer + /// [configuration option] that determines + /// what property of SQLite is to be configured. Subsequent arguments + /// vary depending on the [configuration option] + /// in the first argument. /// - /// See also: [sqlite3_bind_parameter_count()], - /// [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. - int sqlite3_bind_blob( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - int n, - ffi.Pointer)>> - arg4, - ) { - return _sqlite3_bind_blob(arg0, arg1, arg2, n, arg4); + /// ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. + /// ^If the option is unknown or SQLite is unable to set the option + /// then this routine returns a non-zero [error code]. + int sqlite3_config(int arg0) { + return _sqlite3_config(arg0); } - late final _sqlite3_bind_blobPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('sqlite3_bind_blob'); - late final _sqlite3_bind_blob = _sqlite3_bind_blobPtr - .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); + late final _sqlite3_configPtr = + _lookup>('sqlite3_config'); + late final _sqlite3_config = _sqlite3_configPtr + .asFunction(); - int sqlite3_bind_blob64( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer)>> - arg4, + /// CAPI3REF: Database Connection For Functions + /// METHOD: sqlite3_context + /// + /// ^The sqlite3_context_db_handle() interface returns a copy of + /// the pointer to the [database connection] (the 1st parameter) + /// of the [sqlite3_create_function()] + /// and [sqlite3_create_function16()] routines that originally + /// registered the application defined function. + ffi.Pointer sqlite3_context_db_handle( + ffi.Pointer arg0, ) { - return _sqlite3_bind_blob64(arg0, arg1, arg2, arg3, arg4); + return _sqlite3_context_db_handle(arg0); } - late final _sqlite3_bind_blob64Ptr = + late final _sqlite3_context_db_handlePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - sqlite3_uint64, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_bind_blob64'); - late final _sqlite3_bind_blob64 = _sqlite3_bind_blob64Ptr + >('sqlite3_context_db_handle'); + late final _sqlite3_context_db_handle = _sqlite3_context_db_handlePtr .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) + ffi.Pointer Function(ffi.Pointer) >(); - int sqlite3_bind_double( - ffi.Pointer arg0, - int arg1, - double arg2, - ) { - return _sqlite3_bind_double(arg0, arg1, arg2); - } - - late final _sqlite3_bind_doublePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Double) - > - >('sqlite3_bind_double'); - late final _sqlite3_bind_double = _sqlite3_bind_doublePtr - .asFunction, int, double)>(); - - int sqlite3_bind_int(ffi.Pointer arg0, int arg1, int arg2) { - return _sqlite3_bind_int(arg0, arg1, arg2); - } - - late final _sqlite3_bind_intPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) - > - >('sqlite3_bind_int'); - late final _sqlite3_bind_int = _sqlite3_bind_intPtr - .asFunction, int, int)>(); - - int sqlite3_bind_int64(ffi.Pointer arg0, int arg1, int arg2) { - return _sqlite3_bind_int64(arg0, arg1, arg2); - } - - late final _sqlite3_bind_int64Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, sqlite3_int64) - > - >('sqlite3_bind_int64'); - late final _sqlite3_bind_int64 = _sqlite3_bind_int64Ptr - .asFunction, int, int)>(); - - int sqlite3_bind_null(ffi.Pointer arg0, int arg1) { - return _sqlite3_bind_null(arg0, arg1); - } - - late final _sqlite3_bind_nullPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_bind_null'); - late final _sqlite3_bind_null = _sqlite3_bind_nullPtr - .asFunction, int)>(); - - int sqlite3_bind_text( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer)>> - arg4, + /// CAPI3REF: Define New Collating Sequences + /// METHOD: sqlite3 + /// + /// ^These functions add, remove, or modify a [collation] associated + /// with the [database connection] specified as the first argument. + /// + /// ^The name of the collation is a UTF-8 string + /// for sqlite3_create_collation() and sqlite3_create_collation_v2() + /// and a UTF-16 string in native byte order for sqlite3_create_collation16(). + /// ^Collation names that compare equal according to [sqlite3_strnicmp()] are + /// considered to be the same name. + /// + /// ^(The third argument (eTextRep) must be one of the constants: + ///
    + ///
  • [SQLITE_UTF8], + ///
  • [SQLITE_UTF16LE], + ///
  • [SQLITE_UTF16BE], + ///
  • [SQLITE_UTF16], or + ///
  • [SQLITE_UTF16_ALIGNED]. + ///
)^ + /// ^The eTextRep argument determines the encoding of strings passed + /// to the collating function callback, xCompare. + /// ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep + /// force strings to be UTF16 with native byte order. + /// ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin + /// on an even byte address. + /// + /// ^The fourth argument, pArg, is an application data pointer that is passed + /// through as the first argument to the collating function callback. + /// + /// ^The fifth argument, xCompare, is a pointer to the collating function. + /// ^Multiple collating functions can be registered using the same name but + /// with different eTextRep parameters and SQLite will use whichever + /// function requires the least amount of data transformation. + /// ^If the xCompare argument is NULL then the collating function is + /// deleted. ^When all collating functions having the same name are deleted, + /// that collation is no longer usable. + /// + /// ^The collating function callback is invoked with a copy of the pArg + /// application data pointer and with two strings in the encoding specified + /// by the eTextRep argument. The two integer parameters to the collating + /// function callback are the length of the two strings, in bytes. The collating + /// function must return an integer that is negative, zero, or positive + /// if the first string is less than, equal to, or greater than the second, + /// respectively. A collating function must always return the same answer + /// given the same inputs. If two or more collating functions are registered + /// to the same collation name (using different eTextRep values) then all + /// must give an equivalent answer when invoked with equivalent strings. + /// The collating function must obey the following properties for all + /// strings A, B, and C: + /// + ///
    + ///
  1. If A==B then B==A. + ///
  2. If A==B and B==C then A==C. + ///
  3. If A<B THEN B>A. + ///
  4. If A<B and B<C then A<C. + ///
+ /// + /// If a collating function fails any of the above constraints and that + /// collating function is registered and used, then the behavior of SQLite + /// is undefined. + /// + /// ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() + /// with the addition that the xDestroy callback is invoked on pArg when + /// the collating function is deleted. + /// ^Collating functions are deleted when they are overridden by later + /// calls to the collation creation functions or when the + /// [database connection] is closed using [sqlite3_close()]. + /// + /// ^The xDestroy callback is not called if the + /// sqlite3_create_collation_v2() function fails. Applications that invoke + /// sqlite3_create_collation_v2() with a non-NULL xDestroy argument should + /// check the return code and dispose of the application data pointer + /// themselves rather than expecting SQLite to deal with it for them. + /// This is different from every other SQLite interface. The inconsistency + /// is unfortunate but cannot be changed without breaking backwards + /// compatibility. + /// + /// See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. + int sqlite3_create_collation( + ffi.Pointer arg0, + ffi.Pointer zName, + int eTextRep, + ffi.Pointer pArg, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xCompare, ) { - return _sqlite3_bind_text(arg0, arg1, arg2, arg3, arg4); + return _sqlite3_create_collation(arg0, zName, eTextRep, pArg, xCompare); } - late final _sqlite3_bind_textPtr = + late final _sqlite3_create_collationPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Int, + ffi.Pointer, ffi.Pointer, ffi.Int, + ffi.Pointer, ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > >, ) > - >('sqlite3_bind_text'); - late final _sqlite3_bind_text = _sqlite3_bind_textPtr + >('sqlite3_create_collation'); + late final _sqlite3_create_collation = _sqlite3_create_collationPtr .asFunction< int Function( - ffi.Pointer, - int, + ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > >, ) >(); - int sqlite3_bind_text16( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - int arg3, - ffi.Pointer)>> - arg4, + int sqlite3_create_collation16( + ffi.Pointer arg0, + ffi.Pointer zName, + int eTextRep, + ffi.Pointer pArg, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xCompare, ) { - return _sqlite3_bind_text16(arg0, arg1, arg2, arg3, arg4); + return _sqlite3_create_collation16(arg0, zName, eTextRep, pArg, xCompare); } - late final _sqlite3_bind_text16Ptr = + late final _sqlite3_create_collation16Ptr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Int, + ffi.Pointer, ffi.Pointer, ffi.Int, + ffi.Pointer, ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > >, ) > - >('sqlite3_bind_text16'); - late final _sqlite3_bind_text16 = _sqlite3_bind_text16Ptr + >('sqlite3_create_collation16'); + late final _sqlite3_create_collation16 = _sqlite3_create_collation16Ptr .asFunction< int Function( - ffi.Pointer, - int, + ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > >, ) >(); - int sqlite3_bind_text64( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - int arg3, + int sqlite3_create_collation_v2( + ffi.Pointer arg0, + ffi.Pointer zName, + int eTextRep, + ffi.Pointer pArg, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xCompare, ffi.Pointer)>> - arg4, - int encoding, + xDestroy, ) { - return _sqlite3_bind_text64(arg0, arg1, arg2, arg3, arg4, encoding); + return _sqlite3_create_collation_v2( + arg0, + zName, + eTextRep, + pArg, + xCompare, + xDestroy, + ); } - late final _sqlite3_bind_text64Ptr = + late final _sqlite3_create_collation_v2Ptr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Int, + ffi.Pointer, ffi.Pointer, - sqlite3_uint64, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + >, ffi.Pointer< ffi.NativeFunction)> >, - ffi.UnsignedChar, ) > - >('sqlite3_bind_text64'); - late final _sqlite3_bind_text64 = _sqlite3_bind_text64Ptr + >('sqlite3_create_collation_v2'); + late final _sqlite3_create_collation_v2 = _sqlite3_create_collation_v2Ptr .asFunction< int Function( - ffi.Pointer, - int, + ffi.Pointer, ffi.Pointer, int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + >, ffi.Pointer< ffi.NativeFunction)> >, - int, ) >(); - int sqlite3_bind_value( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) { - return _sqlite3_bind_value(arg0, arg1, arg2); - } - - late final _sqlite3_bind_valuePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >('sqlite3_bind_value'); - late final _sqlite3_bind_value = _sqlite3_bind_valuePtr - .asFunction< - int Function(ffi.Pointer, int, ffi.Pointer) - >(); - - int sqlite3_bind_pointer( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ffi.Pointer arg3, - ffi.Pointer)>> - arg4, + /// CAPI3REF: Create and Destroy VFS Filenames + /// + /// These interfces are provided for use by [VFS shim] implementations and + /// are not useful outside of that context. + /// + /// The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of + /// database filename D with corresponding journal file J and WAL file W and + /// with N URI parameters key/values pairs in the array P. The result from + /// sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that + /// is safe to pass to routines like: + ///
    + ///
  • [sqlite3_uri_parameter()], + ///
  • [sqlite3_uri_boolean()], + ///
  • [sqlite3_uri_int64()], + ///
  • [sqlite3_uri_key()], + ///
  • [sqlite3_filename_database()], + ///
  • [sqlite3_filename_journal()], or + ///
  • [sqlite3_filename_wal()]. + ///
+ /// If a memory allocation error occurs, sqlite3_create_filename() might + /// return a NULL pointer. The memory obtained from sqlite3_create_filename(X) + /// must be released by a corresponding call to sqlite3_free_filename(Y). + /// + /// The P parameter in sqlite3_create_filename(D,J,W,N,P) should be an array + /// of 2*N pointers to strings. Each pair of pointers in this array corresponds + /// to a key and value for a query parameter. The P parameter may be a NULL + /// pointer if N is zero. None of the 2*N pointers in the P array may be + /// NULL pointers and key pointers should not be empty strings. + /// None of the D, J, or W parameters to sqlite3_create_filename(D,J,W,N,P) may + /// be NULL pointers, though they can be empty strings. + /// + /// The sqlite3_free_filename(Y) routine releases a memory allocation + /// previously obtained from sqlite3_create_filename(). Invoking + /// sqlite3_free_filename(Y) where Y is a NULL pointer is a harmless no-op. + /// + /// If the Y parameter to sqlite3_free_filename(Y) is anything other + /// than a NULL pointer or a pointer previously acquired from + /// sqlite3_create_filename(), then bad things such as heap + /// corruption or segfaults may occur. The value Y should be + /// used again after sqlite3_free_filename(Y) has been called. This means + /// that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, + /// then the corresponding [sqlite3_module.xClose() method should also be + /// invoked prior to calling sqlite3_free_filename(Y). + ffi.Pointer sqlite3_create_filename( + ffi.Pointer zDatabase, + ffi.Pointer zJournal, + ffi.Pointer zWal, + int nParam, + ffi.Pointer> azParam, ) { - return _sqlite3_bind_pointer(arg0, arg1, arg2, arg3, arg4); + return _sqlite3_create_filename(zDatabase, zJournal, zWal, nParam, azParam); } - late final _sqlite3_bind_pointerPtr = + late final _sqlite3_create_filenamePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, + ffi.Pointer Function( ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, ) > - >('sqlite3_bind_pointer'); - late final _sqlite3_bind_pointer = _sqlite3_bind_pointerPtr + >('sqlite3_create_filename'); + late final _sqlite3_create_filename = _sqlite3_create_filenamePtr .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, + ffi.Pointer Function( ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, ) >(); - int sqlite3_bind_zeroblob(ffi.Pointer arg0, int arg1, int n) { - return _sqlite3_bind_zeroblob(arg0, arg1, n); - } - - late final _sqlite3_bind_zeroblobPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) - > - >('sqlite3_bind_zeroblob'); - late final _sqlite3_bind_zeroblob = _sqlite3_bind_zeroblobPtr - .asFunction, int, int)>(); - - int sqlite3_bind_zeroblob64( - ffi.Pointer arg0, - int arg1, - int arg2, - ) { - return _sqlite3_bind_zeroblob64(arg0, arg1, arg2); - } - - late final _sqlite3_bind_zeroblob64Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, sqlite3_uint64) - > - >('sqlite3_bind_zeroblob64'); - late final _sqlite3_bind_zeroblob64 = _sqlite3_bind_zeroblob64Ptr - .asFunction, int, int)>(); - - /// CAPI3REF: Number Of SQL Parameters - /// METHOD: sqlite3_stmt + /// CAPI3REF: Create Or Redefine SQL Functions + /// KEYWORDS: {function creation routines} + /// METHOD: sqlite3 /// - /// ^This routine can be used to find the number of [SQL parameters] - /// in a [prepared statement]. SQL parameters are tokens of the - /// form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as - /// placeholders for values that are [sqlite3_bind_blob | bound] - /// to the parameters at a later time. + /// ^These functions (collectively known as "function creation routines") + /// are used to add SQL functions or aggregates or to redefine the behavior + /// of existing SQL functions or aggregates. The only differences between + /// the three "sqlite3_create_function*" routines are the text encoding + /// expected for the second parameter (the name of the function being + /// created) and the presence or absence of a destructor callback for + /// the application data pointer. Function sqlite3_create_window_function() + /// is similar, but allows the user to supply the extra callback functions + /// needed by [aggregate window functions]. /// - /// ^(This routine actually returns the index of the largest (rightmost) - /// parameter. For all forms except ?NNN, this will correspond to the - /// number of unique parameters. If parameters of the ?NNN form are used, - /// there may be gaps in the list.)^ + /// ^The first parameter is the [database connection] to which the SQL + /// function is to be added. ^If an application uses more than one database + /// connection then application-defined SQL functions must be added + /// to each database connection separately. /// - /// See also: [sqlite3_bind_blob|sqlite3_bind()], - /// [sqlite3_bind_parameter_name()], and - /// [sqlite3_bind_parameter_index()]. - int sqlite3_bind_parameter_count(ffi.Pointer arg0) { - return _sqlite3_bind_parameter_count(arg0); - } - - late final _sqlite3_bind_parameter_countPtr = - _lookup)>>( - 'sqlite3_bind_parameter_count', - ); - late final _sqlite3_bind_parameter_count = _sqlite3_bind_parameter_countPtr - .asFunction)>(); - - /// CAPI3REF: Name Of A Host Parameter - /// METHOD: sqlite3_stmt + /// ^The second parameter is the name of the SQL function to be created or + /// redefined. ^The length of the name is limited to 255 bytes in a UTF-8 + /// representation, exclusive of the zero-terminator. ^Note that the name + /// length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. + /// ^Any attempt to create a function with a longer name + /// will result in [SQLITE_MISUSE] being returned. /// - /// ^The sqlite3_bind_parameter_name(P,N) interface returns - /// the name of the N-th [SQL parameter] in the [prepared statement] P. - /// ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" - /// have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" - /// respectively. - /// In other words, the initial ":" or "$" or "@" or "?" - /// is included as part of the name.)^ - /// ^Parameters of the form "?" without a following integer have no name - /// and are referred to as "nameless" or "anonymous parameters". + /// ^The third parameter (nArg) + /// is the number of arguments that the SQL function or + /// aggregate takes. ^If this parameter is -1, then the SQL function or + /// aggregate may take any number of arguments between 0 and the limit + /// set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third + /// parameter is less than -1 or greater than 127 then the behavior is + /// undefined. /// - /// ^The first host parameter has an index of 1, not 0. + /// ^The fourth parameter, eTextRep, specifies what + /// [SQLITE_UTF8 | text encoding] this SQL function prefers for + /// its parameters. The application should set this parameter to + /// [SQLITE_UTF16LE] if the function implementation invokes + /// [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the + /// implementation invokes [sqlite3_value_text16be()] on an input, or + /// [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8] + /// otherwise. ^The same SQL function may be registered multiple times using + /// different preferred text encodings, with different implementations for + /// each encoding. + /// ^When multiple implementations of the same function are available, SQLite + /// will pick the one that involves the least amount of data conversion. /// - /// ^If the value N is out of range or if the N-th parameter is - /// nameless, then NULL is returned. ^The returned string is - /// always in UTF-8 encoding even if the named parameter was - /// originally specified as UTF-16 in [sqlite3_prepare16()], - /// [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. + /// ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC] + /// to signal that the function will always return the same result given + /// the same inputs within a single SQL statement. Most SQL functions are + /// deterministic. The built-in [random()] SQL function is an example of a + /// function that is not deterministic. The SQLite query planner is able to + /// perform additional optimizations on deterministic functions, so use + /// of the [SQLITE_DETERMINISTIC] flag is recommended where possible. /// - /// See also: [sqlite3_bind_blob|sqlite3_bind()], - /// [sqlite3_bind_parameter_count()], and - /// [sqlite3_bind_parameter_index()]. - ffi.Pointer sqlite3_bind_parameter_name( - ffi.Pointer arg0, - int arg1, - ) { - return _sqlite3_bind_parameter_name(arg0, arg1); - } - - late final _sqlite3_bind_parameter_namePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_bind_parameter_name'); - late final _sqlite3_bind_parameter_name = _sqlite3_bind_parameter_namePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - /// CAPI3REF: Index Of A Parameter With A Given Name - /// METHOD: sqlite3_stmt - /// - /// ^Return the index of an SQL parameter given its name. ^The - /// index value returned is suitable for use as the second - /// parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero - /// is returned if no matching parameter is found. ^The parameter - /// name must be given in UTF-8 even if the original statement - /// was prepared from UTF-16 text using [sqlite3_prepare16_v2()] or - /// [sqlite3_prepare16_v3()]. + /// ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] + /// flag, which if present prevents the function from being invoked from + /// within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, + /// index expressions, or the WHERE clause of partial indexes. /// - /// See also: [sqlite3_bind_blob|sqlite3_bind()], - /// [sqlite3_bind_parameter_count()], and - /// [sqlite3_bind_parameter_name()]. - int sqlite3_bind_parameter_index( - ffi.Pointer arg0, - ffi.Pointer zName, - ) { - return _sqlite3_bind_parameter_index(arg0, zName); - } - - late final _sqlite3_bind_parameter_indexPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sqlite3_bind_parameter_index'); - late final _sqlite3_bind_parameter_index = _sqlite3_bind_parameter_indexPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >(); - - /// CAPI3REF: Reset All Bindings On A Prepared Statement - /// METHOD: sqlite3_stmt + /// + /// For best security, the [SQLITE_DIRECTONLY] flag is recommended for + /// all application-defined SQL functions that do not need to be + /// used inside of triggers, view, CHECK constraints, or other elements of + /// the database schema. This flags is especially recommended for SQL + /// functions that have side effects or reveal internal application state. + /// Without this flag, an attacker might be able to modify the schema of + /// a database file to include invocations of the function with parameters + /// chosen by the attacker, which the application will then execute when + /// the database file is opened and read. + /// /// - /// ^Contrary to the intuition of many, [sqlite3_reset()] does not reset - /// the [sqlite3_bind_blob | bindings] on a [prepared statement]. - /// ^Use this routine to reset all host parameters to NULL. - int sqlite3_clear_bindings(ffi.Pointer arg0) { - return _sqlite3_clear_bindings(arg0); - } - - late final _sqlite3_clear_bindingsPtr = - _lookup)>>( - 'sqlite3_clear_bindings', - ); - late final _sqlite3_clear_bindings = _sqlite3_clear_bindingsPtr - .asFunction)>(); - - /// CAPI3REF: Number Of Columns In A Result Set - /// METHOD: sqlite3_stmt + /// ^(The fifth parameter is an arbitrary pointer. The implementation of the + /// function can gain access to this pointer using [sqlite3_user_data()].)^ /// - /// ^Return the number of columns in the result set returned by the - /// [prepared statement]. ^If this routine returns 0, that means the - /// [prepared statement] returns no data (for example an [UPDATE]). - /// ^However, just because this routine returns a positive number does not - /// mean that one or more rows of data will be returned. ^A SELECT statement - /// will always have a positive sqlite3_column_count() but depending on the - /// WHERE clause constraints and the table content, it might return no rows. + /// ^The sixth, seventh and eighth parameters passed to the three + /// "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are + /// pointers to C-language functions that implement the SQL function or + /// aggregate. ^A scalar SQL function requires an implementation of the xFunc + /// callback only; NULL pointers must be passed as the xStep and xFinal + /// parameters. ^An aggregate SQL function requires an implementation of xStep + /// and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing + /// SQL function or aggregate, pass NULL pointers for all three function + /// callbacks. /// - /// See also: [sqlite3_data_count()] - int sqlite3_column_count(ffi.Pointer pStmt) { - return _sqlite3_column_count(pStmt); - } - - late final _sqlite3_column_countPtr = - _lookup)>>( - 'sqlite3_column_count', - ); - late final _sqlite3_column_count = _sqlite3_column_countPtr - .asFunction)>(); - - /// CAPI3REF: Column Names In A Result Set - /// METHOD: sqlite3_stmt + /// ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue + /// and xInverse) passed to sqlite3_create_window_function are pointers to + /// C-language callbacks that implement the new function. xStep and xFinal + /// must both be non-NULL. xValue and xInverse may either both be NULL, in + /// which case a regular aggregate function is created, or must both be + /// non-NULL, in which case the new function may be used as either an aggregate + /// or aggregate window function. More details regarding the implementation + /// of aggregate window functions are + /// [user-defined window functions|available here]. /// - /// ^These routines return the name assigned to a particular column - /// in the result set of a [SELECT] statement. ^The sqlite3_column_name() - /// interface returns a pointer to a zero-terminated UTF-8 string - /// and sqlite3_column_name16() returns a pointer to a zero-terminated - /// UTF-16 string. ^The first parameter is the [prepared statement] - /// that implements the [SELECT] statement. ^The second parameter is the - /// column number. ^The leftmost column is number 0. + /// ^(If the final parameter to sqlite3_create_function_v2() or + /// sqlite3_create_window_function() is not NULL, then it is destructor for + /// the application data pointer. The destructor is invoked when the function + /// is deleted, either by being overloaded or when the database connection + /// closes.)^ ^The destructor is also invoked if the call to + /// sqlite3_create_function_v2() fails. ^When the destructor callback is + /// invoked, it is passed a single argument which is a copy of the application + /// data pointer which was the fifth parameter to sqlite3_create_function_v2(). /// - /// ^The returned string pointer is valid until either the [prepared statement] - /// is destroyed by [sqlite3_finalize()] or until the statement is automatically - /// reprepared by the first call to [sqlite3_step()] for a particular run - /// or until the next call to - /// sqlite3_column_name() or sqlite3_column_name16() on the same column. + /// ^It is permitted to register multiple implementations of the same + /// functions with the same name but with either differing numbers of + /// arguments or differing preferred text encodings. ^SQLite will use + /// the implementation that most closely matches the way in which the + /// SQL function is used. ^A function implementation with a non-negative + /// nArg parameter is a better match than a function implementation with + /// a negative nArg. ^A function where the preferred text encoding + /// matches the database encoding is a better + /// match than a function where the encoding is different. + /// ^A function where the encoding difference is between UTF16le and UTF16be + /// is a closer match than a function where the encoding difference is + /// between UTF8 and UTF16. /// - /// ^If sqlite3_malloc() fails during the processing of either routine - /// (for example during a conversion from UTF-8 to UTF-16) then a - /// NULL pointer is returned. + /// ^Built-in functions may be overloaded by new application-defined functions. /// - /// ^The name of a result column is the value of the "AS" clause for - /// that column, if there is an AS clause. If there is no AS clause - /// then the name of the column is unspecified and may change from - /// one release of SQLite to the next. - ffi.Pointer sqlite3_column_name( - ffi.Pointer arg0, - int N, + /// ^An application-defined function is permitted to call other + /// SQLite interfaces. However, such calls must not + /// close the database connection nor finalize or reset the prepared + /// statement in which the function is running. + int sqlite3_create_function( + ffi.Pointer db, + ffi.Pointer zFunctionName, + int nArg, + int eTextRep, + ffi.Pointer pApp, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xFunc, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xStep, + ffi.Pointer< + ffi.NativeFunction)> + > + xFinal, ) { - return _sqlite3_column_name(arg0, N); + return _sqlite3_create_function( + db, + zFunctionName, + nArg, + eTextRep, + pApp, + xFunc, + xStep, + xFinal, + ); } - late final _sqlite3_column_namePtr = + late final _sqlite3_create_functionPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ) > - >('sqlite3_column_name'); - late final _sqlite3_column_name = _sqlite3_column_namePtr + >('sqlite3_create_function'); + late final _sqlite3_create_function = _sqlite3_create_functionPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - ffi.Pointer sqlite3_column_name16( - ffi.Pointer arg0, - int N, - ) { - return _sqlite3_column_name16(arg0, N); - } - - late final _sqlite3_column_name16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_column_name16'); - late final _sqlite3_column_name16 = _sqlite3_column_name16Ptr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) >(); - /// CAPI3REF: Source Of Data In A Query Result - /// METHOD: sqlite3_stmt - /// - /// ^These routines provide a means to determine the database, table, and - /// table column that is the origin of a particular result column in - /// [SELECT] statement. - /// ^The name of the database or table or column can be returned as - /// either a UTF-8 or UTF-16 string. ^The _database_ routines return - /// the database name, the _table_ routines return the table name, and - /// the origin_ routines return the column name. - /// ^The returned string is valid until the [prepared statement] is destroyed - /// using [sqlite3_finalize()] or until the statement is automatically - /// reprepared by the first call to [sqlite3_step()] for a particular run - /// or until the same information is requested - /// again in a different encoding. - /// - /// ^The names returned are the original un-aliased names of the - /// database, table, and column. - /// - /// ^The first argument to these interfaces is a [prepared statement]. - /// ^These functions return information about the Nth result column returned by - /// the statement, where N is the second function argument. - /// ^The left-most column is column 0 for these routines. - /// - /// ^If the Nth column returned by the statement is an expression or - /// subquery and is not a column value, then all of these functions return - /// NULL. ^These routines might also return NULL if a memory allocation error - /// occurs. ^Otherwise, they return the name of the attached database, table, - /// or column that query result column was extracted from. - /// - /// ^As with all other SQLite APIs, those whose names end with "16" return - /// UTF-16 encoded strings and the other functions return UTF-8. - /// - /// ^These APIs are only available if the library was compiled with the - /// [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. - /// - /// If two or more threads call one or more - /// [sqlite3_column_database_name | column metadata interfaces] - /// for the same [prepared statement] and result column - /// at the same time then the results are undefined. - ffi.Pointer sqlite3_column_database_name( - ffi.Pointer arg0, - int arg1, + int sqlite3_create_function16( + ffi.Pointer db, + ffi.Pointer zFunctionName, + int nArg, + int eTextRep, + ffi.Pointer pApp, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xFunc, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xStep, + ffi.Pointer< + ffi.NativeFunction)> + > + xFinal, ) { - return _sqlite3_column_database_name(arg0, arg1); + return _sqlite3_create_function16( + db, + zFunctionName, + nArg, + eTextRep, + pApp, + xFunc, + xStep, + xFinal, + ); } - late final _sqlite3_column_database_namePtr = + late final _sqlite3_create_function16Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ) > - >('sqlite3_column_database_name'); - late final _sqlite3_column_database_name = _sqlite3_column_database_namePtr + >('sqlite3_create_function16'); + late final _sqlite3_create_function16 = _sqlite3_create_function16Ptr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) >(); - ffi.Pointer sqlite3_column_database_name16( - ffi.Pointer arg0, - int arg1, - ) { - return _sqlite3_column_database_name16(arg0, arg1); - } - - late final _sqlite3_column_database_name16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_column_database_name16'); - late final _sqlite3_column_database_name16 = - _sqlite3_column_database_name16Ptr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - ffi.Pointer sqlite3_column_table_name( - ffi.Pointer arg0, - int arg1, + int sqlite3_create_function_v2( + ffi.Pointer db, + ffi.Pointer zFunctionName, + int nArg, + int eTextRep, + ffi.Pointer pApp, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xFunc, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xStep, + ffi.Pointer< + ffi.NativeFunction)> + > + xFinal, + ffi.Pointer)>> + xDestroy, ) { - return _sqlite3_column_table_name(arg0, arg1); + return _sqlite3_create_function_v2( + db, + zFunctionName, + nArg, + eTextRep, + pApp, + xFunc, + xStep, + xFinal, + xDestroy, + ); } - late final _sqlite3_column_table_namePtr = + late final _sqlite3_create_function_v2Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_column_table_name'); - late final _sqlite3_column_table_name = _sqlite3_column_table_namePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - ffi.Pointer sqlite3_column_table_name16( - ffi.Pointer arg0, - int arg1, - ) { - return _sqlite3_column_table_name16(arg0, arg1); - } - - late final _sqlite3_column_table_name16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_column_table_name16'); - late final _sqlite3_column_table_name16 = _sqlite3_column_table_name16Ptr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - ffi.Pointer sqlite3_column_origin_name( - ffi.Pointer arg0, - int arg1, - ) { - return _sqlite3_column_origin_name(arg0, arg1); - } - - late final _sqlite3_column_origin_namePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_column_origin_name'); - late final _sqlite3_column_origin_name = _sqlite3_column_origin_namePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); - - ffi.Pointer sqlite3_column_origin_name16( - ffi.Pointer arg0, - int arg1, - ) { - return _sqlite3_column_origin_name16(arg0, arg1); - } - - late final _sqlite3_column_origin_name16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) > - >('sqlite3_column_origin_name16'); - late final _sqlite3_column_origin_name16 = _sqlite3_column_origin_name16Ptr + >('sqlite3_create_function_v2'); + late final _sqlite3_create_function_v2 = _sqlite3_create_function_v2Ptr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) >(); - /// CAPI3REF: Declared Datatype Of A Query Result - /// METHOD: sqlite3_stmt - /// - /// ^(The first parameter is a [prepared statement]. - /// If this statement is a [SELECT] statement and the Nth column of the - /// returned result set of that [SELECT] is a table column (not an - /// expression or subquery) then the declared type of the table - /// column is returned.)^ ^If the Nth column of the result set is an - /// expression or subquery, then a NULL pointer is returned. - /// ^The returned string is always UTF-8 encoded. - /// - /// ^(For example, given the database schema: + /// CAPI3REF: Register A Virtual Table Implementation + /// METHOD: sqlite3 /// - /// CREATE TABLE t1(c1 VARIANT); + /// ^These routines are used to register a new [virtual table module] name. + /// ^Module names must be registered before + /// creating a new [virtual table] using the module and before using a + /// preexisting [virtual table] for the module. /// - /// and the following statement to be compiled: + /// ^The module name is registered on the [database connection] specified + /// by the first parameter. ^The name of the module is given by the + /// second parameter. ^The third parameter is a pointer to + /// the implementation of the [virtual table module]. ^The fourth + /// parameter is an arbitrary client data pointer that is passed through + /// into the [xCreate] and [xConnect] methods of the virtual table module + /// when a new virtual table is be being created or reinitialized. /// - /// SELECT c1 + 1, c1 FROM t1; + /// ^The sqlite3_create_module_v2() interface has a fifth parameter which + /// is a pointer to a destructor for the pClientData. ^SQLite will + /// invoke the destructor function (if it is not NULL) when SQLite + /// no longer needs the pClientData pointer. ^The destructor will also + /// be invoked if the call to sqlite3_create_module_v2() fails. + /// ^The sqlite3_create_module() + /// interface is equivalent to sqlite3_create_module_v2() with a NULL + /// destructor. /// - /// this routine would return the string "VARIANT" for the second result - /// column (i==1), and a NULL pointer for the first result column (i==0).)^ + /// ^If the third parameter (the pointer to the sqlite3_module object) is + /// NULL then no new module is create and any existing modules with the + /// same name are dropped. /// - /// ^SQLite uses dynamic run-time typing. ^So just because a column - /// is declared to contain a particular type does not mean that the - /// data stored in that column is of the declared type. SQLite is - /// strongly typed, but the typing is dynamic not static. ^Type - /// is associated with individual values, not with the containers - /// used to hold those values. - ffi.Pointer sqlite3_column_decltype( - ffi.Pointer arg0, - int arg1, + /// See also: [sqlite3_drop_modules()] + int sqlite3_create_module( + ffi.Pointer db, + ffi.Pointer zName, + ffi.Pointer p, + ffi.Pointer pClientData, ) { - return _sqlite3_column_decltype(arg0, arg1); + return _sqlite3_create_module(db, zName, p, pClientData); } - late final _sqlite3_column_decltypePtr = + late final _sqlite3_create_modulePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('sqlite3_column_decltype'); - late final _sqlite3_column_decltype = _sqlite3_column_decltypePtr + >('sqlite3_create_module'); + late final _sqlite3_create_module = _sqlite3_create_modulePtr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >(); - ffi.Pointer sqlite3_column_decltype16( - ffi.Pointer arg0, - int arg1, + int sqlite3_create_module_v2( + ffi.Pointer db, + ffi.Pointer zName, + ffi.Pointer p, + ffi.Pointer pClientData, + ffi.Pointer)>> + xDestroy, ) { - return _sqlite3_column_decltype16(arg0, arg1); + return _sqlite3_create_module_v2(db, zName, p, pClientData, xDestroy); } - late final _sqlite3_column_decltype16Ptr = + late final _sqlite3_create_module_v2Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) > - >('sqlite3_column_decltype16'); - late final _sqlite3_column_decltype16 = _sqlite3_column_decltype16Ptr + >('sqlite3_create_module_v2'); + late final _sqlite3_create_module_v2 = _sqlite3_create_module_v2Ptr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) >(); - /// CAPI3REF: Evaluate An SQL Statement - /// METHOD: sqlite3_stmt - /// - /// After a [prepared statement] has been prepared using any of - /// [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()], - /// or [sqlite3_prepare16_v3()] or one of the legacy - /// interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function - /// must be called one or more times to evaluate the statement. - /// - /// The details of the behavior of the sqlite3_step() interface depend - /// on whether the statement was prepared using the newer "vX" interfaces - /// [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()], - /// [sqlite3_prepare16_v2()] or the older legacy - /// interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the - /// new "vX" interface is recommended for new applications but the legacy - /// interface will continue to be supported. - /// - /// ^In the legacy interface, the return value will be either [SQLITE_BUSY], - /// [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. - /// ^With the "v2" interface, any of the other [result codes] or - /// [extended result codes] might be returned as well. - /// - /// ^[SQLITE_BUSY] means that the database engine was unable to acquire the - /// database locks it needs to do its job. ^If the statement is a [COMMIT] - /// or occurs outside of an explicit transaction, then you can retry the - /// statement. If the statement is not a [COMMIT] and occurs within an - /// explicit transaction then you should rollback the transaction before - /// continuing. - /// - /// ^[SQLITE_DONE] means that the statement has finished executing - /// successfully. sqlite3_step() should not be called again on this virtual - /// machine without first calling [sqlite3_reset()] to reset the virtual - /// machine back to its initial state. - /// - /// ^If the SQL statement being executed returns any data, then [SQLITE_ROW] - /// is returned each time a new row of data is ready for processing by the - /// caller. The values may be accessed using the [column access functions]. - /// sqlite3_step() is called again to retrieve the next row of data. - /// - /// ^[SQLITE_ERROR] means that a run-time error (such as a constraint - /// violation) has occurred. sqlite3_step() should not be called again on - /// the VM. More information may be found by calling [sqlite3_errmsg()]. - /// ^With the legacy interface, a more specific error code (for example, - /// [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) - /// can be obtained by calling [sqlite3_reset()] on the - /// [prepared statement]. ^In the "v2" interface, - /// the more specific error code is returned directly by sqlite3_step(). - /// - /// [SQLITE_MISUSE] means that the this routine was called inappropriately. - /// Perhaps it was called on a [prepared statement] that has - /// already been [sqlite3_finalize | finalized] or on one that had - /// previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could - /// be the case that the same database connection is being used by two or - /// more threads at the same moment in time. - /// - /// For all versions of SQLite up to and including 3.6.23.1, a call to - /// [sqlite3_reset()] was required after sqlite3_step() returned anything - /// other than [SQLITE_ROW] before any subsequent invocation of - /// sqlite3_step(). Failure to reset the prepared statement using - /// [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from - /// sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1], - /// sqlite3_step() began - /// calling [sqlite3_reset()] automatically in this circumstance rather - /// than returning [SQLITE_MISUSE]. This is not considered a compatibility - /// break because any application that ever receives an SQLITE_MISUSE error - /// is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option - /// can be used to restore the legacy behavior. - /// - /// Goofy Interface Alert: In the legacy interface, the sqlite3_step() - /// API always returns a generic error code, [SQLITE_ERROR], following any - /// error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call - /// [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the - /// specific [error codes] that better describes the error. - /// We admit that this is a goofy design. The problem has been fixed - /// with the "v2" interface. If you prepare all of your SQL statements - /// using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()] - /// or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead - /// of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, - /// then the more specific [error codes] are returned directly - /// by sqlite3_step(). The use of the "vX" interfaces is recommended. - int sqlite3_step(ffi.Pointer arg0) { - return _sqlite3_step(arg0); + int sqlite3_create_window_function( + ffi.Pointer db, + ffi.Pointer zFunctionName, + int nArg, + int eTextRep, + ffi.Pointer pApp, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xStep, + ffi.Pointer< + ffi.NativeFunction)> + > + xFinal, + ffi.Pointer< + ffi.NativeFunction)> + > + xValue, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xInverse, + ffi.Pointer)>> + xDestroy, + ) { + return _sqlite3_create_window_function( + db, + zFunctionName, + nArg, + eTextRep, + pApp, + xStep, + xFinal, + xValue, + xInverse, + xDestroy, + ); } - late final _sqlite3_stepPtr = - _lookup)>>( - 'sqlite3_step', - ); - late final _sqlite3_step = _sqlite3_stepPtr - .asFunction)>(); + late final _sqlite3_create_window_functionPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_create_window_function'); + late final _sqlite3_create_window_function = + _sqlite3_create_window_functionPtr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer) + > + >, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + >, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); /// CAPI3REF: Number of columns in a result set /// METHOD: sqlite3_stmt @@ -4061,3835 +3670,3083 @@ class SQLite { late final _sqlite3_data_count = _sqlite3_data_countPtr .asFunction)>(); - /// CAPI3REF: Result Values From A Query - /// KEYWORDS: {column access functions} - /// METHOD: sqlite3_stmt + /// CAPI3REF: Name Of The Folder Holding Database Files /// - /// Summary: - ///
- ///
sqlite3_column_blobBLOB result - ///
sqlite3_column_doubleREAL result - ///
sqlite3_column_int32-bit INTEGER result - ///
sqlite3_column_int6464-bit INTEGER result - ///
sqlite3_column_textUTF-8 TEXT result - ///
sqlite3_column_text16UTF-16 TEXT result - ///
sqlite3_column_valueThe result as an - /// [sqlite3_value|unprotected sqlite3_value] object. - ///
    - ///
sqlite3_column_bytesSize of a BLOB - /// or a UTF-8 TEXT result in bytes - ///
sqlite3_column_bytes16   - /// →  Size of UTF-16 - /// TEXT in bytes - ///
sqlite3_column_typeDefault - /// datatype of the result - ///
+ /// ^(If this global variable is made to point to a string which is + /// the name of a folder (a.k.a. directory), then all database files + /// specified with a relative pathname and created or accessed by + /// SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed + /// to be relative to that directory.)^ ^If this variable is a NULL + /// pointer, then SQLite assumes that all database files specified + /// with a relative pathname are relative to the current directory + /// for the process. Only the windows VFS makes use of this global + /// variable; it is ignored by the unix VFS. /// - /// Details: + /// Changing the value of this variable while a database connection is + /// open can result in a corrupt database. /// - /// ^These routines return information about a single column of the current - /// result row of a query. ^In every case the first argument is a pointer - /// to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] - /// that was returned from [sqlite3_prepare_v2()] or one of its variants) - /// and the second argument is the index of the column for which information - /// should be returned. ^The leftmost column of the result set has the index 0. - /// ^The number of columns in the result can be determined using - /// [sqlite3_column_count()]. + /// It is not safe to read or modify this variable in more than one + /// thread at a time. It is not safe to read or modify this variable + /// if a [database connection] is being used at the same time in a separate + /// thread. + /// It is intended that this variable be set once + /// as part of process initialization and before any SQLite interface + /// routines have been called and that this variable remain unchanged + /// thereafter. /// - /// If the SQL statement does not currently point to a valid row, or if the - /// column index is out of range, the result is undefined. - /// These routines may only be called when the most recent call to - /// [sqlite3_step()] has returned [SQLITE_ROW] and neither - /// [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. - /// If any of these routines are called after [sqlite3_reset()] or - /// [sqlite3_finalize()] or after [sqlite3_step()] has returned - /// something other than [SQLITE_ROW], the results are undefined. - /// If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] - /// are called from a different thread while any of these routines - /// are pending, then the results are undefined. - /// - /// The first six interfaces (_blob, _double, _int, _int64, _text, and _text16) - /// each return the value of a result column in a specific data format. If - /// the result column is not initially in the requested format (for example, - /// if the query returns an integer but the sqlite3_column_text() interface - /// is used to extract the value) then an automatic type conversion is performed. - /// - /// ^The sqlite3_column_type() routine returns the - /// [SQLITE_INTEGER | datatype code] for the initial data type - /// of the result column. ^The returned value is one of [SQLITE_INTEGER], - /// [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. - /// The return value of sqlite3_column_type() can be used to decide which - /// of the first six interface should be used to extract the column value. - /// The value returned by sqlite3_column_type() is only meaningful if no - /// automatic type conversions have occurred for the value in question. - /// After a type conversion, the result of calling sqlite3_column_type() - /// is undefined, though harmless. Future - /// versions of SQLite may change the behavior of sqlite3_column_type() - /// following a type conversion. + /// ^The [data_store_directory pragma] may modify this variable and cause + /// it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, + /// the [data_store_directory pragma] always assumes that any string + /// that this variable points to is held in memory obtained from + /// [sqlite3_malloc] and the pragma may attempt to free that memory + /// using [sqlite3_free]. + /// Hence, if this variable is modified directly, either it should be + /// made NULL or made to point to memory obtained from [sqlite3_malloc] + /// or else the use of the [data_store_directory pragma] should be avoided. + late final ffi.Pointer> _sqlite3_data_directory = + _lookup>('sqlite3_data_directory'); + + ffi.Pointer get sqlite3_data_directory => + _sqlite3_data_directory.value; + + set sqlite3_data_directory(ffi.Pointer value) => + _sqlite3_data_directory.value = value; + + /// CAPI3REF: Database File Corresponding To A Journal /// - /// If the result is a BLOB or a TEXT string, then the sqlite3_column_bytes() - /// or sqlite3_column_bytes16() interfaces can be used to determine the size - /// of that BLOB or string. + /// ^If X is the name of a rollback or WAL-mode journal file that is + /// passed into the xOpen method of [sqlite3_vfs], then + /// sqlite3_database_file_object(X) returns a pointer to the [sqlite3_file] + /// object that represents the main database file. /// - /// ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() - /// routine returns the number of bytes in that BLOB or string. - /// ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts - /// the string to UTF-8 and then returns the number of bytes. - /// ^If the result is a numeric value then sqlite3_column_bytes() uses - /// [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns - /// the number of bytes in that string. - /// ^If the result is NULL, then sqlite3_column_bytes() returns zero. + /// This routine is intended for use in custom [VFS] implementations + /// only. It is not a general-purpose interface. + /// The argument sqlite3_file_object(X) must be a filename pointer that + /// has been passed into [sqlite3_vfs].xOpen method where the + /// flags parameter to xOpen contains one of the bits + /// [SQLITE_OPEN_MAIN_JOURNAL] or [SQLITE_OPEN_WAL]. Any other use + /// of this routine results in undefined and probably undesirable + /// behavior. + ffi.Pointer sqlite3_database_file_object( + ffi.Pointer arg0, + ) { + return _sqlite3_database_file_object(arg0); + } + + late final _sqlite3_database_file_objectPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_database_file_object'); + late final _sqlite3_database_file_object = _sqlite3_database_file_objectPtr + .asFunction Function(ffi.Pointer)>(); + + /// CAPI3REF: Flush caches to disk mid-transaction /// - /// ^If the result is a BLOB or UTF-16 string then the sqlite3_column_bytes16() - /// routine returns the number of bytes in that BLOB or string. - /// ^If the result is a UTF-8 string, then sqlite3_column_bytes16() converts - /// the string to UTF-16 and then returns the number of bytes. - /// ^If the result is a numeric value then sqlite3_column_bytes16() uses - /// [sqlite3_snprintf()] to convert that value to a UTF-16 string and returns - /// the number of bytes in that string. - /// ^If the result is NULL, then sqlite3_column_bytes16() returns zero. + /// ^If a write-transaction is open on [database connection] D when the + /// [sqlite3_db_cacheflush(D)] interface invoked, any dirty + /// pages in the pager-cache that are not currently in use are written out + /// to disk. A dirty page may be in use if a database cursor created by an + /// active SQL statement is reading from it, or if it is page 1 of a database + /// file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)] + /// interface flushes caches for all schemas - "main", "temp", and + /// any [attached] databases. /// - /// ^The values returned by [sqlite3_column_bytes()] and - /// [sqlite3_column_bytes16()] do not include the zero terminators at the end - /// of the string. ^For clarity: the values returned by - /// [sqlite3_column_bytes()] and [sqlite3_column_bytes16()] are the number of - /// bytes in the string, not the number of characters. + /// ^If this function needs to obtain extra database locks before dirty pages + /// can be flushed to disk, it does so. ^If those locks cannot be obtained + /// immediately and there is a busy-handler callback configured, it is invoked + /// in the usual manner. ^If the required lock still cannot be obtained, then + /// the database is skipped and an attempt made to flush any dirty pages + /// belonging to the next (if any) database. ^If any databases are skipped + /// because locks cannot be obtained, but no other error occurs, this + /// function returns SQLITE_BUSY. /// - /// ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), - /// even empty strings, are always zero-terminated. ^The return - /// value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer. + /// ^If any other error occurs while flushing dirty pages to disk (for + /// example an IO error or out-of-memory condition), then processing is + /// abandoned and an SQLite [error code] is returned to the caller immediately. /// - /// Warning: ^The object returned by [sqlite3_column_value()] is an - /// [unprotected sqlite3_value] object. In a multithreaded environment, - /// an unprotected sqlite3_value object may only be used safely with - /// [sqlite3_bind_value()] and [sqlite3_result_value()]. - /// If the [unprotected sqlite3_value] object returned by - /// [sqlite3_column_value()] is used in any other way, including calls - /// to routines like [sqlite3_value_int()], [sqlite3_value_text()], - /// or [sqlite3_value_bytes()], the behavior is not threadsafe. - /// Hence, the sqlite3_column_value() interface - /// is normally only useful within the implementation of - /// [application-defined SQL functions] or [virtual tables], not within - /// top-level application code. + /// ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK. /// - /// The these routines may attempt to convert the datatype of the result. - /// ^For example, if the internal representation is FLOAT and a text result - /// is requested, [sqlite3_snprintf()] is used internally to perform the - /// conversion automatically. ^(The following table details the conversions - /// that are applied: + /// ^This function does not set the database handle error code or message + /// returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions. + int sqlite3_db_cacheflush(ffi.Pointer arg0) { + return _sqlite3_db_cacheflush(arg0); + } + + late final _sqlite3_db_cacheflushPtr = + _lookup)>>( + 'sqlite3_db_cacheflush', + ); + late final _sqlite3_db_cacheflush = _sqlite3_db_cacheflushPtr + .asFunction)>(); + + /// CAPI3REF: Configure database connections + /// METHOD: sqlite3 /// - ///
- /// - ///
Internal
Type
Requested
Type
Conversion + /// The sqlite3_db_config() interface is used to make configuration + /// changes to a [database connection]. The interface is similar to + /// [sqlite3_config()] except that the changes apply to a single + /// [database connection] (specified in the first argument). /// - ///
NULL INTEGER Result is 0 - ///
NULL FLOAT Result is 0.0 - ///
NULL TEXT Result is a NULL pointer - ///
NULL BLOB Result is a NULL pointer - ///
INTEGER FLOAT Convert from integer to float - ///
INTEGER TEXT ASCII rendering of the integer - ///
INTEGER BLOB Same as INTEGER->TEXT - ///
FLOAT INTEGER [CAST] to INTEGER - ///
FLOAT TEXT ASCII rendering of the float - ///
FLOAT BLOB [CAST] to BLOB - ///
TEXT INTEGER [CAST] to INTEGER - ///
TEXT FLOAT [CAST] to REAL - ///
TEXT BLOB No change - ///
BLOB INTEGER [CAST] to INTEGER - ///
BLOB FLOAT [CAST] to REAL - ///
BLOB TEXT Add a zero terminator if needed - ///
- ///
)^ + /// The second argument to sqlite3_db_config(D,V,...) is the + /// [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code + /// that indicates what aspect of the [database connection] is being configured. + /// Subsequent arguments vary depending on the configuration verb. /// - /// Note that when type conversions occur, pointers returned by prior - /// calls to sqlite3_column_blob(), sqlite3_column_text(), and/or - /// sqlite3_column_text16() may be invalidated. - /// Type conversions and pointer invalidations might occur - /// in the following cases: + /// ^Calls to sqlite3_db_config() return SQLITE_OK if and only if + /// the call is considered successful. + int sqlite3_db_config(ffi.Pointer arg0, int op) { + return _sqlite3_db_config(arg0, op); + } + + late final _sqlite3_db_configPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_db_config'); + late final _sqlite3_db_config = _sqlite3_db_configPtr + .asFunction, int)>(); + + /// CAPI3REF: Return The Filename For A Database Connection + /// METHOD: sqlite3 /// - ///
    - ///
  • The initial content is a BLOB and sqlite3_column_text() or - /// sqlite3_column_text16() is called. A zero-terminator might - /// need to be added to the string.
  • - ///
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or - /// sqlite3_column_text16() is called. The content must be converted - /// to UTF-16.
  • - ///
  • The initial content is UTF-16 text and sqlite3_column_bytes() or - /// sqlite3_column_text() is called. The content must be converted - /// to UTF-8.
  • - ///
+ /// ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename + /// associated with database N of connection D. + /// ^If there is no attached database N on the database + /// connection D, or if database N is a temporary or in-memory database, then + /// this function will return either a NULL pointer or an empty string. /// - /// ^Conversions between UTF-16be and UTF-16le are always done in place and do - /// not invalidate a prior pointer, though of course the content of the buffer - /// that the prior pointer references will have been modified. Other kinds - /// of conversion are done in place when it is possible, but sometimes they - /// are not possible and in those cases prior pointers are invalidated. + /// ^The string value returned by this routine is owned and managed by + /// the database connection. ^The value will be valid until the database N + /// is [DETACH]-ed or until the database connection closes. /// - /// The safest policy is to invoke these routines - /// in one of the following ways: + /// ^The filename returned by this function is the output of the + /// xFullPathname method of the [VFS]. ^In other words, the filename + /// will be an absolute pathname, even if the filename used + /// to open the database originally was a URI or relative pathname. /// + /// If the filename pointer returned by this routine is not NULL, then it + /// can be used as the filename input parameter to these routines: ///
    - ///
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • - ///
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • - ///
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • + ///
  • [sqlite3_uri_parameter()] + ///
  • [sqlite3_uri_boolean()] + ///
  • [sqlite3_uri_int64()] + ///
  • [sqlite3_filename_database()] + ///
  • [sqlite3_filename_journal()] + ///
  • [sqlite3_filename_wal()] ///
- /// - /// In other words, you should call sqlite3_column_text(), - /// sqlite3_column_blob(), or sqlite3_column_text16() first to force the result - /// into the desired format, then invoke sqlite3_column_bytes() or - /// sqlite3_column_bytes16() to find the size of the result. Do not mix calls - /// to sqlite3_column_text() or sqlite3_column_blob() with calls to - /// sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() - /// with calls to sqlite3_column_bytes(). - /// - /// ^The pointers returned are valid until a type conversion occurs as - /// described above, or until [sqlite3_step()] or [sqlite3_reset()] or - /// [sqlite3_finalize()] is called. ^The memory space used to hold strings - /// and BLOBs is freed automatically. Do not pass the pointers returned - /// from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into - /// [sqlite3_free()]. - /// - /// As long as the input parameters are correct, these routines will only - /// fail if an out-of-memory error occurs during a format conversion. - /// Only the following subset of interfaces are subject to out-of-memory - /// errors: - /// - ///
    - ///
  • sqlite3_column_blob() - ///
  • sqlite3_column_text() - ///
  • sqlite3_column_text16() - ///
  • sqlite3_column_bytes() - ///
  • sqlite3_column_bytes16() - ///
- /// - /// If an out-of-memory error occurs, then the return value from these - /// routines is the same as if the column had contained an SQL NULL value. - /// Valid SQL NULL returns can be distinguished from out-of-memory errors - /// by invoking the [sqlite3_errcode()] immediately after the suspect - /// return value is obtained and before any - /// other SQLite interface is called on the same [database connection]. - ffi.Pointer sqlite3_column_blob( - ffi.Pointer arg0, - int iCol, + ffi.Pointer sqlite3_db_filename( + ffi.Pointer db, + ffi.Pointer zDbName, ) { - return _sqlite3_column_blob(arg0, iCol); + return _sqlite3_db_filename(db, zDbName); } - late final _sqlite3_column_blobPtr = + late final _sqlite3_db_filenamePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) > - >('sqlite3_column_blob'); - late final _sqlite3_column_blob = _sqlite3_column_blobPtr + >('sqlite3_db_filename'); + late final _sqlite3_db_filename = _sqlite3_db_filenamePtr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) >(); - double sqlite3_column_double(ffi.Pointer arg0, int iCol) { - return _sqlite3_column_double(arg0, iCol); + /// CAPI3REF: Find The Database Handle Of A Prepared Statement + /// METHOD: sqlite3_stmt + /// + /// ^The sqlite3_db_handle interface returns the [database connection] handle + /// to which a [prepared statement] belongs. ^The [database connection] + /// returned by sqlite3_db_handle is the same [database connection] + /// that was the first argument + /// to the [sqlite3_prepare_v2()] call (or its variants) that was used to + /// create the statement in the first place. + ffi.Pointer sqlite3_db_handle(ffi.Pointer arg0) { + return _sqlite3_db_handle(arg0); } - late final _sqlite3_column_doublePtr = + late final _sqlite3_db_handlePtr = _lookup< ffi.NativeFunction< - ffi.Double Function(ffi.Pointer, ffi.Int) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_column_double'); - late final _sqlite3_column_double = _sqlite3_column_doublePtr - .asFunction, int)>(); + >('sqlite3_db_handle'); + late final _sqlite3_db_handle = _sqlite3_db_handlePtr + .asFunction Function(ffi.Pointer)>(); - int sqlite3_column_int(ffi.Pointer arg0, int iCol) { - return _sqlite3_column_int(arg0, iCol); + /// CAPI3REF: Retrieve the mutex for a database connection + /// METHOD: sqlite3 + /// + /// ^This interface returns a pointer the [sqlite3_mutex] object that + /// serializes access to the [database connection] given in the argument + /// when the [threading mode] is Serialized. + /// ^If the [threading mode] is Single-thread or Multi-thread then this + /// routine returns a NULL pointer. + ffi.Pointer sqlite3_db_mutex(ffi.Pointer arg0) { + return _sqlite3_db_mutex(arg0); } - late final _sqlite3_column_intPtr = + late final _sqlite3_db_mutexPtr = _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_column_int'); - late final _sqlite3_column_int = _sqlite3_column_intPtr - .asFunction, int)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_db_mutex'); + late final _sqlite3_db_mutex = _sqlite3_db_mutexPtr + .asFunction Function(ffi.Pointer)>(); - int sqlite3_column_int64(ffi.Pointer arg0, int iCol) { - return _sqlite3_column_int64(arg0, iCol); + /// CAPI3REF: Determine if a database is read-only + /// METHOD: sqlite3 + /// + /// ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N + /// of connection D is read-only, 0 if it is read/write, or -1 if N is not + /// the name of a database on connection D. + int sqlite3_db_readonly( + ffi.Pointer db, + ffi.Pointer zDbName, + ) { + return _sqlite3_db_readonly(db, zDbName); } - late final _sqlite3_column_int64Ptr = + late final _sqlite3_db_readonlyPtr = _lookup< ffi.NativeFunction< - sqlite3_int64 Function(ffi.Pointer, ffi.Int) + ffi.Int Function(ffi.Pointer, ffi.Pointer) > - >('sqlite3_column_int64'); - late final _sqlite3_column_int64 = _sqlite3_column_int64Ptr - .asFunction, int)>(); + >('sqlite3_db_readonly'); + late final _sqlite3_db_readonly = _sqlite3_db_readonlyPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer sqlite3_column_text( - ffi.Pointer arg0, - int iCol, + /// CAPI3REF: Free Memory Used By A Database Connection + /// METHOD: sqlite3 + /// + /// ^The sqlite3_db_release_memory(D) interface attempts to free as much heap + /// memory as possible from database connection D. Unlike the + /// [sqlite3_release_memory()] interface, this interface is in effect even + /// when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is + /// omitted. + /// + /// See also: [sqlite3_release_memory()] + int sqlite3_db_release_memory(ffi.Pointer arg0) { + return _sqlite3_db_release_memory(arg0); + } + + late final _sqlite3_db_release_memoryPtr = + _lookup)>>( + 'sqlite3_db_release_memory', + ); + late final _sqlite3_db_release_memory = _sqlite3_db_release_memoryPtr + .asFunction)>(); + + /// CAPI3REF: Database Connection Status + /// METHOD: sqlite3 + /// + /// ^This interface is used to retrieve runtime status information + /// about a single [database connection]. ^The first argument is the + /// database connection object to be interrogated. ^The second argument + /// is an integer constant, taken from the set of + /// [SQLITE_DBSTATUS options], that + /// determines the parameter to interrogate. The set of + /// [SQLITE_DBSTATUS options] is likely + /// to grow in future releases of SQLite. + /// + /// ^The current value of the requested parameter is written into *pCur + /// and the highest instantaneous value is written into *pHiwtr. ^If + /// the resetFlg is true, then the highest instantaneous value is + /// reset back down to the current value. + /// + /// ^The sqlite3_db_status() routine returns SQLITE_OK on success and a + /// non-zero [error code] on failure. + /// + /// See also: [sqlite3_status()] and [sqlite3_stmt_status()]. + int sqlite3_db_status( + ffi.Pointer arg0, + int op, + ffi.Pointer pCur, + ffi.Pointer pHiwtr, + int resetFlg, ) { - return _sqlite3_column_text(arg0, iCol); + return _sqlite3_db_status(arg0, op, pCur, pHiwtr, resetFlg); } - late final _sqlite3_column_textPtr = + late final _sqlite3_db_statusPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, ffi.Int, ) > - >('sqlite3_column_text'); - late final _sqlite3_column_text = _sqlite3_column_textPtr + >('sqlite3_db_status'); + late final _sqlite3_db_status = _sqlite3_db_statusPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + int, + ) >(); - ffi.Pointer sqlite3_column_text16( - ffi.Pointer arg0, - int iCol, + /// CAPI3REF: Declare The Schema Of A Virtual Table + /// + /// ^The [xCreate] and [xConnect] methods of a + /// [virtual table module] call this interface + /// to declare the format (the names and datatypes of the columns) of + /// the virtual tables they implement. + int sqlite3_declare_vtab( + ffi.Pointer arg0, + ffi.Pointer zSQL, ) { - return _sqlite3_column_text16(arg0, iCol); + return _sqlite3_declare_vtab(arg0, zSQL); } - late final _sqlite3_column_text16Ptr = + late final _sqlite3_declare_vtabPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function(ffi.Pointer, ffi.Pointer) > - >('sqlite3_column_text16'); - late final _sqlite3_column_text16 = _sqlite3_column_text16Ptr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); + >('sqlite3_declare_vtab'); + late final _sqlite3_declare_vtab = _sqlite3_declare_vtabPtr + .asFunction, ffi.Pointer)>(); - ffi.Pointer sqlite3_column_value( - ffi.Pointer arg0, - int iCol, + /// CAPI3REF: Deserialize a database + /// + /// The sqlite3_deserialize(D,S,P,N,M,F) interface causes the + /// [database connection] D to disconnect from database S and then + /// reopen S as an in-memory database based on the serialization contained + /// in P. The serialized database P is N bytes in size. M is the size of + /// the buffer P, which might be larger than N. If M is larger than N, and + /// the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is + /// permitted to add content to the in-memory database as long as the total + /// size does not exceed M bytes. + /// + /// If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will + /// invoke sqlite3_free() on the serialization buffer when the database + /// connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then + /// SQLite will try to increase the buffer size using sqlite3_realloc64() + /// if writes on the database cause it to grow larger than M bytes. + /// + /// The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the + /// database is currently in a read transaction or is involved in a backup + /// operation. + /// + /// If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the + /// SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then + /// [sqlite3_free()] is invoked on argument P prior to returning. + /// + /// This interface is only available if SQLite is compiled with the + /// [SQLITE_ENABLE_DESERIALIZE] option. + int sqlite3_deserialize( + ffi.Pointer db, + ffi.Pointer zSchema, + ffi.Pointer pData, + int szDb, + int szBuf, + int mFlags, ) { - return _sqlite3_column_value(arg0, iCol); + return _sqlite3_deserialize(db, zSchema, pData, szDb, szBuf, mFlags); } - late final _sqlite3_column_valuePtr = + late final _sqlite3_deserializePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + sqlite3_int64, + sqlite3_int64, + ffi.UnsignedInt, ) > - >('sqlite3_column_value'); - late final _sqlite3_column_value = _sqlite3_column_valuePtr + >('sqlite3_deserialize'); + late final _sqlite3_deserialize = _sqlite3_deserializePtr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + int, + int, + ) >(); - int sqlite3_column_bytes(ffi.Pointer arg0, int iCol) { - return _sqlite3_column_bytes(arg0, iCol); - } - - late final _sqlite3_column_bytesPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_column_bytes'); - late final _sqlite3_column_bytes = _sqlite3_column_bytesPtr - .asFunction, int)>(); - - int sqlite3_column_bytes16(ffi.Pointer arg0, int iCol) { - return _sqlite3_column_bytes16(arg0, iCol); - } - - late final _sqlite3_column_bytes16Ptr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_column_bytes16'); - late final _sqlite3_column_bytes16 = _sqlite3_column_bytes16Ptr - .asFunction, int)>(); - - int sqlite3_column_type(ffi.Pointer arg0, int iCol) { - return _sqlite3_column_type(arg0, iCol); + /// CAPI3REF: Remove Unnecessary Virtual Table Implementations + /// METHOD: sqlite3 + /// + /// ^The sqlite3_drop_modules(D,L) interface removes all virtual + /// table modules from database connection D except those named on list L. + /// The L parameter must be either NULL or a pointer to an array of pointers + /// to strings where the array is terminated by a single NULL pointer. + /// ^If the L parameter is NULL, then all virtual table modules are removed. + /// + /// See also: [sqlite3_create_module()] + int sqlite3_drop_modules( + ffi.Pointer db, + ffi.Pointer> azKeep, + ) { + return _sqlite3_drop_modules(db, azKeep); } - late final _sqlite3_column_typePtr = + late final _sqlite3_drop_modulesPtr = _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_column_type'); - late final _sqlite3_column_type = _sqlite3_column_typePtr - .asFunction, int)>(); + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer>, + ) + > + >('sqlite3_drop_modules'); + late final _sqlite3_drop_modules = _sqlite3_drop_modulesPtr + .asFunction< + int Function(ffi.Pointer, ffi.Pointer>) + >(); - /// CAPI3REF: Destroy A Prepared Statement Object - /// DESTRUCTOR: sqlite3_stmt + /// CAPI3REF: Enable Or Disable Extension Loading + /// METHOD: sqlite3 /// - /// ^The sqlite3_finalize() function is called to delete a [prepared statement]. - /// ^If the most recent evaluation of the statement encountered no errors - /// or if the statement is never been evaluated, then sqlite3_finalize() returns - /// SQLITE_OK. ^If the most recent evaluation of statement S failed, then - /// sqlite3_finalize(S) returns the appropriate [error code] or - /// [extended error code]. + /// ^So as not to open security holes in older applications that are + /// unprepared to deal with [extension loading], and as a means of disabling + /// [extension loading] while evaluating user-entered SQL, the following API + /// is provided to turn the [sqlite3_load_extension()] mechanism on and off. /// - /// ^The sqlite3_finalize(S) routine can be called at any point during - /// the life cycle of [prepared statement] S: - /// before statement S is ever evaluated, after - /// one or more calls to [sqlite3_reset()], or after any call - /// to [sqlite3_step()] regardless of whether or not the statement has - /// completed execution. + /// ^Extension loading is off by default. + /// ^Call the sqlite3_enable_load_extension() routine with onoff==1 + /// to turn extension loading on and call it with onoff==0 to turn + /// it back off again. /// - /// ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. + /// ^This interface enables or disables both the C-API + /// [sqlite3_load_extension()] and the SQL function [load_extension()]. + /// ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) + /// to enable or disable only the C-API.)^ /// - /// The application must finalize every [prepared statement] in order to avoid - /// resource leaks. It is a grievous error for the application to try to use - /// a prepared statement after it has been finalized. Any use of a prepared - /// statement after it has been finalized can result in undefined and - /// undesirable behavior such as segfaults and heap corruption. - int sqlite3_finalize(ffi.Pointer pStmt) { - return _sqlite3_finalize(pStmt); + /// Security warning: It is recommended that extension loading + /// be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method + /// rather than this interface, so the [load_extension()] SQL function + /// remains disabled. This will prevent SQL injections from giving attackers + /// access to extension loading capabilities. + int sqlite3_enable_load_extension(ffi.Pointer db, int onoff) { + return _sqlite3_enable_load_extension(db, onoff); } - late final _sqlite3_finalizePtr = - _lookup)>>( - 'sqlite3_finalize', - ); - late final _sqlite3_finalize = _sqlite3_finalizePtr - .asFunction)>(); + late final _sqlite3_enable_load_extensionPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_enable_load_extension'); + late final _sqlite3_enable_load_extension = _sqlite3_enable_load_extensionPtr + .asFunction, int)>(); - /// CAPI3REF: Reset A Prepared Statement Object - /// METHOD: sqlite3_stmt + /// CAPI3REF: Enable Or Disable Shared Pager Cache /// - /// The sqlite3_reset() function is called to reset a [prepared statement] - /// object back to its initial state, ready to be re-executed. - /// ^Any SQL statement variables that had values bound to them using - /// the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. - /// Use [sqlite3_clear_bindings()] to reset the bindings. + /// ^(This routine enables or disables the sharing of the database cache + /// and schema data structures between [database connection | connections] + /// to the same database. Sharing is enabled if the argument is true + /// and disabled if the argument is false.)^ /// - /// ^The [sqlite3_reset(S)] interface resets the [prepared statement] S - /// back to the beginning of its program. + /// ^Cache sharing is enabled and disabled for an entire process. + /// This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). + /// In prior versions of SQLite, + /// sharing was enabled or disabled for each thread separately. /// - /// ^If the most recent call to [sqlite3_step(S)] for the - /// [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], - /// or if [sqlite3_step(S)] has never before been called on S, - /// then [sqlite3_reset(S)] returns [SQLITE_OK]. + /// ^(The cache sharing mode set by this interface effects all subsequent + /// calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. + /// Existing database connections continue to use the sharing mode + /// that was in effect at the time they were opened.)^ /// - /// ^If the most recent call to [sqlite3_step(S)] for the - /// [prepared statement] S indicated an error, then - /// [sqlite3_reset(S)] returns an appropriate [error code]. + /// ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled + /// successfully. An [error code] is returned otherwise.)^ /// - /// ^The [sqlite3_reset(S)] interface does not change the values - /// of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. - int sqlite3_reset(ffi.Pointer pStmt) { - return _sqlite3_reset(pStmt); + /// ^Shared cache is disabled by default. It is recommended that it stay + /// that way. In other words, do not use this routine. This interface + /// continues to be provided for historical compatibility, but its use is + /// discouraged. Any use of shared cache is discouraged. If shared cache + /// must be used, it is recommended that shared cache only be enabled for + /// individual database connections using the [sqlite3_open_v2()] interface + /// with the [SQLITE_OPEN_SHAREDCACHE] flag. + /// + /// Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 + /// and will always return SQLITE_MISUSE. On those systems, + /// shared cache mode should be enabled per-database connection via + /// [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. + /// + /// This interface is threadsafe on processors where writing a + /// 32-bit integer is atomic. + /// + /// See Also: [SQLite Shared-Cache Mode] + int sqlite3_enable_shared_cache(int arg0) { + return _sqlite3_enable_shared_cache(arg0); } - late final _sqlite3_resetPtr = - _lookup)>>( - 'sqlite3_reset', + late final _sqlite3_enable_shared_cachePtr = + _lookup>( + 'sqlite3_enable_shared_cache', ); - late final _sqlite3_reset = _sqlite3_resetPtr - .asFunction)>(); + late final _sqlite3_enable_shared_cache = _sqlite3_enable_shared_cachePtr + .asFunction(); - /// CAPI3REF: Create Or Redefine SQL Functions - /// KEYWORDS: {function creation routines} + /// CAPI3REF: Error Codes And Messages /// METHOD: sqlite3 /// - /// ^These functions (collectively known as "function creation routines") - /// are used to add SQL functions or aggregates or to redefine the behavior - /// of existing SQL functions or aggregates. The only differences between - /// the three "sqlite3_create_function*" routines are the text encoding - /// expected for the second parameter (the name of the function being - /// created) and the presence or absence of a destructor callback for - /// the application data pointer. Function sqlite3_create_window_function() - /// is similar, but allows the user to supply the extra callback functions - /// needed by [aggregate window functions]. + /// ^If the most recent sqlite3_* API call associated with + /// [database connection] D failed, then the sqlite3_errcode(D) interface + /// returns the numeric [result code] or [extended result code] for that + /// API call. + /// ^The sqlite3_extended_errcode() + /// interface is the same except that it always returns the + /// [extended result code] even when extended result codes are + /// disabled. /// - /// ^The first parameter is the [database connection] to which the SQL - /// function is to be added. ^If an application uses more than one database - /// connection then application-defined SQL functions must be added - /// to each database connection separately. + /// The values returned by sqlite3_errcode() and/or + /// sqlite3_extended_errcode() might change with each API call. + /// Except, there are some interfaces that are guaranteed to never + /// change the value of the error code. The error-code preserving + /// interfaces are: /// - /// ^The second parameter is the name of the SQL function to be created or - /// redefined. ^The length of the name is limited to 255 bytes in a UTF-8 - /// representation, exclusive of the zero-terminator. ^Note that the name - /// length limit is in UTF-8 bytes, not characters nor UTF-16 bytes. - /// ^Any attempt to create a function with a longer name - /// will result in [SQLITE_MISUSE] being returned. + ///
    + ///
  • sqlite3_errcode() + ///
  • sqlite3_extended_errcode() + ///
  • sqlite3_errmsg() + ///
  • sqlite3_errmsg16() + ///
/// - /// ^The third parameter (nArg) - /// is the number of arguments that the SQL function or - /// aggregate takes. ^If this parameter is -1, then the SQL function or - /// aggregate may take any number of arguments between 0 and the limit - /// set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third - /// parameter is less than -1 or greater than 127 then the behavior is - /// undefined. + /// ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language + /// text that describes the error, as either UTF-8 or UTF-16 respectively. + /// ^(Memory to hold the error message string is managed internally. + /// The application does not need to worry about freeing the result. + /// However, the error string might be overwritten or deallocated by + /// subsequent calls to other SQLite interface functions.)^ /// - /// ^The fourth parameter, eTextRep, specifies what - /// [SQLITE_UTF8 | text encoding] this SQL function prefers for - /// its parameters. The application should set this parameter to - /// [SQLITE_UTF16LE] if the function implementation invokes - /// [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the - /// implementation invokes [sqlite3_value_text16be()] on an input, or - /// [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8] - /// otherwise. ^The same SQL function may be registered multiple times using - /// different preferred text encodings, with different implementations for - /// each encoding. - /// ^When multiple implementations of the same function are available, SQLite - /// will pick the one that involves the least amount of data conversion. + /// ^The sqlite3_errstr() interface returns the English-language text + /// that describes the [result code], as UTF-8. + /// ^(Memory to hold the error message string is managed internally + /// and must not be freed by the application)^. /// - /// ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC] - /// to signal that the function will always return the same result given - /// the same inputs within a single SQL statement. Most SQL functions are - /// deterministic. The built-in [random()] SQL function is an example of a - /// function that is not deterministic. The SQLite query planner is able to - /// perform additional optimizations on deterministic functions, so use - /// of the [SQLITE_DETERMINISTIC] flag is recommended where possible. + /// When the serialized [threading mode] is in use, it might be the + /// case that a second error occurs on a separate thread in between + /// the time of the first error and the call to these interfaces. + /// When that happens, the second error will be reported since these + /// interfaces always report the most recent result. To avoid + /// this, each thread can obtain exclusive use of the [database connection] D + /// by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning + /// to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after + /// all calls to the interfaces listed here are completed. /// - /// ^The fourth parameter may also optionally include the [SQLITE_DIRECTONLY] - /// flag, which if present prevents the function from being invoked from - /// within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, - /// index expressions, or the WHERE clause of partial indexes. + /// If an interface fails with SQLITE_MISUSE, that means the interface + /// was invoked incorrectly by the application. In that case, the + /// error code and message may or may not be set. + int sqlite3_errcode(ffi.Pointer db) { + return _sqlite3_errcode(db); + } + + late final _sqlite3_errcodePtr = + _lookup)>>( + 'sqlite3_errcode', + ); + late final _sqlite3_errcode = _sqlite3_errcodePtr + .asFunction)>(); + + ffi.Pointer sqlite3_errmsg(ffi.Pointer arg0) { + return _sqlite3_errmsg(arg0); + } + + late final _sqlite3_errmsgPtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('sqlite3_errmsg'); + late final _sqlite3_errmsg = _sqlite3_errmsgPtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer sqlite3_errmsg16(ffi.Pointer arg0) { + return _sqlite3_errmsg16(arg0); + } + + late final _sqlite3_errmsg16Ptr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >('sqlite3_errmsg16'); + late final _sqlite3_errmsg16 = _sqlite3_errmsg16Ptr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer sqlite3_errstr(int arg0) { + return _sqlite3_errstr(arg0); + } + + late final _sqlite3_errstrPtr = + _lookup Function(ffi.Int)>>( + 'sqlite3_errstr', + ); + late final _sqlite3_errstr = _sqlite3_errstrPtr + .asFunction Function(int)>(); + + /// CAPI3REF: One-Step Query Execution Interface + /// METHOD: sqlite3 /// - /// - /// For best security, the [SQLITE_DIRECTONLY] flag is recommended for - /// all application-defined SQL functions that do not need to be - /// used inside of triggers, view, CHECK constraints, or other elements of - /// the database schema. This flags is especially recommended for SQL - /// functions that have side effects or reveal internal application state. - /// Without this flag, an attacker might be able to modify the schema of - /// a database file to include invocations of the function with parameters - /// chosen by the attacker, which the application will then execute when - /// the database file is opened and read. - /// + /// The sqlite3_exec() interface is a convenience wrapper around + /// [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], + /// that allows an application to run multiple statements of SQL + /// without having to use a lot of C code. /// - /// ^(The fifth parameter is an arbitrary pointer. The implementation of the - /// function can gain access to this pointer using [sqlite3_user_data()].)^ + /// ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, + /// semicolon-separate SQL statements passed into its 2nd argument, + /// in the context of the [database connection] passed in as its 1st + /// argument. ^If the callback function of the 3rd argument to + /// sqlite3_exec() is not NULL, then it is invoked for each result row + /// coming out of the evaluated SQL statements. ^The 4th argument to + /// sqlite3_exec() is relayed through to the 1st argument of each + /// callback invocation. ^If the callback pointer to sqlite3_exec() + /// is NULL, then no callback is ever invoked and result rows are + /// ignored. /// - /// ^The sixth, seventh and eighth parameters passed to the three - /// "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are - /// pointers to C-language functions that implement the SQL function or - /// aggregate. ^A scalar SQL function requires an implementation of the xFunc - /// callback only; NULL pointers must be passed as the xStep and xFinal - /// parameters. ^An aggregate SQL function requires an implementation of xStep - /// and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing - /// SQL function or aggregate, pass NULL pointers for all three function - /// callbacks. + /// ^If an error occurs while evaluating the SQL statements passed into + /// sqlite3_exec(), then execution of the current statement stops and + /// subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() + /// is not NULL then any error message is written into memory obtained + /// from [sqlite3_malloc()] and passed back through the 5th parameter. + /// To avoid memory leaks, the application should invoke [sqlite3_free()] + /// on error message strings returned through the 5th parameter of + /// sqlite3_exec() after the error message string is no longer needed. + /// ^If the 5th parameter to sqlite3_exec() is not NULL and no errors + /// occur, then sqlite3_exec() sets the pointer in its 5th parameter to + /// NULL before returning. /// - /// ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue - /// and xInverse) passed to sqlite3_create_window_function are pointers to - /// C-language callbacks that implement the new function. xStep and xFinal - /// must both be non-NULL. xValue and xInverse may either both be NULL, in - /// which case a regular aggregate function is created, or must both be - /// non-NULL, in which case the new function may be used as either an aggregate - /// or aggregate window function. More details regarding the implementation - /// of aggregate window functions are - /// [user-defined window functions|available here]. + /// ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() + /// routine returns SQLITE_ABORT without invoking the callback again and + /// without running any subsequent SQL statements. /// - /// ^(If the final parameter to sqlite3_create_function_v2() or - /// sqlite3_create_window_function() is not NULL, then it is destructor for - /// the application data pointer. The destructor is invoked when the function - /// is deleted, either by being overloaded or when the database connection - /// closes.)^ ^The destructor is also invoked if the call to - /// sqlite3_create_function_v2() fails. ^When the destructor callback is - /// invoked, it is passed a single argument which is a copy of the application - /// data pointer which was the fifth parameter to sqlite3_create_function_v2(). + /// ^The 2nd argument to the sqlite3_exec() callback function is the + /// number of columns in the result. ^The 3rd argument to the sqlite3_exec() + /// callback is an array of pointers to strings obtained as if from + /// [sqlite3_column_text()], one for each column. ^If an element of a + /// result row is NULL then the corresponding string pointer for the + /// sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the + /// sqlite3_exec() callback is an array of pointers to strings where each + /// entry represents the name of corresponding result column as obtained + /// from [sqlite3_column_name()]. /// - /// ^It is permitted to register multiple implementations of the same - /// functions with the same name but with either differing numbers of - /// arguments or differing preferred text encodings. ^SQLite will use - /// the implementation that most closely matches the way in which the - /// SQL function is used. ^A function implementation with a non-negative - /// nArg parameter is a better match than a function implementation with - /// a negative nArg. ^A function where the preferred text encoding - /// matches the database encoding is a better - /// match than a function where the encoding is different. - /// ^A function where the encoding difference is between UTF16le and UTF16be - /// is a closer match than a function where the encoding difference is - /// between UTF8 and UTF16. + /// ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer + /// to an empty string, or a pointer that contains only whitespace and/or + /// SQL comments, then no SQL statements are evaluated and the database + /// is not changed. /// - /// ^Built-in functions may be overloaded by new application-defined functions. + /// Restrictions: /// - /// ^An application-defined function is permitted to call other - /// SQLite interfaces. However, such calls must not - /// close the database connection nor finalize or reset the prepared - /// statement in which the function is running. - int sqlite3_create_function( - ffi.Pointer db, - ffi.Pointer zFunctionName, - int nArg, - int eTextRep, - ffi.Pointer pApp, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xFunc, + ///
    + ///
  • The application must ensure that the 1st parameter to sqlite3_exec() + /// is a valid and open [database connection]. + ///
  • The application must not close the [database connection] specified by + /// the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. + ///
  • The application must not modify the SQL statement text passed into + /// the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. + ///
+ int sqlite3_exec( + ffi.Pointer arg0, + ffi.Pointer sql, ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, ffi.Int, - ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, ) > > - xStep, - ffi.Pointer< - ffi.NativeFunction)> - > - xFinal, + callback, + ffi.Pointer arg3, + ffi.Pointer> errmsg, ) { - return _sqlite3_create_function( - db, - zFunctionName, - nArg, - eTextRep, - pApp, - xFunc, - xStep, - xFinal, - ); + return _sqlite3_exec(arg0, sql, callback, arg3, errmsg); } - late final _sqlite3_create_functionPtr = + late final _sqlite3_execPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, ffi.Int, - ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, ) > >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, + ffi.Pointer, + ffi.Pointer>, ) > - >('sqlite3_create_function'); - late final _sqlite3_create_function = _sqlite3_create_functionPtr + >('sqlite3_exec'); + late final _sqlite3_exec = _sqlite3_execPtr .asFunction< int Function( ffi.Pointer, ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, ffi.Int, - ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, ) > >, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Pointer, + ffi.Pointer>, ) >(); - int sqlite3_create_function16( - ffi.Pointer db, - ffi.Pointer zFunctionName, - int nArg, - int eTextRep, - ffi.Pointer pApp, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xFunc, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xStep, - ffi.Pointer< - ffi.NativeFunction)> - > - xFinal, + ffi.Pointer sqlite3_expanded_sql(ffi.Pointer pStmt) { + return _sqlite3_expanded_sql(pStmt); + } + + late final _sqlite3_expanded_sqlPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_expanded_sql'); + late final _sqlite3_expanded_sql = _sqlite3_expanded_sqlPtr + .asFunction Function(ffi.Pointer)>(); + + int sqlite3_expired(ffi.Pointer arg0) { + return _sqlite3_expired(arg0); + } + + late final _sqlite3_expiredPtr = + _lookup)>>( + 'sqlite3_expired', + ); + late final _sqlite3_expired = _sqlite3_expiredPtr + .asFunction)>(); + + int sqlite3_extended_errcode(ffi.Pointer db) { + return _sqlite3_extended_errcode(db); + } + + late final _sqlite3_extended_errcodePtr = + _lookup)>>( + 'sqlite3_extended_errcode', + ); + late final _sqlite3_extended_errcode = _sqlite3_extended_errcodePtr + .asFunction)>(); + + /// CAPI3REF: Enable Or Disable Extended Result Codes + /// METHOD: sqlite3 + /// + /// ^The sqlite3_extended_result_codes() routine enables or disables the + /// [extended result codes] feature of SQLite. ^The extended result + /// codes are disabled by default for historical compatibility. + int sqlite3_extended_result_codes(ffi.Pointer arg0, int onoff) { + return _sqlite3_extended_result_codes(arg0, onoff); + } + + late final _sqlite3_extended_result_codesPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_extended_result_codes'); + late final _sqlite3_extended_result_codes = _sqlite3_extended_result_codesPtr + .asFunction, int)>(); + + /// CAPI3REF: Low-Level Control Of Database Files + /// METHOD: sqlite3 + /// KEYWORDS: {file control} + /// + /// ^The [sqlite3_file_control()] interface makes a direct call to the + /// xFileControl method for the [sqlite3_io_methods] object associated + /// with a particular database identified by the second argument. ^The + /// name of the database is "main" for the main database or "temp" for the + /// TEMP database, or the name that appears after the AS keyword for + /// databases that are added using the [ATTACH] SQL command. + /// ^A NULL pointer can be used in place of "main" to refer to the + /// main database file. + /// ^The third and fourth parameters to this routine + /// are passed directly through to the second and third parameters of + /// the xFileControl method. ^The return value of the xFileControl + /// method becomes the return value of this routine. + /// + /// A few opcodes for [sqlite3_file_control()] are handled directly + /// by the SQLite core and never invoke the + /// sqlite3_io_methods.xFileControl method. + /// ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes + /// a pointer to the underlying [sqlite3_file] object to be written into + /// the space pointed to by the 4th parameter. The + /// [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns + /// the [sqlite3_file] object associated with the journal file instead of + /// the main database. The [SQLITE_FCNTL_VFS_POINTER] opcode returns + /// a pointer to the underlying [sqlite3_vfs] object for the file. + /// The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter + /// from the pager. + /// + /// ^If the second parameter (zDbName) does not match the name of any + /// open database file, then SQLITE_ERROR is returned. ^This error + /// code is not remembered and will not be recalled by [sqlite3_errcode()] + /// or [sqlite3_errmsg()]. The underlying xFileControl method might + /// also return SQLITE_ERROR. There is no way to distinguish between + /// an incorrect zDbName and an SQLITE_ERROR return from the underlying + /// xFileControl method. + /// + /// See also: [file control opcodes] + int sqlite3_file_control( + ffi.Pointer arg0, + ffi.Pointer zDbName, + int op, + ffi.Pointer arg3, ) { - return _sqlite3_create_function16( - db, - zFunctionName, - nArg, - eTextRep, - pApp, - xFunc, - xStep, - xFinal, - ); + return _sqlite3_file_control(arg0, zDbName, op, arg3); } - late final _sqlite3_create_function16Ptr = + late final _sqlite3_file_controlPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, - ffi.Pointer, - ffi.Int, + ffi.Pointer, ffi.Int, ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, ) > - >('sqlite3_create_function16'); - late final _sqlite3_create_function16 = _sqlite3_create_function16Ptr + >('sqlite3_file_control'); + late final _sqlite3_file_control = _sqlite3_file_controlPtr .asFunction< int Function( ffi.Pointer, - ffi.Pointer, - int, + ffi.Pointer, int, ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, ) >(); - int sqlite3_create_function_v2( - ffi.Pointer db, - ffi.Pointer zFunctionName, - int nArg, - int eTextRep, - ffi.Pointer pApp, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xFunc, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xStep, - ffi.Pointer< - ffi.NativeFunction)> - > - xFinal, - ffi.Pointer)>> - xDestroy, - ) { - return _sqlite3_create_function_v2( - db, - zFunctionName, - nArg, - eTextRep, - pApp, - xFunc, - xStep, - xFinal, - xDestroy, - ); + /// CAPI3REF: Translate filenames + /// + /// These routines are available to [VFS|custom VFS implementations] for + /// translating filenames between the main database file, the journal file, + /// and the WAL file. + /// + /// If F is the name of an sqlite database file, journal file, or WAL file + /// passed by the SQLite core into the VFS, then sqlite3_filename_database(F) + /// returns the name of the corresponding database file. + /// + /// If F is the name of an sqlite database file, journal file, or WAL file + /// passed by the SQLite core into the VFS, or if F is a database filename + /// obtained from [sqlite3_db_filename()], then sqlite3_filename_journal(F) + /// returns the name of the corresponding rollback journal file. + /// + /// If F is the name of an sqlite database file, journal file, or WAL file + /// that was passed by the SQLite core into the VFS, or if F is a database + /// filename obtained from [sqlite3_db_filename()], then + /// sqlite3_filename_wal(F) returns the name of the corresponding + /// WAL file. + /// + /// In all of the above, if F is not the name of a database, journal or WAL + /// filename passed into the VFS from the SQLite core and F is not the + /// return value from [sqlite3_db_filename()], then the result is + /// undefined and is likely a memory access violation. + ffi.Pointer sqlite3_filename_database(ffi.Pointer arg0) { + return _sqlite3_filename_database(arg0); } - late final _sqlite3_create_function_v2Ptr = + late final _sqlite3_filename_databasePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_create_function_v2'); - late final _sqlite3_create_function_v2 = _sqlite3_create_function_v2Ptr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); + >('sqlite3_filename_database'); + late final _sqlite3_filename_database = _sqlite3_filename_databasePtr + .asFunction Function(ffi.Pointer)>(); - int sqlite3_create_window_function( - ffi.Pointer db, - ffi.Pointer zFunctionName, - int nArg, - int eTextRep, - ffi.Pointer pApp, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xStep, - ffi.Pointer< - ffi.NativeFunction)> - > - xFinal, - ffi.Pointer< - ffi.NativeFunction)> - > - xValue, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - > - xInverse, - ffi.Pointer)>> - xDestroy, - ) { - return _sqlite3_create_window_function( - db, - zFunctionName, - nArg, - eTextRep, - pApp, - xStep, - xFinal, - xValue, - xInverse, - xDestroy, - ); + ffi.Pointer sqlite3_filename_journal(ffi.Pointer arg0) { + return _sqlite3_filename_journal(arg0); } - late final _sqlite3_create_window_functionPtr = + late final _sqlite3_filename_journalPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_create_window_function'); - late final _sqlite3_create_window_function = - _sqlite3_create_window_functionPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer) - > - >, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); + >('sqlite3_filename_journal'); + late final _sqlite3_filename_journal = _sqlite3_filename_journalPtr + .asFunction Function(ffi.Pointer)>(); - int sqlite3_aggregate_count(ffi.Pointer arg0) { - return _sqlite3_aggregate_count(arg0); + ffi.Pointer sqlite3_filename_wal(ffi.Pointer arg0) { + return _sqlite3_filename_wal(arg0); } - late final _sqlite3_aggregate_countPtr = + late final _sqlite3_filename_walPtr = _lookup< - ffi.NativeFunction)> - >('sqlite3_aggregate_count'); - late final _sqlite3_aggregate_count = _sqlite3_aggregate_countPtr - .asFunction)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_filename_wal'); + late final _sqlite3_filename_wal = _sqlite3_filename_walPtr + .asFunction Function(ffi.Pointer)>(); - int sqlite3_expired(ffi.Pointer arg0) { - return _sqlite3_expired(arg0); + /// CAPI3REF: Destroy A Prepared Statement Object + /// DESTRUCTOR: sqlite3_stmt + /// + /// ^The sqlite3_finalize() function is called to delete a [prepared statement]. + /// ^If the most recent evaluation of the statement encountered no errors + /// or if the statement is never been evaluated, then sqlite3_finalize() returns + /// SQLITE_OK. ^If the most recent evaluation of statement S failed, then + /// sqlite3_finalize(S) returns the appropriate [error code] or + /// [extended error code]. + /// + /// ^The sqlite3_finalize(S) routine can be called at any point during + /// the life cycle of [prepared statement] S: + /// before statement S is ever evaluated, after + /// one or more calls to [sqlite3_reset()], or after any call + /// to [sqlite3_step()] regardless of whether or not the statement has + /// completed execution. + /// + /// ^Invoking sqlite3_finalize() on a NULL pointer is a harmless no-op. + /// + /// The application must finalize every [prepared statement] in order to avoid + /// resource leaks. It is a grievous error for the application to try to use + /// a prepared statement after it has been finalized. Any use of a prepared + /// statement after it has been finalized can result in undefined and + /// undesirable behavior such as segfaults and heap corruption. + int sqlite3_finalize(ffi.Pointer pStmt) { + return _sqlite3_finalize(pStmt); } - late final _sqlite3_expiredPtr = + late final _sqlite3_finalizePtr = _lookup)>>( - 'sqlite3_expired', + 'sqlite3_finalize', ); - late final _sqlite3_expired = _sqlite3_expiredPtr + late final _sqlite3_finalize = _sqlite3_finalizePtr .asFunction)>(); - int sqlite3_transfer_bindings( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _sqlite3_transfer_bindings(arg0, arg1); - } - - late final _sqlite3_transfer_bindingsPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sqlite3_transfer_bindings'); - late final _sqlite3_transfer_bindings = _sqlite3_transfer_bindingsPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer) - >(); - - int sqlite3_global_recover() { - return _sqlite3_global_recover(); + void sqlite3_free(ffi.Pointer arg0) { + return _sqlite3_free(arg0); } - late final _sqlite3_global_recoverPtr = - _lookup>('sqlite3_global_recover'); - late final _sqlite3_global_recover = _sqlite3_global_recoverPtr - .asFunction(); + late final _sqlite3_freePtr = + _lookup)>>( + 'sqlite3_free', + ); + late final _sqlite3_free = _sqlite3_freePtr + .asFunction)>(); - void sqlite3_thread_cleanup() { - return _sqlite3_thread_cleanup(); + void sqlite3_free_filename(ffi.Pointer arg0) { + return _sqlite3_free_filename(arg0); } - late final _sqlite3_thread_cleanupPtr = - _lookup>( - 'sqlite3_thread_cleanup', + late final _sqlite3_free_filenamePtr = + _lookup)>>( + 'sqlite3_free_filename', ); - late final _sqlite3_thread_cleanup = _sqlite3_thread_cleanupPtr - .asFunction(); + late final _sqlite3_free_filename = _sqlite3_free_filenamePtr + .asFunction)>(); - int sqlite3_memory_alarm( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, sqlite3_int64, ffi.Int) - > - > - arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _sqlite3_memory_alarm(arg0, arg1, arg2); + void sqlite3_free_table(ffi.Pointer> result) { + return _sqlite3_free_table(result); } - late final _sqlite3_memory_alarmPtr = + late final _sqlite3_free_tablePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, sqlite3_int64, ffi.Int) - > - >, - ffi.Pointer, - sqlite3_int64, - ) + ffi.Void Function(ffi.Pointer>) > - >('sqlite3_memory_alarm'); - late final _sqlite3_memory_alarm = _sqlite3_memory_alarmPtr - .asFunction< - int Function( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, sqlite3_int64, ffi.Int) - > - >, - ffi.Pointer, - int, - ) - >(); + >('sqlite3_free_table'); + late final _sqlite3_free_table = _sqlite3_free_tablePtr + .asFunction>)>(); - /// CAPI3REF: Obtaining SQL Values - /// METHOD: sqlite3_value + /// CAPI3REF: Test For Auto-Commit Mode + /// KEYWORDS: {autocommit mode} + /// METHOD: sqlite3 /// - /// Summary: - ///
- ///
sqlite3_value_blobBLOB value - ///
sqlite3_value_doubleREAL value - ///
sqlite3_value_int32-bit INTEGER value - ///
sqlite3_value_int6464-bit INTEGER value - ///
sqlite3_value_pointerPointer value - ///
sqlite3_value_textUTF-8 TEXT value - ///
sqlite3_value_text16UTF-16 TEXT value in - /// the native byteorder - ///
sqlite3_value_text16beUTF-16be TEXT value - ///
sqlite3_value_text16leUTF-16le TEXT value - ///
    - ///
sqlite3_value_bytesSize of a BLOB - /// or a UTF-8 TEXT in bytes - ///
sqlite3_value_bytes16   - /// →  Size of UTF-16 - /// TEXT in bytes - ///
sqlite3_value_typeDefault - /// datatype of the value - ///
sqlite3_value_numeric_type   - /// →  Best numeric datatype of the value - ///
sqlite3_value_nochange   - /// →  True if the column is unchanged in an UPDATE - /// against a virtual table. - ///
sqlite3_value_frombind   - /// →  True if value originated from a [bound parameter] - ///
+ /// ^The sqlite3_get_autocommit() interface returns non-zero or + /// zero if the given database connection is or is not in autocommit mode, + /// respectively. ^Autocommit mode is on by default. + /// ^Autocommit mode is disabled by a [BEGIN] statement. + /// ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. /// - /// Details: + /// If certain kinds of errors occur on a statement within a multi-statement + /// transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], + /// [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the + /// transaction might be rolled back automatically. The only way to + /// find out whether SQLite automatically rolled back the transaction after + /// an error is to use this function. /// - /// These routines extract type, size, and content information from - /// [protected sqlite3_value] objects. Protected sqlite3_value objects - /// are used to pass parameter information into the functions that - /// implement [application-defined SQL functions] and [virtual tables]. + /// If another thread changes the autocommit status of the database + /// connection while this routine is running, then the return value + /// is undefined. + int sqlite3_get_autocommit(ffi.Pointer arg0) { + return _sqlite3_get_autocommit(arg0); + } + + late final _sqlite3_get_autocommitPtr = + _lookup)>>( + 'sqlite3_get_autocommit', + ); + late final _sqlite3_get_autocommit = _sqlite3_get_autocommitPtr + .asFunction)>(); + + /// CAPI3REF: Function Auxiliary Data + /// METHOD: sqlite3_context /// - /// These routines work only with [protected sqlite3_value] objects. - /// Any attempt to use these routines on an [unprotected sqlite3_value] - /// is not threadsafe. + /// These functions may be used by (non-aggregate) SQL functions to + /// associate metadata with argument values. If the same value is passed to + /// multiple invocations of the same SQL function during query execution, under + /// some circumstances the associated metadata may be preserved. An example + /// of where this might be useful is in a regular-expression matching + /// function. The compiled version of the regular expression can be stored as + /// metadata associated with the pattern string. + /// Then as long as the pattern string remains the same, + /// the compiled regular expression can be reused on multiple + /// invocations of the same function. /// - /// ^These routines work just like the corresponding [column access functions] - /// except that these routines take a single [protected sqlite3_value] object - /// pointer instead of a [sqlite3_stmt*] pointer and an integer column number. + /// ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata + /// associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument + /// value to the application-defined function. ^N is zero for the left-most + /// function argument. ^If there is no metadata + /// associated with the function argument, the sqlite3_get_auxdata(C,N) interface + /// returns a NULL pointer. /// - /// ^The sqlite3_value_text16() interface extracts a UTF-16 string - /// in the native byte-order of the host machine. ^The - /// sqlite3_value_text16be() and sqlite3_value_text16le() interfaces - /// extract UTF-16 strings as big-endian and little-endian respectively. + /// ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th + /// argument of the application-defined function. ^Subsequent + /// calls to sqlite3_get_auxdata(C,N) return P from the most recent + /// sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or + /// NULL if the metadata has been discarded. + /// ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, + /// SQLite will invoke the destructor function X with parameter P exactly + /// once, when the metadata is discarded. + /// SQLite is free to discard the metadata at any time, including:
    + ///
  • ^(when the corresponding function parameter changes)^, or + ///
  • ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the + /// SQL statement)^, or + ///
  • ^(when sqlite3_set_auxdata() is invoked again on the same + /// parameter)^, or + ///
  • ^(during the original sqlite3_set_auxdata() call when a memory + /// allocation error occurs.)^
/// - /// ^If [sqlite3_value] object V was initialized - /// using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] - /// and if X and Y are strings that compare equal according to strcmp(X,Y), - /// then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, - /// sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() - /// routine is part of the [pointer passing interface] added for SQLite 3.20.0. + /// Note the last bullet in particular. The destructor X in + /// sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the + /// sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() + /// should be called near the end of the function implementation and the + /// function implementation should not make any use of P after + /// sqlite3_set_auxdata() has been called. /// - /// ^(The sqlite3_value_type(V) interface returns the - /// [SQLITE_INTEGER | datatype code] for the initial datatype of the - /// [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], - /// [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ - /// Other interfaces might change the datatype for an sqlite3_value object. - /// For example, if the datatype is initially SQLITE_INTEGER and - /// sqlite3_value_text(V) is called to extract a text value for that - /// integer, then subsequent calls to sqlite3_value_type(V) might return - /// SQLITE_TEXT. Whether or not a persistent internal datatype conversion - /// occurs is undefined and may change from one release of SQLite to the next. - /// - /// ^(The sqlite3_value_numeric_type() interface attempts to apply - /// numeric affinity to the value. This means that an attempt is - /// made to convert the value to an integer or floating point. If - /// such a conversion is possible without loss of information (in other - /// words, if the value is a string that looks like a number) - /// then the conversion is performed. Otherwise no conversion occurs. - /// The [SQLITE_INTEGER | datatype] after conversion is returned.)^ - /// - /// ^Within the [xUpdate] method of a [virtual table], the - /// sqlite3_value_nochange(X) interface returns true if and only if - /// the column corresponding to X is unchanged by the UPDATE operation - /// that the xUpdate method call was invoked to implement and if - /// and the prior [xColumn] method call that was invoked to extracted - /// the value for that column returned without setting a result (probably - /// because it queried [sqlite3_vtab_nochange()] and found that the column - /// was unchanging). ^Within an [xUpdate] method, any value for which - /// sqlite3_value_nochange(X) is true will in all other respects appear - /// to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other - /// than within an [xUpdate] method call for an UPDATE statement, then - /// the return value is arbitrary and meaningless. - /// - /// ^The sqlite3_value_frombind(X) interface returns non-zero if the - /// value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] - /// interfaces. ^If X comes from an SQL literal value, or a table column, - /// or an expression, then sqlite3_value_frombind(X) returns zero. - /// - /// Please pay particular attention to the fact that the pointer returned - /// from [sqlite3_value_blob()], [sqlite3_value_text()], or - /// [sqlite3_value_text16()] can be invalidated by a subsequent call to - /// [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], - /// or [sqlite3_value_text16()]. - /// - /// These routines must be called from the same thread as - /// the SQL function that supplied the [sqlite3_value*] parameters. - /// - /// As long as the input parameter is correct, these routines can only - /// fail if an out-of-memory error occurs during a format conversion. - /// Only the following subset of interfaces are subject to out-of-memory - /// errors: + /// ^(In practice, metadata is preserved between function calls for + /// function parameters that are compile-time constants, including literal + /// values and [parameters] and expressions composed from the same.)^ /// - ///
    - ///
  • sqlite3_value_blob() - ///
  • sqlite3_value_text() - ///
  • sqlite3_value_text16() - ///
  • sqlite3_value_text16le() - ///
  • sqlite3_value_text16be() - ///
  • sqlite3_value_bytes() - ///
  • sqlite3_value_bytes16() - ///
+ /// The value of the N parameter to these interfaces should be non-negative. + /// Future enhancements may make use of negative N values to define new + /// kinds of function caching behavior. /// - /// If an out-of-memory error occurs, then the return value from these - /// routines is the same as if the column had contained an SQL NULL value. - /// Valid SQL NULL returns can be distinguished from out-of-memory errors - /// by invoking the [sqlite3_errcode()] immediately after the suspect - /// return value is obtained and before any - /// other SQLite interface is called on the same [database connection]. - ffi.Pointer sqlite3_value_blob(ffi.Pointer arg0) { - return _sqlite3_value_blob(arg0); + /// These routines must be called from the same thread in which + /// the SQL function is running. + ffi.Pointer sqlite3_get_auxdata( + ffi.Pointer arg0, + int N, + ) { + return _sqlite3_get_auxdata(arg0, N); } - late final _sqlite3_value_blobPtr = + late final _sqlite3_get_auxdataPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function(ffi.Pointer, ffi.Int) > - >('sqlite3_value_blob'); - late final _sqlite3_value_blob = _sqlite3_value_blobPtr - .asFunction Function(ffi.Pointer)>(); - - double sqlite3_value_double(ffi.Pointer arg0) { - return _sqlite3_value_double(arg0); - } - - late final _sqlite3_value_doublePtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_value_double'); - late final _sqlite3_value_double = _sqlite3_value_doublePtr - .asFunction)>(); - - int sqlite3_value_int(ffi.Pointer arg0) { - return _sqlite3_value_int(arg0); - } - - late final _sqlite3_value_intPtr = - _lookup)>>( - 'sqlite3_value_int', - ); - late final _sqlite3_value_int = _sqlite3_value_intPtr - .asFunction)>(); - - int sqlite3_value_int64(ffi.Pointer arg0) { - return _sqlite3_value_int64(arg0); - } - - late final _sqlite3_value_int64Ptr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_value_int64'); - late final _sqlite3_value_int64 = _sqlite3_value_int64Ptr - .asFunction)>(); + >('sqlite3_get_auxdata'); + late final _sqlite3_get_auxdata = _sqlite3_get_auxdataPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - ffi.Pointer sqlite3_value_pointer( - ffi.Pointer arg0, - ffi.Pointer arg1, + /// CAPI3REF: Convenience Routines For Running Queries + /// METHOD: sqlite3 + /// + /// This is a legacy interface that is preserved for backwards compatibility. + /// Use of this interface is not recommended. + /// + /// Definition: A result table is memory data structure created by the + /// [sqlite3_get_table()] interface. A result table records the + /// complete query results from one or more queries. + /// + /// The table conceptually has a number of rows and columns. But + /// these numbers are not part of the result table itself. These + /// numbers are obtained separately. Let N be the number of rows + /// and M be the number of columns. + /// + /// A result table is an array of pointers to zero-terminated UTF-8 strings. + /// There are (N+1)*M elements in the array. The first M pointers point + /// to zero-terminated strings that contain the names of the columns. + /// The remaining entries all point to query results. NULL values result + /// in NULL pointers. All other values are in their UTF-8 zero-terminated + /// string representation as returned by [sqlite3_column_text()]. + /// + /// A result table might consist of one or more memory allocations. + /// It is not safe to pass a result table directly to [sqlite3_free()]. + /// A result table should be deallocated using [sqlite3_free_table()]. + /// + /// ^(As an example of the result table format, suppose a query result + /// is as follows: + /// + ///
+  /// Name        | Age
+  /// -----------------------
+  /// Alice       | 43
+  /// Bob         | 28
+  /// Cindy       | 21
+  /// 
+ /// + /// There are two columns (M==2) and three rows (N==3). Thus the + /// result table has 8 entries. Suppose the result table is stored + /// in an array named azResult. Then azResult holds this content: + /// + ///
+  /// azResult[0] = "Name";
+  /// azResult[1] = "Age";
+  /// azResult[2] = "Alice";
+  /// azResult[3] = "43";
+  /// azResult[4] = "Bob";
+  /// azResult[5] = "28";
+  /// azResult[6] = "Cindy";
+  /// azResult[7] = "21";
+  /// 
)^ + /// + /// ^The sqlite3_get_table() function evaluates one or more + /// semicolon-separated SQL statements in the zero-terminated UTF-8 + /// string of its 2nd parameter and returns a result table to the + /// pointer given in its 3rd parameter. + /// + /// After the application has finished with the result from sqlite3_get_table(), + /// it must pass the result table pointer to sqlite3_free_table() in order to + /// release the memory that was malloced. Because of the way the + /// [sqlite3_malloc()] happens within sqlite3_get_table(), the calling + /// function must not try to call [sqlite3_free()] directly. Only + /// [sqlite3_free_table()] is able to release the memory properly and safely. + /// + /// The sqlite3_get_table() interface is implemented as a wrapper around + /// [sqlite3_exec()]. The sqlite3_get_table() routine does not have access + /// to any internal data structures of SQLite. It uses only the public + /// interface defined here. As a consequence, errors that occur in the + /// wrapper layer outside of the internal [sqlite3_exec()] call are not + /// reflected in subsequent calls to [sqlite3_errcode()] or + /// [sqlite3_errmsg()]. + int sqlite3_get_table( + ffi.Pointer db, + ffi.Pointer zSql, + ffi.Pointer>> pazResult, + ffi.Pointer pnRow, + ffi.Pointer pnColumn, + ffi.Pointer> pzErrmsg, ) { - return _sqlite3_value_pointer(arg0, arg1); + return _sqlite3_get_table(db, zSql, pazResult, pnRow, pnColumn, pzErrmsg); } - late final _sqlite3_value_pointerPtr = + late final _sqlite3_get_tablePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, ffi.Pointer, + ffi.Pointer>>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, ) > - >('sqlite3_value_pointer'); - late final _sqlite3_value_pointer = _sqlite3_value_pointerPtr + >('sqlite3_get_table'); + late final _sqlite3_get_table = _sqlite3_get_tablePtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, + int Function( + ffi.Pointer, ffi.Pointer, + ffi.Pointer>>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, ) >(); - ffi.Pointer sqlite3_value_text( - ffi.Pointer arg0, - ) { - return _sqlite3_value_text(arg0); + int sqlite3_global_recover() { + return _sqlite3_global_recover(); } - late final _sqlite3_value_textPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_value_text'); - late final _sqlite3_value_text = _sqlite3_value_textPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); + late final _sqlite3_global_recoverPtr = + _lookup>('sqlite3_global_recover'); + late final _sqlite3_global_recover = _sqlite3_global_recoverPtr + .asFunction(); - ffi.Pointer sqlite3_value_text16(ffi.Pointer arg0) { - return _sqlite3_value_text16(arg0); + int sqlite3_hard_heap_limit64(int N) { + return _sqlite3_hard_heap_limit64(N); } - late final _sqlite3_value_text16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_value_text16'); - late final _sqlite3_value_text16 = _sqlite3_value_text16Ptr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer sqlite3_value_text16le( - ffi.Pointer arg0, - ) { - return _sqlite3_value_text16le(arg0); - } - - late final _sqlite3_value_text16lePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_value_text16le'); - late final _sqlite3_value_text16le = _sqlite3_value_text16lePtr - .asFunction Function(ffi.Pointer)>(); - - ffi.Pointer sqlite3_value_text16be( - ffi.Pointer arg0, - ) { - return _sqlite3_value_text16be(arg0); - } - - late final _sqlite3_value_text16bePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_value_text16be'); - late final _sqlite3_value_text16be = _sqlite3_value_text16bePtr - .asFunction Function(ffi.Pointer)>(); + late final _sqlite3_hard_heap_limit64Ptr = + _lookup>( + 'sqlite3_hard_heap_limit64', + ); + late final _sqlite3_hard_heap_limit64 = _sqlite3_hard_heap_limit64Ptr + .asFunction(); - int sqlite3_value_bytes(ffi.Pointer arg0) { - return _sqlite3_value_bytes(arg0); + /// CAPI3REF: Initialize The SQLite Library + /// + /// ^The sqlite3_initialize() routine initializes the + /// SQLite library. ^The sqlite3_shutdown() routine + /// deallocates any resources that were allocated by sqlite3_initialize(). + /// These routines are designed to aid in process initialization and + /// shutdown on embedded systems. Workstation applications using + /// SQLite normally do not need to invoke either of these routines. + /// + /// A call to sqlite3_initialize() is an "effective" call if it is + /// the first time sqlite3_initialize() is invoked during the lifetime of + /// the process, or if it is the first time sqlite3_initialize() is invoked + /// following a call to sqlite3_shutdown(). ^(Only an effective call + /// of sqlite3_initialize() does any initialization. All other calls + /// are harmless no-ops.)^ + /// + /// A call to sqlite3_shutdown() is an "effective" call if it is the first + /// call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only + /// an effective call to sqlite3_shutdown() does any deinitialization. + /// All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ + /// + /// The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() + /// is not. The sqlite3_shutdown() interface must only be called from a + /// single thread. All open [database connections] must be closed and all + /// other SQLite resources must be deallocated prior to invoking + /// sqlite3_shutdown(). + /// + /// Among other things, ^sqlite3_initialize() will invoke + /// sqlite3_os_init(). Similarly, ^sqlite3_shutdown() + /// will invoke sqlite3_os_end(). + /// + /// ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. + /// ^If for some reason, sqlite3_initialize() is unable to initialize + /// the library (perhaps it is unable to allocate a needed resource such + /// as a mutex) it returns an [error code] other than [SQLITE_OK]. + /// + /// ^The sqlite3_initialize() routine is called internally by many other + /// SQLite interfaces so that an application usually does not need to + /// invoke sqlite3_initialize() directly. For example, [sqlite3_open()] + /// calls sqlite3_initialize() so the SQLite library will be automatically + /// initialized when [sqlite3_open()] is called if it has not be initialized + /// already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] + /// compile-time option, then the automatic calls to sqlite3_initialize() + /// are omitted and the application must call sqlite3_initialize() directly + /// prior to using any other SQLite interface. For maximum portability, + /// it is recommended that applications always invoke sqlite3_initialize() + /// directly prior to using any other SQLite interface. Future releases + /// of SQLite may require this. In other words, the behavior exhibited + /// when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the + /// default behavior in some future release of SQLite. + /// + /// The sqlite3_os_init() routine does operating-system specific + /// initialization of the SQLite library. The sqlite3_os_end() + /// routine undoes the effect of sqlite3_os_init(). Typical tasks + /// performed by these routines include allocation or deallocation + /// of static resources, initialization of global variables, + /// setting up a default [sqlite3_vfs] module, or setting up + /// a default configuration using [sqlite3_config()]. + /// + /// The application should never invoke either sqlite3_os_init() + /// or sqlite3_os_end() directly. The application should only invoke + /// sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() + /// interface is called automatically by sqlite3_initialize() and + /// sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate + /// implementations for sqlite3_os_init() and sqlite3_os_end() + /// are built into SQLite when it is compiled for Unix, Windows, or OS/2. + /// When [custom builds | built for other platforms] + /// (using the [SQLITE_OS_OTHER=1] compile-time + /// option) the application must supply a suitable implementation for + /// sqlite3_os_init() and sqlite3_os_end(). An application-supplied + /// implementation of sqlite3_os_init() or sqlite3_os_end() + /// must return [SQLITE_OK] on success and some other [error code] upon + /// failure. + int sqlite3_initialize() { + return _sqlite3_initialize(); } - late final _sqlite3_value_bytesPtr = - _lookup)>>( - 'sqlite3_value_bytes', - ); - late final _sqlite3_value_bytes = _sqlite3_value_bytesPtr - .asFunction)>(); + late final _sqlite3_initializePtr = + _lookup>('sqlite3_initialize'); + late final _sqlite3_initialize = _sqlite3_initializePtr + .asFunction(); - int sqlite3_value_bytes16(ffi.Pointer arg0) { - return _sqlite3_value_bytes16(arg0); + /// CAPI3REF: Interrupt A Long-Running Query + /// METHOD: sqlite3 + /// + /// ^This function causes any pending database operation to abort and + /// return at its earliest opportunity. This routine is typically + /// called in response to a user action such as pressing "Cancel" + /// or Ctrl-C where the user wants a long query operation to halt + /// immediately. + /// + /// ^It is safe to call this routine from a thread different from the + /// thread that is currently running the database operation. But it + /// is not safe to call this routine with a [database connection] that + /// is closed or might close before sqlite3_interrupt() returns. + /// + /// ^If an SQL operation is very nearly finished at the time when + /// sqlite3_interrupt() is called, then it might not have an opportunity + /// to be interrupted and might continue to completion. + /// + /// ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. + /// ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE + /// that is inside an explicit transaction, then the entire transaction + /// will be rolled back automatically. + /// + /// ^The sqlite3_interrupt(D) call is in effect until all currently running + /// SQL statements on [database connection] D complete. ^Any new SQL statements + /// that are started after the sqlite3_interrupt() call and before the + /// running statement count reaches zero are interrupted as if they had been + /// running prior to the sqlite3_interrupt() call. ^New SQL statements + /// that are started after the running statement count reaches zero are + /// not effected by the sqlite3_interrupt(). + /// ^A call to sqlite3_interrupt(D) that occurs when there are no running + /// SQL statements is a no-op and has no effect on SQL statements + /// that are started after the sqlite3_interrupt() call returns. + void sqlite3_interrupt(ffi.Pointer arg0) { + return _sqlite3_interrupt(arg0); } - late final _sqlite3_value_bytes16Ptr = - _lookup)>>( - 'sqlite3_value_bytes16', + late final _sqlite3_interruptPtr = + _lookup)>>( + 'sqlite3_interrupt', ); - late final _sqlite3_value_bytes16 = _sqlite3_value_bytes16Ptr - .asFunction)>(); + late final _sqlite3_interrupt = _sqlite3_interruptPtr + .asFunction)>(); - int sqlite3_value_type(ffi.Pointer arg0) { - return _sqlite3_value_type(arg0); + int sqlite3_keyword_check(ffi.Pointer arg0, int arg1) { + return _sqlite3_keyword_check(arg0, arg1); } - late final _sqlite3_value_typePtr = - _lookup)>>( - 'sqlite3_value_type', - ); - late final _sqlite3_value_type = _sqlite3_value_typePtr - .asFunction)>(); + late final _sqlite3_keyword_checkPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_keyword_check'); + late final _sqlite3_keyword_check = _sqlite3_keyword_checkPtr + .asFunction, int)>(); - int sqlite3_value_numeric_type(ffi.Pointer arg0) { - return _sqlite3_value_numeric_type(arg0); + /// CAPI3REF: SQL Keyword Checking + /// + /// These routines provide access to the set of SQL language keywords + /// recognized by SQLite. Applications can uses these routines to determine + /// whether or not a specific identifier needs to be escaped (for example, + /// by enclosing in double-quotes) so as not to confuse the parser. + /// + /// The sqlite3_keyword_count() interface returns the number of distinct + /// keywords understood by SQLite. + /// + /// The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and + /// makes *Z point to that keyword expressed as UTF8 and writes the number + /// of bytes in the keyword into *L. The string that *Z points to is not + /// zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns + /// SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z + /// or L are NULL or invalid pointers then calls to + /// sqlite3_keyword_name(N,Z,L) result in undefined behavior. + /// + /// The sqlite3_keyword_check(Z,L) interface checks to see whether or not + /// the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero + /// if it is and zero if not. + /// + /// The parser used by SQLite is forgiving. It is often possible to use + /// a keyword as an identifier as long as such use does not result in a + /// parsing ambiguity. For example, the statement + /// "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and + /// creates a new table named "BEGIN" with three columns named + /// "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid + /// using keywords as identifiers. Common techniques used to avoid keyword + /// name collisions include: + ///
    + ///
  • Put all identifier names inside double-quotes. This is the official + /// SQL way to escape identifier names. + ///
  • Put identifier names inside [...]. This is not standard SQL, + /// but it is what SQL Server does and so lots of programmers use this + /// technique. + ///
  • Begin every identifier with the letter "Z" as no SQL keywords start + /// with "Z". + ///
  • Include a digit somewhere in every identifier name. + ///
+ /// + /// Note that the number of keywords understood by SQLite can depend on + /// compile-time options. For example, "VACUUM" is not a keyword if + /// SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also, + /// new keywords may be added to future releases of SQLite. + int sqlite3_keyword_count() { + return _sqlite3_keyword_count(); } - late final _sqlite3_value_numeric_typePtr = - _lookup)>>( - 'sqlite3_value_numeric_type', - ); - late final _sqlite3_value_numeric_type = _sqlite3_value_numeric_typePtr - .asFunction)>(); + late final _sqlite3_keyword_countPtr = + _lookup>('sqlite3_keyword_count'); + late final _sqlite3_keyword_count = _sqlite3_keyword_countPtr + .asFunction(); - int sqlite3_value_nochange(ffi.Pointer arg0) { - return _sqlite3_value_nochange(arg0); + int sqlite3_keyword_name( + int arg0, + ffi.Pointer> arg1, + ffi.Pointer arg2, + ) { + return _sqlite3_keyword_name(arg0, arg1, arg2); } - late final _sqlite3_value_nochangePtr = - _lookup)>>( - 'sqlite3_value_nochange', - ); - late final _sqlite3_value_nochange = _sqlite3_value_nochangePtr - .asFunction)>(); - - int sqlite3_value_frombind(ffi.Pointer arg0) { - return _sqlite3_value_frombind(arg0); - } - - late final _sqlite3_value_frombindPtr = - _lookup)>>( - 'sqlite3_value_frombind', - ); - late final _sqlite3_value_frombind = _sqlite3_value_frombindPtr - .asFunction)>(); - - /// CAPI3REF: Finding The Subtype Of SQL Values - /// METHOD: sqlite3_value - /// - /// The sqlite3_value_subtype(V) function returns the subtype for - /// an [application-defined SQL function] argument V. The subtype - /// information can be used to pass a limited amount of context from - /// one SQL function to another. Use the [sqlite3_result_subtype()] - /// routine to set the subtype for the return value of an SQL function. - int sqlite3_value_subtype(ffi.Pointer arg0) { - return _sqlite3_value_subtype(arg0); - } - - late final _sqlite3_value_subtypePtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_value_subtype'); - late final _sqlite3_value_subtype = _sqlite3_value_subtypePtr - .asFunction)>(); - - /// CAPI3REF: Copy And Free SQL Values - /// METHOD: sqlite3_value - /// - /// ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value] - /// object D and returns a pointer to that copy. ^The [sqlite3_value] returned - /// is a [protected sqlite3_value] object even if the input is not. - /// ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a - /// memory allocation fails. - /// - /// ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object - /// previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer - /// then sqlite3_value_free(V) is a harmless no-op. - ffi.Pointer sqlite3_value_dup( - ffi.Pointer arg0, - ) { - return _sqlite3_value_dup(arg0); - } - - late final _sqlite3_value_dupPtr = + late final _sqlite3_keyword_namePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Int Function( + ffi.Int, + ffi.Pointer>, + ffi.Pointer, + ) > - >('sqlite3_value_dup'); - late final _sqlite3_value_dup = _sqlite3_value_dupPtr + >('sqlite3_keyword_name'); + late final _sqlite3_keyword_name = _sqlite3_keyword_namePtr .asFunction< - ffi.Pointer Function(ffi.Pointer) + int Function( + int, + ffi.Pointer>, + ffi.Pointer, + ) >(); - void sqlite3_value_free(ffi.Pointer arg0) { - return _sqlite3_value_free(arg0); - } - - late final _sqlite3_value_freePtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_value_free'); - late final _sqlite3_value_free = _sqlite3_value_freePtr - .asFunction)>(); - - /// CAPI3REF: Obtain Aggregate Function Context - /// METHOD: sqlite3_context + /// CAPI3REF: Last Insert Rowid + /// METHOD: sqlite3 /// - /// Implementations of aggregate SQL functions use this - /// routine to allocate memory for storing their state. + /// ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) + /// has a unique 64-bit signed + /// integer key called the [ROWID | "rowid"]. ^The rowid is always available + /// as an undeclared column named ROWID, OID, or _ROWID_ as long as those + /// names are not also used by explicitly declared columns. ^If + /// the table has a column of type [INTEGER PRIMARY KEY] then that column + /// is another alias for the rowid. /// - /// ^The first time the sqlite3_aggregate_context(C,N) routine is called - /// for a particular aggregate function, SQLite allocates - /// N bytes of memory, zeroes out that memory, and returns a pointer - /// to the new memory. ^On second and subsequent calls to - /// sqlite3_aggregate_context() for the same aggregate function instance, - /// the same buffer is returned. Sqlite3_aggregate_context() is normally - /// called once for each invocation of the xStep callback and then one - /// last time when the xFinal callback is invoked. ^(When no rows match - /// an aggregate query, the xStep() callback of the aggregate function - /// implementation is never called and xFinal() is called exactly once. - /// In those cases, sqlite3_aggregate_context() might be called for the - /// first time from within xFinal().)^ + /// ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of + /// the most recent successful [INSERT] into a rowid table or [virtual table] + /// on database connection D. ^Inserts into [WITHOUT ROWID] tables are not + /// recorded. ^If no successful [INSERT]s into rowid tables have ever occurred + /// on the database connection D, then sqlite3_last_insert_rowid(D) returns + /// zero. /// - /// ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer - /// when first called if N is less than or equal to zero or if a memory - /// allocate error occurs. + /// As well as being set automatically as rows are inserted into database + /// tables, the value returned by this function may be set explicitly by + /// [sqlite3_set_last_insert_rowid()] /// - /// ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is - /// determined by the N parameter on first successful call. Changing the - /// value of N in any subsequent call to sqlite3_aggregate_context() within - /// the same aggregate function instance will not resize the memory - /// allocation.)^ Within the xFinal callback, it is customary to set - /// N=0 in calls to sqlite3_aggregate_context(C,N) so that no - /// pointless memory allocations occur. + /// Some virtual table implementations may INSERT rows into rowid tables as + /// part of committing a transaction (e.g. to flush data accumulated in memory + /// to disk). In this case subsequent calls to this function return the rowid + /// associated with these internal INSERT operations, which leads to + /// unintuitive results. Virtual table implementations that do write to rowid + /// tables in this way can avoid this problem by restoring the original + /// rowid value using [sqlite3_set_last_insert_rowid()] before returning + /// control to the user. /// - /// ^SQLite automatically frees the memory allocated by - /// sqlite3_aggregate_context() when the aggregate query concludes. + /// ^(If an [INSERT] occurs within a trigger then this routine will + /// return the [rowid] of the inserted row as long as the trigger is + /// running. Once the trigger program ends, the value returned + /// by this routine reverts to what it was before the trigger was fired.)^ /// - /// The first parameter must be a copy of the - /// [sqlite3_context | SQL function context] that is the first parameter - /// to the xStep or xFinal callback routine that implements the aggregate - /// function. + /// ^An [INSERT] that fails due to a constraint violation is not a + /// successful [INSERT] and does not change the value returned by this + /// routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, + /// and INSERT OR ABORT make no changes to the return value of this + /// routine when their insertion fails. ^(When INSERT OR REPLACE + /// encounters a constraint violation, it does not fail. The + /// INSERT continues to completion after deleting rows that caused + /// the constraint problem so INSERT OR REPLACE will always change + /// the return value of this interface.)^ /// - /// This routine must be called from the same thread in which - /// the aggregate SQL function is running. - ffi.Pointer sqlite3_aggregate_context( - ffi.Pointer arg0, - int nBytes, - ) { - return _sqlite3_aggregate_context(arg0, nBytes); + /// ^For the purposes of this routine, an [INSERT] is considered to + /// be successful even if it is subsequently rolled back. + /// + /// This function is accessible to SQL statements via the + /// [last_insert_rowid() SQL function]. + /// + /// If a separate thread performs a new [INSERT] on the same + /// database connection while the [sqlite3_last_insert_rowid()] + /// function is running and thus changes the last insert [rowid], + /// then the value returned by [sqlite3_last_insert_rowid()] is + /// unpredictable and might not equal either the old or the new + /// last insert [rowid]. + int sqlite3_last_insert_rowid(ffi.Pointer arg0) { + return _sqlite3_last_insert_rowid(arg0); } - late final _sqlite3_aggregate_contextPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_aggregate_context'); - late final _sqlite3_aggregate_context = _sqlite3_aggregate_contextPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); + late final _sqlite3_last_insert_rowidPtr = + _lookup)>>( + 'sqlite3_last_insert_rowid', + ); + late final _sqlite3_last_insert_rowid = _sqlite3_last_insert_rowidPtr + .asFunction)>(); - /// CAPI3REF: User Data For Functions - /// METHOD: sqlite3_context - /// - /// ^The sqlite3_user_data() interface returns a copy of - /// the pointer that was the pUserData parameter (the 5th parameter) - /// of the [sqlite3_create_function()] - /// and [sqlite3_create_function16()] routines that originally - /// registered the application defined function. - /// - /// This routine must be called from the same thread in which - /// the application-defined function is running. - ffi.Pointer sqlite3_user_data(ffi.Pointer arg0) { - return _sqlite3_user_data(arg0); + ffi.Pointer sqlite3_libversion() { + return _sqlite3_libversion(); } - late final _sqlite3_user_dataPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_user_data'); - late final _sqlite3_user_data = _sqlite3_user_dataPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); + late final _sqlite3_libversionPtr = + _lookup Function()>>( + 'sqlite3_libversion', + ); + late final _sqlite3_libversion = _sqlite3_libversionPtr + .asFunction Function()>(); - /// CAPI3REF: Database Connection For Functions - /// METHOD: sqlite3_context - /// - /// ^The sqlite3_context_db_handle() interface returns a copy of - /// the pointer to the [database connection] (the 1st parameter) - /// of the [sqlite3_create_function()] - /// and [sqlite3_create_function16()] routines that originally - /// registered the application defined function. - ffi.Pointer sqlite3_context_db_handle( - ffi.Pointer arg0, - ) { - return _sqlite3_context_db_handle(arg0); + int sqlite3_libversion_number() { + return _sqlite3_libversion_number(); } - late final _sqlite3_context_db_handlePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_context_db_handle'); - late final _sqlite3_context_db_handle = _sqlite3_context_db_handlePtr - .asFunction< - ffi.Pointer Function(ffi.Pointer) - >(); + late final _sqlite3_libversion_numberPtr = + _lookup>( + 'sqlite3_libversion_number', + ); + late final _sqlite3_libversion_number = _sqlite3_libversion_numberPtr + .asFunction(); - /// CAPI3REF: Function Auxiliary Data - /// METHOD: sqlite3_context + /// CAPI3REF: Run-time Limits + /// METHOD: sqlite3 /// - /// These functions may be used by (non-aggregate) SQL functions to - /// associate metadata with argument values. If the same value is passed to - /// multiple invocations of the same SQL function during query execution, under - /// some circumstances the associated metadata may be preserved. An example - /// of where this might be useful is in a regular-expression matching - /// function. The compiled version of the regular expression can be stored as - /// metadata associated with the pattern string. - /// Then as long as the pattern string remains the same, - /// the compiled regular expression can be reused on multiple - /// invocations of the same function. - /// - /// ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata - /// associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument - /// value to the application-defined function. ^N is zero for the left-most - /// function argument. ^If there is no metadata - /// associated with the function argument, the sqlite3_get_auxdata(C,N) interface - /// returns a NULL pointer. - /// - /// ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th - /// argument of the application-defined function. ^Subsequent - /// calls to sqlite3_get_auxdata(C,N) return P from the most recent - /// sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or - /// NULL if the metadata has been discarded. - /// ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, - /// SQLite will invoke the destructor function X with parameter P exactly - /// once, when the metadata is discarded. - /// SQLite is free to discard the metadata at any time, including:
    - ///
  • ^(when the corresponding function parameter changes)^, or - ///
  • ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the - /// SQL statement)^, or - ///
  • ^(when sqlite3_set_auxdata() is invoked again on the same - /// parameter)^, or - ///
  • ^(during the original sqlite3_set_auxdata() call when a memory - /// allocation error occurs.)^
+ /// ^(This interface allows the size of various constructs to be limited + /// on a connection by connection basis. The first parameter is the + /// [database connection] whose limit is to be set or queried. The + /// second parameter is one of the [limit categories] that define a + /// class of constructs to be size limited. The third parameter is the + /// new limit for that construct.)^ /// - /// Note the last bullet in particular. The destructor X in - /// sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the - /// sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() - /// should be called near the end of the function implementation and the - /// function implementation should not make any use of P after - /// sqlite3_set_auxdata() has been called. + /// ^If the new limit is a negative number, the limit is unchanged. + /// ^(For each limit category SQLITE_LIMIT_NAME there is a + /// [limits | hard upper bound] + /// set at compile-time by a C preprocessor macro called + /// [limits | SQLITE_MAX_NAME]. + /// (The "_LIMIT_" in the name is changed to "_MAX_".))^ + /// ^Attempts to increase a limit above its hard upper bound are + /// silently truncated to the hard upper bound. /// - /// ^(In practice, metadata is preserved between function calls for - /// function parameters that are compile-time constants, including literal - /// values and [parameters] and expressions composed from the same.)^ + /// ^Regardless of whether or not the limit was changed, the + /// [sqlite3_limit()] interface returns the prior value of the limit. + /// ^Hence, to find the current value of a limit without changing it, + /// simply invoke this interface with the third parameter set to -1. /// - /// The value of the N parameter to these interfaces should be non-negative. - /// Future enhancements may make use of negative N values to define new - /// kinds of function caching behavior. + /// Run-time limits are intended for use in applications that manage + /// both their own internal database and also databases that are controlled + /// by untrusted external sources. An example application might be a + /// web browser that has its own databases for storing history and + /// separate databases controlled by JavaScript applications downloaded + /// off the Internet. The internal databases can be given the + /// large, default limits. Databases managed by external sources can + /// be given much smaller limits designed to prevent a denial of service + /// attack. Developers might also want to use the [sqlite3_set_authorizer()] + /// interface to further control untrusted SQL. The size of the database + /// created by an untrusted script can be contained using the + /// [max_page_count] [PRAGMA]. /// - /// These routines must be called from the same thread in which - /// the SQL function is running. - ffi.Pointer sqlite3_get_auxdata( - ffi.Pointer arg0, - int N, - ) { - return _sqlite3_get_auxdata(arg0, N); + /// New run-time limit categories may be added in future releases. + int sqlite3_limit(ffi.Pointer arg0, int id, int newVal) { + return _sqlite3_limit(arg0, id, newVal); } - late final _sqlite3_get_auxdataPtr = + late final _sqlite3_limitPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Int) > - >('sqlite3_get_auxdata'); - late final _sqlite3_get_auxdata = _sqlite3_get_auxdataPtr - .asFunction< - ffi.Pointer Function(ffi.Pointer, int) - >(); + >('sqlite3_limit'); + late final _sqlite3_limit = _sqlite3_limitPtr + .asFunction, int, int)>(); - void sqlite3_set_auxdata( - ffi.Pointer arg0, - int N, - ffi.Pointer arg2, - ffi.Pointer)>> - arg3, + /// CAPI3REF: Load An Extension + /// METHOD: sqlite3 + /// + /// ^This interface loads an SQLite extension library from the named file. + /// + /// ^The sqlite3_load_extension() interface attempts to load an + /// [SQLite extension] library contained in the file zFile. If + /// the file cannot be loaded directly, attempts are made to load + /// with various operating-system specific extensions added. + /// So for example, if "samplelib" cannot be loaded, then names like + /// "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might + /// be tried also. + /// + /// ^The entry point is zProc. + /// ^(zProc may be 0, in which case SQLite will try to come up with an + /// entry point name on its own. It first tries "sqlite3_extension_init". + /// If that does not work, it constructs a name "sqlite3_X_init" where the + /// X is consists of the lower-case equivalent of all ASCII alphabetic + /// characters in the filename from the last "/" to the first following + /// "." and omitting any initial "lib".)^ + /// ^The sqlite3_load_extension() interface returns + /// [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. + /// ^If an error occurs and pzErrMsg is not 0, then the + /// [sqlite3_load_extension()] interface shall attempt to + /// fill *pzErrMsg with error message text stored in memory + /// obtained from [sqlite3_malloc()]. The calling function + /// should free this memory by calling [sqlite3_free()]. + /// + /// ^Extension loading must be enabled using + /// [sqlite3_enable_load_extension()] or + /// [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL) + /// prior to calling this API, + /// otherwise an error will be returned. + /// + /// Security warning: It is recommended that the + /// [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this + /// interface. The use of the [sqlite3_enable_load_extension()] interface + /// should be avoided. This will keep the SQL function [load_extension()] + /// disabled and prevent SQL injections from giving attackers + /// access to extension loading capabilities. + /// + /// See also the [load_extension() SQL function]. + int sqlite3_load_extension( + ffi.Pointer db, + ffi.Pointer zFile, + ffi.Pointer zProc, + ffi.Pointer> pzErrMsg, ) { - return _sqlite3_set_auxdata(arg0, N, arg2, arg3); + return _sqlite3_load_extension(db, zFile, zProc, pzErrMsg); } - late final _sqlite3_set_auxdataPtr = + late final _sqlite3_load_extensionPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, ) > - >('sqlite3_set_auxdata'); - late final _sqlite3_set_auxdata = _sqlite3_set_auxdataPtr + >('sqlite3_load_extension'); + late final _sqlite3_load_extension = _sqlite3_load_extensionPtr .asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, ) >(); - /// CAPI3REF: Setting The Result Of An SQL Function - /// METHOD: sqlite3_context - /// - /// These routines are used by the xFunc or xFinal callbacks that - /// implement SQL functions and aggregates. See - /// [sqlite3_create_function()] and [sqlite3_create_function16()] - /// for additional information. + /// CAPI3REF: Error Logging Interface /// - /// These functions work very much like the [parameter binding] family of - /// functions used to bind values to host parameters in prepared statements. - /// Refer to the [SQL parameter] documentation for additional information. + /// ^The [sqlite3_log()] interface writes a message into the [error log] + /// established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. + /// ^If logging is enabled, the zFormat string and subsequent arguments are + /// used with [sqlite3_snprintf()] to generate the final output string. /// - /// ^The sqlite3_result_blob() interface sets the result from - /// an application-defined function to be the BLOB whose content is pointed - /// to by the second parameter and which is N bytes long where N is the - /// third parameter. + /// The sqlite3_log() interface is intended for use by extensions such as + /// virtual tables, collating functions, and SQL functions. While there is + /// nothing to prevent an application from calling sqlite3_log(), doing so + /// is considered bad form. /// - /// ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N) - /// interfaces set the result of the application-defined function to be - /// a BLOB containing all zero bytes and N bytes in size. + /// The zFormat string must not be NULL. /// - /// ^The sqlite3_result_double() interface sets the result from - /// an application-defined function to be a floating point value specified - /// by its 2nd argument. + /// To avoid deadlocks and other threading problems, the sqlite3_log() routine + /// will not use dynamically allocated memory. The log message is stored in + /// a fixed-length buffer on the stack. If the log message is longer than + /// a few hundred characters, it will be truncated to the length of the + /// buffer. + void sqlite3_log(int iErrCode, ffi.Pointer zFormat) { + return _sqlite3_log(iErrCode, zFormat); + } + + late final _sqlite3_logPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_log'); + late final _sqlite3_log = _sqlite3_logPtr + .asFunction)>(); + + /// CAPI3REF: Memory Allocation Subsystem /// - /// ^The sqlite3_result_error() and sqlite3_result_error16() functions - /// cause the implemented SQL function to throw an exception. - /// ^SQLite uses the string pointed to by the - /// 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() - /// as the text of an error message. ^SQLite interprets the error - /// message string from sqlite3_result_error() as UTF-8. ^SQLite - /// interprets the string from sqlite3_result_error16() as UTF-16 using - /// the same [byte-order determination rules] as [sqlite3_bind_text16()]. - /// ^If the third parameter to sqlite3_result_error() - /// or sqlite3_result_error16() is negative then SQLite takes as the error - /// message all text up through the first zero character. - /// ^If the third parameter to sqlite3_result_error() or - /// sqlite3_result_error16() is non-negative then SQLite takes that many - /// bytes (not characters) from the 2nd parameter as the error message. - /// ^The sqlite3_result_error() and sqlite3_result_error16() - /// routines make a private copy of the error message text before - /// they return. Hence, the calling function can deallocate or - /// modify the text after they return without harm. - /// ^The sqlite3_result_error_code() function changes the error code - /// returned by SQLite as a result of an error in a function. ^By default, - /// the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() - /// or sqlite3_result_error16() resets the error code to SQLITE_ERROR. + /// The SQLite core uses these three routines for all of its own + /// internal memory allocation needs. "Core" in the previous sentence + /// does not include operating-system specific [VFS] implementation. The + /// Windows VFS uses native malloc() and free() for some operations. /// - /// ^The sqlite3_result_error_toobig() interface causes SQLite to throw an - /// error indicating that a string or BLOB is too long to represent. - /// - /// ^The sqlite3_result_error_nomem() interface causes SQLite to throw an - /// error indicating that a memory allocation failed. + /// ^The sqlite3_malloc() routine returns a pointer to a block + /// of memory at least N bytes in length, where N is the parameter. + /// ^If sqlite3_malloc() is unable to obtain sufficient free + /// memory, it returns a NULL pointer. ^If the parameter N to + /// sqlite3_malloc() is zero or negative then sqlite3_malloc() returns + /// a NULL pointer. /// - /// ^The sqlite3_result_int() interface sets the return value - /// of the application-defined function to be the 32-bit signed integer - /// value given in the 2nd argument. - /// ^The sqlite3_result_int64() interface sets the return value - /// of the application-defined function to be the 64-bit signed integer - /// value given in the 2nd argument. + /// ^The sqlite3_malloc64(N) routine works just like + /// sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead + /// of a signed 32-bit integer. /// - /// ^The sqlite3_result_null() interface sets the return value - /// of the application-defined function to be NULL. + /// ^Calling sqlite3_free() with a pointer previously returned + /// by sqlite3_malloc() or sqlite3_realloc() releases that memory so + /// that it might be reused. ^The sqlite3_free() routine is + /// a no-op if is called with a NULL pointer. Passing a NULL pointer + /// to sqlite3_free() is harmless. After being freed, memory + /// should neither be read nor written. Even reading previously freed + /// memory might result in a segmentation fault or other severe error. + /// Memory corruption, a segmentation fault, or other severe error + /// might result if sqlite3_free() is called with a non-NULL pointer that + /// was not obtained from sqlite3_malloc() or sqlite3_realloc(). /// - /// ^The sqlite3_result_text(), sqlite3_result_text16(), - /// sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces - /// set the return value of the application-defined function to be - /// a text string which is represented as UTF-8, UTF-16 native byte order, - /// UTF-16 little endian, or UTF-16 big endian, respectively. - /// ^The sqlite3_result_text64() interface sets the return value of an - /// application-defined function to be a text string in an encoding - /// specified by the fifth (and last) parameter, which must be one - /// of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]. - /// ^SQLite takes the text result from the application from - /// the 2nd parameter of the sqlite3_result_text* interfaces. - /// ^If the 3rd parameter to the sqlite3_result_text* interfaces - /// is negative, then SQLite takes result text from the 2nd parameter - /// through the first zero character. - /// ^If the 3rd parameter to the sqlite3_result_text* interfaces - /// is non-negative, then as many bytes (not characters) of the text - /// pointed to by the 2nd parameter are taken as the application-defined - /// function result. If the 3rd parameter is non-negative, then it - /// must be the byte offset into the string where the NUL terminator would - /// appear if the string where NUL terminated. If any NUL characters occur - /// in the string at a byte offset that is less than the value of the 3rd - /// parameter, then the resulting string will contain embedded NULs and the - /// result of expressions operating on strings with embedded NULs is undefined. - /// ^If the 4th parameter to the sqlite3_result_text* interfaces - /// or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that - /// function as the destructor on the text or BLOB result when it has - /// finished using that result. - /// ^If the 4th parameter to the sqlite3_result_text* interfaces or to - /// sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite - /// assumes that the text or BLOB result is in constant space and does not - /// copy the content of the parameter nor call a destructor on the content - /// when it has finished using that result. - /// ^If the 4th parameter to the sqlite3_result_text* interfaces - /// or sqlite3_result_blob is the special constant SQLITE_TRANSIENT - /// then SQLite makes a copy of the result into space obtained - /// from [sqlite3_malloc()] before it returns. + /// ^The sqlite3_realloc(X,N) interface attempts to resize a + /// prior memory allocation X to be at least N bytes. + /// ^If the X parameter to sqlite3_realloc(X,N) + /// is a NULL pointer then its behavior is identical to calling + /// sqlite3_malloc(N). + /// ^If the N parameter to sqlite3_realloc(X,N) is zero or + /// negative then the behavior is exactly the same as calling + /// sqlite3_free(X). + /// ^sqlite3_realloc(X,N) returns a pointer to a memory allocation + /// of at least N bytes in size or NULL if insufficient memory is available. + /// ^If M is the size of the prior allocation, then min(N,M) bytes + /// of the prior allocation are copied into the beginning of buffer returned + /// by sqlite3_realloc(X,N) and the prior allocation is freed. + /// ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the + /// prior allocation is not freed. /// - /// ^For the sqlite3_result_text16(), sqlite3_result_text16le(), and - /// sqlite3_result_text16be() routines, and for sqlite3_result_text64() - /// when the encoding is not UTF8, if the input UTF16 begins with a - /// byte-order mark (BOM, U+FEFF) then the BOM is removed from the - /// string and the rest of the string is interpreted according to the - /// byte-order specified by the BOM. ^The byte-order specified by - /// the BOM at the beginning of the text overrides the byte-order - /// specified by the interface procedure. ^So, for example, if - /// sqlite3_result_text16le() is invoked with text that begins - /// with bytes 0xfe, 0xff (a big-endian byte-order mark) then the - /// first two bytes of input are skipped and the remaining input - /// is interpreted as UTF16BE text. + /// ^The sqlite3_realloc64(X,N) interfaces works the same as + /// sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead + /// of a 32-bit signed integer. /// - /// ^For UTF16 input text to the sqlite3_result_text16(), - /// sqlite3_result_text16be(), sqlite3_result_text16le(), and - /// sqlite3_result_text64() routines, if the text contains invalid - /// UTF16 characters, the invalid characters might be converted - /// into the unicode replacement character, U+FFFD. + /// ^If X is a memory allocation previously obtained from sqlite3_malloc(), + /// sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then + /// sqlite3_msize(X) returns the size of that memory allocation in bytes. + /// ^The value returned by sqlite3_msize(X) might be larger than the number + /// of bytes requested when X was allocated. ^If X is a NULL pointer then + /// sqlite3_msize(X) returns zero. If X points to something that is not + /// the beginning of memory allocation, or if it points to a formerly + /// valid memory allocation that has now been freed, then the behavior + /// of sqlite3_msize(X) is undefined and possibly harmful. /// - /// ^The sqlite3_result_value() interface sets the result of - /// the application-defined function to be a copy of the - /// [unprotected sqlite3_value] object specified by the 2nd parameter. ^The - /// sqlite3_result_value() interface makes a copy of the [sqlite3_value] - /// so that the [sqlite3_value] specified in the parameter may change or - /// be deallocated after sqlite3_result_value() returns without harm. - /// ^A [protected sqlite3_value] object may always be used where an - /// [unprotected sqlite3_value] object is required, so either - /// kind of [sqlite3_value] object can be used with this interface. + /// ^The memory returned by sqlite3_malloc(), sqlite3_realloc(), + /// sqlite3_malloc64(), and sqlite3_realloc64() + /// is always aligned to at least an 8 byte boundary, or to a + /// 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time + /// option is used. /// - /// ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an - /// SQL NULL value, just like [sqlite3_result_null(C)], except that it - /// also associates the host-language pointer P or type T with that - /// NULL value such that the pointer can be retrieved within an - /// [application-defined SQL function] using [sqlite3_value_pointer()]. - /// ^If the D parameter is not NULL, then it is a pointer to a destructor - /// for the P parameter. ^SQLite invokes D with P as its only argument - /// when SQLite is finished with P. The T parameter should be a static - /// string and preferably a string literal. The sqlite3_result_pointer() - /// routine is part of the [pointer passing interface] added for SQLite 3.20.0. + /// The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] + /// must be either NULL or else pointers obtained from a prior + /// invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have + /// not yet been released. /// - /// If these routines are called from within the different thread - /// than the one containing the application-defined function that received - /// the [sqlite3_context] pointer, the results are undefined. - void sqlite3_result_blob( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer)>> - arg3, - ) { - return _sqlite3_result_blob(arg0, arg1, arg2, arg3); + /// The application must not read or write any part of + /// a block of memory after it has been released using + /// [sqlite3_free()] or [sqlite3_realloc()]. + ffi.Pointer sqlite3_malloc(int arg0) { + return _sqlite3_malloc(arg0); } - late final _sqlite3_result_blobPtr = + late final _sqlite3_mallocPtr = + _lookup Function(ffi.Int)>>( + 'sqlite3_malloc', + ); + late final _sqlite3_malloc = _sqlite3_mallocPtr + .asFunction Function(int)>(); + + ffi.Pointer sqlite3_malloc64(int arg0) { + return _sqlite3_malloc64(arg0); + } + + late final _sqlite3_malloc64Ptr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('sqlite3_result_blob'); - late final _sqlite3_result_blob = _sqlite3_result_blobPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); + ffi.NativeFunction Function(sqlite3_uint64)> + >('sqlite3_malloc64'); + late final _sqlite3_malloc64 = _sqlite3_malloc64Ptr + .asFunction Function(int)>(); - void sqlite3_result_blob64( - ffi.Pointer arg0, + int sqlite3_memory_alarm( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, sqlite3_int64, ffi.Int) + > + > + arg0, ffi.Pointer arg1, int arg2, - ffi.Pointer)>> - arg3, ) { - return _sqlite3_result_blob64(arg0, arg1, arg2, arg3); + return _sqlite3_memory_alarm(arg0, arg1, arg2); } - late final _sqlite3_result_blob64Ptr = + late final _sqlite3_memory_alarmPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_uint64, + ffi.Int Function( ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, sqlite3_int64, ffi.Int) + > >, + ffi.Pointer, + sqlite3_int64, ) > - >('sqlite3_result_blob64'); - late final _sqlite3_result_blob64 = _sqlite3_result_blob64Ptr + >('sqlite3_memory_alarm'); + late final _sqlite3_memory_alarm = _sqlite3_memory_alarmPtr .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, + int Function( ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, sqlite3_int64, ffi.Int) + > >, + ffi.Pointer, + int, ) >(); - void sqlite3_result_double(ffi.Pointer arg0, double arg1) { - return _sqlite3_result_double(arg0, arg1); + int sqlite3_memory_highwater(int resetFlag) { + return _sqlite3_memory_highwater(resetFlag); } - late final _sqlite3_result_doublePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Double) - > - >('sqlite3_result_double'); - late final _sqlite3_result_double = _sqlite3_result_doublePtr - .asFunction, double)>(); + late final _sqlite3_memory_highwaterPtr = + _lookup>( + 'sqlite3_memory_highwater', + ); + late final _sqlite3_memory_highwater = _sqlite3_memory_highwaterPtr + .asFunction(); - void sqlite3_result_error( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _sqlite3_result_error(arg0, arg1, arg2); + /// CAPI3REF: Memory Allocator Statistics + /// + /// SQLite provides these two interfaces for reporting on the status + /// of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] + /// routines, which form the built-in memory allocation subsystem. + /// + /// ^The [sqlite3_memory_used()] routine returns the number of bytes + /// of memory currently outstanding (malloced but not freed). + /// ^The [sqlite3_memory_highwater()] routine returns the maximum + /// value of [sqlite3_memory_used()] since the high-water mark + /// was last reset. ^The values returned by [sqlite3_memory_used()] and + /// [sqlite3_memory_highwater()] include any overhead + /// added by SQLite in its implementation of [sqlite3_malloc()], + /// but not overhead added by the any underlying system library + /// routines that [sqlite3_malloc()] may call. + /// + /// ^The memory high-water mark is reset to the current value of + /// [sqlite3_memory_used()] if and only if the parameter to + /// [sqlite3_memory_highwater()] is true. ^The value returned + /// by [sqlite3_memory_highwater(1)] is the high-water mark + /// prior to the reset. + int sqlite3_memory_used() { + return _sqlite3_memory_used(); } - late final _sqlite3_result_errorPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('sqlite3_result_error'); - late final _sqlite3_result_error = _sqlite3_result_errorPtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); + late final _sqlite3_memory_usedPtr = + _lookup>( + 'sqlite3_memory_used', + ); + late final _sqlite3_memory_used = _sqlite3_memory_usedPtr + .asFunction(); - void sqlite3_result_error16( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _sqlite3_result_error16(arg0, arg1, arg2); + /// CAPI3REF: Formatted String Printing Functions + /// + /// These routines are work-alikes of the "printf()" family of functions + /// from the standard C library. + /// These routines understand most of the common formatting options from + /// the standard library printf() + /// plus some additional non-standard formats ([%q], [%Q], [%w], and [%z]). + /// See the [built-in printf()] documentation for details. + /// + /// ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their + /// results into memory obtained from [sqlite3_malloc64()]. + /// The strings returned by these two routines should be + /// released by [sqlite3_free()]. ^Both routines return a + /// NULL pointer if [sqlite3_malloc64()] is unable to allocate enough + /// memory to hold the resulting string. + /// + /// ^(The sqlite3_snprintf() routine is similar to "snprintf()" from + /// the standard C library. The result is written into the + /// buffer supplied as the second parameter whose size is given by + /// the first parameter. Note that the order of the + /// first two parameters is reversed from snprintf().)^ This is an + /// historical accident that cannot be fixed without breaking + /// backwards compatibility. ^(Note also that sqlite3_snprintf() + /// returns a pointer to its buffer instead of the number of + /// characters actually written into the buffer.)^ We admit that + /// the number of characters written would be a more useful return + /// value but we cannot change the implementation of sqlite3_snprintf() + /// now without breaking compatibility. + /// + /// ^As long as the buffer size is greater than zero, sqlite3_snprintf() + /// guarantees that the buffer is always zero-terminated. ^The first + /// parameter "n" is the total size of the buffer, including space for + /// the zero terminator. So the longest string that can be completely + /// written will be n-1 characters. + /// + /// ^The sqlite3_vsnprintf() routine is a varargs version of sqlite3_snprintf(). + /// + /// See also: [built-in printf()], [printf() SQL function] + ffi.Pointer sqlite3_mprintf(ffi.Pointer arg0) { + return _sqlite3_mprintf(arg0); } - late final _sqlite3_result_error16Ptr = + late final _sqlite3_mprintfPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_result_error16'); - late final _sqlite3_result_error16 = _sqlite3_result_error16Ptr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); + >('sqlite3_mprintf'); + late final _sqlite3_mprintf = _sqlite3_mprintfPtr + .asFunction Function(ffi.Pointer)>(); - void sqlite3_result_error_toobig(ffi.Pointer arg0) { - return _sqlite3_result_error_toobig(arg0); + int sqlite3_msize(ffi.Pointer arg0) { + return _sqlite3_msize(arg0); } - late final _sqlite3_result_error_toobigPtr = + late final _sqlite3_msizePtr = _lookup< - ffi.NativeFunction)> - >('sqlite3_result_error_toobig'); - late final _sqlite3_result_error_toobig = _sqlite3_result_error_toobigPtr - .asFunction)>(); + ffi.NativeFunction)> + >('sqlite3_msize'); + late final _sqlite3_msize = _sqlite3_msizePtr + .asFunction)>(); - void sqlite3_result_error_nomem(ffi.Pointer arg0) { - return _sqlite3_result_error_nomem(arg0); + /// CAPI3REF: Mutexes + /// + /// The SQLite core uses these routines for thread + /// synchronization. Though they are intended for internal + /// use by SQLite, code that links against SQLite is + /// permitted to use any of these routines. + /// + /// The SQLite source code contains multiple implementations + /// of these mutex routines. An appropriate implementation + /// is selected automatically at compile-time. The following + /// implementations are available in the SQLite core: + /// + ///
    + ///
  • SQLITE_MUTEX_PTHREADS + ///
  • SQLITE_MUTEX_W32 + ///
  • SQLITE_MUTEX_NOOP + ///
+ /// + /// The SQLITE_MUTEX_NOOP implementation is a set of routines + /// that does no real locking and is appropriate for use in + /// a single-threaded application. The SQLITE_MUTEX_PTHREADS and + /// SQLITE_MUTEX_W32 implementations are appropriate for use on Unix + /// and Windows. + /// + /// If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor + /// macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex + /// implementation is included with the library. In this case the + /// application must supply a custom mutex implementation using the + /// [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function + /// before calling sqlite3_initialize() or any other public sqlite3_ + /// function that calls sqlite3_initialize(). + /// + /// ^The sqlite3_mutex_alloc() routine allocates a new + /// mutex and returns a pointer to it. ^The sqlite3_mutex_alloc() + /// routine returns NULL if it is unable to allocate the requested + /// mutex. The argument to sqlite3_mutex_alloc() must one of these + /// integer constants: + /// + ///
    + ///
  • SQLITE_MUTEX_FAST + ///
  • SQLITE_MUTEX_RECURSIVE + ///
  • SQLITE_MUTEX_STATIC_MASTER + ///
  • SQLITE_MUTEX_STATIC_MEM + ///
  • SQLITE_MUTEX_STATIC_OPEN + ///
  • SQLITE_MUTEX_STATIC_PRNG + ///
  • SQLITE_MUTEX_STATIC_LRU + ///
  • SQLITE_MUTEX_STATIC_PMEM + ///
  • SQLITE_MUTEX_STATIC_APP1 + ///
  • SQLITE_MUTEX_STATIC_APP2 + ///
  • SQLITE_MUTEX_STATIC_APP3 + ///
  • SQLITE_MUTEX_STATIC_VFS1 + ///
  • SQLITE_MUTEX_STATIC_VFS2 + ///
  • SQLITE_MUTEX_STATIC_VFS3 + ///
+ /// + /// ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) + /// cause sqlite3_mutex_alloc() to create + /// a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE + /// is used but not necessarily so when SQLITE_MUTEX_FAST is used. + /// The mutex implementation does not need to make a distinction + /// between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does + /// not want to. SQLite will only request a recursive mutex in + /// cases where it really needs one. If a faster non-recursive mutex + /// implementation is available on the host platform, the mutex subsystem + /// might return such a mutex in response to SQLITE_MUTEX_FAST. + /// + /// ^The other allowed parameters to sqlite3_mutex_alloc() (anything other + /// than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return + /// a pointer to a static preexisting mutex. ^Nine static mutexes are + /// used by the current version of SQLite. Future versions of SQLite + /// may add additional static mutexes. Static mutexes are for internal + /// use by SQLite only. Applications that use SQLite mutexes should + /// use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or + /// SQLITE_MUTEX_RECURSIVE. + /// + /// ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST + /// or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() + /// returns a different mutex on every call. ^For the static + /// mutex types, the same mutex is returned on every call that has + /// the same type number. + /// + /// ^The sqlite3_mutex_free() routine deallocates a previously + /// allocated dynamic mutex. Attempting to deallocate a static + /// mutex results in undefined behavior. + /// + /// ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt + /// to enter a mutex. ^If another thread is already within the mutex, + /// sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return + /// SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] + /// upon successful entry. ^(Mutexes created using + /// SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. + /// In such cases, the + /// mutex must be exited an equal number of times before another thread + /// can enter.)^ If the same thread tries to enter any mutex other + /// than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined. + /// + /// ^(Some systems (for example, Windows 95) do not support the operation + /// implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() + /// will always return SQLITE_BUSY. The SQLite core only ever uses + /// sqlite3_mutex_try() as an optimization so this is acceptable + /// behavior.)^ + /// + /// ^The sqlite3_mutex_leave() routine exits a mutex that was + /// previously entered by the same thread. The behavior + /// is undefined if the mutex is not currently entered by the + /// calling thread or is not currently allocated. + /// + /// ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or + /// sqlite3_mutex_leave() is a NULL pointer, then all three routines + /// behave as no-ops. + /// + /// See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. + ffi.Pointer sqlite3_mutex_alloc(int arg0) { + return _sqlite3_mutex_alloc(arg0); } - late final _sqlite3_result_error_nomemPtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_result_error_nomem'); - late final _sqlite3_result_error_nomem = _sqlite3_result_error_nomemPtr - .asFunction)>(); + late final _sqlite3_mutex_allocPtr = + _lookup Function(ffi.Int)>>( + 'sqlite3_mutex_alloc', + ); + late final _sqlite3_mutex_alloc = _sqlite3_mutex_allocPtr + .asFunction Function(int)>(); - void sqlite3_result_error_code(ffi.Pointer arg0, int arg1) { - return _sqlite3_result_error_code(arg0, arg1); + void sqlite3_mutex_enter(ffi.Pointer arg0) { + return _sqlite3_mutex_enter(arg0); } - late final _sqlite3_result_error_codePtr = + late final _sqlite3_mutex_enterPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_result_error_code'); - late final _sqlite3_result_error_code = _sqlite3_result_error_codePtr - .asFunction, int)>(); + ffi.NativeFunction)> + >('sqlite3_mutex_enter'); + late final _sqlite3_mutex_enter = _sqlite3_mutex_enterPtr + .asFunction)>(); - void sqlite3_result_int(ffi.Pointer arg0, int arg1) { - return _sqlite3_result_int(arg0, arg1); + void sqlite3_mutex_free(ffi.Pointer arg0) { + return _sqlite3_mutex_free(arg0); } - late final _sqlite3_result_intPtr = + late final _sqlite3_mutex_freePtr = _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_result_int'); - late final _sqlite3_result_int = _sqlite3_result_intPtr - .asFunction, int)>(); + ffi.NativeFunction)> + >('sqlite3_mutex_free'); + late final _sqlite3_mutex_free = _sqlite3_mutex_freePtr + .asFunction)>(); - void sqlite3_result_int64(ffi.Pointer arg0, int arg1) { - return _sqlite3_result_int64(arg0, arg1); + int sqlite3_mutex_held(ffi.Pointer arg0) { + return _sqlite3_mutex_held(arg0); } - late final _sqlite3_result_int64Ptr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, sqlite3_int64) - > - >('sqlite3_result_int64'); - late final _sqlite3_result_int64 = _sqlite3_result_int64Ptr - .asFunction, int)>(); + late final _sqlite3_mutex_heldPtr = + _lookup)>>( + 'sqlite3_mutex_held', + ); + late final _sqlite3_mutex_held = _sqlite3_mutex_heldPtr + .asFunction)>(); - void sqlite3_result_null(ffi.Pointer arg0) { - return _sqlite3_result_null(arg0); + void sqlite3_mutex_leave(ffi.Pointer arg0) { + return _sqlite3_mutex_leave(arg0); } - late final _sqlite3_result_nullPtr = + late final _sqlite3_mutex_leavePtr = _lookup< - ffi.NativeFunction)> - >('sqlite3_result_null'); - late final _sqlite3_result_null = _sqlite3_result_nullPtr - .asFunction)>(); + ffi.NativeFunction)> + >('sqlite3_mutex_leave'); + late final _sqlite3_mutex_leave = _sqlite3_mutex_leavePtr + .asFunction)>(); - void sqlite3_result_text( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer)>> - arg3, - ) { - return _sqlite3_result_text(arg0, arg1, arg2, arg3); + int sqlite3_mutex_notheld(ffi.Pointer arg0) { + return _sqlite3_mutex_notheld(arg0); } - late final _sqlite3_result_textPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('sqlite3_result_text'); - late final _sqlite3_result_text = _sqlite3_result_textPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); + late final _sqlite3_mutex_notheldPtr = + _lookup)>>( + 'sqlite3_mutex_notheld', + ); + late final _sqlite3_mutex_notheld = _sqlite3_mutex_notheldPtr + .asFunction)>(); - void sqlite3_result_text64( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer)>> - arg3, - int encoding, - ) { - return _sqlite3_result_text64(arg0, arg1, arg2, arg3, encoding); + int sqlite3_mutex_try(ffi.Pointer arg0) { + return _sqlite3_mutex_try(arg0); } - late final _sqlite3_result_text64Ptr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_uint64, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.UnsignedChar, - ) - > - >('sqlite3_result_text64'); - late final _sqlite3_result_text64 = _sqlite3_result_text64Ptr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - int, - ) - >(); + late final _sqlite3_mutex_tryPtr = + _lookup)>>( + 'sqlite3_mutex_try', + ); + late final _sqlite3_mutex_try = _sqlite3_mutex_tryPtr + .asFunction)>(); - void sqlite3_result_text16( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer)>> - arg3, + /// CAPI3REF: Find the next prepared statement + /// METHOD: sqlite3 + /// + /// ^This interface returns a pointer to the next [prepared statement] after + /// pStmt associated with the [database connection] pDb. ^If pStmt is NULL + /// then this interface returns a pointer to the first prepared statement + /// associated with the database connection pDb. ^If no prepared statement + /// satisfies the conditions of this routine, it returns NULL. + /// + /// The [database connection] pointer D in a call to + /// [sqlite3_next_stmt(D,S)] must refer to an open database + /// connection and in particular must not be a NULL pointer. + ffi.Pointer sqlite3_next_stmt( + ffi.Pointer pDb, + ffi.Pointer pStmt, ) { - return _sqlite3_result_text16(arg0, arg1, arg2, arg3); + return _sqlite3_next_stmt(pDb, pStmt); } - late final _sqlite3_result_text16Ptr = + late final _sqlite3_next_stmtPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, ) > - >('sqlite3_result_text16'); - late final _sqlite3_result_text16 = _sqlite3_result_text16Ptr + >('sqlite3_next_stmt'); + late final _sqlite3_next_stmt = _sqlite3_next_stmtPtr .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, ) >(); - void sqlite3_result_text16le( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer)>> - arg3, + ffi.Pointer sqlite3_normalized_sql( + ffi.Pointer pStmt, ) { - return _sqlite3_result_text16le(arg0, arg1, arg2, arg3); + return _sqlite3_normalized_sql(pStmt); } - late final _sqlite3_result_text16lePtr = + late final _sqlite3_normalized_sqlPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_result_text16le'); - late final _sqlite3_result_text16le = _sqlite3_result_text16lePtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); - - void sqlite3_result_text16be( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ffi.Pointer)>> - arg3, - ) { - return _sqlite3_result_text16be(arg0, arg1, arg2, arg3); - } + >('sqlite3_normalized_sql'); + late final _sqlite3_normalized_sql = _sqlite3_normalized_sqlPtr + .asFunction Function(ffi.Pointer)>(); - late final _sqlite3_result_text16bePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('sqlite3_result_text16be'); - late final _sqlite3_result_text16be = _sqlite3_result_text16bePtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); - - void sqlite3_result_value( - ffi.Pointer arg0, - ffi.Pointer arg1, - ) { - return _sqlite3_result_value(arg0, arg1); - } - - late final _sqlite3_result_valuePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('sqlite3_result_value'); - late final _sqlite3_result_value = _sqlite3_result_valuePtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer) - >(); - - void sqlite3_result_pointer( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer arg2, - ffi.Pointer)>> - arg3, - ) { - return _sqlite3_result_pointer(arg0, arg1, arg2, arg3); - } - - late final _sqlite3_result_pointerPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('sqlite3_result_pointer'); - late final _sqlite3_result_pointer = _sqlite3_result_pointerPtr - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); - - void sqlite3_result_zeroblob(ffi.Pointer arg0, int n) { - return _sqlite3_result_zeroblob(arg0, n); - } - - late final _sqlite3_result_zeroblobPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int) - > - >('sqlite3_result_zeroblob'); - late final _sqlite3_result_zeroblob = _sqlite3_result_zeroblobPtr - .asFunction, int)>(); - - int sqlite3_result_zeroblob64(ffi.Pointer arg0, int n) { - return _sqlite3_result_zeroblob64(arg0, n); - } - - late final _sqlite3_result_zeroblob64Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, sqlite3_uint64) - > - >('sqlite3_result_zeroblob64'); - late final _sqlite3_result_zeroblob64 = _sqlite3_result_zeroblob64Ptr - .asFunction, int)>(); - - /// CAPI3REF: Setting The Subtype Of An SQL Function - /// METHOD: sqlite3_context + /// CAPI3REF: Opening A New Database Connection + /// CONSTRUCTOR: sqlite3 /// - /// The sqlite3_result_subtype(C,T) function causes the subtype of - /// the result from the [application-defined SQL function] with - /// [sqlite3_context] C to be the value T. Only the lower 8 bits - /// of the subtype T are preserved in current versions of SQLite; - /// higher order bits are discarded. - /// The number of subtype bytes preserved by SQLite might increase - /// in future releases of SQLite. - void sqlite3_result_subtype(ffi.Pointer arg0, int arg1) { - return _sqlite3_result_subtype(arg0, arg1); - } - - late final _sqlite3_result_subtypePtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) - > - >('sqlite3_result_subtype'); - late final _sqlite3_result_subtype = _sqlite3_result_subtypePtr - .asFunction, int)>(); - - /// CAPI3REF: Define New Collating Sequences - /// METHOD: sqlite3 + /// ^These routines open an SQLite database file as specified by the + /// filename argument. ^The filename argument is interpreted as UTF-8 for + /// sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte + /// order for sqlite3_open16(). ^(A [database connection] handle is usually + /// returned in *ppDb, even if an error occurs. The only exception is that + /// if SQLite is unable to allocate memory to hold the [sqlite3] object, + /// a NULL will be written into *ppDb instead of a pointer to the [sqlite3] + /// object.)^ ^(If the database is opened (and/or created) successfully, then + /// [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The + /// [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain + /// an English language description of the error following a failure of any + /// of the sqlite3_open() routines. /// - /// ^These functions add, remove, or modify a [collation] associated - /// with the [database connection] specified as the first argument. + /// ^The default encoding will be UTF-8 for databases created using + /// sqlite3_open() or sqlite3_open_v2(). ^The default encoding for databases + /// created using sqlite3_open16() will be UTF-16 in the native byte order. /// - /// ^The name of the collation is a UTF-8 string - /// for sqlite3_create_collation() and sqlite3_create_collation_v2() - /// and a UTF-16 string in native byte order for sqlite3_create_collation16(). - /// ^Collation names that compare equal according to [sqlite3_strnicmp()] are - /// considered to be the same name. + /// Whether or not an error occurs when it is opened, resources + /// associated with the [database connection] handle should be released by + /// passing it to [sqlite3_close()] when it is no longer required. /// - /// ^(The third argument (eTextRep) must be one of the constants: - ///
    - ///
  • [SQLITE_UTF8], - ///
  • [SQLITE_UTF16LE], - ///
  • [SQLITE_UTF16BE], - ///
  • [SQLITE_UTF16], or - ///
  • [SQLITE_UTF16_ALIGNED]. - ///
)^ - /// ^The eTextRep argument determines the encoding of strings passed - /// to the collating function callback, xCompare. - /// ^The [SQLITE_UTF16] and [SQLITE_UTF16_ALIGNED] values for eTextRep - /// force strings to be UTF16 with native byte order. - /// ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin - /// on an even byte address. + /// The sqlite3_open_v2() interface works like sqlite3_open() + /// except that it accepts two additional parameters for additional control + /// over the new database connection. ^(The flags parameter to + /// sqlite3_open_v2() must include, at a minimum, one of the following + /// three flag combinations:)^ /// - /// ^The fourth argument, pArg, is an application data pointer that is passed - /// through as the first argument to the collating function callback. + ///
+ /// ^(
[SQLITE_OPEN_READONLY]
+ ///
The database is opened in read-only mode. If the database does not + /// already exist, an error is returned.
)^ /// - /// ^The fifth argument, xCompare, is a pointer to the collating function. - /// ^Multiple collating functions can be registered using the same name but - /// with different eTextRep parameters and SQLite will use whichever - /// function requires the least amount of data transformation. - /// ^If the xCompare argument is NULL then the collating function is - /// deleted. ^When all collating functions having the same name are deleted, - /// that collation is no longer usable. + /// ^(
[SQLITE_OPEN_READWRITE]
+ ///
The database is opened for reading and writing if possible, or reading + /// only if the file is write protected by the operating system. In either + /// case the database must already exist, otherwise an error is returned.
)^ /// - /// ^The collating function callback is invoked with a copy of the pArg - /// application data pointer and with two strings in the encoding specified - /// by the eTextRep argument. The two integer parameters to the collating - /// function callback are the length of the two strings, in bytes. The collating - /// function must return an integer that is negative, zero, or positive - /// if the first string is less than, equal to, or greater than the second, - /// respectively. A collating function must always return the same answer - /// given the same inputs. If two or more collating functions are registered - /// to the same collation name (using different eTextRep values) then all - /// must give an equivalent answer when invoked with equivalent strings. - /// The collating function must obey the following properties for all - /// strings A, B, and C: + /// ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
+ ///
The database is opened for reading and writing, and is created if + /// it does not already exist. This is the behavior that is always used for + /// sqlite3_open() and sqlite3_open16().
)^ + ///
/// - ///
    - ///
  1. If A==B then B==A. - ///
  2. If A==B and B==C then A==C. - ///
  3. If A<B THEN B>A. - ///
  4. If A<B and B<C then A<C. - ///
+ /// In addition to the required flags, the following optional flags are + /// also supported: /// - /// If a collating function fails any of the above constraints and that - /// collating function is registered and used, then the behavior of SQLite - /// is undefined. + ///
+ /// ^(
[SQLITE_OPEN_URI]
+ ///
The filename can be interpreted as a URI if this flag is set.
)^ /// - /// ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() - /// with the addition that the xDestroy callback is invoked on pArg when - /// the collating function is deleted. - /// ^Collating functions are deleted when they are overridden by later - /// calls to the collation creation functions or when the - /// [database connection] is closed using [sqlite3_close()]. + /// ^(
[SQLITE_OPEN_MEMORY]
+ ///
The database will be opened as an in-memory database. The database + /// is named by the "filename" argument for the purposes of cache-sharing, + /// if shared cache mode is enabled, but the "filename" is otherwise ignored. + ///
)^ /// - /// ^The xDestroy callback is not called if the - /// sqlite3_create_collation_v2() function fails. Applications that invoke - /// sqlite3_create_collation_v2() with a non-NULL xDestroy argument should - /// check the return code and dispose of the application data pointer - /// themselves rather than expecting SQLite to deal with it for them. - /// This is different from every other SQLite interface. The inconsistency - /// is unfortunate but cannot be changed without breaking backwards - /// compatibility. + /// ^(
[SQLITE_OPEN_NOMUTEX]
+ ///
The new database connection will use the "multi-thread" + /// [threading mode].)^ This means that separate threads are allowed + /// to use SQLite at the same time, as long as each thread is using + /// a different [database connection]. /// - /// See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. - int sqlite3_create_collation( - ffi.Pointer arg0, - ffi.Pointer zName, - int eTextRep, - ffi.Pointer pArg, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xCompare, - ) { - return _sqlite3_create_collation(arg0, zName, eTextRep, pArg, xCompare); - } - - late final _sqlite3_create_collationPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - > - >('sqlite3_create_collation'); - late final _sqlite3_create_collation = _sqlite3_create_collationPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - >(); - - int sqlite3_create_collation_v2( - ffi.Pointer arg0, - ffi.Pointer zName, - int eTextRep, - ffi.Pointer pArg, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xCompare, - ffi.Pointer)>> - xDestroy, - ) { - return _sqlite3_create_collation_v2( - arg0, - zName, - eTextRep, - pArg, - xCompare, - xDestroy, - ); - } - - late final _sqlite3_create_collation_v2Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - >('sqlite3_create_collation_v2'); - late final _sqlite3_create_collation_v2 = _sqlite3_create_collation_v2Ptr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); - - int sqlite3_create_collation16( - ffi.Pointer arg0, - ffi.Pointer zName, - int eTextRep, - ffi.Pointer pArg, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xCompare, - ) { - return _sqlite3_create_collation16(arg0, zName, eTextRep, pArg, xCompare); - } - - late final _sqlite3_create_collation16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - > - >('sqlite3_create_collation16'); - late final _sqlite3_create_collation16 = _sqlite3_create_collation16Ptr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - >(); - - /// CAPI3REF: Collation Needed Callbacks - /// METHOD: sqlite3 - /// - /// ^To avoid having to register all collation sequences before a database - /// can be used, a single callback function may be registered with the - /// [database connection] to be invoked whenever an undefined collation - /// sequence is required. - /// - /// ^If the function is registered using the sqlite3_collation_needed() API, - /// then it is passed the names of undefined collation sequences as strings - /// encoded in UTF-8. ^If sqlite3_collation_needed16() is used, - /// the names are passed as UTF-16 in machine native byte order. - /// ^A call to either function replaces the existing collation-needed callback. - /// - /// ^(When the callback is invoked, the first argument passed is a copy - /// of the second argument to sqlite3_collation_needed() or - /// sqlite3_collation_needed16(). The second argument is the database - /// connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], - /// or [SQLITE_UTF16LE], indicating the most desirable form of the collation - /// sequence function required. The fourth parameter is the name of the - /// required collation sequence.)^ - /// - /// The callback function should register the desired collation using - /// [sqlite3_create_collation()], [sqlite3_create_collation16()], or - /// [sqlite3_create_collation_v2()]. - int sqlite3_collation_needed( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - arg2, - ) { - return _sqlite3_collation_needed(arg0, arg1, arg2); - } - - late final _sqlite3_collation_neededPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - > - >('sqlite3_collation_needed'); - late final _sqlite3_collation_needed = _sqlite3_collation_neededPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - >(); - - int sqlite3_collation_needed16( - ffi.Pointer arg0, - ffi.Pointer arg1, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - arg2, - ) { - return _sqlite3_collation_needed16(arg0, arg1, arg2); - } - - late final _sqlite3_collation_needed16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - > - >('sqlite3_collation_needed16'); - late final _sqlite3_collation_needed16 = _sqlite3_collation_needed16Ptr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - >, - ) - >(); - - /// CAPI3REF: Suspend Execution For A Short Time - /// - /// The sqlite3_sleep() function causes the current thread to suspend execution - /// for at least a number of milliseconds specified in its parameter. - /// - /// If the operating system does not support sleep requests with - /// millisecond time resolution, then the time will be rounded up to - /// the nearest second. The number of milliseconds of sleep actually - /// requested from the operating system is returned. - /// - /// ^SQLite implements this interface by calling the xSleep() - /// method of the default [sqlite3_vfs] object. If the xSleep() method - /// of the default VFS is not implemented correctly, or not implemented at - /// all, then the behavior of sqlite3_sleep() may deviate from the description - /// in the previous paragraphs. - int sqlite3_sleep(int arg0) { - return _sqlite3_sleep(arg0); - } - - late final _sqlite3_sleepPtr = - _lookup>('sqlite3_sleep'); - late final _sqlite3_sleep = _sqlite3_sleepPtr.asFunction(); - - /// CAPI3REF: Name Of The Folder Holding Temporary Files - /// - /// ^(If this global variable is made to point to a string which is - /// the name of a folder (a.k.a. directory), then all temporary files - /// created by SQLite when using a built-in [sqlite3_vfs | VFS] - /// will be placed in that directory.)^ ^If this variable - /// is a NULL pointer, then SQLite performs a search for an appropriate - /// temporary file directory. - /// - /// Applications are strongly discouraged from using this global variable. - /// It is required to set a temporary folder on Windows Runtime (WinRT). - /// But for all other platforms, it is highly recommended that applications - /// neither read nor write this variable. This global variable is a relic - /// that exists for backwards compatibility of legacy applications and should - /// be avoided in new projects. - /// - /// It is not safe to read or modify this variable in more than one - /// thread at a time. It is not safe to read or modify this variable - /// if a [database connection] is being used at the same time in a separate - /// thread. - /// It is intended that this variable be set once - /// as part of process initialization and before any SQLite interface - /// routines have been called and that this variable remain unchanged - /// thereafter. - /// - /// ^The [temp_store_directory pragma] may modify this variable and cause - /// it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, - /// the [temp_store_directory pragma] always assumes that any string - /// that this variable points to is held in memory obtained from - /// [sqlite3_malloc] and the pragma may attempt to free that memory - /// using [sqlite3_free]. - /// Hence, if this variable is modified directly, either it should be - /// made NULL or made to point to memory obtained from [sqlite3_malloc] - /// or else the use of the [temp_store_directory pragma] should be avoided. - /// Except when requested by the [temp_store_directory pragma], SQLite - /// does not free the memory that sqlite3_temp_directory points to. If - /// the application wants that memory to be freed, it must do - /// so itself, taking care to only do so after all [database connection] - /// objects have been destroyed. - /// - /// Note to Windows Runtime users: The temporary directory must be set - /// prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various - /// features that require the use of temporary files may fail. Here is an - /// example of how to do this using C++ with the Windows Runtime: - /// - ///
-  /// LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
-  ///       TemporaryFolder->Path->Data();
-  /// char zPathBuf[MAX_PATH + 1];
-  /// memset(zPathBuf, 0, sizeof(zPathBuf));
-  /// WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
-  ///       NULL, NULL);
-  /// sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
-  /// 
- late final ffi.Pointer> _sqlite3_temp_directory = - _lookup>('sqlite3_temp_directory'); - - ffi.Pointer get sqlite3_temp_directory => - _sqlite3_temp_directory.value; - - set sqlite3_temp_directory(ffi.Pointer value) => - _sqlite3_temp_directory.value = value; - - /// CAPI3REF: Name Of The Folder Holding Database Files - /// - /// ^(If this global variable is made to point to a string which is - /// the name of a folder (a.k.a. directory), then all database files - /// specified with a relative pathname and created or accessed by - /// SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed - /// to be relative to that directory.)^ ^If this variable is a NULL - /// pointer, then SQLite assumes that all database files specified - /// with a relative pathname are relative to the current directory - /// for the process. Only the windows VFS makes use of this global - /// variable; it is ignored by the unix VFS. - /// - /// Changing the value of this variable while a database connection is - /// open can result in a corrupt database. - /// - /// It is not safe to read or modify this variable in more than one - /// thread at a time. It is not safe to read or modify this variable - /// if a [database connection] is being used at the same time in a separate - /// thread. - /// It is intended that this variable be set once - /// as part of process initialization and before any SQLite interface - /// routines have been called and that this variable remain unchanged - /// thereafter. + /// ^(
[SQLITE_OPEN_FULLMUTEX]
+ ///
The new database connection will use the "serialized" + /// [threading mode].)^ This means the multiple threads can safely + /// attempt to use the same database connection at the same time. + /// (Mutexes will block any actual concurrency, but in this mode + /// there is no harm in trying.) /// - /// ^The [data_store_directory pragma] may modify this variable and cause - /// it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, - /// the [data_store_directory pragma] always assumes that any string - /// that this variable points to is held in memory obtained from - /// [sqlite3_malloc] and the pragma may attempt to free that memory - /// using [sqlite3_free]. - /// Hence, if this variable is modified directly, either it should be - /// made NULL or made to point to memory obtained from [sqlite3_malloc] - /// or else the use of the [data_store_directory pragma] should be avoided. - late final ffi.Pointer> _sqlite3_data_directory = - _lookup>('sqlite3_data_directory'); - - ffi.Pointer get sqlite3_data_directory => - _sqlite3_data_directory.value; - - set sqlite3_data_directory(ffi.Pointer value) => - _sqlite3_data_directory.value = value; - - /// CAPI3REF: Win32 Specific Interface + /// ^(
[SQLITE_OPEN_SHAREDCACHE]
+ ///
The database is opened [shared cache] enabled, overriding + /// the default shared cache setting provided by + /// [sqlite3_enable_shared_cache()].)^ /// - /// These interfaces are available only on Windows. The - /// [sqlite3_win32_set_directory] interface is used to set the value associated - /// with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to - /// zValue, depending on the value of the type parameter. The zValue parameter - /// should be NULL to cause the previous value to be freed via [sqlite3_free]; - /// a non-NULL value will be copied into memory obtained from [sqlite3_malloc] - /// prior to being used. The [sqlite3_win32_set_directory] interface returns - /// [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported, - /// or [SQLITE_NOMEM] if memory could not be allocated. The value of the - /// [sqlite3_data_directory] variable is intended to act as a replacement for - /// the current directory on the sub-platforms of Win32 where that concept is - /// not present, e.g. WinRT and UWP. The [sqlite3_win32_set_directory8] and - /// [sqlite3_win32_set_directory16] interfaces behave exactly the same as the - /// sqlite3_win32_set_directory interface except the string parameter must be - /// UTF-8 or UTF-16, respectively. - int sqlite3_win32_set_directory(int type, ffi.Pointer zValue) { - return _sqlite3_win32_set_directory(type, zValue); - } - - late final _sqlite3_win32_set_directoryPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.UnsignedLong, ffi.Pointer) - > - >('sqlite3_win32_set_directory'); - late final _sqlite3_win32_set_directory = _sqlite3_win32_set_directoryPtr - .asFunction)>(); - - int sqlite3_win32_set_directory8(int type, ffi.Pointer zValue) { - return _sqlite3_win32_set_directory8(type, zValue); - } - - late final _sqlite3_win32_set_directory8Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.UnsignedLong, ffi.Pointer) - > - >('sqlite3_win32_set_directory8'); - late final _sqlite3_win32_set_directory8 = _sqlite3_win32_set_directory8Ptr - .asFunction)>(); - - int sqlite3_win32_set_directory16(int type, ffi.Pointer zValue) { - return _sqlite3_win32_set_directory16(type, zValue); - } - - late final _sqlite3_win32_set_directory16Ptr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.UnsignedLong, ffi.Pointer) - > - >('sqlite3_win32_set_directory16'); - late final _sqlite3_win32_set_directory16 = _sqlite3_win32_set_directory16Ptr - .asFunction)>(); - - /// CAPI3REF: Test For Auto-Commit Mode - /// KEYWORDS: {autocommit mode} - /// METHOD: sqlite3 + /// ^(
[SQLITE_OPEN_PRIVATECACHE]
+ ///
The database is opened [shared cache] disabled, overriding + /// the default shared cache setting provided by + /// [sqlite3_enable_shared_cache()].)^ /// - /// ^The sqlite3_get_autocommit() interface returns non-zero or - /// zero if the given database connection is or is not in autocommit mode, - /// respectively. ^Autocommit mode is on by default. - /// ^Autocommit mode is disabled by a [BEGIN] statement. - /// ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. + /// [[OPEN_NOFOLLOW]] ^(
[SQLITE_OPEN_NOFOLLOW]
+ ///
The database filename is not allowed to be a symbolic link
+ ///
)^ /// - /// If certain kinds of errors occur on a statement within a multi-statement - /// transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], - /// [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the - /// transaction might be rolled back automatically. The only way to - /// find out whether SQLite automatically rolled back the transaction after - /// an error is to use this function. + /// If the 3rd parameter to sqlite3_open_v2() is not one of the + /// required combinations shown above optionally combined with other + /// [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] + /// then the behavior is undefined. /// - /// If another thread changes the autocommit status of the database - /// connection while this routine is running, then the return value - /// is undefined. - int sqlite3_get_autocommit(ffi.Pointer arg0) { - return _sqlite3_get_autocommit(arg0); - } - - late final _sqlite3_get_autocommitPtr = - _lookup)>>( - 'sqlite3_get_autocommit', - ); - late final _sqlite3_get_autocommit = _sqlite3_get_autocommitPtr - .asFunction)>(); - - /// CAPI3REF: Find The Database Handle Of A Prepared Statement - /// METHOD: sqlite3_stmt + /// ^The fourth parameter to sqlite3_open_v2() is the name of the + /// [sqlite3_vfs] object that defines the operating system interface that + /// the new database connection should use. ^If the fourth parameter is + /// a NULL pointer then the default [sqlite3_vfs] object is used. /// - /// ^The sqlite3_db_handle interface returns the [database connection] handle - /// to which a [prepared statement] belongs. ^The [database connection] - /// returned by sqlite3_db_handle is the same [database connection] - /// that was the first argument - /// to the [sqlite3_prepare_v2()] call (or its variants) that was used to - /// create the statement in the first place. - ffi.Pointer sqlite3_db_handle(ffi.Pointer arg0) { - return _sqlite3_db_handle(arg0); - } - - late final _sqlite3_db_handlePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_db_handle'); - late final _sqlite3_db_handle = _sqlite3_db_handlePtr - .asFunction Function(ffi.Pointer)>(); - - /// CAPI3REF: Return The Filename For A Database Connection - /// METHOD: sqlite3 + /// ^If the filename is ":memory:", then a private, temporary in-memory database + /// is created for the connection. ^This in-memory database will vanish when + /// the database connection is closed. Future versions of SQLite might + /// make use of additional special filenames that begin with the ":" character. + /// It is recommended that when a database filename actually does begin with + /// a ":" character you should prefix the filename with a pathname such as + /// "./" to avoid ambiguity. /// - /// ^The sqlite3_db_filename(D,N) interface returns a pointer to the filename - /// associated with database N of connection D. - /// ^If there is no attached database N on the database - /// connection D, or if database N is a temporary or in-memory database, then - /// this function will return either a NULL pointer or an empty string. + /// ^If the filename is an empty string, then a private, temporary + /// on-disk database will be created. ^This private database will be + /// automatically deleted as soon as the database connection is closed. /// - /// ^The string value returned by this routine is owned and managed by - /// the database connection. ^The value will be valid until the database N - /// is [DETACH]-ed or until the database connection closes. + /// [[URI filenames in sqlite3_open()]]

URI Filenames

/// - /// ^The filename returned by this function is the output of the - /// xFullPathname method of the [VFS]. ^In other words, the filename - /// will be an absolute pathname, even if the filename used - /// to open the database originally was a URI or relative pathname. + /// ^If [URI filename] interpretation is enabled, and the filename argument + /// begins with "file:", then the filename is interpreted as a URI. ^URI + /// filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is + /// set in the third argument to sqlite3_open_v2(), or if it has + /// been enabled globally using the [SQLITE_CONFIG_URI] option with the + /// [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option. + /// URI filename interpretation is turned off + /// by default, but future releases of SQLite might enable URI filename + /// interpretation by default. See "[URI filenames]" for additional + /// information. + /// + /// URI filenames are parsed according to RFC 3986. ^If the URI contains an + /// authority, then it must be either an empty string or the string + /// "localhost". ^If the authority is not an empty string or "localhost", an + /// error is returned to the caller. ^The fragment component of a URI, if + /// present, is ignored. + /// + /// ^SQLite uses the path component of the URI as the name of the disk file + /// which contains the database. ^If the path begins with a '/' character, + /// then it is interpreted as an absolute path. ^If the path does not begin + /// with a '/' (meaning that the authority section is omitted from the URI) + /// then the path is interpreted as a relative path. + /// ^(On windows, the first component of an absolute path + /// is a drive specification (e.g. "C:").)^ + /// + /// [[core URI query parameters]] + /// The query component of a URI may contain parameters that are interpreted + /// either by SQLite itself, or by a [VFS | custom VFS implementation]. + /// SQLite and its built-in [VFSes] interpret the + /// following query parameters: /// - /// If the filename pointer returned by this routine is not NULL, then it - /// can be used as the filename input parameter to these routines: ///
    - ///
  • [sqlite3_uri_parameter()] - ///
  • [sqlite3_uri_boolean()] - ///
  • [sqlite3_uri_int64()] - ///
  • [sqlite3_filename_database()] - ///
  • [sqlite3_filename_journal()] - ///
  • [sqlite3_filename_wal()] - ///
- ffi.Pointer sqlite3_db_filename( - ffi.Pointer db, - ffi.Pointer zDbName, - ) { - return _sqlite3_db_filename(db, zDbName); - } - - late final _sqlite3_db_filenamePtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('sqlite3_db_filename'); - late final _sqlite3_db_filename = _sqlite3_db_filenamePtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - /// CAPI3REF: Determine if a database is read-only - /// METHOD: sqlite3 + ///
  • vfs: ^The "vfs" parameter may be used to specify the name of + /// a VFS object that provides the operating system interface that should + /// be used to access the database file on disk. ^If this option is set to + /// an empty string the default VFS object is used. ^Specifying an unknown + /// VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is + /// present, then the VFS specified by the option takes precedence over + /// the value passed as the fourth parameter to sqlite3_open_v2(). /// - /// ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N - /// of connection D is read-only, 0 if it is read/write, or -1 if N is not - /// the name of a database on connection D. - int sqlite3_db_readonly( - ffi.Pointer db, - ffi.Pointer zDbName, - ) { - return _sqlite3_db_readonly(db, zDbName); - } - - late final _sqlite3_db_readonlyPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sqlite3_db_readonly'); - late final _sqlite3_db_readonly = _sqlite3_db_readonlyPtr - .asFunction, ffi.Pointer)>(); - - /// CAPI3REF: Find the next prepared statement - /// METHOD: sqlite3 + ///
  • mode: ^(The mode parameter may be set to either "ro", "rw", + /// "rwc", or "memory". Attempting to set it to any other value is + /// an error)^. + /// ^If "ro" is specified, then the database is opened for read-only + /// access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the + /// third argument to sqlite3_open_v2(). ^If the mode option is set to + /// "rw", then the database is opened for read-write (but not create) + /// access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had + /// been set. ^Value "rwc" is equivalent to setting both + /// SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is + /// set to "memory" then a pure [in-memory database] that never reads + /// or writes from disk is used. ^It is an error to specify a value for + /// the mode parameter that is less restrictive than that specified by + /// the flags passed in the third parameter to sqlite3_open_v2(). /// - /// ^This interface returns a pointer to the next [prepared statement] after - /// pStmt associated with the [database connection] pDb. ^If pStmt is NULL - /// then this interface returns a pointer to the first prepared statement - /// associated with the database connection pDb. ^If no prepared statement - /// satisfies the conditions of this routine, it returns NULL. + ///
  • cache: ^The cache parameter may be set to either "shared" or + /// "private". ^Setting it to "shared" is equivalent to setting the + /// SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to + /// sqlite3_open_v2(). ^Setting the cache parameter to "private" is + /// equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. + /// ^If sqlite3_open_v2() is used and the "cache" parameter is present in + /// a URI filename, its value overrides any behavior requested by setting + /// SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. /// - /// The [database connection] pointer D in a call to - /// [sqlite3_next_stmt(D,S)] must refer to an open database - /// connection and in particular must not be a NULL pointer. - ffi.Pointer sqlite3_next_stmt( - ffi.Pointer pDb, - ffi.Pointer pStmt, - ) { - return _sqlite3_next_stmt(pDb, pStmt); - } - - late final _sqlite3_next_stmtPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >('sqlite3_next_stmt'); - late final _sqlite3_next_stmt = _sqlite3_next_stmtPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); - - /// CAPI3REF: Commit And Rollback Notification Callbacks - /// METHOD: sqlite3 + ///
  • psow: ^The psow parameter indicates whether or not the + /// [powersafe overwrite] property does or does not apply to the + /// storage media on which the database file resides. /// - /// ^The sqlite3_commit_hook() interface registers a callback - /// function to be invoked whenever a transaction is [COMMIT | committed]. - /// ^Any callback set by a previous call to sqlite3_commit_hook() - /// for the same database connection is overridden. - /// ^The sqlite3_rollback_hook() interface registers a callback - /// function to be invoked whenever a transaction is [ROLLBACK | rolled back]. - /// ^Any callback set by a previous call to sqlite3_rollback_hook() - /// for the same database connection is overridden. - /// ^The pArg argument is passed through to the callback. - /// ^If the callback on a commit hook function returns non-zero, - /// then the commit is converted into a rollback. + ///
  • nolock: ^The nolock parameter is a boolean query parameter + /// which if set disables file locking in rollback journal modes. This + /// is useful for accessing a database on a filesystem that does not + /// support locking. Caution: Database corruption might result if two + /// or more processes write to the same database and any one of those + /// processes uses nolock=1. + /// + ///
  • immutable: ^The immutable parameter is a boolean query + /// parameter that indicates that the database file is stored on + /// read-only media. ^When immutable is set, SQLite assumes that the + /// database file cannot be changed, even by a process with higher + /// privilege, and so the database is opened read-only and all locking + /// and change detection is disabled. Caution: Setting the immutable + /// property on a database file that does in fact change can result + /// in incorrect query results and/or [SQLITE_CORRUPT] errors. + /// See also: [SQLITE_IOCAP_IMMUTABLE]. /// - /// ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions - /// return the P argument from the previous call of the same function - /// on the same [database connection] D, or NULL for - /// the first call for each function on D. + /// /// - /// The commit and rollback hook callbacks are not reentrant. - /// The callback implementation must not do anything that will modify - /// the database connection that invoked the callback. Any actions - /// to modify the database connection must be deferred until after the - /// completion of the [sqlite3_step()] call that triggered the commit - /// or rollback hook in the first place. - /// Note that running any other SQL statements, including SELECT statements, - /// or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify - /// the database connections for the meaning of "modify" in this paragraph. + /// ^Specifying an unknown parameter in the query component of a URI is not an + /// error. Future versions of SQLite might understand additional query + /// parameters. See "[query parameters with special meaning to SQLite]" for + /// additional information. /// - /// ^Registering a NULL function disables the callback. + /// [[URI filename examples]]

    URI filename examples

    /// - /// ^When the commit hook callback routine returns zero, the [COMMIT] - /// operation is allowed to continue normally. ^If the commit hook - /// returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. - /// ^The rollback hook is invoked on a rollback that results from a commit - /// hook returning non-zero, just as it would be with any other rollback. + /// + ///
    URI filenames Results + ///
    file:data.db + /// Open the file "data.db" in the current directory. + ///
    file:/home/fred/data.db
    + /// file:///home/fred/data.db
    + /// file://localhost/home/fred/data.db
    + /// Open the database file "/home/fred/data.db". + ///
    file://darkstar/home/fred/data.db + /// An error. "darkstar" is not a recognized authority. + ///
    + /// file:///C:/Documents%20and%20Settings/fred/Desktop/data.db + /// Windows only: Open the file "data.db" on fred's desktop on drive + /// C:. Note that the %20 escaping in this example is not strictly + /// necessary - space characters can be used literally + /// in URI filenames. + ///
    file:data.db?mode=ro&cache=private + /// Open file "data.db" in the current directory for read-only access. + /// Regardless of whether or not shared-cache mode is enabled by + /// default, use a private cache. + ///
    file:/home/fred/data.db?vfs=unix-dotfile + /// Open file "/home/fred/data.db". Use the special VFS "unix-dotfile" + /// that uses dot-files in place of posix advisory locking. + ///
    file:data.db?mode=readonly + /// An error. "readonly" is not a valid option for the "mode" parameter. + ///
    /// - /// ^For the purposes of this API, a transaction is said to have been - /// rolled back if an explicit "ROLLBACK" statement is executed, or - /// an error or constraint causes an implicit rollback to occur. - /// ^The rollback callback is not invoked if a transaction is - /// automatically rolled back because the database connection is closed. + /// ^URI hexadecimal escape sequences (%HH) are supported within the path and + /// query components of a URI. A hexadecimal escape sequence consists of a + /// percent sign - "%" - followed by exactly two hexadecimal digits + /// specifying an octet value. ^Before the path or query components of a + /// URI filename are interpreted, they are encoded using UTF-8 and all + /// hexadecimal escape sequences replaced by a single byte containing the + /// corresponding octet. If this process generates an invalid UTF-8 encoding, + /// the results are undefined. /// - /// See also the [sqlite3_update_hook()] interface. - ffi.Pointer sqlite3_commit_hook( - ffi.Pointer arg0, - ffi.Pointer)>> - arg1, - ffi.Pointer arg2, + /// Note to Windows users: The encoding used for the filename argument + /// of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever + /// codepage is currently defined. Filenames containing international + /// characters must be converted to UTF-8 prior to passing them into + /// sqlite3_open() or sqlite3_open_v2(). + /// + /// Note to Windows Runtime users: The temporary directory must be set + /// prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various + /// features that require the use of temporary files may fail. + /// + /// See also: [sqlite3_temp_directory] + int sqlite3_open( + ffi.Pointer filename, + ffi.Pointer> ppDb, ) { - return _sqlite3_commit_hook(arg0, arg1, arg2); + return _sqlite3_open(filename, ppDb); } - late final _sqlite3_commit_hookPtr = + late final _sqlite3_openPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, + ffi.Pointer>, ) > - >('sqlite3_commit_hook'); - late final _sqlite3_commit_hook = _sqlite3_commit_hookPtr + >('sqlite3_open'); + late final _sqlite3_open = _sqlite3_openPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer>) >(); - ffi.Pointer sqlite3_rollback_hook( - ffi.Pointer arg0, - ffi.Pointer)>> - arg1, - ffi.Pointer arg2, + int sqlite3_open16( + ffi.Pointer filename, + ffi.Pointer> ppDb, ) { - return _sqlite3_rollback_hook(arg0, arg1, arg2); + return _sqlite3_open16(filename, ppDb); } - late final _sqlite3_rollback_hookPtr = + late final _sqlite3_open16Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, + ffi.Int Function( ffi.Pointer, + ffi.Pointer>, ) > - >('sqlite3_rollback_hook'); - late final _sqlite3_rollback_hook = _sqlite3_rollback_hookPtr + >('sqlite3_open16'); + late final _sqlite3_open16 = _sqlite3_open16Ptr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer>) >(); - /// CAPI3REF: Data Change Notification Callbacks - /// METHOD: sqlite3 - /// - /// ^The sqlite3_update_hook() interface registers a callback function - /// with the [database connection] identified by the first argument - /// to be invoked whenever a row is updated, inserted or deleted in - /// a [rowid table]. - /// ^Any callback set by a previous call to this function - /// for the same database connection is overridden. - /// - /// ^The second argument is a pointer to the function to invoke when a - /// row is updated, inserted or deleted in a rowid table. - /// ^The first argument to the callback is a copy of the third argument - /// to sqlite3_update_hook(). - /// ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], - /// or [SQLITE_UPDATE], depending on the operation that caused the callback - /// to be invoked. - /// ^The third and fourth arguments to the callback contain pointers to the - /// database and table name containing the affected row. - /// ^The final callback parameter is the [rowid] of the row. - /// ^In the case of an update, this is the [rowid] after the update takes place. - /// - /// ^(The update hook is not invoked when internal system tables are - /// modified (i.e. sqlite_master and sqlite_sequence).)^ - /// ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. - /// - /// ^In the current implementation, the update hook - /// is not invoked when conflicting rows are deleted because of an - /// [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook - /// invoked when rows are deleted using the [truncate optimization]. - /// The exceptions defined in this paragraph might change in a future - /// release of SQLite. - /// - /// The update hook implementation must not do anything that will modify - /// the database connection that invoked the update hook. Any actions - /// to modify the database connection must be deferred until after the - /// completion of the [sqlite3_step()] call that triggered the update hook. - /// Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their - /// database connections for the meaning of "modify" in this paragraph. - /// - /// ^The sqlite3_update_hook(D,C,P) function - /// returns the P argument from the previous call - /// on the same [database connection] D, or NULL for - /// the first call on D. - /// - /// See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()], - /// and [sqlite3_preupdate_hook()] interfaces. - ffi.Pointer sqlite3_update_hook( - ffi.Pointer arg0, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - sqlite3_int64, - ) - > - > - arg1, - ffi.Pointer arg2, + int sqlite3_open_v2( + ffi.Pointer filename, + ffi.Pointer> ppDb, + int flags, + ffi.Pointer zVfs, ) { - return _sqlite3_update_hook(arg0, arg1, arg2); + return _sqlite3_open_v2(filename, ppDb, flags, zVfs); } - late final _sqlite3_update_hookPtr = + late final _sqlite3_open_v2Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - sqlite3_int64, - ) - > - >, - ffi.Pointer, + ffi.Int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer, ) > - >('sqlite3_update_hook'); - late final _sqlite3_update_hook = _sqlite3_update_hookPtr - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - sqlite3_int64, - ) - > - >, - ffi.Pointer, + >('sqlite3_open_v2'); + late final _sqlite3_open_v2 = _sqlite3_open_v2Ptr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer>, + int, + ffi.Pointer, ) >(); - /// CAPI3REF: Enable Or Disable Shared Pager Cache - /// - /// ^(This routine enables or disables the sharing of the database cache - /// and schema data structures between [database connection | connections] - /// to the same database. Sharing is enabled if the argument is true - /// and disabled if the argument is false.)^ - /// - /// ^Cache sharing is enabled and disabled for an entire process. - /// This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]). - /// In prior versions of SQLite, - /// sharing was enabled or disabled for each thread separately. - /// - /// ^(The cache sharing mode set by this interface effects all subsequent - /// calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. - /// Existing database connections continue to use the sharing mode - /// that was in effect at the time they were opened.)^ - /// - /// ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled - /// successfully. An [error code] is returned otherwise.)^ - /// - /// ^Shared cache is disabled by default. It is recommended that it stay - /// that way. In other words, do not use this routine. This interface - /// continues to be provided for historical compatibility, but its use is - /// discouraged. Any use of shared cache is discouraged. If shared cache - /// must be used, it is recommended that shared cache only be enabled for - /// individual database connections using the [sqlite3_open_v2()] interface - /// with the [SQLITE_OPEN_SHAREDCACHE] flag. - /// - /// Note: This method is disabled on MacOS X 10.7 and iOS version 5.0 - /// and will always return SQLITE_MISUSE. On those systems, - /// shared cache mode should be enabled per-database connection via - /// [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE]. - /// - /// This interface is threadsafe on processors where writing a - /// 32-bit integer is atomic. - /// - /// See Also: [SQLite Shared-Cache Mode] - int sqlite3_enable_shared_cache(int arg0) { - return _sqlite3_enable_shared_cache(arg0); + int sqlite3_os_end() { + return _sqlite3_os_end(); } - late final _sqlite3_enable_shared_cachePtr = - _lookup>( - 'sqlite3_enable_shared_cache', - ); - late final _sqlite3_enable_shared_cache = _sqlite3_enable_shared_cachePtr - .asFunction(); + late final _sqlite3_os_endPtr = + _lookup>('sqlite3_os_end'); + late final _sqlite3_os_end = _sqlite3_os_endPtr.asFunction(); - /// CAPI3REF: Attempt To Free Heap Memory - /// - /// ^The sqlite3_release_memory() interface attempts to free N bytes - /// of heap memory by deallocating non-essential memory allocations - /// held by the database library. Memory used to cache database - /// pages to improve performance is an example of non-essential memory. - /// ^sqlite3_release_memory() returns the number of bytes actually freed, - /// which might be more or less than the amount requested. - /// ^The sqlite3_release_memory() routine is a no-op returning zero - /// if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. - /// - /// See also: [sqlite3_db_release_memory()] - int sqlite3_release_memory(int arg0) { - return _sqlite3_release_memory(arg0); + int sqlite3_os_init() { + return _sqlite3_os_init(); } - late final _sqlite3_release_memoryPtr = - _lookup>( - 'sqlite3_release_memory', - ); - late final _sqlite3_release_memory = _sqlite3_release_memoryPtr - .asFunction(); + late final _sqlite3_os_initPtr = + _lookup>('sqlite3_os_init'); + late final _sqlite3_os_init = _sqlite3_os_initPtr + .asFunction(); - /// CAPI3REF: Free Memory Used By A Database Connection + /// CAPI3REF: Overload A Function For A Virtual Table /// METHOD: sqlite3 /// - /// ^The sqlite3_db_release_memory(D) interface attempts to free as much heap - /// memory as possible from database connection D. Unlike the - /// [sqlite3_release_memory()] interface, this interface is in effect even - /// when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is - /// omitted. + /// ^(Virtual tables can provide alternative implementations of functions + /// using the [xFindFunction] method of the [virtual table module]. + /// But global versions of those functions + /// must exist in order to be overloaded.)^ /// - /// See also: [sqlite3_release_memory()] - int sqlite3_db_release_memory(ffi.Pointer arg0) { - return _sqlite3_db_release_memory(arg0); + /// ^(This API makes sure a global version of a function with a particular + /// name and number of parameters exists. If no such function exists + /// before this API is called, a new function is created.)^ ^The implementation + /// of the new function always causes an exception to be thrown. So + /// the new function is not good for anything by itself. Its only + /// purpose is to be a placeholder function that can be overloaded + /// by a [virtual table]. + int sqlite3_overload_function( + ffi.Pointer arg0, + ffi.Pointer zFuncName, + int nArg, + ) { + return _sqlite3_overload_function(arg0, zFuncName, nArg); } - late final _sqlite3_db_release_memoryPtr = - _lookup)>>( - 'sqlite3_db_release_memory', - ); - late final _sqlite3_db_release_memory = _sqlite3_db_release_memoryPtr - .asFunction)>(); + late final _sqlite3_overload_functionPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) + > + >('sqlite3_overload_function'); + late final _sqlite3_overload_function = _sqlite3_overload_functionPtr + .asFunction< + int Function(ffi.Pointer, ffi.Pointer, int) + >(); - /// CAPI3REF: Impose A Limit On Heap Size + /// CAPI3REF: Compiling An SQL Statement + /// KEYWORDS: {SQL statement compiler} + /// METHOD: sqlite3 + /// CONSTRUCTOR: sqlite3_stmt /// - /// These interfaces impose limits on the amount of heap memory that will be - /// by all database connections within a single process. + /// To execute an SQL statement, it must first be compiled into a byte-code + /// program using one of these routines. Or, in other words, these routines + /// are constructors for the [prepared statement] object. /// - /// ^The sqlite3_soft_heap_limit64() interface sets and/or queries the - /// soft limit on the amount of heap memory that may be allocated by SQLite. - /// ^SQLite strives to keep heap memory utilization below the soft heap - /// limit by reducing the number of pages held in the page cache - /// as heap memory usages approaches the limit. - /// ^The soft heap limit is "soft" because even though SQLite strives to stay - /// below the limit, it will exceed the limit rather than generate - /// an [SQLITE_NOMEM] error. In other words, the soft heap limit - /// is advisory only. + /// The preferred routine to use is [sqlite3_prepare_v2()]. The + /// [sqlite3_prepare()] interface is legacy and should be avoided. + /// [sqlite3_prepare_v3()] has an extra "prepFlags" option that is used + /// for special purposes. /// - /// ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of - /// N bytes on the amount of memory that will be allocated. ^The - /// sqlite3_hard_heap_limit64(N) interface is similar to - /// sqlite3_soft_heap_limit64(N) except that memory allocations will fail - /// when the hard heap limit is reached. + /// The use of the UTF-8 interfaces is preferred, as SQLite currently + /// does all parsing using UTF-8. The UTF-16 interfaces are provided + /// as a convenience. The UTF-16 interfaces work by converting the + /// input text into UTF-8, then invoking the corresponding UTF-8 interface. /// - /// ^The return value from both sqlite3_soft_heap_limit64() and - /// sqlite3_hard_heap_limit64() is the size of - /// the heap limit prior to the call, or negative in the case of an - /// error. ^If the argument N is negative - /// then no change is made to the heap limit. Hence, the current - /// size of heap limits can be determined by invoking - /// sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1). + /// The first argument, "db", is a [database connection] obtained from a + /// prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or + /// [sqlite3_open16()]. The database connection must not have been closed. /// - /// ^Setting the heap limits to zero disables the heap limiter mechanism. + /// The second argument, "zSql", is the statement to be compiled, encoded + /// as either UTF-8 or UTF-16. The sqlite3_prepare(), sqlite3_prepare_v2(), + /// and sqlite3_prepare_v3() + /// interfaces use UTF-8, and sqlite3_prepare16(), sqlite3_prepare16_v2(), + /// and sqlite3_prepare16_v3() use UTF-16. /// - /// ^The soft heap limit may not be greater than the hard heap limit. - /// ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) - /// is invoked with a value of N that is greater than the hard heap limit, - /// the the soft heap limit is set to the value of the hard heap limit. - /// ^The soft heap limit is automatically enabled whenever the hard heap - /// limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and - /// the soft heap limit is outside the range of 1..N, then the soft heap - /// limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the - /// hard heap limit is enabled makes the soft heap limit equal to the - /// hard heap limit. + /// ^If the nByte argument is negative, then zSql is read up to the + /// first zero terminator. ^If nByte is positive, then it is the + /// number of bytes read from zSql. ^If nByte is zero, then no prepared + /// statement is generated. + /// If the caller knows that the supplied string is nul-terminated, then + /// there is a small performance advantage to passing an nByte parameter that + /// is the number of bytes in the input string including + /// the nul-terminator. /// - /// The memory allocation limits can also be adjusted using - /// [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit]. + /// ^If pzTail is not NULL then *pzTail is made to point to the first byte + /// past the end of the first SQL statement in zSql. These routines only + /// compile the first statement in zSql, so *pzTail is left pointing to + /// what remains uncompiled. /// - /// ^(The heap limits are not enforced in the current implementation - /// if one or more of following conditions are true: + /// ^*ppStmt is left pointing to a compiled [prepared statement] that can be + /// executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set + /// to NULL. ^If the input text contains no SQL (if the input is an empty + /// string or a comment) then *ppStmt is set to NULL. + /// The calling procedure is responsible for deleting the compiled + /// SQL statement using [sqlite3_finalize()] after it has finished with it. + /// ppStmt may not be NULL. /// - ///
      - ///
    • The limit value is set to zero. - ///
    • Memory accounting is disabled using a combination of the - /// [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and - /// the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. - ///
    • An alternative page cache implementation is specified using - /// [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...). - ///
    • The page cache allocates from its own memory pool supplied - /// by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than - /// from the heap. - ///
    )^ + /// ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; + /// otherwise an [error code] is returned. + /// + /// The sqlite3_prepare_v2(), sqlite3_prepare_v3(), sqlite3_prepare16_v2(), + /// and sqlite3_prepare16_v3() interfaces are recommended for all new programs. + /// The older interfaces (sqlite3_prepare() and sqlite3_prepare16()) + /// are retained for backwards compatibility, but their use is discouraged. + /// ^In the "vX" interfaces, the prepared statement + /// that is returned (the [sqlite3_stmt] object) contains a copy of the + /// original SQL text. This causes the [sqlite3_step()] interface to + /// behave differently in three ways: + /// + ///
      + ///
    1. + /// ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it + /// always used to do, [sqlite3_step()] will automatically recompile the SQL + /// statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY] + /// retries will occur before sqlite3_step() gives up and returns an error. + ///
    2. + /// + ///
    3. + /// ^When an error occurs, [sqlite3_step()] will return one of the detailed + /// [error codes] or [extended error codes]. ^The legacy behavior was that + /// [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code + /// and the application would have to make a second call to [sqlite3_reset()] + /// in order to find the underlying cause of the problem. With the "v2" prepare + /// interfaces, the underlying reason for the error is returned immediately. + ///
    4. + /// + ///
    5. + /// ^If the specific value bound to a [parameter | host parameter] in the + /// WHERE clause might influence the choice of query plan for a statement, + /// then the statement will be automatically recompiled, as if there had been + /// a schema change, on the first [sqlite3_step()] call following any change + /// to the [sqlite3_bind_text | bindings] of that [parameter]. + /// ^The specific value of a WHERE-clause [parameter] might influence the + /// choice of query plan if the parameter is the left-hand side of a [LIKE] + /// or [GLOB] operator or if the parameter is compared to an indexed column + /// and the [SQLITE_ENABLE_STAT4] compile-time option is enabled. + ///
    6. + ///
    /// - /// The circumstances under which SQLite will enforce the heap limits may - /// changes in future releases of SQLite. - int sqlite3_soft_heap_limit64(int N) { - return _sqlite3_soft_heap_limit64(N); + ///

    ^sqlite3_prepare_v3() differs from sqlite3_prepare_v2() only in having + /// the extra prepFlags parameter, which is a bit array consisting of zero or + /// more of the [SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_*] flags. ^The + /// sqlite3_prepare_v2() interface works exactly the same as + /// sqlite3_prepare_v3() with a zero prepFlags parameter. + int sqlite3_prepare( + ffi.Pointer db, + ffi.Pointer zSql, + int nByte, + ffi.Pointer> ppStmt, + ffi.Pointer> pzTail, + ) { + return _sqlite3_prepare(db, zSql, nByte, ppStmt, pzTail); } - late final _sqlite3_soft_heap_limit64Ptr = - _lookup>( - 'sqlite3_soft_heap_limit64', - ); - late final _sqlite3_soft_heap_limit64 = _sqlite3_soft_heap_limit64Ptr - .asFunction(); + late final _sqlite3_preparePtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ) + > + >('sqlite3_prepare'); + late final _sqlite3_prepare = _sqlite3_preparePtr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>, + ) + >(); - int sqlite3_hard_heap_limit64(int N) { - return _sqlite3_hard_heap_limit64(N); + int sqlite3_prepare16( + ffi.Pointer db, + ffi.Pointer zSql, + int nByte, + ffi.Pointer> ppStmt, + ffi.Pointer> pzTail, + ) { + return _sqlite3_prepare16(db, zSql, nByte, ppStmt, pzTail); } - late final _sqlite3_hard_heap_limit64Ptr = - _lookup>( - 'sqlite3_hard_heap_limit64', - ); - late final _sqlite3_hard_heap_limit64 = _sqlite3_hard_heap_limit64Ptr - .asFunction(); + late final _sqlite3_prepare16Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ) + > + >('sqlite3_prepare16'); + late final _sqlite3_prepare16 = _sqlite3_prepare16Ptr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>, + ) + >(); - /// CAPI3REF: Deprecated Soft Heap Limit Interface - /// DEPRECATED - /// - /// This is a deprecated version of the [sqlite3_soft_heap_limit64()] - /// interface. This routine is provided for historical compatibility - /// only. All new applications should use the - /// [sqlite3_soft_heap_limit64()] interface rather than this one. - void sqlite3_soft_heap_limit(int N) { - return _sqlite3_soft_heap_limit(N); + int sqlite3_prepare16_v2( + ffi.Pointer db, + ffi.Pointer zSql, + int nByte, + ffi.Pointer> ppStmt, + ffi.Pointer> pzTail, + ) { + return _sqlite3_prepare16_v2(db, zSql, nByte, ppStmt, pzTail); } - late final _sqlite3_soft_heap_limitPtr = - _lookup>( - 'sqlite3_soft_heap_limit', - ); - late final _sqlite3_soft_heap_limit = _sqlite3_soft_heap_limitPtr - .asFunction(); + late final _sqlite3_prepare16_v2Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ) + > + >('sqlite3_prepare16_v2'); + late final _sqlite3_prepare16_v2 = _sqlite3_prepare16_v2Ptr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>, + ) + >(); - /// CAPI3REF: Extract Metadata About A Column Of A Table - /// METHOD: sqlite3 - /// - /// ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns - /// information about column C of table T in database D - /// on [database connection] X.)^ ^The sqlite3_table_column_metadata() - /// interface returns SQLITE_OK and fills in the non-NULL pointers in - /// the final five arguments with appropriate values if the specified - /// column exists. ^The sqlite3_table_column_metadata() interface returns - /// SQLITE_ERROR if the specified column does not exist. - /// ^If the column-name parameter to sqlite3_table_column_metadata() is a - /// NULL pointer, then this routine simply checks for the existence of the - /// table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it - /// does not. If the table name parameter T in a call to - /// sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is - /// undefined behavior. - /// - /// ^The column is identified by the second, third and fourth parameters to - /// this function. ^(The second parameter is either the name of the database - /// (i.e. "main", "temp", or an attached database) containing the specified - /// table or NULL.)^ ^If it is NULL, then all attached databases are searched - /// for the table using the same algorithm used by the database engine to - /// resolve unqualified table references. - /// - /// ^The third and fourth parameters to this function are the table and column - /// name of the desired column, respectively. - /// - /// ^Metadata is returned by writing to the memory locations passed as the 5th - /// and subsequent parameters to this function. ^Any of these arguments may be - /// NULL, in which case the corresponding element of metadata is omitted. - /// - /// ^(

    - /// - ///
    Parameter Output
    Type
    Description - /// - ///
    5th const char* Data type - ///
    6th const char* Name of default collation sequence - ///
    7th int True if column has a NOT NULL constraint - ///
    8th int True if column is part of the PRIMARY KEY - ///
    9th int True if column is [AUTOINCREMENT] - ///
    - ///
    )^ - /// - /// ^The memory pointed to by the character pointers returned for the - /// declaration type and collation sequence is valid until the next - /// call to any SQLite API function. - /// - /// ^If the specified table is actually a view, an [error code] is returned. - /// - /// ^If the specified column is "rowid", "oid" or "_rowid_" and the table - /// is not a [WITHOUT ROWID] table and an - /// [INTEGER PRIMARY KEY] column has been explicitly declared, then the output - /// parameters are set for the explicitly declared column. ^(If there is no - /// [INTEGER PRIMARY KEY] column, then the outputs - /// for the [rowid] are set as follows: - /// - ///
    -  /// data type: "INTEGER"
    -  /// collation sequence: "BINARY"
    -  /// not null: 0
    -  /// primary key: 1
    -  /// auto increment: 0
    -  /// 
    )^ - /// - /// ^This function causes all database schemas to be read from disk and - /// parsed, if that has not already been done, and returns an error if - /// any errors are encountered while loading the schema. - int sqlite3_table_column_metadata( + int sqlite3_prepare16_v3( + ffi.Pointer db, + ffi.Pointer zSql, + int nByte, + int prepFlags, + ffi.Pointer> ppStmt, + ffi.Pointer> pzTail, + ) { + return _sqlite3_prepare16_v3(db, zSql, nByte, prepFlags, ppStmt, pzTail); + } + + late final _sqlite3_prepare16_v3Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.UnsignedInt, + ffi.Pointer>, + ffi.Pointer>, + ) + > + >('sqlite3_prepare16_v3'); + late final _sqlite3_prepare16_v3 = _sqlite3_prepare16_v3Ptr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + int, + ffi.Pointer>, + ffi.Pointer>, + ) + >(); + + int sqlite3_prepare_v2( + ffi.Pointer db, + ffi.Pointer zSql, + int nByte, + ffi.Pointer> ppStmt, + ffi.Pointer> pzTail, + ) { + return _sqlite3_prepare_v2(db, zSql, nByte, ppStmt, pzTail); + } + + late final _sqlite3_prepare_v2Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ) + > + >('sqlite3_prepare_v2'); + late final _sqlite3_prepare_v2 = _sqlite3_prepare_v2Ptr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>, + ) + >(); + + int sqlite3_prepare_v3( ffi.Pointer db, - ffi.Pointer zDbName, - ffi.Pointer zTableName, - ffi.Pointer zColumnName, - ffi.Pointer> pzDataType, - ffi.Pointer> pzCollSeq, - ffi.Pointer pNotNull, - ffi.Pointer pPrimaryKey, - ffi.Pointer pAutoinc, + ffi.Pointer zSql, + int nByte, + int prepFlags, + ffi.Pointer> ppStmt, + ffi.Pointer> pzTail, ) { - return _sqlite3_table_column_metadata( - db, - zDbName, - zTableName, - zColumnName, - pzDataType, - pzCollSeq, - pNotNull, - pPrimaryKey, - pAutoinc, - ); + return _sqlite3_prepare_v3(db, zSql, nByte, prepFlags, ppStmt, pzTail); } - late final _sqlite3_table_column_metadataPtr = + late final _sqlite3_prepare_v3Ptr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + ffi.Int, + ffi.UnsignedInt, + ffi.Pointer>, ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, ) > - >('sqlite3_table_column_metadata'); - late final _sqlite3_table_column_metadata = _sqlite3_table_column_metadataPtr + >('sqlite3_prepare_v3'); + late final _sqlite3_prepare_v3 = _sqlite3_prepare_v3Ptr .asFunction< int Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, + int, + int, + ffi.Pointer>, ffi.Pointer>, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, ) >(); - /// CAPI3REF: Load An Extension + ffi.Pointer sqlite3_profile( + ffi.Pointer arg0, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + sqlite3_uint64, + ) + > + > + xProfile, + ffi.Pointer arg2, + ) { + return _sqlite3_profile(arg0, xProfile, arg2); + } + + late final _sqlite3_profilePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + sqlite3_uint64, + ) + > + >, + ffi.Pointer, + ) + > + >('sqlite3_profile'); + late final _sqlite3_profile = _sqlite3_profilePtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + sqlite3_uint64, + ) + > + >, + ffi.Pointer, + ) + >(); + + /// CAPI3REF: Query Progress Callbacks /// METHOD: sqlite3 /// - /// ^This interface loads an SQLite extension library from the named file. + /// ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback + /// function X to be invoked periodically during long running calls to + /// [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for + /// database connection D. An example use for this + /// interface is to keep a GUI updated during a large query. /// - /// ^The sqlite3_load_extension() interface attempts to load an - /// [SQLite extension] library contained in the file zFile. If - /// the file cannot be loaded directly, attempts are made to load - /// with various operating-system specific extensions added. - /// So for example, if "samplelib" cannot be loaded, then names like - /// "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might - /// be tried also. + /// ^The parameter P is passed through as the only parameter to the + /// callback function X. ^The parameter N is the approximate number of + /// [virtual machine instructions] that are evaluated between successive + /// invocations of the callback X. ^If N is less than one then the progress + /// handler is disabled. /// - /// ^The entry point is zProc. - /// ^(zProc may be 0, in which case SQLite will try to come up with an - /// entry point name on its own. It first tries "sqlite3_extension_init". - /// If that does not work, it constructs a name "sqlite3_X_init" where the - /// X is consists of the lower-case equivalent of all ASCII alphabetic - /// characters in the filename from the last "/" to the first following - /// "." and omitting any initial "lib".)^ - /// ^The sqlite3_load_extension() interface returns - /// [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. - /// ^If an error occurs and pzErrMsg is not 0, then the - /// [sqlite3_load_extension()] interface shall attempt to - /// fill *pzErrMsg with error message text stored in memory - /// obtained from [sqlite3_malloc()]. The calling function - /// should free this memory by calling [sqlite3_free()]. + /// ^Only a single progress handler may be defined at one time per + /// [database connection]; setting a new progress handler cancels the + /// old one. ^Setting parameter X to NULL disables the progress handler. + /// ^The progress handler is also disabled by setting N to a value less + /// than 1. /// - /// ^Extension loading must be enabled using - /// [sqlite3_enable_load_extension()] or - /// [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL) - /// prior to calling this API, - /// otherwise an error will be returned. + /// ^If the progress callback returns non-zero, the operation is + /// interrupted. This feature can be used to implement a + /// "Cancel" button on a GUI progress dialog box. /// - /// Security warning: It is recommended that the - /// [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this - /// interface. The use of the [sqlite3_enable_load_extension()] interface - /// should be avoided. This will keep the SQL function [load_extension()] - /// disabled and prevent SQL injections from giving attackers - /// access to extension loading capabilities. + /// The progress handler callback must not do anything that will modify + /// the database connection that invoked the progress handler. + /// Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + /// database connections for the meaning of "modify" in this paragraph. + void sqlite3_progress_handler( + ffi.Pointer arg0, + int arg1, + ffi.Pointer)>> + arg2, + ffi.Pointer arg3, + ) { + return _sqlite3_progress_handler(arg0, arg1, arg2, arg3); + } + + late final _sqlite3_progress_handlerPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ) + > + >('sqlite3_progress_handler'); + late final _sqlite3_progress_handler = _sqlite3_progress_handlerPtr + .asFunction< + void Function( + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ) + >(); + + /// CAPI3REF: Pseudo-Random Number Generator /// - /// See also the [load_extension() SQL function]. - int sqlite3_load_extension( - ffi.Pointer db, - ffi.Pointer zFile, - ffi.Pointer zProc, - ffi.Pointer> pzErrMsg, + /// SQLite contains a high-quality pseudo-random number generator (PRNG) used to + /// select random [ROWID | ROWIDs] when inserting new records into a table that + /// already uses the largest possible [ROWID]. The PRNG is also used for + /// the built-in random() and randomblob() SQL functions. This interface allows + /// applications to access the same PRNG for other purposes. + /// + /// ^A call to this routine stores N bytes of randomness into buffer P. + /// ^The P parameter can be a NULL pointer. + /// + /// ^If this routine has not been previously called or if the previous + /// call had N less than one or a NULL pointer for P, then the PRNG is + /// seeded using randomness obtained from the xRandomness method of + /// the default [sqlite3_vfs] object. + /// ^If the previous call to this routine had an N of 1 or more and a + /// non-NULL P then the pseudo-randomness is generated + /// internally and without recourse to the [sqlite3_vfs] xRandomness + /// method. + void sqlite3_randomness(int N, ffi.Pointer P) { + return _sqlite3_randomness(N, P); + } + + late final _sqlite3_randomnessPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_randomness'); + late final _sqlite3_randomness = _sqlite3_randomnessPtr + .asFunction)>(); + + ffi.Pointer sqlite3_realloc(ffi.Pointer arg0, int arg1) { + return _sqlite3_realloc(arg0, arg1); + } + + late final _sqlite3_reallocPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_realloc'); + late final _sqlite3_realloc = _sqlite3_reallocPtr + .asFunction Function(ffi.Pointer, int)>(); + + ffi.Pointer sqlite3_realloc64( + ffi.Pointer arg0, + int arg1, ) { - return _sqlite3_load_extension(db, zFile, zProc, pzErrMsg); + return _sqlite3_realloc64(arg0, arg1); } - late final _sqlite3_load_extensionPtr = + late final _sqlite3_realloc64Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) + ffi.Pointer Function(ffi.Pointer, sqlite3_uint64) > - >('sqlite3_load_extension'); - late final _sqlite3_load_extension = _sqlite3_load_extensionPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) - >(); + >('sqlite3_realloc64'); + late final _sqlite3_realloc64 = _sqlite3_realloc64Ptr + .asFunction Function(ffi.Pointer, int)>(); - /// CAPI3REF: Enable Or Disable Extension Loading - /// METHOD: sqlite3 - /// - /// ^So as not to open security holes in older applications that are - /// unprepared to deal with [extension loading], and as a means of disabling - /// [extension loading] while evaluating user-entered SQL, the following API - /// is provided to turn the [sqlite3_load_extension()] mechanism on and off. - /// - /// ^Extension loading is off by default. - /// ^Call the sqlite3_enable_load_extension() routine with onoff==1 - /// to turn extension loading on and call it with onoff==0 to turn - /// it back off again. + /// CAPI3REF: Attempt To Free Heap Memory /// - /// ^This interface enables or disables both the C-API - /// [sqlite3_load_extension()] and the SQL function [load_extension()]. - /// ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) - /// to enable or disable only the C-API.)^ + /// ^The sqlite3_release_memory() interface attempts to free N bytes + /// of heap memory by deallocating non-essential memory allocations + /// held by the database library. Memory used to cache database + /// pages to improve performance is an example of non-essential memory. + /// ^sqlite3_release_memory() returns the number of bytes actually freed, + /// which might be more or less than the amount requested. + /// ^The sqlite3_release_memory() routine is a no-op returning zero + /// if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. /// - /// Security warning: It is recommended that extension loading - /// be enabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method - /// rather than this interface, so the [load_extension()] SQL function - /// remains disabled. This will prevent SQL injections from giving attackers - /// access to extension loading capabilities. - int sqlite3_enable_load_extension(ffi.Pointer db, int onoff) { - return _sqlite3_enable_load_extension(db, onoff); + /// See also: [sqlite3_db_release_memory()] + int sqlite3_release_memory(int arg0) { + return _sqlite3_release_memory(arg0); } - late final _sqlite3_enable_load_extensionPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_enable_load_extension'); - late final _sqlite3_enable_load_extension = _sqlite3_enable_load_extensionPtr - .asFunction, int)>(); + late final _sqlite3_release_memoryPtr = + _lookup>( + 'sqlite3_release_memory', + ); + late final _sqlite3_release_memory = _sqlite3_release_memoryPtr + .asFunction(); - /// CAPI3REF: Automatically Load Statically Linked Extensions - /// - /// ^This interface causes the xEntryPoint() function to be invoked for - /// each new [database connection] that is created. The idea here is that - /// xEntryPoint() is the entry point for a statically linked [SQLite extension] - /// that is to be automatically loaded into all new database connections. - /// - /// ^(Even though the function prototype shows that xEntryPoint() takes - /// no arguments and returns void, SQLite invokes xEntryPoint() with three - /// arguments and expects an integer result as if the signature of the - /// entry point where as follows: + /// CAPI3REF: Reset A Prepared Statement Object + /// METHOD: sqlite3_stmt /// - ///
    -  ///    int xEntryPoint(
    -  ///      sqlite3 *db,
    -  ///      const char **pzErrMsg,
    -  ///      const struct sqlite3_api_routines *pThunk
    -  ///    );
    -  /// 
    )^ + /// The sqlite3_reset() function is called to reset a [prepared statement] + /// object back to its initial state, ready to be re-executed. + /// ^Any SQL statement variables that had values bound to them using + /// the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. + /// Use [sqlite3_clear_bindings()] to reset the bindings. /// - /// If the xEntryPoint routine encounters an error, it should make *pzErrMsg - /// point to an appropriate error message (obtained from [sqlite3_mprintf()]) - /// and return an appropriate [error code]. ^SQLite ensures that *pzErrMsg - /// is NULL before calling the xEntryPoint(). ^SQLite will invoke - /// [sqlite3_free()] on *pzErrMsg after xEntryPoint() returns. ^If any - /// xEntryPoint() returns an error, the [sqlite3_open()], [sqlite3_open16()], - /// or [sqlite3_open_v2()] call that provoked the xEntryPoint() will fail. + /// ^The [sqlite3_reset(S)] interface resets the [prepared statement] S + /// back to the beginning of its program. /// - /// ^Calling sqlite3_auto_extension(X) with an entry point X that is already - /// on the list of automatic extensions is a harmless no-op. ^No entry point - /// will be called more than once for each database connection that is opened. + /// ^If the most recent call to [sqlite3_step(S)] for the + /// [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], + /// or if [sqlite3_step(S)] has never before been called on S, + /// then [sqlite3_reset(S)] returns [SQLITE_OK]. /// - /// See also: [sqlite3_reset_auto_extension()] - /// and [sqlite3_cancel_auto_extension()] - int sqlite3_auto_extension( - ffi.Pointer> xEntryPoint, - ) { - return _sqlite3_auto_extension(xEntryPoint); - } - - late final _sqlite3_auto_extensionPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer>) - > - >('sqlite3_auto_extension'); - late final _sqlite3_auto_extension = _sqlite3_auto_extensionPtr - .asFunction< - int Function(ffi.Pointer>) - >(); - - /// CAPI3REF: Cancel Automatic Extension Loading + /// ^If the most recent call to [sqlite3_step(S)] for the + /// [prepared statement] S indicated an error, then + /// [sqlite3_reset(S)] returns an appropriate [error code]. /// - /// ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the - /// initialization routine X that was registered using a prior call to - /// [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] - /// routine returns 1 if initialization routine X was successfully - /// unregistered and it returns 0 if X was not on the list of initialization - /// routines. - int sqlite3_cancel_auto_extension( - ffi.Pointer> xEntryPoint, - ) { - return _sqlite3_cancel_auto_extension(xEntryPoint); + /// ^The [sqlite3_reset(S)] interface does not change the values + /// of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. + int sqlite3_reset(ffi.Pointer pStmt) { + return _sqlite3_reset(pStmt); } - late final _sqlite3_cancel_auto_extensionPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer>) - > - >('sqlite3_cancel_auto_extension'); - late final _sqlite3_cancel_auto_extension = _sqlite3_cancel_auto_extensionPtr - .asFunction< - int Function(ffi.Pointer>) - >(); + late final _sqlite3_resetPtr = + _lookup)>>( + 'sqlite3_reset', + ); + late final _sqlite3_reset = _sqlite3_resetPtr + .asFunction)>(); /// CAPI3REF: Reset Automatic Extension Loading /// @@ -7906,1204 +6763,1505 @@ class SQLite { late final _sqlite3_reset_auto_extension = _sqlite3_reset_auto_extensionPtr .asFunction(); - /// CAPI3REF: Register A Virtual Table Implementation - /// METHOD: sqlite3 + /// CAPI3REF: Setting The Result Of An SQL Function + /// METHOD: sqlite3_context + /// + /// These routines are used by the xFunc or xFinal callbacks that + /// implement SQL functions and aggregates. See + /// [sqlite3_create_function()] and [sqlite3_create_function16()] + /// for additional information. + /// + /// These functions work very much like the [parameter binding] family of + /// functions used to bind values to host parameters in prepared statements. + /// Refer to the [SQL parameter] documentation for additional information. + /// + /// ^The sqlite3_result_blob() interface sets the result from + /// an application-defined function to be the BLOB whose content is pointed + /// to by the second parameter and which is N bytes long where N is the + /// third parameter. + /// + /// ^The sqlite3_result_zeroblob(C,N) and sqlite3_result_zeroblob64(C,N) + /// interfaces set the result of the application-defined function to be + /// a BLOB containing all zero bytes and N bytes in size. + /// + /// ^The sqlite3_result_double() interface sets the result from + /// an application-defined function to be a floating point value specified + /// by its 2nd argument. + /// + /// ^The sqlite3_result_error() and sqlite3_result_error16() functions + /// cause the implemented SQL function to throw an exception. + /// ^SQLite uses the string pointed to by the + /// 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() + /// as the text of an error message. ^SQLite interprets the error + /// message string from sqlite3_result_error() as UTF-8. ^SQLite + /// interprets the string from sqlite3_result_error16() as UTF-16 using + /// the same [byte-order determination rules] as [sqlite3_bind_text16()]. + /// ^If the third parameter to sqlite3_result_error() + /// or sqlite3_result_error16() is negative then SQLite takes as the error + /// message all text up through the first zero character. + /// ^If the third parameter to sqlite3_result_error() or + /// sqlite3_result_error16() is non-negative then SQLite takes that many + /// bytes (not characters) from the 2nd parameter as the error message. + /// ^The sqlite3_result_error() and sqlite3_result_error16() + /// routines make a private copy of the error message text before + /// they return. Hence, the calling function can deallocate or + /// modify the text after they return without harm. + /// ^The sqlite3_result_error_code() function changes the error code + /// returned by SQLite as a result of an error in a function. ^By default, + /// the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() + /// or sqlite3_result_error16() resets the error code to SQLITE_ERROR. + /// + /// ^The sqlite3_result_error_toobig() interface causes SQLite to throw an + /// error indicating that a string or BLOB is too long to represent. + /// + /// ^The sqlite3_result_error_nomem() interface causes SQLite to throw an + /// error indicating that a memory allocation failed. + /// + /// ^The sqlite3_result_int() interface sets the return value + /// of the application-defined function to be the 32-bit signed integer + /// value given in the 2nd argument. + /// ^The sqlite3_result_int64() interface sets the return value + /// of the application-defined function to be the 64-bit signed integer + /// value given in the 2nd argument. + /// + /// ^The sqlite3_result_null() interface sets the return value + /// of the application-defined function to be NULL. + /// + /// ^The sqlite3_result_text(), sqlite3_result_text16(), + /// sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces + /// set the return value of the application-defined function to be + /// a text string which is represented as UTF-8, UTF-16 native byte order, + /// UTF-16 little endian, or UTF-16 big endian, respectively. + /// ^The sqlite3_result_text64() interface sets the return value of an + /// application-defined function to be a text string in an encoding + /// specified by the fifth (and last) parameter, which must be one + /// of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]. + /// ^SQLite takes the text result from the application from + /// the 2nd parameter of the sqlite3_result_text* interfaces. + /// ^If the 3rd parameter to the sqlite3_result_text* interfaces + /// is negative, then SQLite takes result text from the 2nd parameter + /// through the first zero character. + /// ^If the 3rd parameter to the sqlite3_result_text* interfaces + /// is non-negative, then as many bytes (not characters) of the text + /// pointed to by the 2nd parameter are taken as the application-defined + /// function result. If the 3rd parameter is non-negative, then it + /// must be the byte offset into the string where the NUL terminator would + /// appear if the string where NUL terminated. If any NUL characters occur + /// in the string at a byte offset that is less than the value of the 3rd + /// parameter, then the resulting string will contain embedded NULs and the + /// result of expressions operating on strings with embedded NULs is undefined. + /// ^If the 4th parameter to the sqlite3_result_text* interfaces + /// or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that + /// function as the destructor on the text or BLOB result when it has + /// finished using that result. + /// ^If the 4th parameter to the sqlite3_result_text* interfaces or to + /// sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite + /// assumes that the text or BLOB result is in constant space and does not + /// copy the content of the parameter nor call a destructor on the content + /// when it has finished using that result. + /// ^If the 4th parameter to the sqlite3_result_text* interfaces + /// or sqlite3_result_blob is the special constant SQLITE_TRANSIENT + /// then SQLite makes a copy of the result into space obtained + /// from [sqlite3_malloc()] before it returns. /// - /// ^These routines are used to register a new [virtual table module] name. - /// ^Module names must be registered before - /// creating a new [virtual table] using the module and before using a - /// preexisting [virtual table] for the module. + /// ^For the sqlite3_result_text16(), sqlite3_result_text16le(), and + /// sqlite3_result_text16be() routines, and for sqlite3_result_text64() + /// when the encoding is not UTF8, if the input UTF16 begins with a + /// byte-order mark (BOM, U+FEFF) then the BOM is removed from the + /// string and the rest of the string is interpreted according to the + /// byte-order specified by the BOM. ^The byte-order specified by + /// the BOM at the beginning of the text overrides the byte-order + /// specified by the interface procedure. ^So, for example, if + /// sqlite3_result_text16le() is invoked with text that begins + /// with bytes 0xfe, 0xff (a big-endian byte-order mark) then the + /// first two bytes of input are skipped and the remaining input + /// is interpreted as UTF16BE text. /// - /// ^The module name is registered on the [database connection] specified - /// by the first parameter. ^The name of the module is given by the - /// second parameter. ^The third parameter is a pointer to - /// the implementation of the [virtual table module]. ^The fourth - /// parameter is an arbitrary client data pointer that is passed through - /// into the [xCreate] and [xConnect] methods of the virtual table module - /// when a new virtual table is be being created or reinitialized. + /// ^For UTF16 input text to the sqlite3_result_text16(), + /// sqlite3_result_text16be(), sqlite3_result_text16le(), and + /// sqlite3_result_text64() routines, if the text contains invalid + /// UTF16 characters, the invalid characters might be converted + /// into the unicode replacement character, U+FFFD. /// - /// ^The sqlite3_create_module_v2() interface has a fifth parameter which - /// is a pointer to a destructor for the pClientData. ^SQLite will - /// invoke the destructor function (if it is not NULL) when SQLite - /// no longer needs the pClientData pointer. ^The destructor will also - /// be invoked if the call to sqlite3_create_module_v2() fails. - /// ^The sqlite3_create_module() - /// interface is equivalent to sqlite3_create_module_v2() with a NULL - /// destructor. + /// ^The sqlite3_result_value() interface sets the result of + /// the application-defined function to be a copy of the + /// [unprotected sqlite3_value] object specified by the 2nd parameter. ^The + /// sqlite3_result_value() interface makes a copy of the [sqlite3_value] + /// so that the [sqlite3_value] specified in the parameter may change or + /// be deallocated after sqlite3_result_value() returns without harm. + /// ^A [protected sqlite3_value] object may always be used where an + /// [unprotected sqlite3_value] object is required, so either + /// kind of [sqlite3_value] object can be used with this interface. /// - /// ^If the third parameter (the pointer to the sqlite3_module object) is - /// NULL then no new module is create and any existing modules with the - /// same name are dropped. + /// ^The sqlite3_result_pointer(C,P,T,D) interface sets the result to an + /// SQL NULL value, just like [sqlite3_result_null(C)], except that it + /// also associates the host-language pointer P or type T with that + /// NULL value such that the pointer can be retrieved within an + /// [application-defined SQL function] using [sqlite3_value_pointer()]. + /// ^If the D parameter is not NULL, then it is a pointer to a destructor + /// for the P parameter. ^SQLite invokes D with P as its only argument + /// when SQLite is finished with P. The T parameter should be a static + /// string and preferably a string literal. The sqlite3_result_pointer() + /// routine is part of the [pointer passing interface] added for SQLite 3.20.0. /// - /// See also: [sqlite3_drop_modules()] - int sqlite3_create_module( - ffi.Pointer db, - ffi.Pointer zName, - ffi.Pointer p, - ffi.Pointer pClientData, + /// If these routines are called from within the different thread + /// than the one containing the application-defined function that received + /// the [sqlite3_context] pointer, the results are undefined. + void sqlite3_result_blob( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ffi.Pointer)>> + arg3, ) { - return _sqlite3_create_module(db, zName, p, pClientData); + return _sqlite3_result_blob(arg0, arg1, arg2, arg3); } - late final _sqlite3_create_modulePtr = + late final _sqlite3_result_blobPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, ) > - >('sqlite3_create_module'); - late final _sqlite3_create_module = _sqlite3_create_modulePtr + >('sqlite3_result_blob'); + late final _sqlite3_result_blob = _sqlite3_result_blobPtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, ) >(); - int sqlite3_create_module_v2( - ffi.Pointer db, - ffi.Pointer zName, - ffi.Pointer p, - ffi.Pointer pClientData, + void sqlite3_result_blob64( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, ffi.Pointer)>> - xDestroy, + arg3, ) { - return _sqlite3_create_module_v2(db, zName, p, pClientData, xDestroy); + return _sqlite3_result_blob64(arg0, arg1, arg2, arg3); } - late final _sqlite3_create_module_v2Ptr = + late final _sqlite3_result_blob64Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, ffi.Pointer, + sqlite3_uint64, ffi.Pointer< ffi.NativeFunction)> >, ) > - >('sqlite3_create_module_v2'); - late final _sqlite3_create_module_v2 = _sqlite3_create_module_v2Ptr + >('sqlite3_result_blob64'); + late final _sqlite3_result_blob64 = _sqlite3_result_blob64Ptr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, ffi.Pointer, + int, ffi.Pointer< ffi.NativeFunction)> >, ) >(); - /// CAPI3REF: Remove Unnecessary Virtual Table Implementations - /// METHOD: sqlite3 - /// - /// ^The sqlite3_drop_modules(D,L) interface removes all virtual - /// table modules from database connection D except those named on list L. - /// The L parameter must be either NULL or a pointer to an array of pointers - /// to strings where the array is terminated by a single NULL pointer. - /// ^If the L parameter is NULL, then all virtual table modules are removed. - /// - /// See also: [sqlite3_create_module()] - int sqlite3_drop_modules( - ffi.Pointer db, - ffi.Pointer> azKeep, + void sqlite3_result_double(ffi.Pointer arg0, double arg1) { + return _sqlite3_result_double(arg0, arg1); + } + + late final _sqlite3_result_doublePtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Double) + > + >('sqlite3_result_double'); + late final _sqlite3_result_double = _sqlite3_result_doublePtr + .asFunction, double)>(); + + void sqlite3_result_error( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, ) { - return _sqlite3_drop_modules(db, azKeep); + return _sqlite3_result_error(arg0, arg1, arg2); } - late final _sqlite3_drop_modulesPtr = + late final _sqlite3_result_errorPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, ) > - >('sqlite3_drop_modules'); - late final _sqlite3_drop_modules = _sqlite3_drop_modulesPtr + >('sqlite3_result_error'); + late final _sqlite3_result_error = _sqlite3_result_errorPtr .asFunction< - int Function(ffi.Pointer, ffi.Pointer>) + void Function(ffi.Pointer, ffi.Pointer, int) >(); - /// CAPI3REF: Declare The Schema Of A Virtual Table - /// - /// ^The [xCreate] and [xConnect] methods of a - /// [virtual table module] call this interface - /// to declare the format (the names and datatypes of the columns) of - /// the virtual tables they implement. - int sqlite3_declare_vtab( - ffi.Pointer arg0, - ffi.Pointer zSQL, + void sqlite3_result_error16( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, ) { - return _sqlite3_declare_vtab(arg0, zSQL); + return _sqlite3_result_error16(arg0, arg1, arg2); + } + + late final _sqlite3_result_error16Ptr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + >('sqlite3_result_error16'); + late final _sqlite3_result_error16 = _sqlite3_result_error16Ptr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, int) + >(); + + void sqlite3_result_error_code(ffi.Pointer arg0, int arg1) { + return _sqlite3_result_error_code(arg0, arg1); + } + + late final _sqlite3_result_error_codePtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_result_error_code'); + late final _sqlite3_result_error_code = _sqlite3_result_error_codePtr + .asFunction, int)>(); + + void sqlite3_result_error_nomem(ffi.Pointer arg0) { + return _sqlite3_result_error_nomem(arg0); + } + + late final _sqlite3_result_error_nomemPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_result_error_nomem'); + late final _sqlite3_result_error_nomem = _sqlite3_result_error_nomemPtr + .asFunction)>(); + + void sqlite3_result_error_toobig(ffi.Pointer arg0) { + return _sqlite3_result_error_toobig(arg0); + } + + late final _sqlite3_result_error_toobigPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_result_error_toobig'); + late final _sqlite3_result_error_toobig = _sqlite3_result_error_toobigPtr + .asFunction)>(); + + void sqlite3_result_int(ffi.Pointer arg0, int arg1) { + return _sqlite3_result_int(arg0, arg1); } - late final _sqlite3_declare_vtabPtr = + late final _sqlite3_result_intPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) + ffi.Void Function(ffi.Pointer, ffi.Int) > - >('sqlite3_declare_vtab'); - late final _sqlite3_declare_vtab = _sqlite3_declare_vtabPtr - .asFunction, ffi.Pointer)>(); + >('sqlite3_result_int'); + late final _sqlite3_result_int = _sqlite3_result_intPtr + .asFunction, int)>(); - /// CAPI3REF: Overload A Function For A Virtual Table - /// METHOD: sqlite3 - /// - /// ^(Virtual tables can provide alternative implementations of functions - /// using the [xFindFunction] method of the [virtual table module]. - /// But global versions of those functions - /// must exist in order to be overloaded.)^ - /// - /// ^(This API makes sure a global version of a function with a particular - /// name and number of parameters exists. If no such function exists - /// before this API is called, a new function is created.)^ ^The implementation - /// of the new function always causes an exception to be thrown. So - /// the new function is not good for anything by itself. Its only - /// purpose is to be a placeholder function that can be overloaded - /// by a [virtual table]. - int sqlite3_overload_function( - ffi.Pointer arg0, - ffi.Pointer zFuncName, - int nArg, - ) { - return _sqlite3_overload_function(arg0, zFuncName, nArg); + void sqlite3_result_int64(ffi.Pointer arg0, int arg1) { + return _sqlite3_result_int64(arg0, arg1); } - late final _sqlite3_overload_functionPtr = + late final _sqlite3_result_int64Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) + ffi.Void Function(ffi.Pointer, sqlite3_int64) > - >('sqlite3_overload_function'); - late final _sqlite3_overload_function = _sqlite3_overload_functionPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); + >('sqlite3_result_int64'); + late final _sqlite3_result_int64 = _sqlite3_result_int64Ptr + .asFunction, int)>(); - /// CAPI3REF: Open A BLOB For Incremental I/O - /// METHOD: sqlite3 - /// CONSTRUCTOR: sqlite3_blob - /// - /// ^(This interfaces opens a [BLOB handle | handle] to the BLOB located - /// in row iRow, column zColumn, table zTable in database zDb; - /// in other words, the same BLOB that would be selected by: - /// - ///
    -  /// SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
    -  /// 
    )^ - /// - /// ^(Parameter zDb is not the filename that contains the database, but - /// rather the symbolic name of the database. For attached databases, this is - /// the name that appears after the AS keyword in the [ATTACH] statement. - /// For the main database file, the database name is "main". For TEMP - /// tables, the database name is "temp".)^ - /// - /// ^If the flags parameter is non-zero, then the BLOB is opened for read - /// and write access. ^If the flags parameter is zero, the BLOB is opened for - /// read-only access. - /// - /// ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored - /// in *ppBlob. Otherwise an [error code] is returned and, unless the error - /// code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided - /// the API is not misused, it is always safe to call [sqlite3_blob_close()] - /// on *ppBlob after this function it returns. - /// - /// This function fails with SQLITE_ERROR if any of the following are true: - ///
      - ///
    • ^(Database zDb does not exist)^, - ///
    • ^(Table zTable does not exist within database zDb)^, - ///
    • ^(Table zTable is a WITHOUT ROWID table)^, - ///
    • ^(Column zColumn does not exist)^, - ///
    • ^(Row iRow is not present in the table)^, - ///
    • ^(The specified column of row iRow contains a value that is not - /// a TEXT or BLOB value)^, - ///
    • ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE - /// constraint and the blob is being opened for read/write access)^, - ///
    • ^([foreign key constraints | Foreign key constraints] are enabled, - /// column zColumn is part of a [child key] definition and the blob is - /// being opened for read/write access)^. - ///
    - /// - /// ^Unless it returns SQLITE_MISUSE, this function sets the - /// [database connection] error code and message accessible via - /// [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. - /// - /// A BLOB referenced by sqlite3_blob_open() may be read using the - /// [sqlite3_blob_read()] interface and modified by using - /// [sqlite3_blob_write()]. The [BLOB handle] can be moved to a - /// different row of the same table using the [sqlite3_blob_reopen()] - /// interface. However, the column, table, or database of a [BLOB handle] - /// cannot be changed after the [BLOB handle] is opened. - /// - /// ^(If the row that a BLOB handle points to is modified by an - /// [UPDATE], [DELETE], or by [ON CONFLICT] side-effects - /// then the BLOB handle is marked as "expired". - /// This is true if any column of the row is changed, even a column - /// other than the one the BLOB handle is open on.)^ - /// ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for - /// an expired BLOB handle fail with a return code of [SQLITE_ABORT]. - /// ^(Changes written into a BLOB prior to the BLOB expiring are not - /// rolled back by the expiration of the BLOB. Such changes will eventually - /// commit if the transaction continues to completion.)^ - /// - /// ^Use the [sqlite3_blob_bytes()] interface to determine the size of - /// the opened blob. ^The size of a blob may not be changed by this - /// interface. Use the [UPDATE] SQL command to change the size of a - /// blob. - /// - /// ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces - /// and the built-in [zeroblob] SQL function may be used to create a - /// zero-filled blob to read or write using the incremental-blob interface. - /// - /// To avoid a resource leak, every open [BLOB handle] should eventually - /// be released by a call to [sqlite3_blob_close()]. - /// - /// See also: [sqlite3_blob_close()], - /// [sqlite3_blob_reopen()], [sqlite3_blob_read()], - /// [sqlite3_blob_bytes()], [sqlite3_blob_write()]. - int sqlite3_blob_open( - ffi.Pointer arg0, - ffi.Pointer zDb, - ffi.Pointer zTable, - ffi.Pointer zColumn, - int iRow, - int flags, - ffi.Pointer> ppBlob, + void sqlite3_result_null(ffi.Pointer arg0) { + return _sqlite3_result_null(arg0); + } + + late final _sqlite3_result_nullPtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_result_null'); + late final _sqlite3_result_null = _sqlite3_result_nullPtr + .asFunction)>(); + + void sqlite3_result_pointer( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ffi.Pointer)>> + arg3, ) { - return _sqlite3_blob_open(arg0, zDb, zTable, zColumn, iRow, flags, ppBlob); + return _sqlite3_result_pointer(arg0, arg1, arg2, arg3); } - late final _sqlite3_blob_openPtr = + late final _sqlite3_result_pointerPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, ffi.Pointer, - sqlite3_int64, - ffi.Int, - ffi.Pointer>, + ffi.Pointer< + ffi.NativeFunction)> + >, ) > - >('sqlite3_blob_open'); - late final _sqlite3_blob_open = _sqlite3_blob_openPtr + >('sqlite3_result_pointer'); + late final _sqlite3_result_pointer = _sqlite3_result_pointerPtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, + void Function( + ffi.Pointer, + ffi.Pointer, ffi.Pointer, - int, - int, - ffi.Pointer>, + ffi.Pointer< + ffi.NativeFunction)> + >, ) >(); - /// CAPI3REF: Move a BLOB Handle to a New Row - /// METHOD: sqlite3_blob - /// - /// ^This function is used to move an existing [BLOB handle] so that it points - /// to a different row of the same database table. ^The new row is identified - /// by the rowid value passed as the second argument. Only the row can be - /// changed. ^The database, table and column on which the blob handle is open - /// remain the same. Moving an existing [BLOB handle] to a new row is - /// faster than closing the existing handle and opening a new one. - /// - /// ^(The new row must meet the same criteria as for [sqlite3_blob_open()] - - /// it must exist and there must be either a blob or text value stored in - /// the nominated column.)^ ^If the new row is not present in the table, or if - /// it does not contain a blob or text value, or if another error occurs, an - /// SQLite error code is returned and the blob handle is considered aborted. - /// ^All subsequent calls to [sqlite3_blob_read()], [sqlite3_blob_write()] or - /// [sqlite3_blob_reopen()] on an aborted blob handle immediately return - /// SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle - /// always returns zero. + /// CAPI3REF: Setting The Subtype Of An SQL Function + /// METHOD: sqlite3_context /// - /// ^This function sets the database handle error code and message. - int sqlite3_blob_reopen(ffi.Pointer arg0, int arg1) { - return _sqlite3_blob_reopen(arg0, arg1); + /// The sqlite3_result_subtype(C,T) function causes the subtype of + /// the result from the [application-defined SQL function] with + /// [sqlite3_context] C to be the value T. Only the lower 8 bits + /// of the subtype T are preserved in current versions of SQLite; + /// higher order bits are discarded. + /// The number of subtype bytes preserved by SQLite might increase + /// in future releases of SQLite. + void sqlite3_result_subtype(ffi.Pointer arg0, int arg1) { + return _sqlite3_result_subtype(arg0, arg1); } - late final _sqlite3_blob_reopenPtr = + late final _sqlite3_result_subtypePtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, sqlite3_int64) + ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) > - >('sqlite3_blob_reopen'); - late final _sqlite3_blob_reopen = _sqlite3_blob_reopenPtr - .asFunction, int)>(); + >('sqlite3_result_subtype'); + late final _sqlite3_result_subtype = _sqlite3_result_subtypePtr + .asFunction, int)>(); - /// CAPI3REF: Close A BLOB Handle - /// DESTRUCTOR: sqlite3_blob - /// - /// ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed - /// unconditionally. Even if this routine returns an error code, the - /// handle is still closed.)^ - /// - /// ^If the blob handle being closed was opened for read-write access, and if - /// the database is in auto-commit mode and there are no other open read-write - /// blob handles or active write statements, the current transaction is - /// committed. ^If an error occurs while committing the transaction, an error - /// code is returned and the transaction rolled back. - /// - /// Calling this function with an argument that is not a NULL pointer or an - /// open blob handle results in undefined behaviour. ^Calling this routine - /// with a null pointer (such as would be returned by a failed call to - /// [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function - /// is passed a valid open blob handle, the values returned by the - /// sqlite3_errcode() and sqlite3_errmsg() functions are set before returning. - int sqlite3_blob_close(ffi.Pointer arg0) { - return _sqlite3_blob_close(arg0); + void sqlite3_result_text( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ffi.Pointer)>> + arg3, + ) { + return _sqlite3_result_text(arg0, arg1, arg2, arg3); } - late final _sqlite3_blob_closePtr = - _lookup)>>( - 'sqlite3_blob_close', - ); - late final _sqlite3_blob_close = _sqlite3_blob_closePtr - .asFunction)>(); + late final _sqlite3_result_textPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_result_text'); + late final _sqlite3_result_text = _sqlite3_result_textPtr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); - /// CAPI3REF: Return The Size Of An Open BLOB - /// METHOD: sqlite3_blob - /// - /// ^Returns the size in bytes of the BLOB accessible via the - /// successfully opened [BLOB handle] in its only argument. ^The - /// incremental blob I/O routines can only read or overwriting existing - /// blob content; they cannot change the size of a blob. - /// - /// This routine only works on a [BLOB handle] which has been created - /// by a prior successful call to [sqlite3_blob_open()] and which has not - /// been closed by [sqlite3_blob_close()]. Passing any other pointer in - /// to this routine results in undefined and probably undesirable behavior. - int sqlite3_blob_bytes(ffi.Pointer arg0) { - return _sqlite3_blob_bytes(arg0); + void sqlite3_result_text16( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ffi.Pointer)>> + arg3, + ) { + return _sqlite3_result_text16(arg0, arg1, arg2, arg3); } - late final _sqlite3_blob_bytesPtr = - _lookup)>>( - 'sqlite3_blob_bytes', - ); - late final _sqlite3_blob_bytes = _sqlite3_blob_bytesPtr - .asFunction)>(); + late final _sqlite3_result_text16Ptr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_result_text16'); + late final _sqlite3_result_text16 = _sqlite3_result_text16Ptr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); - /// CAPI3REF: Read Data From A BLOB Incrementally - /// METHOD: sqlite3_blob - /// - /// ^(This function is used to read data from an open [BLOB handle] into a - /// caller-supplied buffer. N bytes of data are copied into buffer Z - /// from the open BLOB, starting at offset iOffset.)^ - /// - /// ^If offset iOffset is less than N bytes from the end of the BLOB, - /// [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is - /// less than zero, [SQLITE_ERROR] is returned and no data is read. - /// ^The size of the blob (and hence the maximum value of N+iOffset) - /// can be determined using the [sqlite3_blob_bytes()] interface. - /// - /// ^An attempt to read from an expired [BLOB handle] fails with an - /// error code of [SQLITE_ABORT]. - /// - /// ^(On success, sqlite3_blob_read() returns SQLITE_OK. - /// Otherwise, an [error code] or an [extended error code] is returned.)^ - /// - /// This routine only works on a [BLOB handle] which has been created - /// by a prior successful call to [sqlite3_blob_open()] and which has not - /// been closed by [sqlite3_blob_close()]. Passing any other pointer in - /// to this routine results in undefined and probably undesirable behavior. - /// - /// See also: [sqlite3_blob_write()]. - int sqlite3_blob_read( - ffi.Pointer arg0, - ffi.Pointer Z, - int N, - int iOffset, + void sqlite3_result_text16be( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ffi.Pointer)>> + arg3, ) { - return _sqlite3_blob_read(arg0, Z, N, iOffset); + return _sqlite3_result_text16be(arg0, arg1, arg2, arg3); } - late final _sqlite3_blob_readPtr = + late final _sqlite3_result_text16bePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Int, - ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, ) > - >('sqlite3_blob_read'); - late final _sqlite3_blob_read = _sqlite3_blob_readPtr + >('sqlite3_result_text16be'); + late final _sqlite3_result_text16be = _sqlite3_result_text16bePtr .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, int) + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) >(); - /// CAPI3REF: Write Data Into A BLOB Incrementally - /// METHOD: sqlite3_blob - /// - /// ^(This function is used to write data into an open [BLOB handle] from a - /// caller-supplied buffer. N bytes of data are copied from the buffer Z - /// into the open BLOB, starting at offset iOffset.)^ - /// - /// ^(On success, sqlite3_blob_write() returns SQLITE_OK. - /// Otherwise, an [error code] or an [extended error code] is returned.)^ - /// ^Unless SQLITE_MISUSE is returned, this function sets the - /// [database connection] error code and message accessible via - /// [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions. - /// - /// ^If the [BLOB handle] passed as the first argument was not opened for - /// writing (the flags parameter to [sqlite3_blob_open()] was zero), - /// this function returns [SQLITE_READONLY]. - /// - /// This function may only modify the contents of the BLOB; it is - /// not possible to increase the size of a BLOB using this API. - /// ^If offset iOffset is less than N bytes from the end of the BLOB, - /// [SQLITE_ERROR] is returned and no data is written. The size of the - /// BLOB (and hence the maximum value of N+iOffset) can be determined - /// using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less - /// than zero [SQLITE_ERROR] is returned and no data is written. - /// - /// ^An attempt to write to an expired [BLOB handle] fails with an - /// error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred - /// before the [BLOB handle] expired are not rolled back by the - /// expiration of the handle, though of course those changes might - /// have been overwritten by the statement that expired the BLOB handle - /// or by other independent statements. - /// - /// This routine only works on a [BLOB handle] which has been created - /// by a prior successful call to [sqlite3_blob_open()] and which has not - /// been closed by [sqlite3_blob_close()]. Passing any other pointer in - /// to this routine results in undefined and probably undesirable behavior. - /// - /// See also: [sqlite3_blob_read()]. - int sqlite3_blob_write( - ffi.Pointer arg0, - ffi.Pointer z, - int n, - int iOffset, + void sqlite3_result_text16le( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ffi.Pointer)>> + arg3, ) { - return _sqlite3_blob_write(arg0, z, n, iOffset); + return _sqlite3_result_text16le(arg0, arg1, arg2, arg3); } - late final _sqlite3_blob_writePtr = + late final _sqlite3_result_text16lePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, + ffi.Void Function( + ffi.Pointer, ffi.Pointer, ffi.Int, - ffi.Int, + ffi.Pointer< + ffi.NativeFunction)> + >, ) > - >('sqlite3_blob_write'); - late final _sqlite3_blob_write = _sqlite3_blob_writePtr + >('sqlite3_result_text16le'); + late final _sqlite3_result_text16le = _sqlite3_result_text16lePtr .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int, int) + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) >(); - /// CAPI3REF: Virtual File System Objects - /// - /// A virtual filesystem (VFS) is an [sqlite3_vfs] object - /// that SQLite uses to interact - /// with the underlying operating system. Most SQLite builds come with a - /// single default VFS that is appropriate for the host computer. - /// New VFSes can be registered and existing VFSes can be unregistered. - /// The following interfaces are provided. - /// - /// ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. - /// ^Names are case sensitive. - /// ^Names are zero-terminated UTF-8 strings. - /// ^If there is no match, a NULL pointer is returned. - /// ^If zVfsName is NULL then the default VFS is returned. - /// - /// ^New VFSes are registered with sqlite3_vfs_register(). - /// ^Each new VFS becomes the default VFS if the makeDflt flag is set. - /// ^The same VFS can be registered multiple times without injury. - /// ^To make an existing VFS into the default VFS, register it again - /// with the makeDflt flag set. If two different VFSes with the - /// same name are registered, the behavior is undefined. If a - /// VFS is registered with a name that is NULL or an empty string, - /// then the behavior is undefined. - /// - /// ^Unregister a VFS with the sqlite3_vfs_unregister() interface. - /// ^(If the default VFS is unregistered, another VFS is chosen as - /// the default. The choice for the new VFS is arbitrary.)^ - ffi.Pointer sqlite3_vfs_find(ffi.Pointer zVfsName) { - return _sqlite3_vfs_find(zVfsName); + void sqlite3_result_text64( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ffi.Pointer)>> + arg3, + int encoding, + ) { + return _sqlite3_result_text64(arg0, arg1, arg2, arg3, encoding); } - late final _sqlite3_vfs_findPtr = + late final _sqlite3_result_text64Ptr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + sqlite3_uint64, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.UnsignedChar, + ) > - >('sqlite3_vfs_find'); - late final _sqlite3_vfs_find = _sqlite3_vfs_findPtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_result_text64'); + late final _sqlite3_result_text64 = _sqlite3_result_text64Ptr + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction)> + >, + int, + ) + >(); - int sqlite3_vfs_register(ffi.Pointer arg0, int makeDflt) { - return _sqlite3_vfs_register(arg0, makeDflt); + void sqlite3_result_value( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) { + return _sqlite3_result_value(arg0, arg1); } - late final _sqlite3_vfs_registerPtr = + late final _sqlite3_result_valuePtr = _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_vfs_register'); - late final _sqlite3_vfs_register = _sqlite3_vfs_registerPtr - .asFunction, int)>(); - - int sqlite3_vfs_unregister(ffi.Pointer arg0) { - return _sqlite3_vfs_unregister(arg0); - } - - late final _sqlite3_vfs_unregisterPtr = - _lookup)>>( - 'sqlite3_vfs_unregister', - ); - late final _sqlite3_vfs_unregister = _sqlite3_vfs_unregisterPtr - .asFunction)>(); - - /// CAPI3REF: Mutexes - /// - /// The SQLite core uses these routines for thread - /// synchronization. Though they are intended for internal - /// use by SQLite, code that links against SQLite is - /// permitted to use any of these routines. - /// - /// The SQLite source code contains multiple implementations - /// of these mutex routines. An appropriate implementation - /// is selected automatically at compile-time. The following - /// implementations are available in the SQLite core: - /// - ///
      - ///
    • SQLITE_MUTEX_PTHREADS - ///
    • SQLITE_MUTEX_W32 - ///
    • SQLITE_MUTEX_NOOP - ///
    - /// - /// The SQLITE_MUTEX_NOOP implementation is a set of routines - /// that does no real locking and is appropriate for use in - /// a single-threaded application. The SQLITE_MUTEX_PTHREADS and - /// SQLITE_MUTEX_W32 implementations are appropriate for use on Unix - /// and Windows. - /// - /// If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor - /// macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex - /// implementation is included with the library. In this case the - /// application must supply a custom mutex implementation using the - /// [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function - /// before calling sqlite3_initialize() or any other public sqlite3_ - /// function that calls sqlite3_initialize(). - /// - /// ^The sqlite3_mutex_alloc() routine allocates a new - /// mutex and returns a pointer to it. ^The sqlite3_mutex_alloc() - /// routine returns NULL if it is unable to allocate the requested - /// mutex. The argument to sqlite3_mutex_alloc() must one of these - /// integer constants: - /// - ///
      - ///
    • SQLITE_MUTEX_FAST - ///
    • SQLITE_MUTEX_RECURSIVE - ///
    • SQLITE_MUTEX_STATIC_MASTER - ///
    • SQLITE_MUTEX_STATIC_MEM - ///
    • SQLITE_MUTEX_STATIC_OPEN - ///
    • SQLITE_MUTEX_STATIC_PRNG - ///
    • SQLITE_MUTEX_STATIC_LRU - ///
    • SQLITE_MUTEX_STATIC_PMEM - ///
    • SQLITE_MUTEX_STATIC_APP1 - ///
    • SQLITE_MUTEX_STATIC_APP2 - ///
    • SQLITE_MUTEX_STATIC_APP3 - ///
    • SQLITE_MUTEX_STATIC_VFS1 - ///
    • SQLITE_MUTEX_STATIC_VFS2 - ///
    • SQLITE_MUTEX_STATIC_VFS3 - ///
    - /// - /// ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) - /// cause sqlite3_mutex_alloc() to create - /// a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE - /// is used but not necessarily so when SQLITE_MUTEX_FAST is used. - /// The mutex implementation does not need to make a distinction - /// between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does - /// not want to. SQLite will only request a recursive mutex in - /// cases where it really needs one. If a faster non-recursive mutex - /// implementation is available on the host platform, the mutex subsystem - /// might return such a mutex in response to SQLITE_MUTEX_FAST. - /// - /// ^The other allowed parameters to sqlite3_mutex_alloc() (anything other - /// than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return - /// a pointer to a static preexisting mutex. ^Nine static mutexes are - /// used by the current version of SQLite. Future versions of SQLite - /// may add additional static mutexes. Static mutexes are for internal - /// use by SQLite only. Applications that use SQLite mutexes should - /// use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or - /// SQLITE_MUTEX_RECURSIVE. - /// - /// ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST - /// or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() - /// returns a different mutex on every call. ^For the static - /// mutex types, the same mutex is returned on every call that has - /// the same type number. - /// - /// ^The sqlite3_mutex_free() routine deallocates a previously - /// allocated dynamic mutex. Attempting to deallocate a static - /// mutex results in undefined behavior. - /// - /// ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt - /// to enter a mutex. ^If another thread is already within the mutex, - /// sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return - /// SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] - /// upon successful entry. ^(Mutexes created using - /// SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. - /// In such cases, the - /// mutex must be exited an equal number of times before another thread - /// can enter.)^ If the same thread tries to enter any mutex other - /// than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined. - /// - /// ^(Some systems (for example, Windows 95) do not support the operation - /// implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() - /// will always return SQLITE_BUSY. The SQLite core only ever uses - /// sqlite3_mutex_try() as an optimization so this is acceptable - /// behavior.)^ - /// - /// ^The sqlite3_mutex_leave() routine exits a mutex that was - /// previously entered by the same thread. The behavior - /// is undefined if the mutex is not currently entered by the - /// calling thread or is not currently allocated. - /// - /// ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or - /// sqlite3_mutex_leave() is a NULL pointer, then all three routines - /// behave as no-ops. - /// - /// See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. - ffi.Pointer sqlite3_mutex_alloc(int arg0) { - return _sqlite3_mutex_alloc(arg0); - } - - late final _sqlite3_mutex_allocPtr = - _lookup Function(ffi.Int)>>( - 'sqlite3_mutex_alloc', - ); - late final _sqlite3_mutex_alloc = _sqlite3_mutex_allocPtr - .asFunction Function(int)>(); + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >('sqlite3_result_value'); + late final _sqlite3_result_value = _sqlite3_result_valuePtr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >(); - void sqlite3_mutex_free(ffi.Pointer arg0) { - return _sqlite3_mutex_free(arg0); + void sqlite3_result_zeroblob(ffi.Pointer arg0, int n) { + return _sqlite3_result_zeroblob(arg0, n); } - late final _sqlite3_mutex_freePtr = + late final _sqlite3_result_zeroblobPtr = _lookup< - ffi.NativeFunction)> - >('sqlite3_mutex_free'); - late final _sqlite3_mutex_free = _sqlite3_mutex_freePtr - .asFunction)>(); + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_result_zeroblob'); + late final _sqlite3_result_zeroblob = _sqlite3_result_zeroblobPtr + .asFunction, int)>(); - void sqlite3_mutex_enter(ffi.Pointer arg0) { - return _sqlite3_mutex_enter(arg0); + int sqlite3_result_zeroblob64(ffi.Pointer arg0, int n) { + return _sqlite3_result_zeroblob64(arg0, n); } - late final _sqlite3_mutex_enterPtr = + late final _sqlite3_result_zeroblob64Ptr = _lookup< - ffi.NativeFunction)> - >('sqlite3_mutex_enter'); - late final _sqlite3_mutex_enter = _sqlite3_mutex_enterPtr - .asFunction)>(); + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, sqlite3_uint64) + > + >('sqlite3_result_zeroblob64'); + late final _sqlite3_result_zeroblob64 = _sqlite3_result_zeroblob64Ptr + .asFunction, int)>(); - int sqlite3_mutex_try(ffi.Pointer arg0) { - return _sqlite3_mutex_try(arg0); + ffi.Pointer sqlite3_rollback_hook( + ffi.Pointer arg0, + ffi.Pointer)>> + arg1, + ffi.Pointer arg2, + ) { + return _sqlite3_rollback_hook(arg0, arg1, arg2); } - late final _sqlite3_mutex_tryPtr = - _lookup)>>( - 'sqlite3_mutex_try', - ); - late final _sqlite3_mutex_try = _sqlite3_mutex_tryPtr - .asFunction)>(); + late final _sqlite3_rollback_hookPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ) + > + >('sqlite3_rollback_hook'); + late final _sqlite3_rollback_hook = _sqlite3_rollback_hookPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ffi.Pointer, + ) + >(); - void sqlite3_mutex_leave(ffi.Pointer arg0) { - return _sqlite3_mutex_leave(arg0); + /// Register a geometry callback named zGeom that can be used as part of an + /// R-Tree geometry query as follows: + /// + /// SELECT ... FROM WHERE MATCH $zGeom(... params ...) + int sqlite3_rtree_geometry_callback( + ffi.Pointer db, + ffi.Pointer zGeom, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xGeom, + ffi.Pointer pContext, + ) { + return _sqlite3_rtree_geometry_callback(db, zGeom, xGeom, pContext); } - late final _sqlite3_mutex_leavePtr = + late final _sqlite3_rtree_geometry_callbackPtr = _lookup< - ffi.NativeFunction)> - >('sqlite3_mutex_leave'); - late final _sqlite3_mutex_leave = _sqlite3_mutex_leavePtr - .asFunction)>(); + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ffi.Pointer, + ) + > + >('sqlite3_rtree_geometry_callback'); + late final _sqlite3_rtree_geometry_callback = + _sqlite3_rtree_geometry_callbackPtr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ffi.Pointer, + ) + >(); - int sqlite3_mutex_held(ffi.Pointer arg0) { - return _sqlite3_mutex_held(arg0); + /// Register a 2nd-generation geometry callback named zScore that can be + /// used as part of an R-Tree geometry query as follows: + /// + /// SELECT ... FROM WHERE MATCH $zQueryFunc(... params ...) + int sqlite3_rtree_query_callback( + ffi.Pointer db, + ffi.Pointer zQueryFunc, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer) + > + > + xQueryFunc, + ffi.Pointer pContext, + ffi.Pointer)>> + xDestructor, + ) { + return _sqlite3_rtree_query_callback( + db, + zQueryFunc, + xQueryFunc, + pContext, + xDestructor, + ); } - late final _sqlite3_mutex_heldPtr = - _lookup)>>( - 'sqlite3_mutex_held', - ); - late final _sqlite3_mutex_held = _sqlite3_mutex_heldPtr - .asFunction)>(); + late final _sqlite3_rtree_query_callbackPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer) + > + >, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_rtree_query_callback'); + late final _sqlite3_rtree_query_callback = _sqlite3_rtree_query_callbackPtr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer) + > + >, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + >(); - int sqlite3_mutex_notheld(ffi.Pointer arg0) { - return _sqlite3_mutex_notheld(arg0); + /// CAPI3REF: Serialize a database + /// + /// The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory + /// that is a serialization of the S database on [database connection] D. + /// If P is not a NULL pointer, then the size of the database in bytes + /// is written into *P. + /// + /// For an ordinary on-disk database file, the serialization is just a + /// copy of the disk file. For an in-memory database or a "TEMP" database, + /// the serialization is the same sequence of bytes which would be written + /// to disk if that database where backed up to disk. + /// + /// The usual case is that sqlite3_serialize() copies the serialization of + /// the database into memory obtained from [sqlite3_malloc64()] and returns + /// a pointer to that memory. The caller is responsible for freeing the + /// returned value to avoid a memory leak. However, if the F argument + /// contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations + /// are made, and the sqlite3_serialize() function will return a pointer + /// to the contiguous memory representation of the database that SQLite + /// is currently using for that database, or NULL if the no such contiguous + /// memory representation of the database exists. A contiguous memory + /// representation of the database will usually only exist if there has + /// been a prior call to [sqlite3_deserialize(D,S,...)] with the same + /// values of D and S. + /// The size of the database is written into *P even if the + /// SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy + /// of the database exists. + /// + /// A call to sqlite3_serialize(D,S,P,F) might return NULL even if the + /// SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory + /// allocation error occurs. + /// + /// This interface is only available if SQLite is compiled with the + /// [SQLITE_ENABLE_DESERIALIZE] option. + ffi.Pointer sqlite3_serialize( + ffi.Pointer db, + ffi.Pointer zSchema, + ffi.Pointer piSize, + int mFlags, + ) { + return _sqlite3_serialize(db, zSchema, piSize, mFlags); } - late final _sqlite3_mutex_notheldPtr = - _lookup)>>( - 'sqlite3_mutex_notheld', - ); - late final _sqlite3_mutex_notheld = _sqlite3_mutex_notheldPtr - .asFunction)>(); + late final _sqlite3_serializePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ) + > + >('sqlite3_serialize'); + late final _sqlite3_serialize = _sqlite3_serializePtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); - /// CAPI3REF: Retrieve the mutex for a database connection + /// CAPI3REF: Compile-Time Authorization Callbacks /// METHOD: sqlite3 + /// KEYWORDS: {authorizer callback} + /// + /// ^This routine registers an authorizer callback with a particular + /// [database connection], supplied in the first argument. + /// ^The authorizer callback is invoked as SQL statements are being compiled + /// by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], + /// [sqlite3_prepare_v3()], [sqlite3_prepare16()], [sqlite3_prepare16_v2()], + /// and [sqlite3_prepare16_v3()]. ^At various + /// points during the compilation process, as logic is being created + /// to perform various actions, the authorizer callback is invoked to + /// see if those actions are allowed. ^The authorizer callback should + /// return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the + /// specific action but allow the SQL statement to continue to be + /// compiled, or [SQLITE_DENY] to cause the entire SQL statement to be + /// rejected with an error. ^If the authorizer callback returns + /// any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] + /// then the [sqlite3_prepare_v2()] or equivalent call that triggered + /// the authorizer will fail with an error message. + /// + /// When the callback returns [SQLITE_OK], that means the operation + /// requested is ok. ^When the callback returns [SQLITE_DENY], the + /// [sqlite3_prepare_v2()] or equivalent call that triggered the + /// authorizer will fail with an error message explaining that + /// access is denied. + /// + /// ^The first parameter to the authorizer callback is a copy of the third + /// parameter to the sqlite3_set_authorizer() interface. ^The second parameter + /// to the callback is an integer [SQLITE_COPY | action code] that specifies + /// the particular action to be authorized. ^The third through sixth parameters + /// to the callback are either NULL pointers or zero-terminated strings + /// that contain additional details about the action to be authorized. + /// Applications must always be prepared to encounter a NULL pointer in any + /// of the third through the sixth parameters of the authorization callback. + /// + /// ^If the action code is [SQLITE_READ] + /// and the callback returns [SQLITE_IGNORE] then the + /// [prepared statement] statement is constructed to substitute + /// a NULL value in place of the table column that would have + /// been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] + /// return can be used to deny an untrusted user access to individual + /// columns of a table. + /// ^When a table is referenced by a [SELECT] but no column values are + /// extracted from that table (for example in a query like + /// "SELECT count(*) FROM tab") then the [SQLITE_READ] authorizer callback + /// is invoked once for that table with a column name that is an empty string. + /// ^If the action code is [SQLITE_DELETE] and the callback returns + /// [SQLITE_IGNORE] then the [DELETE] operation proceeds but the + /// [truncate optimization] is disabled and all rows are deleted individually. + /// + /// An authorizer is used when [sqlite3_prepare | preparing] + /// SQL statements from an untrusted source, to ensure that the SQL statements + /// do not try to access data they are not allowed to see, or that they do not + /// try to execute malicious statements that damage the database. For + /// example, an application may allow a user to enter arbitrary + /// SQL queries for evaluation by a database. But the application does + /// not want the user to be able to make arbitrary changes to the + /// database. An authorizer could then be put in place while the + /// user-entered SQL is being [sqlite3_prepare | prepared] that + /// disallows everything except [SELECT] statements. /// - /// ^This interface returns a pointer the [sqlite3_mutex] object that - /// serializes access to the [database connection] given in the argument - /// when the [threading mode] is Serialized. - /// ^If the [threading mode] is Single-thread or Multi-thread then this - /// routine returns a NULL pointer. - ffi.Pointer sqlite3_db_mutex(ffi.Pointer arg0) { - return _sqlite3_db_mutex(arg0); - } - - late final _sqlite3_db_mutexPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_db_mutex'); - late final _sqlite3_db_mutex = _sqlite3_db_mutexPtr - .asFunction Function(ffi.Pointer)>(); - - /// CAPI3REF: Low-Level Control Of Database Files - /// METHOD: sqlite3 - /// KEYWORDS: {file control} + /// Applications that need to process SQL from untrusted sources + /// might also consider lowering resource limits using [sqlite3_limit()] + /// and limiting database size using the [max_page_count] [PRAGMA] + /// in addition to using an authorizer. /// - /// ^The [sqlite3_file_control()] interface makes a direct call to the - /// xFileControl method for the [sqlite3_io_methods] object associated - /// with a particular database identified by the second argument. ^The - /// name of the database is "main" for the main database or "temp" for the - /// TEMP database, or the name that appears after the AS keyword for - /// databases that are added using the [ATTACH] SQL command. - /// ^A NULL pointer can be used in place of "main" to refer to the - /// main database file. - /// ^The third and fourth parameters to this routine - /// are passed directly through to the second and third parameters of - /// the xFileControl method. ^The return value of the xFileControl - /// method becomes the return value of this routine. + /// ^(Only a single authorizer can be in place on a database connection + /// at a time. Each call to sqlite3_set_authorizer overrides the + /// previous call.)^ ^Disable the authorizer by installing a NULL callback. + /// The authorizer is disabled by default. /// - /// A few opcodes for [sqlite3_file_control()] are handled directly - /// by the SQLite core and never invoke the - /// sqlite3_io_methods.xFileControl method. - /// ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes - /// a pointer to the underlying [sqlite3_file] object to be written into - /// the space pointed to by the 4th parameter. The - /// [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns - /// the [sqlite3_file] object associated with the journal file instead of - /// the main database. The [SQLITE_FCNTL_VFS_POINTER] opcode returns - /// a pointer to the underlying [sqlite3_vfs] object for the file. - /// The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter - /// from the pager. + /// The authorizer callback must not do anything that will modify + /// the database connection that invoked the authorizer callback. + /// Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + /// database connections for the meaning of "modify" in this paragraph. /// - /// ^If the second parameter (zDbName) does not match the name of any - /// open database file, then SQLITE_ERROR is returned. ^This error - /// code is not remembered and will not be recalled by [sqlite3_errcode()] - /// or [sqlite3_errmsg()]. The underlying xFileControl method might - /// also return SQLITE_ERROR. There is no way to distinguish between - /// an incorrect zDbName and an SQLITE_ERROR return from the underlying - /// xFileControl method. + /// ^When [sqlite3_prepare_v2()] is used to prepare a statement, the + /// statement might be re-prepared during [sqlite3_step()] due to a + /// schema change. Hence, the application should ensure that the + /// correct authorizer callback remains in place during the [sqlite3_step()]. /// - /// See also: [file control opcodes] - int sqlite3_file_control( + /// ^Note that the authorizer callback is invoked only during + /// [sqlite3_prepare()] or its variants. Authorization is not + /// performed during statement evaluation in [sqlite3_step()], unless + /// as stated in the previous paragraph, sqlite3_step() invokes + /// sqlite3_prepare_v2() to reprepare a statement after a schema change. + int sqlite3_set_authorizer( ffi.Pointer arg0, - ffi.Pointer zDbName, - int op, - ffi.Pointer arg3, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xAuth, + ffi.Pointer pUserData, ) { - return _sqlite3_file_control(arg0, zDbName, op, arg3); + return _sqlite3_set_authorizer(arg0, xAuth, pUserData); } - late final _sqlite3_file_controlPtr = + late final _sqlite3_set_authorizerPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, - ffi.Pointer, - ffi.Int, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >, ffi.Pointer, ) > - >('sqlite3_file_control'); - late final _sqlite3_file_control = _sqlite3_file_controlPtr + >('sqlite3_set_authorizer'); + late final _sqlite3_set_authorizer = _sqlite3_set_authorizerPtr .asFunction< int Function( ffi.Pointer, - ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ffi.Pointer, + ) + >(); + + void sqlite3_set_auxdata( + ffi.Pointer arg0, + int N, + ffi.Pointer arg2, + ffi.Pointer)>> + arg3, + ) { + return _sqlite3_set_auxdata(arg0, N, arg2, arg3); + } + + late final _sqlite3_set_auxdataPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + >('sqlite3_set_auxdata'); + late final _sqlite3_set_auxdata = _sqlite3_set_auxdataPtr + .asFunction< + void Function( + ffi.Pointer, int, ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, ) >(); - /// CAPI3REF: Testing Interface - /// - /// ^The sqlite3_test_control() interface is used to read out internal - /// state of SQLite and to inject faults into SQLite for testing - /// purposes. ^The first parameter is an operation code that determines - /// the number, meaning, and operation of all subsequent parameters. - /// - /// This interface is not for use by applications. It exists solely - /// for verifying the correct operation of the SQLite library. Depending - /// on how the SQLite library is compiled, this interface might not exist. + /// CAPI3REF: Set the Last Insert Rowid value. + /// METHOD: sqlite3 /// - /// The details of the operation codes, their meanings, the parameters - /// they take, and what they do are all subject to change without notice. - /// Unlike most of the SQLite API, this function is not guaranteed to - /// operate consistently from one release to the next. - int sqlite3_test_control(int op) { - return _sqlite3_test_control(op); + /// The sqlite3_set_last_insert_rowid(D, R) method allows the application to + /// set the value returned by calling sqlite3_last_insert_rowid(D) to R + /// without inserting a row into the database. + void sqlite3_set_last_insert_rowid(ffi.Pointer arg0, int arg1) { + return _sqlite3_set_last_insert_rowid(arg0, arg1); } - late final _sqlite3_test_controlPtr = - _lookup>( - 'sqlite3_test_control', - ); - late final _sqlite3_test_control = _sqlite3_test_controlPtr - .asFunction(); + late final _sqlite3_set_last_insert_rowidPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, sqlite3_int64) + > + >('sqlite3_set_last_insert_rowid'); + late final _sqlite3_set_last_insert_rowid = _sqlite3_set_last_insert_rowidPtr + .asFunction, int)>(); - /// CAPI3REF: SQL Keyword Checking - /// - /// These routines provide access to the set of SQL language keywords - /// recognized by SQLite. Applications can uses these routines to determine - /// whether or not a specific identifier needs to be escaped (for example, - /// by enclosing in double-quotes) so as not to confuse the parser. - /// - /// The sqlite3_keyword_count() interface returns the number of distinct - /// keywords understood by SQLite. - /// - /// The sqlite3_keyword_name(N,Z,L) interface finds the N-th keyword and - /// makes *Z point to that keyword expressed as UTF8 and writes the number - /// of bytes in the keyword into *L. The string that *Z points to is not - /// zero-terminated. The sqlite3_keyword_name(N,Z,L) routine returns - /// SQLITE_OK if N is within bounds and SQLITE_ERROR if not. If either Z - /// or L are NULL or invalid pointers then calls to - /// sqlite3_keyword_name(N,Z,L) result in undefined behavior. - /// - /// The sqlite3_keyword_check(Z,L) interface checks to see whether or not - /// the L-byte UTF8 identifier that Z points to is a keyword, returning non-zero - /// if it is and zero if not. - /// - /// The parser used by SQLite is forgiving. It is often possible to use - /// a keyword as an identifier as long as such use does not result in a - /// parsing ambiguity. For example, the statement - /// "CREATE TABLE BEGIN(REPLACE,PRAGMA,END);" is accepted by SQLite, and - /// creates a new table named "BEGIN" with three columns named - /// "REPLACE", "PRAGMA", and "END". Nevertheless, best practice is to avoid - /// using keywords as identifiers. Common techniques used to avoid keyword - /// name collisions include: - ///
      - ///
    • Put all identifier names inside double-quotes. This is the official - /// SQL way to escape identifier names. - ///
    • Put identifier names inside [...]. This is not standard SQL, - /// but it is what SQL Server does and so lots of programmers use this - /// technique. - ///
    • Begin every identifier with the letter "Z" as no SQL keywords start - /// with "Z". - ///
    • Include a digit somewhere in every identifier name. - ///
    - /// - /// Note that the number of keywords understood by SQLite can depend on - /// compile-time options. For example, "VACUUM" is not a keyword if - /// SQLite is compiled with the [-DSQLITE_OMIT_VACUUM] option. Also, - /// new keywords may be added to future releases of SQLite. - int sqlite3_keyword_count() { - return _sqlite3_keyword_count(); + int sqlite3_shutdown() { + return _sqlite3_shutdown(); } - late final _sqlite3_keyword_countPtr = - _lookup>('sqlite3_keyword_count'); - late final _sqlite3_keyword_count = _sqlite3_keyword_countPtr + late final _sqlite3_shutdownPtr = + _lookup>('sqlite3_shutdown'); + late final _sqlite3_shutdown = _sqlite3_shutdownPtr .asFunction(); - int sqlite3_keyword_name( - int arg0, - ffi.Pointer> arg1, - ffi.Pointer arg2, + /// CAPI3REF: Suspend Execution For A Short Time + /// + /// The sqlite3_sleep() function causes the current thread to suspend execution + /// for at least a number of milliseconds specified in its parameter. + /// + /// If the operating system does not support sleep requests with + /// millisecond time resolution, then the time will be rounded up to + /// the nearest second. The number of milliseconds of sleep actually + /// requested from the operating system is returned. + /// + /// ^SQLite implements this interface by calling the xSleep() + /// method of the default [sqlite3_vfs] object. If the xSleep() method + /// of the default VFS is not implemented correctly, or not implemented at + /// all, then the behavior of sqlite3_sleep() may deviate from the description + /// in the previous paragraphs. + int sqlite3_sleep(int arg0) { + return _sqlite3_sleep(arg0); + } + + late final _sqlite3_sleepPtr = + _lookup>('sqlite3_sleep'); + late final _sqlite3_sleep = _sqlite3_sleepPtr.asFunction(); + + /// CAPI3REF: Compare the ages of two snapshot handles. + /// METHOD: sqlite3_snapshot + /// + /// The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages + /// of two valid snapshot handles. + /// + /// If the two snapshot handles are not associated with the same database + /// file, the result of the comparison is undefined. + /// + /// Additionally, the result of the comparison is only valid if both of the + /// snapshot handles were obtained by calling sqlite3_snapshot_get() since the + /// last time the wal file was deleted. The wal file is deleted when the + /// database is changed back to rollback mode or when the number of database + /// clients drops to zero. If either snapshot handle was obtained before the + /// wal file was last deleted, the value returned by this function + /// is undefined. + /// + /// Otherwise, this API returns a negative value if P1 refers to an older + /// snapshot than P2, zero if the two handles refer to the same database + /// snapshot, and a positive value if P1 is a newer snapshot than P2. + /// + /// This interface is only available if SQLite is compiled with the + /// [SQLITE_ENABLE_SNAPSHOT] option. + int sqlite3_snapshot_cmp( + ffi.Pointer p1, + ffi.Pointer p2, ) { - return _sqlite3_keyword_name(arg0, arg1, arg2); + return _sqlite3_snapshot_cmp(p1, p2); } - late final _sqlite3_keyword_namePtr = + late final _sqlite3_snapshot_cmpPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Int, - ffi.Pointer>, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) > - >('sqlite3_keyword_name'); - late final _sqlite3_keyword_name = _sqlite3_keyword_namePtr + >('sqlite3_snapshot_cmp'); + late final _sqlite3_snapshot_cmp = _sqlite3_snapshot_cmpPtr .asFunction< int Function( - int, - ffi.Pointer>, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) >(); - int sqlite3_keyword_check(ffi.Pointer arg0, int arg1) { - return _sqlite3_keyword_check(arg0, arg1); + /// CAPI3REF: Destroy a snapshot + /// DESTRUCTOR: sqlite3_snapshot + /// + /// ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P. + /// The application must eventually free every [sqlite3_snapshot] object + /// using this routine to avoid a memory leak. + /// + /// The [sqlite3_snapshot_free()] interface is only available when the + /// [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. + void sqlite3_snapshot_free(ffi.Pointer arg0) { + return _sqlite3_snapshot_free(arg0); } - late final _sqlite3_keyword_checkPtr = + late final _sqlite3_snapshot_freePtr = _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_keyword_check'); - late final _sqlite3_keyword_check = _sqlite3_keyword_checkPtr - .asFunction, int)>(); + ffi.NativeFunction)> + >('sqlite3_snapshot_free'); + late final _sqlite3_snapshot_free = _sqlite3_snapshot_freePtr + .asFunction)>(); - /// CAPI3REF: Create A New Dynamic String Object - /// CONSTRUCTOR: sqlite3_str + /// CAPI3REF: Record A Database Snapshot + /// CONSTRUCTOR: sqlite3_snapshot /// - /// ^The [sqlite3_str_new(D)] interface allocates and initializes - /// a new [sqlite3_str] object. To avoid memory leaks, the object returned by - /// [sqlite3_str_new()] must be freed by a subsequent call to - /// [sqlite3_str_finish(X)]. + /// ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a + /// new [sqlite3_snapshot] object that records the current state of + /// schema S in database connection D. ^On success, the + /// [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly + /// created [sqlite3_snapshot] object into *P and returns SQLITE_OK. + /// If there is not already a read-transaction open on schema S when + /// this function is called, one is opened automatically. /// - /// ^The [sqlite3_str_new(D)] interface always returns a pointer to a - /// valid [sqlite3_str] object, though in the event of an out-of-memory - /// error the returned object might be a special singleton that will - /// silently reject new text, always return SQLITE_NOMEM from - /// [sqlite3_str_errcode()], always return 0 for - /// [sqlite3_str_length()], and always return NULL from - /// [sqlite3_str_finish(X)]. It is always safe to use the value - /// returned by [sqlite3_str_new(D)] as the sqlite3_str parameter - /// to any of the other [sqlite3_str] methods. + /// The following must be true for this function to succeed. If any of + /// the following statements are false when sqlite3_snapshot_get() is + /// called, SQLITE_ERROR is returned. The final value of *P is undefined + /// in this case. /// - /// The D parameter to [sqlite3_str_new(D)] may be NULL. If the - /// D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum - /// length of the string contained in the [sqlite3_str] object will be - /// the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead - /// of [SQLITE_MAX_LENGTH]. - ffi.Pointer sqlite3_str_new(ffi.Pointer arg0) { - return _sqlite3_str_new(arg0); - } - - late final _sqlite3_str_newPtr = - _lookup< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) - > - >('sqlite3_str_new'); - late final _sqlite3_str_new = _sqlite3_str_newPtr - .asFunction Function(ffi.Pointer)>(); - - /// CAPI3REF: Finalize A Dynamic String - /// DESTRUCTOR: sqlite3_str + ///
      + ///
    • The database handle must not be in [autocommit mode]. /// - /// ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X - /// and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()] - /// that contains the constructed string. The calling application should - /// pass the returned value to [sqlite3_free()] to avoid a memory leak. - /// ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any - /// errors were encountered during construction of the string. ^The - /// [sqlite3_str_finish(X)] interface will also return a NULL pointer if the - /// string in [sqlite3_str] object X is zero bytes long. - ffi.Pointer sqlite3_str_finish(ffi.Pointer arg0) { - return _sqlite3_str_finish(arg0); + ///
    • Schema S of [database connection] D must be a [WAL mode] database. + /// + ///
    • There must not be a write transaction open on schema S of database + /// connection D. + /// + ///
    • One or more transactions must have been written to the current wal + /// file since it was created on disk (by any connection). This means + /// that a snapshot cannot be taken on a wal mode database with no wal + /// file immediately after it is first opened. At least one transaction + /// must be written to it first. + ///
    + /// + /// This function may also return SQLITE_NOMEM. If it is called with the + /// database handle in autocommit mode but fails for some other reason, + /// whether or not a read transaction is opened on schema S is undefined. + /// + /// The [sqlite3_snapshot] object returned from a successful call to + /// [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()] + /// to avoid a memory leak. + /// + /// The [sqlite3_snapshot_get()] interface is only available when the + /// [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. + int sqlite3_snapshot_get( + ffi.Pointer db, + ffi.Pointer zSchema, + ffi.Pointer> ppSnapshot, + ) { + return _sqlite3_snapshot_get(db, zSchema, ppSnapshot); } - late final _sqlite3_str_finishPtr = + late final _sqlite3_snapshot_getPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ) > - >('sqlite3_str_finish'); - late final _sqlite3_str_finish = _sqlite3_str_finishPtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_snapshot_get'); + late final _sqlite3_snapshot_get = _sqlite3_snapshot_getPtr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ) + >(); - /// CAPI3REF: Add Content To A Dynamic String - /// METHOD: sqlite3_str - /// - /// These interfaces add content to an sqlite3_str object previously obtained - /// from [sqlite3_str_new()]. + /// CAPI3REF: Start a read transaction on an historical snapshot + /// METHOD: sqlite3_snapshot /// - /// ^The [sqlite3_str_appendf(X,F,...)] and - /// [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf] - /// functionality of SQLite to append formatted text onto the end of - /// [sqlite3_str] object X. + /// ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read + /// transaction or upgrades an existing one for schema S of + /// [database connection] D such that the read transaction refers to + /// historical [snapshot] P, rather than the most recent change to the + /// database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK + /// on success or an appropriate [error code] if it fails. /// - /// ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S - /// onto the end of the [sqlite3_str] object X. N must be non-negative. - /// S must contain at least N non-zero bytes of content. To append a - /// zero-terminated string in its entirety, use the [sqlite3_str_appendall()] - /// method instead. + /// ^In order to succeed, the database connection must not be in + /// [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there + /// is already a read transaction open on schema S, then the database handle + /// must have no active statements (SELECT statements that have been passed + /// to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). + /// SQLITE_ERROR is returned if either of these conditions is violated, or + /// if schema S does not exist, or if the snapshot object is invalid. /// - /// ^The [sqlite3_str_appendall(X,S)] method appends the complete content of - /// zero-terminated string S onto the end of [sqlite3_str] object X. + /// ^A call to sqlite3_snapshot_open() will fail to open if the specified + /// snapshot has been overwritten by a [checkpoint]. In this case + /// SQLITE_ERROR_SNAPSHOT is returned. /// - /// ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the - /// single-byte character C onto the end of [sqlite3_str] object X. - /// ^This method can be used, for example, to add whitespace indentation. + /// If there is already a read transaction open when this function is + /// invoked, then the same read transaction remains open (on the same + /// database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT + /// is returned. If another error code - for example SQLITE_PROTOCOL or an + /// SQLITE_IOERR error code - is returned, then the final state of the + /// read transaction is undefined. If SQLITE_OK is returned, then the + /// read transaction is now open on database snapshot P. /// - /// ^The [sqlite3_str_reset(X)] method resets the string under construction - /// inside [sqlite3_str] object X back to zero bytes in length. + /// ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the + /// database connection D does not know that the database file for + /// schema S is in [WAL mode]. A database connection might not know + /// that the database file is in [WAL mode] if there has been no prior + /// I/O on that database connection, or if the database entered [WAL mode] + /// after the most recent I/O on the database connection.)^ + /// (Hint: Run "[PRAGMA application_id]" against a newly opened + /// database connection in order to make it ready to use snapshots.) /// - /// These methods do not return a result code. ^If an error occurs, that fact - /// is recorded in the [sqlite3_str] object and can be recovered by a - /// subsequent call to [sqlite3_str_errcode(X)]. - void sqlite3_str_appendf( - ffi.Pointer arg0, - ffi.Pointer zFormat, + /// The [sqlite3_snapshot_open()] interface is only available when the + /// [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. + int sqlite3_snapshot_open( + ffi.Pointer db, + ffi.Pointer zSchema, + ffi.Pointer pSnapshot, ) { - return _sqlite3_str_appendf(arg0, zFormat); + return _sqlite3_snapshot_open(db, zSchema, pSnapshot); } - late final _sqlite3_str_appendfPtr = + late final _sqlite3_snapshot_openPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) > - >('sqlite3_str_appendf'); - late final _sqlite3_str_appendf = _sqlite3_str_appendfPtr + >('sqlite3_snapshot_open'); + late final _sqlite3_snapshot_open = _sqlite3_snapshot_openPtr .asFunction< - void Function(ffi.Pointer, ffi.Pointer) + int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) >(); - void sqlite3_str_append( - ffi.Pointer arg0, - ffi.Pointer zIn, - int N, + /// CAPI3REF: Recover snapshots from a wal file + /// METHOD: sqlite3_snapshot + /// + /// If a [WAL file] remains on disk after all database connections close + /// (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control] + /// or because the last process to have the database opened exited without + /// calling [sqlite3_close()]) and a new connection is subsequently opened + /// on that database and [WAL file], the [sqlite3_snapshot_open()] interface + /// will only be able to open the last transaction added to the WAL file + /// even though the WAL file contains other valid transactions. + /// + /// This function attempts to scan the WAL file associated with database zDb + /// of database handle db and make all valid snapshots available to + /// sqlite3_snapshot_open(). It is an error if there is already a read + /// transaction open on the database, or if the database is not a WAL mode + /// database. + /// + /// SQLITE_OK is returned if successful, or an SQLite error code otherwise. + /// + /// This interface is only available if SQLite is compiled with the + /// [SQLITE_ENABLE_SNAPSHOT] option. + int sqlite3_snapshot_recover( + ffi.Pointer db, + ffi.Pointer zDb, ) { - return _sqlite3_str_append(arg0, zIn, N); + return _sqlite3_snapshot_recover(db, zDb); } - late final _sqlite3_str_appendPtr = + late final _sqlite3_snapshot_recoverPtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) + ffi.Int Function(ffi.Pointer, ffi.Pointer) > - >('sqlite3_str_append'); - late final _sqlite3_str_append = _sqlite3_str_appendPtr - .asFunction< - void Function(ffi.Pointer, ffi.Pointer, int) - >(); + >('sqlite3_snapshot_recover'); + late final _sqlite3_snapshot_recover = _sqlite3_snapshot_recoverPtr + .asFunction, ffi.Pointer)>(); - void sqlite3_str_appendall( - ffi.Pointer arg0, - ffi.Pointer zIn, + ffi.Pointer sqlite3_snprintf( + int arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, ) { - return _sqlite3_str_appendall(arg0, zIn); + return _sqlite3_snprintf(arg0, arg1, arg2); } - late final _sqlite3_str_appendallPtr = + late final _sqlite3_snprintfPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function( + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) > - >('sqlite3_str_appendall'); - late final _sqlite3_str_appendall = _sqlite3_str_appendallPtr + >('sqlite3_snprintf'); + late final _sqlite3_snprintf = _sqlite3_snprintfPtr .asFunction< - void Function(ffi.Pointer, ffi.Pointer) + ffi.Pointer Function( + int, + ffi.Pointer, + ffi.Pointer, + ) >(); - void sqlite3_str_appendchar(ffi.Pointer arg0, int N, int C) { - return _sqlite3_str_appendchar(arg0, N, C); - } - - late final _sqlite3_str_appendcharPtr = - _lookup< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Char) - > - >('sqlite3_str_appendchar'); - late final _sqlite3_str_appendchar = _sqlite3_str_appendcharPtr - .asFunction, int, int)>(); - - void sqlite3_str_reset(ffi.Pointer arg0) { - return _sqlite3_str_reset(arg0); + /// CAPI3REF: Deprecated Soft Heap Limit Interface + /// DEPRECATED + /// + /// This is a deprecated version of the [sqlite3_soft_heap_limit64()] + /// interface. This routine is provided for historical compatibility + /// only. All new applications should use the + /// [sqlite3_soft_heap_limit64()] interface rather than this one. + void sqlite3_soft_heap_limit(int N) { + return _sqlite3_soft_heap_limit(N); } - late final _sqlite3_str_resetPtr = - _lookup)>>( - 'sqlite3_str_reset', + late final _sqlite3_soft_heap_limitPtr = + _lookup>( + 'sqlite3_soft_heap_limit', ); - late final _sqlite3_str_reset = _sqlite3_str_resetPtr - .asFunction)>(); + late final _sqlite3_soft_heap_limit = _sqlite3_soft_heap_limitPtr + .asFunction(); - /// CAPI3REF: Status Of A Dynamic String - /// METHOD: sqlite3_str + /// CAPI3REF: Impose A Limit On Heap Size /// - /// These interfaces return the current status of an [sqlite3_str] object. + /// These interfaces impose limits on the amount of heap memory that will be + /// by all database connections within a single process. /// - /// ^If any prior errors have occurred while constructing the dynamic string - /// in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return - /// an appropriate error code. ^The [sqlite3_str_errcode(X)] method returns - /// [SQLITE_NOMEM] following any out-of-memory error, or - /// [SQLITE_TOOBIG] if the size of the dynamic string exceeds - /// [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors. + /// ^The sqlite3_soft_heap_limit64() interface sets and/or queries the + /// soft limit on the amount of heap memory that may be allocated by SQLite. + /// ^SQLite strives to keep heap memory utilization below the soft heap + /// limit by reducing the number of pages held in the page cache + /// as heap memory usages approaches the limit. + /// ^The soft heap limit is "soft" because even though SQLite strives to stay + /// below the limit, it will exceed the limit rather than generate + /// an [SQLITE_NOMEM] error. In other words, the soft heap limit + /// is advisory only. /// - /// ^The [sqlite3_str_length(X)] method returns the current length, in bytes, - /// of the dynamic string under construction in [sqlite3_str] object X. - /// ^The length returned by [sqlite3_str_length(X)] does not include the - /// zero-termination byte. + /// ^The sqlite3_hard_heap_limit64(N) interface sets a hard upper bound of + /// N bytes on the amount of memory that will be allocated. ^The + /// sqlite3_hard_heap_limit64(N) interface is similar to + /// sqlite3_soft_heap_limit64(N) except that memory allocations will fail + /// when the hard heap limit is reached. /// - /// ^The [sqlite3_str_value(X)] method returns a pointer to the current - /// content of the dynamic string under construction in X. The value - /// returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X - /// and might be freed or altered by any subsequent method on the same - /// [sqlite3_str] object. Applications must not used the pointer returned - /// [sqlite3_str_value(X)] after any subsequent method call on the same - /// object. ^Applications may change the content of the string returned - /// by [sqlite3_str_value(X)] as long as they do not write into any bytes - /// outside the range of 0 to [sqlite3_str_length(X)] and do not read or - /// write any byte after any subsequent sqlite3_str method call. - int sqlite3_str_errcode(ffi.Pointer arg0) { - return _sqlite3_str_errcode(arg0); + /// ^The return value from both sqlite3_soft_heap_limit64() and + /// sqlite3_hard_heap_limit64() is the size of + /// the heap limit prior to the call, or negative in the case of an + /// error. ^If the argument N is negative + /// then no change is made to the heap limit. Hence, the current + /// size of heap limits can be determined by invoking + /// sqlite3_soft_heap_limit64(-1) or sqlite3_hard_heap_limit(-1). + /// + /// ^Setting the heap limits to zero disables the heap limiter mechanism. + /// + /// ^The soft heap limit may not be greater than the hard heap limit. + /// ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N) + /// is invoked with a value of N that is greater than the hard heap limit, + /// the the soft heap limit is set to the value of the hard heap limit. + /// ^The soft heap limit is automatically enabled whenever the hard heap + /// limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and + /// the soft heap limit is outside the range of 1..N, then the soft heap + /// limit is set to N. ^Invoking sqlite3_soft_heap_limit64(0) when the + /// hard heap limit is enabled makes the soft heap limit equal to the + /// hard heap limit. + /// + /// The memory allocation limits can also be adjusted using + /// [PRAGMA soft_heap_limit] and [PRAGMA hard_heap_limit]. + /// + /// ^(The heap limits are not enforced in the current implementation + /// if one or more of following conditions are true: + /// + ///
      + ///
    • The limit value is set to zero. + ///
    • Memory accounting is disabled using a combination of the + /// [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and + /// the [SQLITE_DEFAULT_MEMSTATUS] compile-time option. + ///
    • An alternative page cache implementation is specified using + /// [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...). + ///
    • The page cache allocates from its own memory pool supplied + /// by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than + /// from the heap. + ///
    )^ + /// + /// The circumstances under which SQLite will enforce the heap limits may + /// changes in future releases of SQLite. + int sqlite3_soft_heap_limit64(int N) { + return _sqlite3_soft_heap_limit64(N); } - late final _sqlite3_str_errcodePtr = - _lookup)>>( - 'sqlite3_str_errcode', + late final _sqlite3_soft_heap_limit64Ptr = + _lookup>( + 'sqlite3_soft_heap_limit64', ); - late final _sqlite3_str_errcode = _sqlite3_str_errcodePtr - .asFunction)>(); + late final _sqlite3_soft_heap_limit64 = _sqlite3_soft_heap_limit64Ptr + .asFunction(); - int sqlite3_str_length(ffi.Pointer arg0) { - return _sqlite3_str_length(arg0); + ffi.Pointer sqlite3_sourceid() { + return _sqlite3_sourceid(); } - late final _sqlite3_str_lengthPtr = - _lookup)>>( - 'sqlite3_str_length', + late final _sqlite3_sourceidPtr = + _lookup Function()>>( + 'sqlite3_sourceid', ); - late final _sqlite3_str_length = _sqlite3_str_lengthPtr - .asFunction)>(); + late final _sqlite3_sourceid = _sqlite3_sourceidPtr + .asFunction Function()>(); - ffi.Pointer sqlite3_str_value(ffi.Pointer arg0) { - return _sqlite3_str_value(arg0); + /// CAPI3REF: Retrieving Statement SQL + /// METHOD: sqlite3_stmt + /// + /// ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 + /// SQL text used to create [prepared statement] P if P was + /// created by [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], + /// [sqlite3_prepare16_v2()], or [sqlite3_prepare16_v3()]. + /// ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 + /// string containing the SQL text of prepared statement P with + /// [bound parameters] expanded. + /// ^The sqlite3_normalized_sql(P) interface returns a pointer to a UTF-8 + /// string containing the normalized SQL text of prepared statement P. The + /// semantics used to normalize a SQL statement are unspecified and subject + /// to change. At a minimum, literal values will be replaced with suitable + /// placeholders. + /// + /// ^(For example, if a prepared statement is created using the SQL + /// text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 + /// and parameter :xyz is unbound, then sqlite3_sql() will return + /// the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() + /// will return "SELECT 2345,NULL".)^ + /// + /// ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory + /// is available to hold the result, or if the result would exceed the + /// the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. + /// + /// ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of + /// bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time + /// option causes sqlite3_expanded_sql() to always return NULL. + /// + /// ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P) + /// are managed by SQLite and are automatically freed when the prepared + /// statement is finalized. + /// ^The string returned by sqlite3_expanded_sql(P), on the other hand, + /// is obtained from [sqlite3_malloc()] and must be free by the application + /// by passing it to [sqlite3_free()]. + ffi.Pointer sqlite3_sql(ffi.Pointer pStmt) { + return _sqlite3_sql(pStmt); } - late final _sqlite3_str_valuePtr = + late final _sqlite3_sqlPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_str_value'); - late final _sqlite3_str_value = _sqlite3_str_valuePtr - .asFunction Function(ffi.Pointer)>(); + >('sqlite3_sql'); + late final _sqlite3_sql = _sqlite3_sqlPtr + .asFunction Function(ffi.Pointer)>(); /// CAPI3REF: SQLite Runtime Status /// @@ -9184,60 +8342,259 @@ class SQLite { ) >(); - /// CAPI3REF: Database Connection Status - /// METHOD: sqlite3 + /// CAPI3REF: Evaluate An SQL Statement + /// METHOD: sqlite3_stmt /// - /// ^This interface is used to retrieve runtime status information - /// about a single [database connection]. ^The first argument is the - /// database connection object to be interrogated. ^The second argument - /// is an integer constant, taken from the set of - /// [SQLITE_DBSTATUS options], that - /// determines the parameter to interrogate. The set of - /// [SQLITE_DBSTATUS options] is likely - /// to grow in future releases of SQLite. + /// After a [prepared statement] has been prepared using any of + /// [sqlite3_prepare_v2()], [sqlite3_prepare_v3()], [sqlite3_prepare16_v2()], + /// or [sqlite3_prepare16_v3()] or one of the legacy + /// interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function + /// must be called one or more times to evaluate the statement. /// - /// ^The current value of the requested parameter is written into *pCur - /// and the highest instantaneous value is written into *pHiwtr. ^If - /// the resetFlg is true, then the highest instantaneous value is - /// reset back down to the current value. + /// The details of the behavior of the sqlite3_step() interface depend + /// on whether the statement was prepared using the newer "vX" interfaces + /// [sqlite3_prepare_v3()], [sqlite3_prepare_v2()], [sqlite3_prepare16_v3()], + /// [sqlite3_prepare16_v2()] or the older legacy + /// interfaces [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the + /// new "vX" interface is recommended for new applications but the legacy + /// interface will continue to be supported. + /// + /// ^In the legacy interface, the return value will be either [SQLITE_BUSY], + /// [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. + /// ^With the "v2" interface, any of the other [result codes] or + /// [extended result codes] might be returned as well. + /// + /// ^[SQLITE_BUSY] means that the database engine was unable to acquire the + /// database locks it needs to do its job. ^If the statement is a [COMMIT] + /// or occurs outside of an explicit transaction, then you can retry the + /// statement. If the statement is not a [COMMIT] and occurs within an + /// explicit transaction then you should rollback the transaction before + /// continuing. + /// + /// ^[SQLITE_DONE] means that the statement has finished executing + /// successfully. sqlite3_step() should not be called again on this virtual + /// machine without first calling [sqlite3_reset()] to reset the virtual + /// machine back to its initial state. + /// + /// ^If the SQL statement being executed returns any data, then [SQLITE_ROW] + /// is returned each time a new row of data is ready for processing by the + /// caller. The values may be accessed using the [column access functions]. + /// sqlite3_step() is called again to retrieve the next row of data. + /// + /// ^[SQLITE_ERROR] means that a run-time error (such as a constraint + /// violation) has occurred. sqlite3_step() should not be called again on + /// the VM. More information may be found by calling [sqlite3_errmsg()]. + /// ^With the legacy interface, a more specific error code (for example, + /// [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) + /// can be obtained by calling [sqlite3_reset()] on the + /// [prepared statement]. ^In the "v2" interface, + /// the more specific error code is returned directly by sqlite3_step(). + /// + /// [SQLITE_MISUSE] means that the this routine was called inappropriately. + /// Perhaps it was called on a [prepared statement] that has + /// already been [sqlite3_finalize | finalized] or on one that had + /// previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could + /// be the case that the same database connection is being used by two or + /// more threads at the same moment in time. + /// + /// For all versions of SQLite up to and including 3.6.23.1, a call to + /// [sqlite3_reset()] was required after sqlite3_step() returned anything + /// other than [SQLITE_ROW] before any subsequent invocation of + /// sqlite3_step(). Failure to reset the prepared statement using + /// [sqlite3_reset()] would result in an [SQLITE_MISUSE] return from + /// sqlite3_step(). But after [version 3.6.23.1] ([dateof:3.6.23.1], + /// sqlite3_step() began + /// calling [sqlite3_reset()] automatically in this circumstance rather + /// than returning [SQLITE_MISUSE]. This is not considered a compatibility + /// break because any application that ever receives an SQLITE_MISUSE error + /// is broken by definition. The [SQLITE_OMIT_AUTORESET] compile-time option + /// can be used to restore the legacy behavior. + /// + /// Goofy Interface Alert: In the legacy interface, the sqlite3_step() + /// API always returns a generic error code, [SQLITE_ERROR], following any + /// error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call + /// [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the + /// specific [error codes] that better describes the error. + /// We admit that this is a goofy design. The problem has been fixed + /// with the "v2" interface. If you prepare all of your SQL statements + /// using [sqlite3_prepare_v3()] or [sqlite3_prepare_v2()] + /// or [sqlite3_prepare16_v2()] or [sqlite3_prepare16_v3()] instead + /// of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, + /// then the more specific [error codes] are returned directly + /// by sqlite3_step(). The use of the "vX" interfaces is recommended. + int sqlite3_step(ffi.Pointer arg0) { + return _sqlite3_step(arg0); + } + + late final _sqlite3_stepPtr = + _lookup)>>( + 'sqlite3_step', + ); + late final _sqlite3_step = _sqlite3_stepPtr + .asFunction)>(); + + /// CAPI3REF: Determine If A Prepared Statement Has Been Reset + /// METHOD: sqlite3_stmt + /// + /// ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the + /// [prepared statement] S has been stepped at least once using + /// [sqlite3_step(S)] but has neither run to completion (returned + /// [SQLITE_DONE] from [sqlite3_step(S)]) nor + /// been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) + /// interface returns false if S is a NULL pointer. If S is not a + /// NULL pointer and is not a pointer to a valid [prepared statement] + /// object, then the behavior is undefined and probably undesirable. + /// + /// This interface can be used in combination [sqlite3_next_stmt()] + /// to locate all prepared statements associated with a database + /// connection that are in need of being reset. This can be used, + /// for example, in diagnostic routines to search for prepared + /// statements that are holding a transaction open. + int sqlite3_stmt_busy(ffi.Pointer arg0) { + return _sqlite3_stmt_busy(arg0); + } + + late final _sqlite3_stmt_busyPtr = + _lookup)>>( + 'sqlite3_stmt_busy', + ); + late final _sqlite3_stmt_busy = _sqlite3_stmt_busyPtr + .asFunction)>(); + + /// CAPI3REF: Query The EXPLAIN Setting For A Prepared Statement + /// METHOD: sqlite3_stmt + /// + /// ^The sqlite3_stmt_isexplain(S) interface returns 1 if the + /// prepared statement S is an EXPLAIN statement, or 2 if the + /// statement S is an EXPLAIN QUERY PLAN. + /// ^The sqlite3_stmt_isexplain(S) interface returns 0 if S is + /// an ordinary statement or a NULL pointer. + int sqlite3_stmt_isexplain(ffi.Pointer pStmt) { + return _sqlite3_stmt_isexplain(pStmt); + } + + late final _sqlite3_stmt_isexplainPtr = + _lookup)>>( + 'sqlite3_stmt_isexplain', + ); + late final _sqlite3_stmt_isexplain = _sqlite3_stmt_isexplainPtr + .asFunction)>(); + + /// CAPI3REF: Determine If An SQL Statement Writes The Database + /// METHOD: sqlite3_stmt + /// + /// ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if + /// and only if the [prepared statement] X makes no direct changes to + /// the content of the database file. + /// + /// Note that [application-defined SQL functions] or + /// [virtual tables] might change the database indirectly as a side effect. + /// ^(For example, if an application defines a function "eval()" that + /// calls [sqlite3_exec()], then the following SQL statement would + /// change the database file through side-effects: + /// + ///
    +  /// SELECT eval('DELETE FROM t1') FROM t2;
    +  /// 
    + /// + /// But because the [SELECT] statement does not change the database file + /// directly, sqlite3_stmt_readonly() would still return true.)^ + /// + /// ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], + /// [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, + /// since the statements themselves do not actually modify the database but + /// rather they control the timing of when other statements modify the + /// database. ^The [ATTACH] and [DETACH] statements also cause + /// sqlite3_stmt_readonly() to return true since, while those statements + /// change the configuration of a database connection, they do not make + /// changes to the content of the database files on disk. + /// ^The sqlite3_stmt_readonly() interface returns true for [BEGIN] since + /// [BEGIN] merely sets internal flags, but the [BEGIN|BEGIN IMMEDIATE] and + /// [BEGIN|BEGIN EXCLUSIVE] commands do touch the database and so + /// sqlite3_stmt_readonly() returns false for those commands. + int sqlite3_stmt_readonly(ffi.Pointer pStmt) { + return _sqlite3_stmt_readonly(pStmt); + } + + late final _sqlite3_stmt_readonlyPtr = + _lookup)>>( + 'sqlite3_stmt_readonly', + ); + late final _sqlite3_stmt_readonly = _sqlite3_stmt_readonlyPtr + .asFunction)>(); + + /// CAPI3REF: Prepared Statement Scan Status + /// METHOD: sqlite3_stmt + /// + /// This interface returns information about the predicted and measured + /// performance for pStmt. Advanced applications can use this + /// interface to compare the predicted and the measured performance and + /// issue warnings and/or rerun [ANALYZE] if discrepancies are found. + /// + /// Since this interface is expected to be rarely used, it is only + /// available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS] + /// compile-time option. + /// + /// The "iScanStatusOp" parameter determines which status information to return. + /// The "iScanStatusOp" must be one of the [scanstatus options] or the behavior + /// of this interface is undefined. + /// ^The requested measurement is written into a variable pointed to by + /// the "pOut" parameter. + /// Parameter "idx" identifies the specific loop to retrieve statistics for. + /// Loops are numbered starting from zero. ^If idx is out of range - less than + /// zero or greater than or equal to the total number of loops used to implement + /// the statement - a non-zero value is returned and the variable that pOut + /// points to is unchanged. /// - /// ^The sqlite3_db_status() routine returns SQLITE_OK on success and a - /// non-zero [error code] on failure. + /// ^Statistics might not be available for all loops in all statements. ^In cases + /// where there exist loops with no available statistics, this function behaves + /// as if the loop did not exist - it returns non-zero and leave the variable + /// that pOut points to unchanged. /// - /// See also: [sqlite3_status()] and [sqlite3_stmt_status()]. - int sqlite3_db_status( - ffi.Pointer arg0, - int op, - ffi.Pointer pCur, - ffi.Pointer pHiwtr, - int resetFlg, + /// See also: [sqlite3_stmt_scanstatus_reset()] + int sqlite3_stmt_scanstatus( + ffi.Pointer pStmt, + int idx, + int iScanStatusOp, + ffi.Pointer pOut, ) { - return _sqlite3_db_status(arg0, op, pCur, pHiwtr, resetFlg); + return _sqlite3_stmt_scanstatus(pStmt, idx, iScanStatusOp, pOut); } - late final _sqlite3_db_statusPtr = + late final _sqlite3_stmt_scanstatusPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, + ffi.Pointer, ffi.Int, - ffi.Pointer, - ffi.Pointer, ffi.Int, + ffi.Pointer, ) > - >('sqlite3_db_status'); - late final _sqlite3_db_status = _sqlite3_db_statusPtr + >('sqlite3_stmt_scanstatus'); + late final _sqlite3_stmt_scanstatus = _sqlite3_stmt_scanstatusPtr .asFunction< - int Function( - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, - int, - ) + int Function(ffi.Pointer, int, int, ffi.Pointer) >(); + /// CAPI3REF: Zero Scan-Status Counters + /// METHOD: sqlite3_stmt + /// + /// ^Zero all [sqlite3_stmt_scanstatus()] related event counters. + /// + /// This API is only available if the library is built with pre-processor + /// symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined. + void sqlite3_stmt_scanstatus_reset(ffi.Pointer arg0) { + return _sqlite3_stmt_scanstatus_reset(arg0); + } + + late final _sqlite3_stmt_scanstatus_resetPtr = + _lookup)>>( + 'sqlite3_stmt_scanstatus_reset', + ); + late final _sqlite3_stmt_scanstatus_reset = _sqlite3_stmt_scanstatus_resetPtr + .asFunction)>(); + /// CAPI3REF: Prepared Statement Status /// METHOD: sqlite3_stmt /// @@ -9277,4072 +8634,5798 @@ class SQLite { late final _sqlite3_stmt_status = _sqlite3_stmt_statusPtr .asFunction, int, int)>(); - /// CAPI3REF: Online Backup API. - /// - /// The backup API copies the content of one database into another. - /// It is useful either for creating backups of databases or - /// for copying in-memory databases to or from persistent files. - /// - /// See Also: [Using the SQLite Online Backup API] - /// - /// ^SQLite holds a write transaction open on the destination database file - /// for the duration of the backup operation. - /// ^The source database is read-locked only while it is being read; - /// it is not locked continuously for the entire backup operation. - /// ^Thus, the backup may be performed on a live source database without - /// preventing other database connections from - /// reading or writing to the source database while the backup is underway. - /// - /// ^(To perform a backup operation: - ///
      - ///
    1. sqlite3_backup_init() is called once to initialize the - /// backup, - ///
    2. sqlite3_backup_step() is called one or more times to transfer - /// the data between the two databases, and finally - ///
    3. sqlite3_backup_finish() is called to release all resources - /// associated with the backup operation. - ///
    )^ - /// There should be exactly one call to sqlite3_backup_finish() for each - /// successful call to sqlite3_backup_init(). - /// - /// [[sqlite3_backup_init()]] sqlite3_backup_init() + void sqlite3_str_append( + ffi.Pointer arg0, + ffi.Pointer zIn, + int N, + ) { + return _sqlite3_str_append(arg0, zIn, N); + } + + late final _sqlite3_str_appendPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + >('sqlite3_str_append'); + late final _sqlite3_str_append = _sqlite3_str_appendPtr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer, int) + >(); + + void sqlite3_str_appendall( + ffi.Pointer arg0, + ffi.Pointer zIn, + ) { + return _sqlite3_str_appendall(arg0, zIn); + } + + late final _sqlite3_str_appendallPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + >('sqlite3_str_appendall'); + late final _sqlite3_str_appendall = _sqlite3_str_appendallPtr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >(); + + void sqlite3_str_appendchar(ffi.Pointer arg0, int N, int C) { + return _sqlite3_str_appendchar(arg0, N, C); + } + + late final _sqlite3_str_appendcharPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int, ffi.Char) + > + >('sqlite3_str_appendchar'); + late final _sqlite3_str_appendchar = _sqlite3_str_appendcharPtr + .asFunction, int, int)>(); + + /// CAPI3REF: Add Content To A Dynamic String + /// METHOD: sqlite3_str /// - /// ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the - /// [database connection] associated with the destination database - /// and the database name, respectively. - /// ^The database name is "main" for the main database, "temp" for the - /// temporary database, or the name specified after the AS keyword in - /// an [ATTACH] statement for an attached database. - /// ^The S and M arguments passed to - /// sqlite3_backup_init(D,N,S,M) identify the [database connection] - /// and database name of the source database, respectively. - /// ^The source and destination [database connections] (parameters S and D) - /// must be different or else sqlite3_backup_init(D,N,S,M) will fail with - /// an error. + /// These interfaces add content to an sqlite3_str object previously obtained + /// from [sqlite3_str_new()]. /// - /// ^A call to sqlite3_backup_init() will fail, returning NULL, if - /// there is already a read or read-write transaction open on the - /// destination database. + /// ^The [sqlite3_str_appendf(X,F,...)] and + /// [sqlite3_str_vappendf(X,F,V)] interfaces uses the [built-in printf] + /// functionality of SQLite to append formatted text onto the end of + /// [sqlite3_str] object X. /// - /// ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is - /// returned and an error code and error message are stored in the - /// destination [database connection] D. - /// ^The error code and message for the failed call to sqlite3_backup_init() - /// can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or - /// [sqlite3_errmsg16()] functions. - /// ^A successful call to sqlite3_backup_init() returns a pointer to an - /// [sqlite3_backup] object. - /// ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and - /// sqlite3_backup_finish() functions to perform the specified backup - /// operation. + /// ^The [sqlite3_str_append(X,S,N)] method appends exactly N bytes from string S + /// onto the end of the [sqlite3_str] object X. N must be non-negative. + /// S must contain at least N non-zero bytes of content. To append a + /// zero-terminated string in its entirety, use the [sqlite3_str_appendall()] + /// method instead. /// - /// [[sqlite3_backup_step()]] sqlite3_backup_step() + /// ^The [sqlite3_str_appendall(X,S)] method appends the complete content of + /// zero-terminated string S onto the end of [sqlite3_str] object X. /// - /// ^Function sqlite3_backup_step(B,N) will copy up to N pages between - /// the source and destination databases specified by [sqlite3_backup] object B. - /// ^If N is negative, all remaining source pages are copied. - /// ^If sqlite3_backup_step(B,N) successfully copies N pages and there - /// are still more pages to be copied, then the function returns [SQLITE_OK]. - /// ^If sqlite3_backup_step(B,N) successfully finishes copying all pages - /// from source to destination, then it returns [SQLITE_DONE]. - /// ^If an error occurs while running sqlite3_backup_step(B,N), - /// then an [error code] is returned. ^As well as [SQLITE_OK] and - /// [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], - /// [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an - /// [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. + /// ^The [sqlite3_str_appendchar(X,N,C)] method appends N copies of the + /// single-byte character C onto the end of [sqlite3_str] object X. + /// ^This method can be used, for example, to add whitespace indentation. /// - /// ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if - ///
      - ///
    1. the destination database was opened read-only, or - ///
    2. the destination database is using write-ahead-log journaling - /// and the destination and source page sizes differ, or - ///
    3. the destination database is an in-memory database and the - /// destination and source page sizes differ. - ///
    )^ + /// ^The [sqlite3_str_reset(X)] method resets the string under construction + /// inside [sqlite3_str] object X back to zero bytes in length. /// - /// ^If sqlite3_backup_step() cannot obtain a required file-system lock, then - /// the [sqlite3_busy_handler | busy-handler function] - /// is invoked (if one is specified). ^If the - /// busy-handler returns non-zero before the lock is available, then - /// [SQLITE_BUSY] is returned to the caller. ^In this case the call to - /// sqlite3_backup_step() can be retried later. ^If the source - /// [database connection] - /// is being used to write to the source database when sqlite3_backup_step() - /// is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this - /// case the call to sqlite3_backup_step() can be retried later on. ^(If - /// [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or - /// [SQLITE_READONLY] is returned, then - /// there is no point in retrying the call to sqlite3_backup_step(). These - /// errors are considered fatal.)^ The application must accept - /// that the backup operation has failed and pass the backup operation handle - /// to the sqlite3_backup_finish() to release associated resources. + /// These methods do not return a result code. ^If an error occurs, that fact + /// is recorded in the [sqlite3_str] object and can be recovered by a + /// subsequent call to [sqlite3_str_errcode(X)]. + void sqlite3_str_appendf( + ffi.Pointer arg0, + ffi.Pointer zFormat, + ) { + return _sqlite3_str_appendf(arg0, zFormat); + } + + late final _sqlite3_str_appendfPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + >('sqlite3_str_appendf'); + late final _sqlite3_str_appendf = _sqlite3_str_appendfPtr + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >(); + + /// CAPI3REF: Status Of A Dynamic String + /// METHOD: sqlite3_str /// - /// ^The first call to sqlite3_backup_step() obtains an exclusive lock - /// on the destination file. ^The exclusive lock is not released until either - /// sqlite3_backup_finish() is called or the backup operation is complete - /// and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to - /// sqlite3_backup_step() obtains a [shared lock] on the source database that - /// lasts for the duration of the sqlite3_backup_step() call. - /// ^Because the source database is not locked between calls to - /// sqlite3_backup_step(), the source database may be modified mid-way - /// through the backup process. ^If the source database is modified by an - /// external process or via a database connection other than the one being - /// used by the backup operation, then the backup will be automatically - /// restarted by the next call to sqlite3_backup_step(). ^If the source - /// database is modified by the using the same database connection as is used - /// by the backup operation, then the backup database is automatically - /// updated at the same time. + /// These interfaces return the current status of an [sqlite3_str] object. /// - /// [[sqlite3_backup_finish()]] sqlite3_backup_finish() + /// ^If any prior errors have occurred while constructing the dynamic string + /// in sqlite3_str X, then the [sqlite3_str_errcode(X)] method will return + /// an appropriate error code. ^The [sqlite3_str_errcode(X)] method returns + /// [SQLITE_NOMEM] following any out-of-memory error, or + /// [SQLITE_TOOBIG] if the size of the dynamic string exceeds + /// [SQLITE_MAX_LENGTH], or [SQLITE_OK] if there have been no errors. /// - /// When sqlite3_backup_step() has returned [SQLITE_DONE], or when the - /// application wishes to abandon the backup operation, the application - /// should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). - /// ^The sqlite3_backup_finish() interfaces releases all - /// resources associated with the [sqlite3_backup] object. - /// ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any - /// active write-transaction on the destination database is rolled back. - /// The [sqlite3_backup] object is invalid - /// and may not be used following a call to sqlite3_backup_finish(). + /// ^The [sqlite3_str_length(X)] method returns the current length, in bytes, + /// of the dynamic string under construction in [sqlite3_str] object X. + /// ^The length returned by [sqlite3_str_length(X)] does not include the + /// zero-termination byte. /// - /// ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no - /// sqlite3_backup_step() errors occurred, regardless or whether or not - /// sqlite3_backup_step() completed. - /// ^If an out-of-memory condition or IO error occurred during any prior - /// sqlite3_backup_step() call on the same [sqlite3_backup] object, then - /// sqlite3_backup_finish() returns the corresponding [error code]. + /// ^The [sqlite3_str_value(X)] method returns a pointer to the current + /// content of the dynamic string under construction in X. The value + /// returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X + /// and might be freed or altered by any subsequent method on the same + /// [sqlite3_str] object. Applications must not used the pointer returned + /// [sqlite3_str_value(X)] after any subsequent method call on the same + /// object. ^Applications may change the content of the string returned + /// by [sqlite3_str_value(X)] as long as they do not write into any bytes + /// outside the range of 0 to [sqlite3_str_length(X)] and do not read or + /// write any byte after any subsequent sqlite3_str method call. + int sqlite3_str_errcode(ffi.Pointer arg0) { + return _sqlite3_str_errcode(arg0); + } + + late final _sqlite3_str_errcodePtr = + _lookup)>>( + 'sqlite3_str_errcode', + ); + late final _sqlite3_str_errcode = _sqlite3_str_errcodePtr + .asFunction)>(); + + /// CAPI3REF: Finalize A Dynamic String + /// DESTRUCTOR: sqlite3_str /// - /// ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() - /// is not a permanent error and does not affect the return value of - /// sqlite3_backup_finish(). + /// ^The [sqlite3_str_finish(X)] interface destroys the sqlite3_str object X + /// and returns a pointer to a memory buffer obtained from [sqlite3_malloc64()] + /// that contains the constructed string. The calling application should + /// pass the returned value to [sqlite3_free()] to avoid a memory leak. + /// ^The [sqlite3_str_finish(X)] interface may return a NULL pointer if any + /// errors were encountered during construction of the string. ^The + /// [sqlite3_str_finish(X)] interface will also return a NULL pointer if the + /// string in [sqlite3_str] object X is zero bytes long. + ffi.Pointer sqlite3_str_finish(ffi.Pointer arg0) { + return _sqlite3_str_finish(arg0); + } + + late final _sqlite3_str_finishPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_str_finish'); + late final _sqlite3_str_finish = _sqlite3_str_finishPtr + .asFunction Function(ffi.Pointer)>(); + + int sqlite3_str_length(ffi.Pointer arg0) { + return _sqlite3_str_length(arg0); + } + + late final _sqlite3_str_lengthPtr = + _lookup)>>( + 'sqlite3_str_length', + ); + late final _sqlite3_str_length = _sqlite3_str_lengthPtr + .asFunction)>(); + + /// CAPI3REF: Create A New Dynamic String Object + /// CONSTRUCTOR: sqlite3_str /// - /// [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]] - /// sqlite3_backup_remaining() and sqlite3_backup_pagecount() + /// ^The [sqlite3_str_new(D)] interface allocates and initializes + /// a new [sqlite3_str] object. To avoid memory leaks, the object returned by + /// [sqlite3_str_new()] must be freed by a subsequent call to + /// [sqlite3_str_finish(X)]. /// - /// ^The sqlite3_backup_remaining() routine returns the number of pages still - /// to be backed up at the conclusion of the most recent sqlite3_backup_step(). - /// ^The sqlite3_backup_pagecount() routine returns the total number of pages - /// in the source database at the conclusion of the most recent - /// sqlite3_backup_step(). - /// ^(The values returned by these functions are only updated by - /// sqlite3_backup_step(). If the source database is modified in a way that - /// changes the size of the source database or the number of pages remaining, - /// those changes are not reflected in the output of sqlite3_backup_pagecount() - /// and sqlite3_backup_remaining() until after the next - /// sqlite3_backup_step().)^ + /// ^The [sqlite3_str_new(D)] interface always returns a pointer to a + /// valid [sqlite3_str] object, though in the event of an out-of-memory + /// error the returned object might be a special singleton that will + /// silently reject new text, always return SQLITE_NOMEM from + /// [sqlite3_str_errcode()], always return 0 for + /// [sqlite3_str_length()], and always return NULL from + /// [sqlite3_str_finish(X)]. It is always safe to use the value + /// returned by [sqlite3_str_new(D)] as the sqlite3_str parameter + /// to any of the other [sqlite3_str] methods. /// - /// Concurrent Usage of Database Handles + /// The D parameter to [sqlite3_str_new(D)] may be NULL. If the + /// D parameter in [sqlite3_str_new(D)] is not NULL, then the maximum + /// length of the string contained in the [sqlite3_str] object will be + /// the value set for [sqlite3_limit](D,[SQLITE_LIMIT_LENGTH]) instead + /// of [SQLITE_MAX_LENGTH]. + ffi.Pointer sqlite3_str_new(ffi.Pointer arg0) { + return _sqlite3_str_new(arg0); + } + + late final _sqlite3_str_newPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_str_new'); + late final _sqlite3_str_new = _sqlite3_str_newPtr + .asFunction Function(ffi.Pointer)>(); + + void sqlite3_str_reset(ffi.Pointer arg0) { + return _sqlite3_str_reset(arg0); + } + + late final _sqlite3_str_resetPtr = + _lookup)>>( + 'sqlite3_str_reset', + ); + late final _sqlite3_str_reset = _sqlite3_str_resetPtr + .asFunction)>(); + + ffi.Pointer sqlite3_str_value(ffi.Pointer arg0) { + return _sqlite3_str_value(arg0); + } + + late final _sqlite3_str_valuePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_str_value'); + late final _sqlite3_str_value = _sqlite3_str_valuePtr + .asFunction Function(ffi.Pointer)>(); + + /// CAPI3REF: String Globbing /// - /// ^The source [database connection] may be used by the application for other - /// purposes while a backup operation is underway or being initialized. - /// ^If SQLite is compiled and configured to support threadsafe database - /// connections, then the source database connection may be used concurrently - /// from within other threads. + /// ^The [sqlite3_strglob(P,X)] interface returns zero if and only if + /// string X matches the [GLOB] pattern P. + /// ^The definition of [GLOB] pattern matching used in + /// [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the + /// SQL dialect understood by SQLite. ^The [sqlite3_strglob(P,X)] function + /// is case sensitive. /// - /// However, the application must guarantee that the destination - /// [database connection] is not passed to any other API (by any thread) after - /// sqlite3_backup_init() is called and before the corresponding call to - /// sqlite3_backup_finish(). SQLite does not currently check to see - /// if the application incorrectly accesses the destination [database connection] - /// and so no error code is reported, but the operations may malfunction - /// nevertheless. Use of the destination database connection while a - /// backup is in progress might also also cause a mutex deadlock. + /// Note that this routine returns zero on a match and non-zero if the strings + /// do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. /// - /// If running in [shared cache mode], the application must - /// guarantee that the shared cache used by the destination database - /// is not accessed while the backup is running. In practice this means - /// that the application must guarantee that the disk file being - /// backed up to is not accessed by any connection within the process, - /// not just the specific connection that was passed to sqlite3_backup_init(). + /// See also: [sqlite3_strlike()]. + int sqlite3_strglob(ffi.Pointer zGlob, ffi.Pointer zStr) { + return _sqlite3_strglob(zGlob, zStr); + } + + late final _sqlite3_strglobPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + >('sqlite3_strglob'); + late final _sqlite3_strglob = _sqlite3_strglobPtr + .asFunction, ffi.Pointer)>(); + + /// CAPI3REF: String Comparison /// - /// The [sqlite3_backup] object itself is partially threadsafe. Multiple - /// threads may safely make multiple concurrent calls to sqlite3_backup_step(). - /// However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() - /// APIs are not strictly speaking threadsafe. If they are invoked at the - /// same time as another thread is invoking sqlite3_backup_step() it is - /// possible that they return invalid values. - ffi.Pointer sqlite3_backup_init( - ffi.Pointer pDest, - ffi.Pointer zDestName, - ffi.Pointer pSource, - ffi.Pointer zSourceName, + /// ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications + /// and extensions to compare the contents of two buffers containing UTF-8 + /// strings in a case-independent fashion, using the same definition of "case + /// independence" that SQLite uses internally when comparing identifiers. + int sqlite3_stricmp(ffi.Pointer arg0, ffi.Pointer arg1) { + return _sqlite3_stricmp(arg0, arg1); + } + + late final _sqlite3_stricmpPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + >('sqlite3_stricmp'); + late final _sqlite3_stricmp = _sqlite3_stricmpPtr + .asFunction, ffi.Pointer)>(); + + /// CAPI3REF: String LIKE Matching + /// + /// ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if + /// string X matches the [LIKE] pattern P with escape character E. + /// ^The definition of [LIKE] pattern matching used in + /// [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E" + /// operator in the SQL dialect understood by SQLite. ^For "X LIKE P" without + /// the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0. + /// ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case + /// insensitive - equivalent upper and lower case ASCII characters match + /// one another. + /// + /// ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though + /// only ASCII characters are case folded. + /// + /// Note that this routine returns zero on a match and non-zero if the strings + /// do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. + /// + /// See also: [sqlite3_strglob()]. + int sqlite3_strlike( + ffi.Pointer zGlob, + ffi.Pointer zStr, + int cEsc, ) { - return _sqlite3_backup_init(pDest, zDestName, pSource, zSourceName); + return _sqlite3_strlike(zGlob, zStr, cEsc); } - late final _sqlite3_backup_initPtr = + late final _sqlite3_strlikePtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Int Function( ffi.Pointer, - ffi.Pointer, ffi.Pointer, + ffi.UnsignedInt, ) > - >('sqlite3_backup_init'); - late final _sqlite3_backup_init = _sqlite3_backup_initPtr + >('sqlite3_strlike'); + late final _sqlite3_strlike = _sqlite3_strlikePtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) + int Function(ffi.Pointer, ffi.Pointer, int) >(); - int sqlite3_backup_step(ffi.Pointer p, int nPage) { - return _sqlite3_backup_step(p, nPage); + int sqlite3_strnicmp( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, + ) { + return _sqlite3_strnicmp(arg0, arg1, arg2); } - late final _sqlite3_backup_stepPtr = + late final _sqlite3_strnicmpPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int) + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) > - >('sqlite3_backup_step'); - late final _sqlite3_backup_step = _sqlite3_backup_stepPtr - .asFunction, int)>(); - - int sqlite3_backup_finish(ffi.Pointer p) { - return _sqlite3_backup_finish(p); - } - - late final _sqlite3_backup_finishPtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_backup_finish'); - late final _sqlite3_backup_finish = _sqlite3_backup_finishPtr - .asFunction)>(); - - int sqlite3_backup_remaining(ffi.Pointer p) { - return _sqlite3_backup_remaining(p); - } - - late final _sqlite3_backup_remainingPtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_backup_remaining'); - late final _sqlite3_backup_remaining = _sqlite3_backup_remainingPtr - .asFunction)>(); + >('sqlite3_strnicmp'); + late final _sqlite3_strnicmp = _sqlite3_strnicmpPtr + .asFunction< + int Function(ffi.Pointer, ffi.Pointer, int) + >(); - int sqlite3_backup_pagecount(ffi.Pointer p) { - return _sqlite3_backup_pagecount(p); + /// CAPI3REF: Low-level system error code + /// + /// ^Attempt to return the underlying operating system error code or error + /// number that caused the most recent I/O error or failure to open a file. + /// The return value is OS-dependent. For example, on unix systems, after + /// [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be + /// called to get back the underlying "errno" that caused the problem, such + /// as ENOSPC, EAUTH, EISDIR, and so forth. + int sqlite3_system_errno(ffi.Pointer arg0) { + return _sqlite3_system_errno(arg0); } - late final _sqlite3_backup_pagecountPtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_backup_pagecount'); - late final _sqlite3_backup_pagecount = _sqlite3_backup_pagecountPtr - .asFunction)>(); + late final _sqlite3_system_errnoPtr = + _lookup)>>( + 'sqlite3_system_errno', + ); + late final _sqlite3_system_errno = _sqlite3_system_errnoPtr + .asFunction)>(); - /// CAPI3REF: Unlock Notification + /// CAPI3REF: Extract Metadata About A Column Of A Table /// METHOD: sqlite3 /// - /// ^When running in shared-cache mode, a database operation may fail with - /// an [SQLITE_LOCKED] error if the required locks on the shared-cache or - /// individual tables within the shared-cache cannot be obtained. See - /// [SQLite Shared-Cache Mode] for a description of shared-cache locking. - /// ^This API may be used to register a callback that SQLite will invoke - /// when the connection currently holding the required lock relinquishes it. - /// ^This API is only available if the library was compiled with the - /// [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. - /// - /// See Also: [Using the SQLite Unlock Notification Feature]. - /// - /// ^Shared-cache locks are released when a database connection concludes - /// its current transaction, either by committing it or rolling it back. - /// - /// ^When a connection (known as the blocked connection) fails to obtain a - /// shared-cache lock and SQLITE_LOCKED is returned to the caller, the - /// identity of the database connection (the blocking connection) that - /// has locked the required resource is stored internally. ^After an - /// application receives an SQLITE_LOCKED error, it may call the - /// sqlite3_unlock_notify() method with the blocked connection handle as - /// the first argument to register for a callback that will be invoked - /// when the blocking connections current transaction is concluded. ^The - /// callback is invoked from within the [sqlite3_step] or [sqlite3_close] - /// call that concludes the blocking connection's transaction. - /// - /// ^(If sqlite3_unlock_notify() is called in a multi-threaded application, - /// there is a chance that the blocking connection will have already - /// concluded its transaction by the time sqlite3_unlock_notify() is invoked. - /// If this happens, then the specified callback is invoked immediately, - /// from within the call to sqlite3_unlock_notify().)^ - /// - /// ^If the blocked connection is attempting to obtain a write-lock on a - /// shared-cache table, and more than one other connection currently holds - /// a read-lock on the same table, then SQLite arbitrarily selects one of - /// the other connections to use as the blocking connection. - /// - /// ^(There may be at most one unlock-notify callback registered by a - /// blocked connection. If sqlite3_unlock_notify() is called when the - /// blocked connection already has a registered unlock-notify callback, - /// then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is - /// called with a NULL pointer as its second argument, then any existing - /// unlock-notify callback is canceled. ^The blocked connections - /// unlock-notify callback may also be canceled by closing the blocked - /// connection using [sqlite3_close()]. - /// - /// The unlock-notify callback is not reentrant. If an application invokes - /// any sqlite3_xxx API functions from within an unlock-notify callback, a - /// crash or deadlock may be the result. - /// - /// ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always - /// returns SQLITE_OK. - /// - /// Callback Invocation Details + /// ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns + /// information about column C of table T in database D + /// on [database connection] X.)^ ^The sqlite3_table_column_metadata() + /// interface returns SQLITE_OK and fills in the non-NULL pointers in + /// the final five arguments with appropriate values if the specified + /// column exists. ^The sqlite3_table_column_metadata() interface returns + /// SQLITE_ERROR if the specified column does not exist. + /// ^If the column-name parameter to sqlite3_table_column_metadata() is a + /// NULL pointer, then this routine simply checks for the existence of the + /// table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it + /// does not. If the table name parameter T in a call to + /// sqlite3_table_column_metadata(X,D,T,C,...) is NULL then the result is + /// undefined behavior. /// - /// When an unlock-notify callback is registered, the application provides a - /// single void* pointer that is passed to the callback when it is invoked. - /// However, the signature of the callback function allows SQLite to pass - /// it an array of void* context pointers. The first argument passed to - /// an unlock-notify callback is a pointer to an array of void* pointers, - /// and the second is the number of entries in the array. + /// ^The column is identified by the second, third and fourth parameters to + /// this function. ^(The second parameter is either the name of the database + /// (i.e. "main", "temp", or an attached database) containing the specified + /// table or NULL.)^ ^If it is NULL, then all attached databases are searched + /// for the table using the same algorithm used by the database engine to + /// resolve unqualified table references. /// - /// When a blocking connection's transaction is concluded, there may be - /// more than one blocked connection that has registered for an unlock-notify - /// callback. ^If two or more such blocked connections have specified the - /// same callback function, then instead of invoking the callback function - /// multiple times, it is invoked once with the set of void* context pointers - /// specified by the blocked connections bundled together into an array. - /// This gives the application an opportunity to prioritize any actions - /// related to the set of unblocked database connections. + /// ^The third and fourth parameters to this function are the table and column + /// name of the desired column, respectively. /// - /// Deadlock Detection + /// ^Metadata is returned by writing to the memory locations passed as the 5th + /// and subsequent parameters to this function. ^Any of these arguments may be + /// NULL, in which case the corresponding element of metadata is omitted. /// - /// Assuming that after registering for an unlock-notify callback a - /// database waits for the callback to be issued before taking any further - /// action (a reasonable assumption), then using this API may cause the - /// application to deadlock. For example, if connection X is waiting for - /// connection Y's transaction to be concluded, and similarly connection - /// Y is waiting on connection X's transaction, then neither connection - /// will proceed and the system may remain deadlocked indefinitely. + /// ^(
    + /// + ///
    Parameter Output
    Type
    Description /// - /// To avoid this scenario, the sqlite3_unlock_notify() performs deadlock - /// detection. ^If a given call to sqlite3_unlock_notify() would put the - /// system in a deadlocked state, then SQLITE_LOCKED is returned and no - /// unlock-notify callback is registered. The system is said to be in - /// a deadlocked state if connection A has registered for an unlock-notify - /// callback on the conclusion of connection B's transaction, and connection - /// B has itself registered for an unlock-notify callback when connection - /// A's transaction is concluded. ^Indirect deadlock is also detected, so - /// the system is also considered to be deadlocked if connection B has - /// registered for an unlock-notify callback on the conclusion of connection - /// C's transaction, where connection C is waiting on connection A. ^Any - /// number of levels of indirection are allowed. + ///
    5th const char* Data type + ///
    6th const char* Name of default collation sequence + ///
    7th int True if column has a NOT NULL constraint + ///
    8th int True if column is part of the PRIMARY KEY + ///
    9th int True if column is [AUTOINCREMENT] + ///
    + ///
    )^ /// - /// The "DROP TABLE" Exception + /// ^The memory pointed to by the character pointers returned for the + /// declaration type and collation sequence is valid until the next + /// call to any SQLite API function. /// - /// When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost - /// always appropriate to call sqlite3_unlock_notify(). There is however, - /// one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, - /// SQLite checks if there are any currently executing SELECT statements - /// that belong to the same connection. If there are, SQLITE_LOCKED is - /// returned. In this case there is no "blocking connection", so invoking - /// sqlite3_unlock_notify() results in the unlock-notify callback being - /// invoked immediately. If the application then re-attempts the "DROP TABLE" - /// or "DROP INDEX" query, an infinite loop might be the result. + /// ^If the specified table is actually a view, an [error code] is returned. /// - /// One way around this problem is to check the extended error code returned - /// by an sqlite3_step() call. ^(If there is a blocking connection, then the - /// extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in - /// the special "DROP TABLE/INDEX" case, the extended error code is just - /// SQLITE_LOCKED.)^ - int sqlite3_unlock_notify( - ffi.Pointer pBlocked, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer> apArg, - ffi.Int nArg, - ) - > - > - xNotify, - ffi.Pointer pNotifyArg, + /// ^If the specified column is "rowid", "oid" or "_rowid_" and the table + /// is not a [WITHOUT ROWID] table and an + /// [INTEGER PRIMARY KEY] column has been explicitly declared, then the output + /// parameters are set for the explicitly declared column. ^(If there is no + /// [INTEGER PRIMARY KEY] column, then the outputs + /// for the [rowid] are set as follows: + /// + ///
    +  /// data type: "INTEGER"
    +  /// collation sequence: "BINARY"
    +  /// not null: 0
    +  /// primary key: 1
    +  /// auto increment: 0
    +  /// 
    )^ + /// + /// ^This function causes all database schemas to be read from disk and + /// parsed, if that has not already been done, and returns an error if + /// any errors are encountered while loading the schema. + int sqlite3_table_column_metadata( + ffi.Pointer db, + ffi.Pointer zDbName, + ffi.Pointer zTableName, + ffi.Pointer zColumnName, + ffi.Pointer> pzDataType, + ffi.Pointer> pzCollSeq, + ffi.Pointer pNotNull, + ffi.Pointer pPrimaryKey, + ffi.Pointer pAutoinc, ) { - return _sqlite3_unlock_notify(pBlocked, xNotify, pNotifyArg); + return _sqlite3_table_column_metadata( + db, + zDbName, + zTableName, + zColumnName, + pzDataType, + pzCollSeq, + pNotNull, + pPrimaryKey, + pAutoinc, + ); } - late final _sqlite3_unlock_notifyPtr = + late final _sqlite3_table_column_metadataPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer> apArg, - ffi.Int nArg, - ) - > - >, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) > - >('sqlite3_unlock_notify'); - late final _sqlite3_unlock_notify = _sqlite3_unlock_notifyPtr + >('sqlite3_table_column_metadata'); + late final _sqlite3_table_column_metadata = _sqlite3_table_column_metadataPtr .asFunction< int Function( ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer> apArg, - ffi.Int nArg, - ) - > - >, - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ) >(); - /// CAPI3REF: String Comparison + /// CAPI3REF: Name Of The Folder Holding Temporary Files /// - /// ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications - /// and extensions to compare the contents of two buffers containing UTF-8 - /// strings in a case-independent fashion, using the same definition of "case - /// independence" that SQLite uses internally when comparing identifiers. - int sqlite3_stricmp(ffi.Pointer arg0, ffi.Pointer arg1) { - return _sqlite3_stricmp(arg0, arg1); - } - - late final _sqlite3_stricmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sqlite3_stricmp'); - late final _sqlite3_stricmp = _sqlite3_stricmpPtr - .asFunction, ffi.Pointer)>(); + /// ^(If this global variable is made to point to a string which is + /// the name of a folder (a.k.a. directory), then all temporary files + /// created by SQLite when using a built-in [sqlite3_vfs | VFS] + /// will be placed in that directory.)^ ^If this variable + /// is a NULL pointer, then SQLite performs a search for an appropriate + /// temporary file directory. + /// + /// Applications are strongly discouraged from using this global variable. + /// It is required to set a temporary folder on Windows Runtime (WinRT). + /// But for all other platforms, it is highly recommended that applications + /// neither read nor write this variable. This global variable is a relic + /// that exists for backwards compatibility of legacy applications and should + /// be avoided in new projects. + /// + /// It is not safe to read or modify this variable in more than one + /// thread at a time. It is not safe to read or modify this variable + /// if a [database connection] is being used at the same time in a separate + /// thread. + /// It is intended that this variable be set once + /// as part of process initialization and before any SQLite interface + /// routines have been called and that this variable remain unchanged + /// thereafter. + /// + /// ^The [temp_store_directory pragma] may modify this variable and cause + /// it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, + /// the [temp_store_directory pragma] always assumes that any string + /// that this variable points to is held in memory obtained from + /// [sqlite3_malloc] and the pragma may attempt to free that memory + /// using [sqlite3_free]. + /// Hence, if this variable is modified directly, either it should be + /// made NULL or made to point to memory obtained from [sqlite3_malloc] + /// or else the use of the [temp_store_directory pragma] should be avoided. + /// Except when requested by the [temp_store_directory pragma], SQLite + /// does not free the memory that sqlite3_temp_directory points to. If + /// the application wants that memory to be freed, it must do + /// so itself, taking care to only do so after all [database connection] + /// objects have been destroyed. + /// + /// Note to Windows Runtime users: The temporary directory must be set + /// prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various + /// features that require the use of temporary files may fail. Here is an + /// example of how to do this using C++ with the Windows Runtime: + /// + ///
    +  /// LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
    +  ///       TemporaryFolder->Path->Data();
    +  /// char zPathBuf[MAX_PATH + 1];
    +  /// memset(zPathBuf, 0, sizeof(zPathBuf));
    +  /// WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
    +  ///       NULL, NULL);
    +  /// sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
    +  /// 
    + late final ffi.Pointer> _sqlite3_temp_directory = + _lookup>('sqlite3_temp_directory'); - int sqlite3_strnicmp( - ffi.Pointer arg0, - ffi.Pointer arg1, - int arg2, - ) { - return _sqlite3_strnicmp(arg0, arg1, arg2); - } + ffi.Pointer get sqlite3_temp_directory => + _sqlite3_temp_directory.value; - late final _sqlite3_strnicmpPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - >('sqlite3_strnicmp'); - late final _sqlite3_strnicmp = _sqlite3_strnicmpPtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); + set sqlite3_temp_directory(ffi.Pointer value) => + _sqlite3_temp_directory.value = value; - /// CAPI3REF: String Globbing + /// CAPI3REF: Testing Interface /// - /// ^The [sqlite3_strglob(P,X)] interface returns zero if and only if - /// string X matches the [GLOB] pattern P. - /// ^The definition of [GLOB] pattern matching used in - /// [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the - /// SQL dialect understood by SQLite. ^The [sqlite3_strglob(P,X)] function - /// is case sensitive. + /// ^The sqlite3_test_control() interface is used to read out internal + /// state of SQLite and to inject faults into SQLite for testing + /// purposes. ^The first parameter is an operation code that determines + /// the number, meaning, and operation of all subsequent parameters. /// - /// Note that this routine returns zero on a match and non-zero if the strings - /// do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. + /// This interface is not for use by applications. It exists solely + /// for verifying the correct operation of the SQLite library. Depending + /// on how the SQLite library is compiled, this interface might not exist. /// - /// See also: [sqlite3_strlike()]. - int sqlite3_strglob(ffi.Pointer zGlob, ffi.Pointer zStr) { - return _sqlite3_strglob(zGlob, zStr); + /// The details of the operation codes, their meanings, the parameters + /// they take, and what they do are all subject to change without notice. + /// Unlike most of the SQLite API, this function is not guaranteed to + /// operate consistently from one release to the next. + int sqlite3_test_control(int op) { + return _sqlite3_test_control(op); } - late final _sqlite3_strglobPtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sqlite3_strglob'); - late final _sqlite3_strglob = _sqlite3_strglobPtr - .asFunction, ffi.Pointer)>(); + late final _sqlite3_test_controlPtr = + _lookup>( + 'sqlite3_test_control', + ); + late final _sqlite3_test_control = _sqlite3_test_controlPtr + .asFunction(); - /// CAPI3REF: String LIKE Matching + void sqlite3_thread_cleanup() { + return _sqlite3_thread_cleanup(); + } + + late final _sqlite3_thread_cleanupPtr = + _lookup>( + 'sqlite3_thread_cleanup', + ); + late final _sqlite3_thread_cleanup = _sqlite3_thread_cleanupPtr + .asFunction(); + + /// CAPI3REF: Test To See If The Library Is Threadsafe /// - /// ^The [sqlite3_strlike(P,X,E)] interface returns zero if and only if - /// string X matches the [LIKE] pattern P with escape character E. - /// ^The definition of [LIKE] pattern matching used in - /// [sqlite3_strlike(P,X,E)] is the same as for the "X LIKE P ESCAPE E" - /// operator in the SQL dialect understood by SQLite. ^For "X LIKE P" without - /// the ESCAPE clause, set the E parameter of [sqlite3_strlike(P,X,E)] to 0. - /// ^As with the LIKE operator, the [sqlite3_strlike(P,X,E)] function is case - /// insensitive - equivalent upper and lower case ASCII characters match - /// one another. + /// ^The sqlite3_threadsafe() function returns zero if and only if + /// SQLite was compiled with mutexing code omitted due to the + /// [SQLITE_THREADSAFE] compile-time option being set to 0. /// - /// ^The [sqlite3_strlike(P,X,E)] function matches Unicode characters, though - /// only ASCII characters are case folded. + /// SQLite can be compiled with or without mutexes. When + /// the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes + /// are enabled and SQLite is threadsafe. When the + /// [SQLITE_THREADSAFE] macro is 0, + /// the mutexes are omitted. Without the mutexes, it is not safe + /// to use SQLite concurrently from more than one thread. + /// + /// Enabling mutexes incurs a measurable performance penalty. + /// So if speed is of utmost importance, it makes sense to disable + /// the mutexes. But for maximum safety, mutexes should be enabled. + /// ^The default behavior is for mutexes to be enabled. + /// + /// This interface can be used by an application to make sure that the + /// version of SQLite that it is linking against was compiled with + /// the desired setting of the [SQLITE_THREADSAFE] macro. /// - /// Note that this routine returns zero on a match and non-zero if the strings - /// do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()]. + /// This interface only reports on the compile-time mutex setting + /// of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with + /// SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but + /// can be fully or partially disabled using a call to [sqlite3_config()] + /// with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], + /// or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the + /// sqlite3_threadsafe() function shows only the compile-time setting of + /// thread safety, not any run-time changes to that setting made by + /// sqlite3_config(). In other words, the return value from sqlite3_threadsafe() + /// is unchanged by calls to sqlite3_config().)^ /// - /// See also: [sqlite3_strglob()]. - int sqlite3_strlike( - ffi.Pointer zGlob, - ffi.Pointer zStr, - int cEsc, - ) { - return _sqlite3_strlike(zGlob, zStr, cEsc); + /// See the [threading mode] documentation for additional information. + int sqlite3_threadsafe() { + return _sqlite3_threadsafe(); } - late final _sqlite3_strlikePtr = - _lookup< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, - ) - > - >('sqlite3_strlike'); - late final _sqlite3_strlike = _sqlite3_strlikePtr - .asFunction< - int Function(ffi.Pointer, ffi.Pointer, int) - >(); + late final _sqlite3_threadsafePtr = + _lookup>('sqlite3_threadsafe'); + late final _sqlite3_threadsafe = _sqlite3_threadsafePtr + .asFunction(); - /// CAPI3REF: Error Logging Interface + /// CAPI3REF: Total Number Of Rows Modified + /// METHOD: sqlite3 /// - /// ^The [sqlite3_log()] interface writes a message into the [error log] - /// established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. - /// ^If logging is enabled, the zFormat string and subsequent arguments are - /// used with [sqlite3_snprintf()] to generate the final output string. + /// ^This function returns the total number of rows inserted, modified or + /// deleted by all [INSERT], [UPDATE] or [DELETE] statements completed + /// since the database connection was opened, including those executed as + /// part of trigger programs. ^Executing any other type of SQL statement + /// does not affect the value returned by sqlite3_total_changes(). /// - /// The sqlite3_log() interface is intended for use by extensions such as - /// virtual tables, collating functions, and SQL functions. While there is - /// nothing to prevent an application from calling sqlite3_log(), doing so - /// is considered bad form. + /// ^Changes made as part of [foreign key actions] are included in the + /// count, but those made as part of REPLACE constraint resolution are + /// not. ^Changes to a view that are intercepted by INSTEAD OF triggers + /// are not counted. /// - /// The zFormat string must not be NULL. + /// The [sqlite3_total_changes(D)] interface only reports the number + /// of rows that changed due to SQL statement run against database + /// connection D. Any changes by other database connections are ignored. + /// To detect changes against a database file from other database + /// connections use the [PRAGMA data_version] command or the + /// [SQLITE_FCNTL_DATA_VERSION] [file control]. /// - /// To avoid deadlocks and other threading problems, the sqlite3_log() routine - /// will not use dynamically allocated memory. The log message is stored in - /// a fixed-length buffer on the stack. If the log message is longer than - /// a few hundred characters, it will be truncated to the length of the - /// buffer. - void sqlite3_log(int iErrCode, ffi.Pointer zFormat) { - return _sqlite3_log(iErrCode, zFormat); + /// If a separate thread makes changes on the same database connection + /// while [sqlite3_total_changes()] is running then the value + /// returned is unpredictable and not meaningful. + /// + /// See also: + ///
      + ///
    • the [sqlite3_changes()] interface + ///
    • the [count_changes pragma] + ///
    • the [changes() SQL function] + ///
    • the [data_version pragma] + ///
    • the [SQLITE_FCNTL_DATA_VERSION] [file control] + ///
    + int sqlite3_total_changes(ffi.Pointer arg0) { + return _sqlite3_total_changes(arg0); } - late final _sqlite3_logPtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_log'); - late final _sqlite3_log = _sqlite3_logPtr - .asFunction)>(); + late final _sqlite3_total_changesPtr = + _lookup)>>( + 'sqlite3_total_changes', + ); + late final _sqlite3_total_changes = _sqlite3_total_changesPtr + .asFunction)>(); - /// CAPI3REF: Write-Ahead Log Commit Hook + /// CAPI3REF: Tracing And Profiling Functions /// METHOD: sqlite3 /// - /// ^The [sqlite3_wal_hook()] function is used to register a callback that - /// is invoked each time data is committed to a database in wal mode. + /// These routines are deprecated. Use the [sqlite3_trace_v2()] interface + /// instead of the routines described here. /// - /// ^(The callback is invoked by SQLite after the commit has taken place and - /// the associated write-lock on the database released)^, so the implementation - /// may read, write or [checkpoint] the database as required. + /// These routines register callback functions that can be used for + /// tracing and profiling the execution of SQL statements. /// - /// ^The first parameter passed to the callback function when it is invoked - /// is a copy of the third parameter passed to sqlite3_wal_hook() when - /// registering the callback. ^The second is a copy of the database handle. - /// ^The third parameter is the name of the database that was written to - - /// either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter - /// is the number of pages currently in the write-ahead log file, - /// including those that were just committed. + /// ^The callback function registered by sqlite3_trace() is invoked at + /// various times when an SQL statement is being run by [sqlite3_step()]. + /// ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the + /// SQL statement text as the statement first begins executing. + /// ^(Additional sqlite3_trace() callbacks might occur + /// as each triggered subprogram is entered. The callbacks for triggers + /// contain a UTF-8 SQL comment that identifies the trigger.)^ /// - /// The callback function should normally return [SQLITE_OK]. ^If an error - /// code is returned, that error will propagate back up through the - /// SQLite code base to cause the statement that provoked the callback - /// to report an error, though the commit will have still occurred. If the - /// callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value - /// that does not correspond to any valid SQLite error code, the results - /// are undefined. + /// The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit + /// the length of [bound parameter] expansion in the output of sqlite3_trace(). /// - /// A single database handle may have at most a single write-ahead log callback - /// registered at one time. ^Calling [sqlite3_wal_hook()] replaces any - /// previously registered write-ahead log callback. ^Note that the - /// [sqlite3_wal_autocheckpoint()] interface and the - /// [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will - /// overwrite any prior [sqlite3_wal_hook()] settings. - ffi.Pointer sqlite3_wal_hook( + /// ^The callback function registered by sqlite3_profile() is invoked + /// as each SQL statement finishes. ^The profile callback contains + /// the original statement text and an estimate of wall-clock time + /// of how long that statement took to run. ^The profile callback + /// time is in units of nanoseconds, however the current implementation + /// is only capable of millisecond resolution so the six least significant + /// digits in the time are meaningless. Future versions of SQLite + /// might provide greater resolution on the profiler callback. Invoking + /// either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the + /// profile callback. + ffi.Pointer sqlite3_trace( ffi.Pointer arg0, ffi.Pointer< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > > - arg1, + xTrace, ffi.Pointer arg2, ) { - return _sqlite3_wal_hook(arg0, arg1, arg2); + return _sqlite3_trace(arg0, xTrace, arg2); } - late final _sqlite3_wal_hookPtr = + late final _sqlite3_tracePtr = _lookup< ffi.NativeFunction< ffi.Pointer Function( ffi.Pointer, ffi.Pointer< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > >, ffi.Pointer, ) > - >('sqlite3_wal_hook'); - late final _sqlite3_wal_hook = _sqlite3_wal_hookPtr + >('sqlite3_trace'); + late final _sqlite3_trace = _sqlite3_tracePtr .asFunction< ffi.Pointer Function( ffi.Pointer, ffi.Pointer< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) + ffi.Void Function(ffi.Pointer, ffi.Pointer) > >, ffi.Pointer, ) >(); - /// CAPI3REF: Configure an auto-checkpoint + /// CAPI3REF: SQL Trace Hook /// METHOD: sqlite3 /// - /// ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around - /// [sqlite3_wal_hook()] that causes any database on [database connection] D - /// to automatically [checkpoint] - /// after committing a transaction if there are N or - /// more frames in the [write-ahead log] file. ^Passing zero or - /// a negative value as the nFrame parameter disables automatic - /// checkpoints entirely. + /// ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback + /// function X against [database connection] D, using property mask M + /// and context pointer P. ^If the X callback is + /// NULL or if the M mask is zero, then tracing is disabled. The + /// M argument should be the bitwise OR-ed combination of + /// zero or more [SQLITE_TRACE] constants. /// - /// ^The callback registered by this function replaces any existing callback - /// registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback - /// using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism - /// configured by this function. + /// ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides + /// (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). /// - /// ^The [wal_autocheckpoint pragma] can be used to invoke this interface - /// from SQL. + /// ^The X callback is invoked whenever any of the events identified by + /// mask M occur. ^The integer return value from the callback is currently + /// ignored, though this may change in future releases. Callback + /// implementations should return zero to ensure future compatibility. /// - /// ^Checkpoints initiated by this mechanism are - /// [sqlite3_wal_checkpoint_v2|PASSIVE]. + /// ^A trace callback is invoked with four arguments: callback(T,C,P,X). + /// ^The T argument is one of the [SQLITE_TRACE] + /// constants to indicate why the callback was invoked. + /// ^The C argument is a copy of the context pointer. + /// The P and X arguments are pointers whose meanings depend on T. /// - /// ^Every new [database connection] defaults to having the auto-checkpoint - /// enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] - /// pages. The use of this interface - /// is only necessary if the default setting is found to be suboptimal - /// for a particular application. - int sqlite3_wal_autocheckpoint(ffi.Pointer db, int N) { - return _sqlite3_wal_autocheckpoint(db, N); + /// The sqlite3_trace_v2() interface is intended to replace the legacy + /// interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which + /// are deprecated. + int sqlite3_trace_v2( + ffi.Pointer arg0, + int uMask, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xCallback, + ffi.Pointer pCtx, + ) { + return _sqlite3_trace_v2(arg0, uMask, xCallback, pCtx); } - late final _sqlite3_wal_autocheckpointPtr = + late final _sqlite3_trace_v2Ptr = _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_wal_autocheckpoint'); - late final _sqlite3_wal_autocheckpoint = _sqlite3_wal_autocheckpointPtr - .asFunction, int)>(); + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.UnsignedInt, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ffi.Pointer, + ) + > + >('sqlite3_trace_v2'); + late final _sqlite3_trace_v2 = _sqlite3_trace_v2Ptr + .asFunction< + int Function( + ffi.Pointer, + int, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.UnsignedInt, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ffi.Pointer, + ) + >(); - /// CAPI3REF: Checkpoint a database - /// METHOD: sqlite3 - /// - /// ^(The sqlite3_wal_checkpoint(D,X) is equivalent to - /// [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^ - /// - /// In brief, sqlite3_wal_checkpoint(D,X) causes the content in the - /// [write-ahead log] for database X on [database connection] D to be - /// transferred into the database file and for the write-ahead log to - /// be reset. See the [checkpointing] documentation for addition - /// information. - /// - /// This interface used to be the only way to cause a checkpoint to - /// occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()] - /// interface was added. This interface is retained for backwards - /// compatibility and as a convenience for applications that need to manually - /// start a callback but which do not need the full power (and corresponding - /// complication) of [sqlite3_wal_checkpoint_v2()]. - int sqlite3_wal_checkpoint( - ffi.Pointer db, - ffi.Pointer zDb, + int sqlite3_transfer_bindings( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _sqlite3_wal_checkpoint(db, zDb); + return _sqlite3_transfer_bindings(arg0, arg1); } - late final _sqlite3_wal_checkpointPtr = + late final _sqlite3_transfer_bindingsPtr = _lookup< ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) + ffi.Int Function(ffi.Pointer, ffi.Pointer) > - >('sqlite3_wal_checkpoint'); - late final _sqlite3_wal_checkpoint = _sqlite3_wal_checkpointPtr - .asFunction, ffi.Pointer)>(); + >('sqlite3_transfer_bindings'); + late final _sqlite3_transfer_bindings = _sqlite3_transfer_bindingsPtr + .asFunction< + int Function(ffi.Pointer, ffi.Pointer) + >(); - /// CAPI3REF: Checkpoint a database + /// CAPI3REF: Unlock Notification /// METHOD: sqlite3 /// - /// ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint - /// operation on database X of [database connection] D in mode M. Status - /// information is written back into integers pointed to by L and C.)^ - /// ^(The M parameter must be a valid [checkpoint mode]:)^ + /// ^When running in shared-cache mode, a database operation may fail with + /// an [SQLITE_LOCKED] error if the required locks on the shared-cache or + /// individual tables within the shared-cache cannot be obtained. See + /// [SQLite Shared-Cache Mode] for a description of shared-cache locking. + /// ^This API may be used to register a callback that SQLite will invoke + /// when the connection currently holding the required lock relinquishes it. + /// ^This API is only available if the library was compiled with the + /// [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. /// - ///
    - ///
    SQLITE_CHECKPOINT_PASSIVE
    - /// ^Checkpoint as many frames as possible without waiting for any database - /// readers or writers to finish, then sync the database file if all frames - /// in the log were checkpointed. ^The [busy-handler callback] - /// is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode. - /// ^On the other hand, passive mode might leave the checkpoint unfinished - /// if there are concurrent readers or writers. + /// See Also: [Using the SQLite Unlock Notification Feature]. /// - ///
    SQLITE_CHECKPOINT_FULL
    - /// ^This mode blocks (it invokes the - /// [sqlite3_busy_handler|busy-handler callback]) until there is no - /// database writer and all readers are reading from the most recent database - /// snapshot. ^It then checkpoints all frames in the log file and syncs the - /// database file. ^This mode blocks new database writers while it is pending, - /// but new database readers are allowed to continue unimpeded. + /// ^Shared-cache locks are released when a database connection concludes + /// its current transaction, either by committing it or rolling it back. /// - ///
    SQLITE_CHECKPOINT_RESTART
    - /// ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition - /// that after checkpointing the log file it blocks (calls the - /// [busy-handler callback]) - /// until all readers are reading from the database file only. ^This ensures - /// that the next writer will restart the log file from the beginning. - /// ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new - /// database writer attempts while it is pending, but does not impede readers. + /// ^When a connection (known as the blocked connection) fails to obtain a + /// shared-cache lock and SQLITE_LOCKED is returned to the caller, the + /// identity of the database connection (the blocking connection) that + /// has locked the required resource is stored internally. ^After an + /// application receives an SQLITE_LOCKED error, it may call the + /// sqlite3_unlock_notify() method with the blocked connection handle as + /// the first argument to register for a callback that will be invoked + /// when the blocking connections current transaction is concluded. ^The + /// callback is invoked from within the [sqlite3_step] or [sqlite3_close] + /// call that concludes the blocking connection's transaction. /// - ///
    SQLITE_CHECKPOINT_TRUNCATE
    - /// ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the - /// addition that it also truncates the log file to zero bytes just prior - /// to a successful return. - ///
    + /// ^(If sqlite3_unlock_notify() is called in a multi-threaded application, + /// there is a chance that the blocking connection will have already + /// concluded its transaction by the time sqlite3_unlock_notify() is invoked. + /// If this happens, then the specified callback is invoked immediately, + /// from within the call to sqlite3_unlock_notify().)^ /// - /// ^If pnLog is not NULL, then *pnLog is set to the total number of frames in - /// the log file or to -1 if the checkpoint could not run because - /// of an error or because the database is not in [WAL mode]. ^If pnCkpt is not - /// NULL,then *pnCkpt is set to the total number of checkpointed frames in the - /// log file (including any that were already checkpointed before the function - /// was called) or to -1 if the checkpoint could not run due to an error or - /// because the database is not in WAL mode. ^Note that upon successful - /// completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been - /// truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero. + /// ^If the blocked connection is attempting to obtain a write-lock on a + /// shared-cache table, and more than one other connection currently holds + /// a read-lock on the same table, then SQLite arbitrarily selects one of + /// the other connections to use as the blocking connection. /// - /// ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If - /// any other process is running a checkpoint operation at the same time, the - /// lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a - /// busy-handler configured, it will not be invoked in this case. + /// ^(There may be at most one unlock-notify callback registered by a + /// blocked connection. If sqlite3_unlock_notify() is called when the + /// blocked connection already has a registered unlock-notify callback, + /// then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is + /// called with a NULL pointer as its second argument, then any existing + /// unlock-notify callback is canceled. ^The blocked connections + /// unlock-notify callback may also be canceled by closing the blocked + /// connection using [sqlite3_close()]. /// - /// ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the - /// exclusive "writer" lock on the database file. ^If the writer lock cannot be - /// obtained immediately, and a busy-handler is configured, it is invoked and - /// the writer lock retried until either the busy-handler returns 0 or the lock - /// is successfully obtained. ^The busy-handler is also invoked while waiting for - /// database readers as described above. ^If the busy-handler returns 0 before - /// the writer lock is obtained or while waiting for database readers, the - /// checkpoint operation proceeds from that point in the same way as - /// SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible - /// without blocking any further. ^SQLITE_BUSY is returned in this case. + /// The unlock-notify callback is not reentrant. If an application invokes + /// any sqlite3_xxx API functions from within an unlock-notify callback, a + /// crash or deadlock may be the result. /// - /// ^If parameter zDb is NULL or points to a zero length string, then the - /// specified operation is attempted on all WAL databases [attached] to - /// [database connection] db. In this case the - /// values written to output parameters *pnLog and *pnCkpt are undefined. ^If - /// an SQLITE_BUSY error is encountered when processing one or more of the - /// attached WAL databases, the operation is still attempted on any remaining - /// attached databases and SQLITE_BUSY is returned at the end. ^If any other - /// error occurs while processing an attached database, processing is abandoned - /// and the error code is returned to the caller immediately. ^If no error - /// (SQLITE_BUSY or otherwise) is encountered while processing the attached - /// databases, SQLITE_OK is returned. + /// ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always + /// returns SQLITE_OK. /// - /// ^If database zDb is the name of an attached database that is not in WAL - /// mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If - /// zDb is not NULL (or a zero length string) and is not the name of any - /// attached database, SQLITE_ERROR is returned to the caller. + /// Callback Invocation Details /// - /// ^Unless it returns SQLITE_MISUSE, - /// the sqlite3_wal_checkpoint_v2() interface - /// sets the error information that is queried by - /// [sqlite3_errcode()] and [sqlite3_errmsg()]. + /// When an unlock-notify callback is registered, the application provides a + /// single void* pointer that is passed to the callback when it is invoked. + /// However, the signature of the callback function allows SQLite to pass + /// it an array of void* context pointers. The first argument passed to + /// an unlock-notify callback is a pointer to an array of void* pointers, + /// and the second is the number of entries in the array. /// - /// ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface - /// from SQL. - int sqlite3_wal_checkpoint_v2( - ffi.Pointer db, - ffi.Pointer zDb, - int eMode, - ffi.Pointer pnLog, - ffi.Pointer pnCkpt, + /// When a blocking connection's transaction is concluded, there may be + /// more than one blocked connection that has registered for an unlock-notify + /// callback. ^If two or more such blocked connections have specified the + /// same callback function, then instead of invoking the callback function + /// multiple times, it is invoked once with the set of void* context pointers + /// specified by the blocked connections bundled together into an array. + /// This gives the application an opportunity to prioritize any actions + /// related to the set of unblocked database connections. + /// + /// Deadlock Detection + /// + /// Assuming that after registering for an unlock-notify callback a + /// database waits for the callback to be issued before taking any further + /// action (a reasonable assumption), then using this API may cause the + /// application to deadlock. For example, if connection X is waiting for + /// connection Y's transaction to be concluded, and similarly connection + /// Y is waiting on connection X's transaction, then neither connection + /// will proceed and the system may remain deadlocked indefinitely. + /// + /// To avoid this scenario, the sqlite3_unlock_notify() performs deadlock + /// detection. ^If a given call to sqlite3_unlock_notify() would put the + /// system in a deadlocked state, then SQLITE_LOCKED is returned and no + /// unlock-notify callback is registered. The system is said to be in + /// a deadlocked state if connection A has registered for an unlock-notify + /// callback on the conclusion of connection B's transaction, and connection + /// B has itself registered for an unlock-notify callback when connection + /// A's transaction is concluded. ^Indirect deadlock is also detected, so + /// the system is also considered to be deadlocked if connection B has + /// registered for an unlock-notify callback on the conclusion of connection + /// C's transaction, where connection C is waiting on connection A. ^Any + /// number of levels of indirection are allowed. + /// + /// The "DROP TABLE" Exception + /// + /// When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost + /// always appropriate to call sqlite3_unlock_notify(). There is however, + /// one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, + /// SQLite checks if there are any currently executing SELECT statements + /// that belong to the same connection. If there are, SQLITE_LOCKED is + /// returned. In this case there is no "blocking connection", so invoking + /// sqlite3_unlock_notify() results in the unlock-notify callback being + /// invoked immediately. If the application then re-attempts the "DROP TABLE" + /// or "DROP INDEX" query, an infinite loop might be the result. + /// + /// One way around this problem is to check the extended error code returned + /// by an sqlite3_step() call. ^(If there is a blocking connection, then the + /// extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in + /// the special "DROP TABLE/INDEX" case, the extended error code is just + /// SQLITE_LOCKED.)^ + int sqlite3_unlock_notify( + ffi.Pointer pBlocked, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer> apArg, + ffi.Int nArg, + ) + > + > + xNotify, + ffi.Pointer pNotifyArg, ) { - return _sqlite3_wal_checkpoint_v2(db, zDb, eMode, pnLog, pnCkpt); + return _sqlite3_unlock_notify(pBlocked, xNotify, pNotifyArg); } - late final _sqlite3_wal_checkpoint_v2Ptr = + late final _sqlite3_unlock_notifyPtr = _lookup< ffi.NativeFunction< ffi.Int Function( ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer> apArg, + ffi.Int nArg, + ) + > + >, + ffi.Pointer, ) > - >('sqlite3_wal_checkpoint_v2'); - late final _sqlite3_wal_checkpoint_v2 = _sqlite3_wal_checkpoint_v2Ptr + >('sqlite3_unlock_notify'); + late final _sqlite3_unlock_notify = _sqlite3_unlock_notifyPtr .asFunction< int Function( ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer> apArg, + ffi.Int nArg, + ) + > + >, + ffi.Pointer, ) >(); - /// CAPI3REF: Virtual Table Interface Configuration - /// - /// This function may be called by either the [xConnect] or [xCreate] method - /// of a [virtual table] implementation to configure - /// various facets of the virtual table interface. + /// CAPI3REF: Data Change Notification Callbacks + /// METHOD: sqlite3 /// - /// If this interface is invoked outside the context of an xConnect or - /// xCreate virtual table method then the behavior is undefined. + /// ^The sqlite3_update_hook() interface registers a callback function + /// with the [database connection] identified by the first argument + /// to be invoked whenever a row is updated, inserted or deleted in + /// a [rowid table]. + /// ^Any callback set by a previous call to this function + /// for the same database connection is overridden. /// - /// In the call sqlite3_vtab_config(D,C,...) the D parameter is the - /// [database connection] in which the virtual table is being created and - /// which is passed in as the first argument to the [xConnect] or [xCreate] - /// method that is invoking sqlite3_vtab_config(). The C parameter is one - /// of the [virtual table configuration options]. The presence and meaning - /// of parameters after C depend on which [virtual table configuration option] - /// is used. - int sqlite3_vtab_config(ffi.Pointer arg0, int op) { - return _sqlite3_vtab_config(arg0, op); - } - - late final _sqlite3_vtab_configPtr = - _lookup< - ffi.NativeFunction, ffi.Int)> - >('sqlite3_vtab_config'); - late final _sqlite3_vtab_config = _sqlite3_vtab_configPtr - .asFunction, int)>(); - - /// CAPI3REF: Determine The Virtual Table Conflict Policy + /// ^The second argument is a pointer to the function to invoke when a + /// row is updated, inserted or deleted in a rowid table. + /// ^The first argument to the callback is a copy of the third argument + /// to sqlite3_update_hook(). + /// ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], + /// or [SQLITE_UPDATE], depending on the operation that caused the callback + /// to be invoked. + /// ^The third and fourth arguments to the callback contain pointers to the + /// database and table name containing the affected row. + /// ^The final callback parameter is the [rowid] of the row. + /// ^In the case of an update, this is the [rowid] after the update takes place. /// - /// This function may only be called from within a call to the [xUpdate] method - /// of a [virtual table] implementation for an INSERT or UPDATE operation. ^The - /// value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], - /// [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode - /// of the SQL statement that triggered the call to the [xUpdate] method of the - /// [virtual table]. - int sqlite3_vtab_on_conflict(ffi.Pointer arg0) { - return _sqlite3_vtab_on_conflict(arg0); - } - - late final _sqlite3_vtab_on_conflictPtr = - _lookup)>>( - 'sqlite3_vtab_on_conflict', - ); - late final _sqlite3_vtab_on_conflict = _sqlite3_vtab_on_conflictPtr - .asFunction)>(); - - /// CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE + /// ^(The update hook is not invoked when internal system tables are + /// modified (i.e. sqlite_master and sqlite_sequence).)^ + /// ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. /// - /// If the sqlite3_vtab_nochange(X) routine is called within the [xColumn] - /// method of a [virtual table], then it returns true if and only if the - /// column is being fetched as part of an UPDATE operation during which the - /// column value will not change. Applications might use this to substitute - /// a return value that is less expensive to compute and that the corresponding - /// [xUpdate] method understands as a "no-change" value. + /// ^In the current implementation, the update hook + /// is not invoked when conflicting rows are deleted because of an + /// [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook + /// invoked when rows are deleted using the [truncate optimization]. + /// The exceptions defined in this paragraph might change in a future + /// release of SQLite. /// - /// If the [xColumn] method calls sqlite3_vtab_nochange() and finds that - /// the column is not changed by the UPDATE statement, then the xColumn - /// method can optionally return without setting a result, without calling - /// any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces]. - /// In that case, [sqlite3_value_nochange(X)] will return true for the - /// same column in the [xUpdate] method. - int sqlite3_vtab_nochange(ffi.Pointer arg0) { - return _sqlite3_vtab_nochange(arg0); - } - - late final _sqlite3_vtab_nochangePtr = - _lookup< - ffi.NativeFunction)> - >('sqlite3_vtab_nochange'); - late final _sqlite3_vtab_nochange = _sqlite3_vtab_nochangePtr - .asFunction)>(); - - /// CAPI3REF: Determine The Collation For a Virtual Table Constraint + /// The update hook implementation must not do anything that will modify + /// the database connection that invoked the update hook. Any actions + /// to modify the database connection must be deferred until after the + /// completion of the [sqlite3_step()] call that triggered the update hook. + /// Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their + /// database connections for the meaning of "modify" in this paragraph. /// - /// This function may only be called from within a call to the [xBestIndex] - /// method of a [virtual table]. + /// ^The sqlite3_update_hook(D,C,P) function + /// returns the P argument from the previous call + /// on the same [database connection] D, or NULL for + /// the first call on D. /// - /// The first argument must be the sqlite3_index_info object that is the - /// first parameter to the xBestIndex() method. The second argument must be - /// an index into the aConstraint[] array belonging to the sqlite3_index_info - /// structure passed to xBestIndex. This function returns a pointer to a buffer - /// containing the name of the collation sequence for the corresponding - /// constraint. - ffi.Pointer sqlite3_vtab_collation( - ffi.Pointer arg0, - int arg1, + /// See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()], + /// and [sqlite3_preupdate_hook()] interfaces. + ffi.Pointer sqlite3_update_hook( + ffi.Pointer arg0, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + sqlite3_int64, + ) + > + > + arg1, + ffi.Pointer arg2, ) { - return _sqlite3_vtab_collation(arg0, arg1); + return _sqlite3_update_hook(arg0, arg1, arg2); } - late final _sqlite3_vtab_collationPtr = + late final _sqlite3_update_hookPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Int, + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + sqlite3_int64, + ) + > + >, + ffi.Pointer, ) > - >('sqlite3_vtab_collation'); - late final _sqlite3_vtab_collation = _sqlite3_vtab_collationPtr + >('sqlite3_update_hook'); + late final _sqlite3_update_hook = _sqlite3_update_hookPtr .asFunction< - ffi.Pointer Function(ffi.Pointer, int) + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + sqlite3_int64, + ) + > + >, + ffi.Pointer, + ) >(); - /// CAPI3REF: Prepared Statement Scan Status - /// METHOD: sqlite3_stmt - /// - /// This interface returns information about the predicted and measured - /// performance for pStmt. Advanced applications can use this - /// interface to compare the predicted and the measured performance and - /// issue warnings and/or rerun [ANALYZE] if discrepancies are found. - /// - /// Since this interface is expected to be rarely used, it is only - /// available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS] - /// compile-time option. - /// - /// The "iScanStatusOp" parameter determines which status information to return. - /// The "iScanStatusOp" must be one of the [scanstatus options] or the behavior - /// of this interface is undefined. - /// ^The requested measurement is written into a variable pointed to by - /// the "pOut" parameter. - /// Parameter "idx" identifies the specific loop to retrieve statistics for. - /// Loops are numbered starting from zero. ^If idx is out of range - less than - /// zero or greater than or equal to the total number of loops used to implement - /// the statement - a non-zero value is returned and the variable that pOut - /// points to is unchanged. - /// - /// ^Statistics might not be available for all loops in all statements. ^In cases - /// where there exist loops with no available statistics, this function behaves - /// as if the loop did not exist - it returns non-zero and leave the variable - /// that pOut points to unchanged. - /// - /// See also: [sqlite3_stmt_scanstatus_reset()] - int sqlite3_stmt_scanstatus( - ffi.Pointer pStmt, - int idx, - int iScanStatusOp, - ffi.Pointer pOut, + int sqlite3_uri_boolean( + ffi.Pointer zFile, + ffi.Pointer zParam, + int bDefault, ) { - return _sqlite3_stmt_scanstatus(pStmt, idx, iScanStatusOp, pOut); + return _sqlite3_uri_boolean(zFile, zParam, bDefault); } - late final _sqlite3_stmt_scanstatusPtr = + late final _sqlite3_uri_booleanPtr = _lookup< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Int, + ffi.Pointer, + ffi.Pointer, ffi.Int, - ffi.Pointer, ) > - >('sqlite3_stmt_scanstatus'); - late final _sqlite3_stmt_scanstatus = _sqlite3_stmt_scanstatusPtr + >('sqlite3_uri_boolean'); + late final _sqlite3_uri_boolean = _sqlite3_uri_booleanPtr .asFunction< - int Function(ffi.Pointer, int, int, ffi.Pointer) + int Function(ffi.Pointer, ffi.Pointer, int) >(); - /// CAPI3REF: Zero Scan-Status Counters - /// METHOD: sqlite3_stmt - /// - /// ^Zero all [sqlite3_stmt_scanstatus()] related event counters. - /// - /// This API is only available if the library is built with pre-processor - /// symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined. - void sqlite3_stmt_scanstatus_reset(ffi.Pointer arg0) { - return _sqlite3_stmt_scanstatus_reset(arg0); - } - - late final _sqlite3_stmt_scanstatus_resetPtr = - _lookup)>>( - 'sqlite3_stmt_scanstatus_reset', - ); - late final _sqlite3_stmt_scanstatus_reset = _sqlite3_stmt_scanstatus_resetPtr - .asFunction)>(); - - /// CAPI3REF: Flush caches to disk mid-transaction - /// - /// ^If a write-transaction is open on [database connection] D when the - /// [sqlite3_db_cacheflush(D)] interface invoked, any dirty - /// pages in the pager-cache that are not currently in use are written out - /// to disk. A dirty page may be in use if a database cursor created by an - /// active SQL statement is reading from it, or if it is page 1 of a database - /// file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)] - /// interface flushes caches for all schemas - "main", "temp", and - /// any [attached] databases. - /// - /// ^If this function needs to obtain extra database locks before dirty pages - /// can be flushed to disk, it does so. ^If those locks cannot be obtained - /// immediately and there is a busy-handler callback configured, it is invoked - /// in the usual manner. ^If the required lock still cannot be obtained, then - /// the database is skipped and an attempt made to flush any dirty pages - /// belonging to the next (if any) database. ^If any databases are skipped - /// because locks cannot be obtained, but no other error occurs, this - /// function returns SQLITE_BUSY. - /// - /// ^If any other error occurs while flushing dirty pages to disk (for - /// example an IO error or out-of-memory condition), then processing is - /// abandoned and an SQLite [error code] is returned to the caller immediately. - /// - /// ^Otherwise, if no error occurs, [sqlite3_db_cacheflush()] returns SQLITE_OK. - /// - /// ^This function does not set the database handle error code or message - /// returned by the [sqlite3_errcode()] and [sqlite3_errmsg()] functions. - int sqlite3_db_cacheflush(ffi.Pointer arg0) { - return _sqlite3_db_cacheflush(arg0); - } - - late final _sqlite3_db_cacheflushPtr = - _lookup)>>( - 'sqlite3_db_cacheflush', - ); - late final _sqlite3_db_cacheflush = _sqlite3_db_cacheflushPtr - .asFunction)>(); - - /// CAPI3REF: Low-level system error code - /// - /// ^Attempt to return the underlying operating system error code or error - /// number that caused the most recent I/O error or failure to open a file. - /// The return value is OS-dependent. For example, on unix systems, after - /// [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be - /// called to get back the underlying "errno" that caused the problem, such - /// as ENOSPC, EAUTH, EISDIR, and so forth. - int sqlite3_system_errno(ffi.Pointer arg0) { - return _sqlite3_system_errno(arg0); - } - - late final _sqlite3_system_errnoPtr = - _lookup)>>( - 'sqlite3_system_errno', - ); - late final _sqlite3_system_errno = _sqlite3_system_errnoPtr - .asFunction)>(); - - /// CAPI3REF: Record A Database Snapshot - /// CONSTRUCTOR: sqlite3_snapshot - /// - /// ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a - /// new [sqlite3_snapshot] object that records the current state of - /// schema S in database connection D. ^On success, the - /// [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly - /// created [sqlite3_snapshot] object into *P and returns SQLITE_OK. - /// If there is not already a read-transaction open on schema S when - /// this function is called, one is opened automatically. - /// - /// The following must be true for this function to succeed. If any of - /// the following statements are false when sqlite3_snapshot_get() is - /// called, SQLITE_ERROR is returned. The final value of *P is undefined - /// in this case. - /// - ///
      - ///
    • The database handle must not be in [autocommit mode]. - /// - ///
    • Schema S of [database connection] D must be a [WAL mode] database. - /// - ///
    • There must not be a write transaction open on schema S of database - /// connection D. - /// - ///
    • One or more transactions must have been written to the current wal - /// file since it was created on disk (by any connection). This means - /// that a snapshot cannot be taken on a wal mode database with no wal - /// file immediately after it is first opened. At least one transaction - /// must be written to it first. - ///
    - /// - /// This function may also return SQLITE_NOMEM. If it is called with the - /// database handle in autocommit mode but fails for some other reason, - /// whether or not a read transaction is opened on schema S is undefined. - /// - /// The [sqlite3_snapshot] object returned from a successful call to - /// [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()] - /// to avoid a memory leak. - /// - /// The [sqlite3_snapshot_get()] interface is only available when the - /// [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. - int sqlite3_snapshot_get( - ffi.Pointer db, - ffi.Pointer zSchema, - ffi.Pointer> ppSnapshot, + int sqlite3_uri_int64( + ffi.Pointer arg0, + ffi.Pointer arg1, + int arg2, ) { - return _sqlite3_snapshot_get(db, zSchema, ppSnapshot); + return _sqlite3_uri_int64(arg0, arg1, arg2); } - late final _sqlite3_snapshot_getPtr = + late final _sqlite3_uri_int64Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, + sqlite3_int64 Function( ffi.Pointer, - ffi.Pointer>, + ffi.Pointer, + sqlite3_int64, ) > - >('sqlite3_snapshot_get'); - late final _sqlite3_snapshot_get = _sqlite3_snapshot_getPtr + >('sqlite3_uri_int64'); + late final _sqlite3_uri_int64 = _sqlite3_uri_int64Ptr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer>, - ) + int Function(ffi.Pointer, ffi.Pointer, int) >(); - /// CAPI3REF: Start a read transaction on an historical snapshot - /// METHOD: sqlite3_snapshot + ffi.Pointer sqlite3_uri_key( + ffi.Pointer zFilename, + int N, + ) { + return _sqlite3_uri_key(zFilename, N); + } + + late final _sqlite3_uri_keyPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + >('sqlite3_uri_key'); + late final _sqlite3_uri_key = _sqlite3_uri_keyPtr + .asFunction Function(ffi.Pointer, int)>(); + + /// CAPI3REF: Obtain Values For URI Parameters /// - /// ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read - /// transaction or upgrades an existing one for schema S of - /// [database connection] D such that the read transaction refers to - /// historical [snapshot] P, rather than the most recent change to the - /// database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK - /// on success or an appropriate [error code] if it fails. + /// These are utility routines, useful to [VFS|custom VFS implementations], + /// that check if a database file was a URI that contained a specific query + /// parameter, and if so obtains the value of that query parameter. /// - /// ^In order to succeed, the database connection must not be in - /// [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there - /// is already a read transaction open on schema S, then the database handle - /// must have no active statements (SELECT statements that have been passed - /// to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). - /// SQLITE_ERROR is returned if either of these conditions is violated, or - /// if schema S does not exist, or if the snapshot object is invalid. + /// The first parameter to these interfaces (hereafter referred to + /// as F) must be one of: + ///
      + ///
    • A database filename pointer created by the SQLite core and + /// passed into the xOpen() method of a VFS implemention, or + ///
    • A filename obtained from [sqlite3_db_filename()], or + ///
    • A new filename constructed using [sqlite3_create_filename()]. + ///
    + /// If the F parameter is not one of the above, then the behavior is + /// undefined and probably undesirable. Older versions of SQLite were + /// more tolerant of invalid F parameters than newer versions. /// - /// ^A call to sqlite3_snapshot_open() will fail to open if the specified - /// snapshot has been overwritten by a [checkpoint]. In this case - /// SQLITE_ERROR_SNAPSHOT is returned. + /// If F is a suitable filename (as described in the previous paragraph) + /// and if P is the name of the query parameter, then + /// sqlite3_uri_parameter(F,P) returns the value of the P + /// parameter if it exists or a NULL pointer if P does not appear as a + /// query parameter on F. If P is a query parameter of F and it + /// has no explicit value, then sqlite3_uri_parameter(F,P) returns + /// a pointer to an empty string. /// - /// If there is already a read transaction open when this function is - /// invoked, then the same read transaction remains open (on the same - /// database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT - /// is returned. If another error code - for example SQLITE_PROTOCOL or an - /// SQLITE_IOERR error code - is returned, then the final state of the - /// read transaction is undefined. If SQLITE_OK is returned, then the - /// read transaction is now open on database snapshot P. + /// The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean + /// parameter and returns true (1) or false (0) according to the value + /// of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the + /// value of query parameter P is one of "yes", "true", or "on" in any + /// case or if the value begins with a non-zero number. The + /// sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of + /// query parameter P is one of "no", "false", or "off" in any case or + /// if the value begins with a numeric zero. If P is not a query + /// parameter on F or if the value of P does not match any of the + /// above, then sqlite3_uri_boolean(F,P,B) returns (B!=0). /// - /// ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the - /// database connection D does not know that the database file for - /// schema S is in [WAL mode]. A database connection might not know - /// that the database file is in [WAL mode] if there has been no prior - /// I/O on that database connection, or if the database entered [WAL mode] - /// after the most recent I/O on the database connection.)^ - /// (Hint: Run "[PRAGMA application_id]" against a newly opened - /// database connection in order to make it ready to use snapshots.) + /// The sqlite3_uri_int64(F,P,D) routine converts the value of P into a + /// 64-bit signed integer and returns that integer, or D if P does not + /// exist. If the value of P is something other than an integer, then + /// zero is returned. + /// + /// The sqlite3_uri_key(F,N) returns a pointer to the name (not + /// the value) of the N-th query parameter for filename F, or a NULL + /// pointer if N is less than zero or greater than the number of query + /// parameters minus 1. The N value is zero-based so N should be 0 to obtain + /// the name of the first query parameter, 1 for the second parameter, and + /// so forth. + /// + /// If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and + /// sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and + /// is not a database file pathname pointer that the SQLite core passed + /// into the xOpen VFS method, then the behavior of this routine is undefined + /// and probably undesirable. /// - /// The [sqlite3_snapshot_open()] interface is only available when the - /// [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. - int sqlite3_snapshot_open( - ffi.Pointer db, - ffi.Pointer zSchema, - ffi.Pointer pSnapshot, + /// Beginning with SQLite [version 3.31.0] ([dateof:3.31.0]) the input F + /// parameter can also be the name of a rollback journal file or WAL file + /// in addition to the main database file. Prior to version 3.31.0, these + /// routines would only work if F was the name of the main database file. + /// When the F parameter is the name of the rollback journal or WAL file, + /// it has access to all the same query parameters as were found on the + /// main database file. + /// + /// See the [URI filename] documentation for additional information. + ffi.Pointer sqlite3_uri_parameter( + ffi.Pointer zFilename, + ffi.Pointer zParam, ) { - return _sqlite3_snapshot_open(db, zSchema, pSnapshot); + return _sqlite3_uri_parameter(zFilename, zParam); } - late final _sqlite3_snapshot_openPtr = + late final _sqlite3_uri_parameterPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer, ) > - >('sqlite3_snapshot_open'); - late final _sqlite3_snapshot_open = _sqlite3_snapshot_openPtr + >('sqlite3_uri_parameter'); + late final _sqlite3_uri_parameter = _sqlite3_uri_parameterPtr .asFunction< - int Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer, ) >(); - /// CAPI3REF: Destroy a snapshot - /// DESTRUCTOR: sqlite3_snapshot + /// CAPI3REF: User Data For Functions + /// METHOD: sqlite3_context /// - /// ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P. - /// The application must eventually free every [sqlite3_snapshot] object - /// using this routine to avoid a memory leak. + /// ^The sqlite3_user_data() interface returns a copy of + /// the pointer that was the pUserData parameter (the 5th parameter) + /// of the [sqlite3_create_function()] + /// and [sqlite3_create_function16()] routines that originally + /// registered the application defined function. /// - /// The [sqlite3_snapshot_free()] interface is only available when the - /// [SQLITE_ENABLE_SNAPSHOT] compile-time option is used. - void sqlite3_snapshot_free(ffi.Pointer arg0) { - return _sqlite3_snapshot_free(arg0); + /// This routine must be called from the same thread in which + /// the application-defined function is running. + ffi.Pointer sqlite3_user_data(ffi.Pointer arg0) { + return _sqlite3_user_data(arg0); } - late final _sqlite3_snapshot_freePtr = + late final _sqlite3_user_dataPtr = _lookup< - ffi.NativeFunction)> - >('sqlite3_snapshot_free'); - late final _sqlite3_snapshot_free = _sqlite3_snapshot_freePtr - .asFunction)>(); + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_user_data'); + late final _sqlite3_user_data = _sqlite3_user_dataPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer) + >(); - /// CAPI3REF: Compare the ages of two snapshot handles. - /// METHOD: sqlite3_snapshot + /// CAPI3REF: Obtaining SQL Values + /// METHOD: sqlite3_value /// - /// The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages - /// of two valid snapshot handles. + /// Summary: + ///
    + ///
    sqlite3_value_blobBLOB value + ///
    sqlite3_value_doubleREAL value + ///
    sqlite3_value_int32-bit INTEGER value + ///
    sqlite3_value_int6464-bit INTEGER value + ///
    sqlite3_value_pointerPointer value + ///
    sqlite3_value_textUTF-8 TEXT value + ///
    sqlite3_value_text16UTF-16 TEXT value in + /// the native byteorder + ///
    sqlite3_value_text16beUTF-16be TEXT value + ///
    sqlite3_value_text16leUTF-16le TEXT value + ///
        + ///
    sqlite3_value_bytesSize of a BLOB + /// or a UTF-8 TEXT in bytes + ///
    sqlite3_value_bytes16   + /// →  Size of UTF-16 + /// TEXT in bytes + ///
    sqlite3_value_typeDefault + /// datatype of the value + ///
    sqlite3_value_numeric_type   + /// →  Best numeric datatype of the value + ///
    sqlite3_value_nochange   + /// →  True if the column is unchanged in an UPDATE + /// against a virtual table. + ///
    sqlite3_value_frombind   + /// →  True if value originated from a [bound parameter] + ///
    /// - /// If the two snapshot handles are not associated with the same database - /// file, the result of the comparison is undefined. + /// Details: /// - /// Additionally, the result of the comparison is only valid if both of the - /// snapshot handles were obtained by calling sqlite3_snapshot_get() since the - /// last time the wal file was deleted. The wal file is deleted when the - /// database is changed back to rollback mode or when the number of database - /// clients drops to zero. If either snapshot handle was obtained before the - /// wal file was last deleted, the value returned by this function - /// is undefined. + /// These routines extract type, size, and content information from + /// [protected sqlite3_value] objects. Protected sqlite3_value objects + /// are used to pass parameter information into the functions that + /// implement [application-defined SQL functions] and [virtual tables]. /// - /// Otherwise, this API returns a negative value if P1 refers to an older - /// snapshot than P2, zero if the two handles refer to the same database - /// snapshot, and a positive value if P1 is a newer snapshot than P2. + /// These routines work only with [protected sqlite3_value] objects. + /// Any attempt to use these routines on an [unprotected sqlite3_value] + /// is not threadsafe. + /// + /// ^These routines work just like the corresponding [column access functions] + /// except that these routines take a single [protected sqlite3_value] object + /// pointer instead of a [sqlite3_stmt*] pointer and an integer column number. + /// + /// ^The sqlite3_value_text16() interface extracts a UTF-16 string + /// in the native byte-order of the host machine. ^The + /// sqlite3_value_text16be() and sqlite3_value_text16le() interfaces + /// extract UTF-16 strings as big-endian and little-endian respectively. + /// + /// ^If [sqlite3_value] object V was initialized + /// using [sqlite3_bind_pointer(S,I,P,X,D)] or [sqlite3_result_pointer(C,P,X,D)] + /// and if X and Y are strings that compare equal according to strcmp(X,Y), + /// then sqlite3_value_pointer(V,Y) will return the pointer P. ^Otherwise, + /// sqlite3_value_pointer(V,Y) returns a NULL. The sqlite3_bind_pointer() + /// routine is part of the [pointer passing interface] added for SQLite 3.20.0. + /// + /// ^(The sqlite3_value_type(V) interface returns the + /// [SQLITE_INTEGER | datatype code] for the initial datatype of the + /// [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER], + /// [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^ + /// Other interfaces might change the datatype for an sqlite3_value object. + /// For example, if the datatype is initially SQLITE_INTEGER and + /// sqlite3_value_text(V) is called to extract a text value for that + /// integer, then subsequent calls to sqlite3_value_type(V) might return + /// SQLITE_TEXT. Whether or not a persistent internal datatype conversion + /// occurs is undefined and may change from one release of SQLite to the next. + /// + /// ^(The sqlite3_value_numeric_type() interface attempts to apply + /// numeric affinity to the value. This means that an attempt is + /// made to convert the value to an integer or floating point. If + /// such a conversion is possible without loss of information (in other + /// words, if the value is a string that looks like a number) + /// then the conversion is performed. Otherwise no conversion occurs. + /// The [SQLITE_INTEGER | datatype] after conversion is returned.)^ + /// + /// ^Within the [xUpdate] method of a [virtual table], the + /// sqlite3_value_nochange(X) interface returns true if and only if + /// the column corresponding to X is unchanged by the UPDATE operation + /// that the xUpdate method call was invoked to implement and if + /// and the prior [xColumn] method call that was invoked to extracted + /// the value for that column returned without setting a result (probably + /// because it queried [sqlite3_vtab_nochange()] and found that the column + /// was unchanging). ^Within an [xUpdate] method, any value for which + /// sqlite3_value_nochange(X) is true will in all other respects appear + /// to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other + /// than within an [xUpdate] method call for an UPDATE statement, then + /// the return value is arbitrary and meaningless. + /// + /// ^The sqlite3_value_frombind(X) interface returns non-zero if the + /// value X originated from one of the [sqlite3_bind_int|sqlite3_bind()] + /// interfaces. ^If X comes from an SQL literal value, or a table column, + /// or an expression, then sqlite3_value_frombind(X) returns zero. + /// + /// Please pay particular attention to the fact that the pointer returned + /// from [sqlite3_value_blob()], [sqlite3_value_text()], or + /// [sqlite3_value_text16()] can be invalidated by a subsequent call to + /// [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], + /// or [sqlite3_value_text16()]. + /// + /// These routines must be called from the same thread as + /// the SQL function that supplied the [sqlite3_value*] parameters. + /// + /// As long as the input parameter is correct, these routines can only + /// fail if an out-of-memory error occurs during a format conversion. + /// Only the following subset of interfaces are subject to out-of-memory + /// errors: + /// + ///
      + ///
    • sqlite3_value_blob() + ///
    • sqlite3_value_text() + ///
    • sqlite3_value_text16() + ///
    • sqlite3_value_text16le() + ///
    • sqlite3_value_text16be() + ///
    • sqlite3_value_bytes() + ///
    • sqlite3_value_bytes16() + ///
    + /// + /// If an out-of-memory error occurs, then the return value from these + /// routines is the same as if the column had contained an SQL NULL value. + /// Valid SQL NULL returns can be distinguished from out-of-memory errors + /// by invoking the [sqlite3_errcode()] immediately after the suspect + /// return value is obtained and before any + /// other SQLite interface is called on the same [database connection]. + ffi.Pointer sqlite3_value_blob(ffi.Pointer arg0) { + return _sqlite3_value_blob(arg0); + } + + late final _sqlite3_value_blobPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_value_blob'); + late final _sqlite3_value_blob = _sqlite3_value_blobPtr + .asFunction Function(ffi.Pointer)>(); + + int sqlite3_value_bytes(ffi.Pointer arg0) { + return _sqlite3_value_bytes(arg0); + } + + late final _sqlite3_value_bytesPtr = + _lookup)>>( + 'sqlite3_value_bytes', + ); + late final _sqlite3_value_bytes = _sqlite3_value_bytesPtr + .asFunction)>(); + + int sqlite3_value_bytes16(ffi.Pointer arg0) { + return _sqlite3_value_bytes16(arg0); + } + + late final _sqlite3_value_bytes16Ptr = + _lookup)>>( + 'sqlite3_value_bytes16', + ); + late final _sqlite3_value_bytes16 = _sqlite3_value_bytes16Ptr + .asFunction)>(); + + double sqlite3_value_double(ffi.Pointer arg0) { + return _sqlite3_value_double(arg0); + } + + late final _sqlite3_value_doublePtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_value_double'); + late final _sqlite3_value_double = _sqlite3_value_doublePtr + .asFunction)>(); + + /// CAPI3REF: Copy And Free SQL Values + /// METHOD: sqlite3_value /// - /// This interface is only available if SQLite is compiled with the - /// [SQLITE_ENABLE_SNAPSHOT] option. - int sqlite3_snapshot_cmp( - ffi.Pointer p1, - ffi.Pointer p2, + /// ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value] + /// object D and returns a pointer to that copy. ^The [sqlite3_value] returned + /// is a [protected sqlite3_value] object even if the input is not. + /// ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a + /// memory allocation fails. + /// + /// ^The sqlite3_value_free(V) interface frees an [sqlite3_value] object + /// previously obtained from [sqlite3_value_dup()]. ^If V is a NULL pointer + /// then sqlite3_value_free(V) is a harmless no-op. + ffi.Pointer sqlite3_value_dup( + ffi.Pointer arg0, ) { - return _sqlite3_snapshot_cmp(p1, p2); + return _sqlite3_value_dup(arg0); } - late final _sqlite3_snapshot_cmpPtr = + late final _sqlite3_value_dupPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_snapshot_cmp'); - late final _sqlite3_snapshot_cmp = _sqlite3_snapshot_cmpPtr + >('sqlite3_value_dup'); + late final _sqlite3_value_dup = _sqlite3_value_dupPtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer) >(); - /// CAPI3REF: Recover snapshots from a wal file - /// METHOD: sqlite3_snapshot - /// - /// If a [WAL file] remains on disk after all database connections close - /// (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control] - /// or because the last process to have the database opened exited without - /// calling [sqlite3_close()]) and a new connection is subsequently opened - /// on that database and [WAL file], the [sqlite3_snapshot_open()] interface - /// will only be able to open the last transaction added to the WAL file - /// even though the WAL file contains other valid transactions. - /// - /// This function attempts to scan the WAL file associated with database zDb - /// of database handle db and make all valid snapshots available to - /// sqlite3_snapshot_open(). It is an error if there is already a read - /// transaction open on the database, or if the database is not a WAL mode - /// database. - /// - /// SQLITE_OK is returned if successful, or an SQLite error code otherwise. - /// - /// This interface is only available if SQLite is compiled with the - /// [SQLITE_ENABLE_SNAPSHOT] option. - int sqlite3_snapshot_recover( - ffi.Pointer db, - ffi.Pointer zDb, - ) { - return _sqlite3_snapshot_recover(db, zDb); + void sqlite3_value_free(ffi.Pointer arg0) { + return _sqlite3_value_free(arg0); } - late final _sqlite3_snapshot_recoverPtr = + late final _sqlite3_value_freePtr = _lookup< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - >('sqlite3_snapshot_recover'); - late final _sqlite3_snapshot_recover = _sqlite3_snapshot_recoverPtr - .asFunction, ffi.Pointer)>(); + ffi.NativeFunction)> + >('sqlite3_value_free'); + late final _sqlite3_value_free = _sqlite3_value_freePtr + .asFunction)>(); - /// CAPI3REF: Serialize a database - /// - /// The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory - /// that is a serialization of the S database on [database connection] D. - /// If P is not a NULL pointer, then the size of the database in bytes - /// is written into *P. - /// - /// For an ordinary on-disk database file, the serialization is just a - /// copy of the disk file. For an in-memory database or a "TEMP" database, - /// the serialization is the same sequence of bytes which would be written - /// to disk if that database where backed up to disk. - /// - /// The usual case is that sqlite3_serialize() copies the serialization of - /// the database into memory obtained from [sqlite3_malloc64()] and returns - /// a pointer to that memory. The caller is responsible for freeing the - /// returned value to avoid a memory leak. However, if the F argument - /// contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations - /// are made, and the sqlite3_serialize() function will return a pointer - /// to the contiguous memory representation of the database that SQLite - /// is currently using for that database, or NULL if the no such contiguous - /// memory representation of the database exists. A contiguous memory - /// representation of the database will usually only exist if there has - /// been a prior call to [sqlite3_deserialize(D,S,...)] with the same - /// values of D and S. - /// The size of the database is written into *P even if the - /// SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy - /// of the database exists. - /// - /// A call to sqlite3_serialize(D,S,P,F) might return NULL even if the - /// SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory - /// allocation error occurs. - /// - /// This interface is only available if SQLite is compiled with the - /// [SQLITE_ENABLE_DESERIALIZE] option. - ffi.Pointer sqlite3_serialize( - ffi.Pointer db, - ffi.Pointer zSchema, - ffi.Pointer piSize, - int mFlags, + int sqlite3_value_frombind(ffi.Pointer arg0) { + return _sqlite3_value_frombind(arg0); + } + + late final _sqlite3_value_frombindPtr = + _lookup)>>( + 'sqlite3_value_frombind', + ); + late final _sqlite3_value_frombind = _sqlite3_value_frombindPtr + .asFunction)>(); + + int sqlite3_value_int(ffi.Pointer arg0) { + return _sqlite3_value_int(arg0); + } + + late final _sqlite3_value_intPtr = + _lookup)>>( + 'sqlite3_value_int', + ); + late final _sqlite3_value_int = _sqlite3_value_intPtr + .asFunction)>(); + + int sqlite3_value_int64(ffi.Pointer arg0) { + return _sqlite3_value_int64(arg0); + } + + late final _sqlite3_value_int64Ptr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_value_int64'); + late final _sqlite3_value_int64 = _sqlite3_value_int64Ptr + .asFunction)>(); + + int sqlite3_value_nochange(ffi.Pointer arg0) { + return _sqlite3_value_nochange(arg0); + } + + late final _sqlite3_value_nochangePtr = + _lookup)>>( + 'sqlite3_value_nochange', + ); + late final _sqlite3_value_nochange = _sqlite3_value_nochangePtr + .asFunction)>(); + + int sqlite3_value_numeric_type(ffi.Pointer arg0) { + return _sqlite3_value_numeric_type(arg0); + } + + late final _sqlite3_value_numeric_typePtr = + _lookup)>>( + 'sqlite3_value_numeric_type', + ); + late final _sqlite3_value_numeric_type = _sqlite3_value_numeric_typePtr + .asFunction)>(); + + ffi.Pointer sqlite3_value_pointer( + ffi.Pointer arg0, + ffi.Pointer arg1, ) { - return _sqlite3_serialize(db, zSchema, piSize, mFlags); + return _sqlite3_value_pointer(arg0, arg1); } - late final _sqlite3_serializePtr = + late final _sqlite3_value_pointerPtr = _lookup< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, ) > - >('sqlite3_serialize'); - late final _sqlite3_serialize = _sqlite3_serializePtr + >('sqlite3_value_pointer'); + late final _sqlite3_value_pointer = _sqlite3_value_pointerPtr .asFunction< - ffi.Pointer Function( - ffi.Pointer, + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, - ffi.Pointer, - int, ) >(); - /// CAPI3REF: Deserialize a database - /// - /// The sqlite3_deserialize(D,S,P,N,M,F) interface causes the - /// [database connection] D to disconnect from database S and then - /// reopen S as an in-memory database based on the serialization contained - /// in P. The serialized database P is N bytes in size. M is the size of - /// the buffer P, which might be larger than N. If M is larger than N, and - /// the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is - /// permitted to add content to the in-memory database as long as the total - /// size does not exceed M bytes. - /// - /// If the SQLITE_DESERIALIZE_FREEONCLOSE bit is set in F, then SQLite will - /// invoke sqlite3_free() on the serialization buffer when the database - /// connection closes. If the SQLITE_DESERIALIZE_RESIZEABLE bit is set, then - /// SQLite will try to increase the buffer size using sqlite3_realloc64() - /// if writes on the database cause it to grow larger than M bytes. - /// - /// The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the - /// database is currently in a read transaction or is involved in a backup - /// operation. - /// - /// If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the - /// SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then - /// [sqlite3_free()] is invoked on argument P prior to returning. + /// CAPI3REF: Finding The Subtype Of SQL Values + /// METHOD: sqlite3_value /// - /// This interface is only available if SQLite is compiled with the - /// [SQLITE_ENABLE_DESERIALIZE] option. - int sqlite3_deserialize( - ffi.Pointer db, - ffi.Pointer zSchema, - ffi.Pointer pData, - int szDb, - int szBuf, - int mFlags, + /// The sqlite3_value_subtype(V) function returns the subtype for + /// an [application-defined SQL function] argument V. The subtype + /// information can be used to pass a limited amount of context from + /// one SQL function to another. Use the [sqlite3_result_subtype()] + /// routine to set the subtype for the return value of an SQL function. + int sqlite3_value_subtype(ffi.Pointer arg0) { + return _sqlite3_value_subtype(arg0); + } + + late final _sqlite3_value_subtypePtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_value_subtype'); + late final _sqlite3_value_subtype = _sqlite3_value_subtypePtr + .asFunction)>(); + + ffi.Pointer sqlite3_value_text( + ffi.Pointer arg0, ) { - return _sqlite3_deserialize(db, zSchema, pData, szDb, szBuf, mFlags); + return _sqlite3_value_text(arg0); } - late final _sqlite3_deserializePtr = + late final _sqlite3_value_textPtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - sqlite3_int64, - sqlite3_int64, - ffi.UnsignedInt, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_deserialize'); - late final _sqlite3_deserialize = _sqlite3_deserializePtr + >('sqlite3_value_text'); + late final _sqlite3_value_text = _sqlite3_value_textPtr .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - int, - int, - int, - ) + ffi.Pointer Function(ffi.Pointer) >(); - /// Register a geometry callback named zGeom that can be used as part of an - /// R-Tree geometry query as follows: - /// - /// SELECT ... FROM WHERE MATCH $zGeom(... params ...) - int sqlite3_rtree_geometry_callback( - ffi.Pointer db, - ffi.Pointer zGeom, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xGeom, - ffi.Pointer pContext, - ) { - return _sqlite3_rtree_geometry_callback(db, zGeom, xGeom, pContext); + ffi.Pointer sqlite3_value_text16(ffi.Pointer arg0) { + return _sqlite3_value_text16(arg0); } - late final _sqlite3_rtree_geometry_callbackPtr = + late final _sqlite3_value_text16Ptr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ffi.Pointer, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_rtree_geometry_callback'); - late final _sqlite3_rtree_geometry_callback = - _sqlite3_rtree_geometry_callbackPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ffi.Pointer, - ) - >(); + >('sqlite3_value_text16'); + late final _sqlite3_value_text16 = _sqlite3_value_text16Ptr + .asFunction Function(ffi.Pointer)>(); - /// Register a 2nd-generation geometry callback named zScore that can be - /// used as part of an R-Tree geometry query as follows: - /// - /// SELECT ... FROM WHERE MATCH $zQueryFunc(... params ...) - int sqlite3_rtree_query_callback( - ffi.Pointer db, - ffi.Pointer zQueryFunc, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer) - > - > - xQueryFunc, - ffi.Pointer pContext, - ffi.Pointer)>> - xDestructor, + ffi.Pointer sqlite3_value_text16be( + ffi.Pointer arg0, ) { - return _sqlite3_rtree_query_callback( - db, - zQueryFunc, - xQueryFunc, - pContext, - xDestructor, - ); + return _sqlite3_value_text16be(arg0); } - late final _sqlite3_rtree_query_callbackPtr = + late final _sqlite3_value_text16bePtr = _lookup< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer) - > - >, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) + ffi.Pointer Function(ffi.Pointer) > - >('sqlite3_rtree_query_callback'); - late final _sqlite3_rtree_query_callback = _sqlite3_rtree_query_callbackPtr - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer) - > - >, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - >(); -} - -final class sqlite3 extends ffi.Opaque {} + >('sqlite3_value_text16be'); + late final _sqlite3_value_text16be = _sqlite3_value_text16bePtr + .asFunction Function(ffi.Pointer)>(); -typedef sqlite_int64 = ffi.LongLong; -typedef Dartsqlite_int64 = int; -typedef sqlite_uint64 = ffi.UnsignedLongLong; -typedef Dartsqlite_uint64 = int; -typedef sqlite3_int64 = sqlite_int64; -typedef sqlite3_uint64 = sqlite_uint64; -typedef sqlite3_callbackFunction = - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ); -typedef Dartsqlite3_callbackFunction = - int Function( - ffi.Pointer, - int, - ffi.Pointer>, - ffi.Pointer>, - ); + ffi.Pointer sqlite3_value_text16le( + ffi.Pointer arg0, + ) { + return _sqlite3_value_text16le(arg0); + } -/// The type for a callback function. -/// This is legacy and deprecated. It is included for historical -/// compatibility and is not documented. -typedef sqlite3_callback = - ffi.Pointer>; + late final _sqlite3_value_text16lePtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_value_text16le'); + late final _sqlite3_value_text16le = _sqlite3_value_text16lePtr + .asFunction Function(ffi.Pointer)>(); -final class sqlite3_io_methods extends ffi.Opaque {} + int sqlite3_value_type(ffi.Pointer arg0) { + return _sqlite3_value_type(arg0); + } -final class sqlite3_file extends ffi.Struct { - /// Methods for an open file - external ffi.Pointer pMethods; -} + late final _sqlite3_value_typePtr = + _lookup)>>( + 'sqlite3_value_type', + ); + late final _sqlite3_value_type = _sqlite3_value_typePtr + .asFunction)>(); -final class sqlite3_mutex extends ffi.Opaque {} + /// CAPI3REF: Run-Time Library Version Numbers + /// KEYWORDS: sqlite3_version sqlite3_sourceid + /// + /// These interfaces provide the same information as the [SQLITE_VERSION], + /// [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros + /// but are associated with the library instead of the header file. ^(Cautious + /// programmers might include assert() statements in their application to + /// verify that values returned by these interfaces match the macros in + /// the header, and thus ensure that the application is + /// compiled with matching library and header files. + /// + ///
    +  /// assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
    +  /// assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
    +  /// assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
    +  /// 
    )^ + /// + /// ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] + /// macro. ^The sqlite3_libversion() function returns a pointer to the + /// to the sqlite3_version[] string constant. The sqlite3_libversion() + /// function is provided for use in DLLs since DLL users usually do not have + /// direct access to string constants within the DLL. ^The + /// sqlite3_libversion_number() function returns an integer equal to + /// [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns + /// a pointer to a string constant whose value is the same as the + /// [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built + /// using an edited copy of [the amalgamation], then the last four characters + /// of the hash might be different from [SQLITE_SOURCE_ID].)^ + /// + /// See also: [sqlite_version()] and [sqlite_source_id()]. + late final ffi.Pointer> _sqlite3_version = + _lookup>('sqlite3_version'); -final class sqlite3_api_routines extends ffi.Opaque {} + ffi.Pointer get sqlite3_version => _sqlite3_version.value; -typedef sqlite3_syscall_ptrFunction = ffi.Void Function(); -typedef Dartsqlite3_syscall_ptrFunction = void Function(); -typedef sqlite3_syscall_ptr = - ffi.Pointer>; + set sqlite3_version(ffi.Pointer value) => + _sqlite3_version.value = value; -final class sqlite3_vfs extends ffi.Struct { - /// Structure version number (currently 3) - @ffi.Int() - external int iVersion; + /// CAPI3REF: Virtual File System Objects + /// + /// A virtual filesystem (VFS) is an [sqlite3_vfs] object + /// that SQLite uses to interact + /// with the underlying operating system. Most SQLite builds come with a + /// single default VFS that is appropriate for the host computer. + /// New VFSes can be registered and existing VFSes can be unregistered. + /// The following interfaces are provided. + /// + /// ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. + /// ^Names are case sensitive. + /// ^Names are zero-terminated UTF-8 strings. + /// ^If there is no match, a NULL pointer is returned. + /// ^If zVfsName is NULL then the default VFS is returned. + /// + /// ^New VFSes are registered with sqlite3_vfs_register(). + /// ^Each new VFS becomes the default VFS if the makeDflt flag is set. + /// ^The same VFS can be registered multiple times without injury. + /// ^To make an existing VFS into the default VFS, register it again + /// with the makeDflt flag set. If two different VFSes with the + /// same name are registered, the behavior is undefined. If a + /// VFS is registered with a name that is NULL or an empty string, + /// then the behavior is undefined. + /// + /// ^Unregister a VFS with the sqlite3_vfs_unregister() interface. + /// ^(If the default VFS is unregistered, another VFS is chosen as + /// the default. The choice for the new VFS is arbitrary.)^ + ffi.Pointer sqlite3_vfs_find(ffi.Pointer zVfsName) { + return _sqlite3_vfs_find(zVfsName); + } - /// Size of subclassed sqlite3_file - @ffi.Int() - external int szOsFile; + late final _sqlite3_vfs_findPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + >('sqlite3_vfs_find'); + late final _sqlite3_vfs_find = _sqlite3_vfs_findPtr + .asFunction Function(ffi.Pointer)>(); - /// Maximum file pathname length - @ffi.Int() - external int mxPathname; + int sqlite3_vfs_register(ffi.Pointer arg0, int makeDflt) { + return _sqlite3_vfs_register(arg0, makeDflt); + } - /// Next registered VFS - external ffi.Pointer pNext; + late final _sqlite3_vfs_registerPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_vfs_register'); + late final _sqlite3_vfs_register = _sqlite3_vfs_registerPtr + .asFunction, int)>(); - /// Name of this virtual file system - external ffi.Pointer zName; + int sqlite3_vfs_unregister(ffi.Pointer arg0) { + return _sqlite3_vfs_unregister(arg0); + } - /// Pointer to application-specific data - external ffi.Pointer pAppData; + late final _sqlite3_vfs_unregisterPtr = + _lookup)>>( + 'sqlite3_vfs_unregister', + ); + late final _sqlite3_vfs_unregister = _sqlite3_vfs_unregisterPtr + .asFunction)>(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xOpen; + /// CAPI3REF: Determine The Collation For a Virtual Table Constraint + /// + /// This function may only be called from within a call to the [xBestIndex] + /// method of a [virtual table]. + /// + /// The first argument must be the sqlite3_index_info object that is the + /// first parameter to the xBestIndex() method. The second argument must be + /// an index into the aConstraint[] array belonging to the sqlite3_index_info + /// structure passed to xBestIndex. This function returns a pointer to a buffer + /// containing the name of the collation sequence for the corresponding + /// constraint. + ffi.Pointer sqlite3_vtab_collation( + ffi.Pointer arg0, + int arg1, + ) { + return _sqlite3_vtab_collation(arg0, arg1); + } - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) - > - > - xDelete; + late final _sqlite3_vtab_collationPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Int, + ) + > + >('sqlite3_vtab_collation'); + late final _sqlite3_vtab_collation = _sqlite3_vtab_collationPtr + .asFunction< + ffi.Pointer Function(ffi.Pointer, int) + >(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xAccess; + /// CAPI3REF: Virtual Table Interface Configuration + /// + /// This function may be called by either the [xConnect] or [xCreate] method + /// of a [virtual table] implementation to configure + /// various facets of the virtual table interface. + /// + /// If this interface is invoked outside the context of an xConnect or + /// xCreate virtual table method then the behavior is undefined. + /// + /// In the call sqlite3_vtab_config(D,C,...) the D parameter is the + /// [database connection] in which the virtual table is being created and + /// which is passed in as the first argument to the [xConnect] or [xCreate] + /// method that is invoking sqlite3_vtab_config(). The C parameter is one + /// of the [virtual table configuration options]. The presence and meaning + /// of parameters after C depend on which [virtual table configuration option] + /// is used. + int sqlite3_vtab_config(ffi.Pointer arg0, int op) { + return _sqlite3_vtab_config(arg0, op); + } - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xFullPathname; + late final _sqlite3_vtab_configPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_vtab_config'); + late final _sqlite3_vtab_config = _sqlite3_vtab_configPtr + .asFunction, int)>(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - > - xDlOpen; + /// CAPI3REF: Determine If Virtual Table Column Access Is For UPDATE + /// + /// If the sqlite3_vtab_nochange(X) routine is called within the [xColumn] + /// method of a [virtual table], then it returns true if and only if the + /// column is being fetched as part of an UPDATE operation during which the + /// column value will not change. Applications might use this to substitute + /// a return value that is less expensive to compute and that the corresponding + /// [xUpdate] method understands as a "no-change" value. + /// + /// If the [xColumn] method calls sqlite3_vtab_nochange() and finds that + /// the column is not changed by the UPDATE statement, then the xColumn + /// method can optionally return without setting a result, without calling + /// any of the [sqlite3_result_int|sqlite3_result_xxxxx() interfaces]. + /// In that case, [sqlite3_value_nochange(X)] will return true for the + /// same column in the [xUpdate] method. + int sqlite3_vtab_nochange(ffi.Pointer arg0) { + return _sqlite3_vtab_nochange(arg0); + } - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xDlError; + late final _sqlite3_vtab_nochangePtr = + _lookup< + ffi.NativeFunction)> + >('sqlite3_vtab_nochange'); + late final _sqlite3_vtab_nochange = _sqlite3_vtab_nochangePtr + .asFunction)>(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer> Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xDlSym; + /// CAPI3REF: Determine The Virtual Table Conflict Policy + /// + /// This function may only be called from within a call to the [xUpdate] method + /// of a [virtual table] implementation for an INSERT or UPDATE operation. ^The + /// value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL], + /// [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode + /// of the SQL statement that triggered the call to the [xUpdate] method of the + /// [virtual table]. + int sqlite3_vtab_on_conflict(ffi.Pointer arg0) { + return _sqlite3_vtab_on_conflict(arg0); + } - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer) - > - > - xDlClose; + late final _sqlite3_vtab_on_conflictPtr = + _lookup)>>( + 'sqlite3_vtab_on_conflict', + ); + late final _sqlite3_vtab_on_conflict = _sqlite3_vtab_on_conflictPtr + .asFunction)>(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Pointer) - > - > - xRandomness; + /// CAPI3REF: Configure an auto-checkpoint + /// METHOD: sqlite3 + /// + /// ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around + /// [sqlite3_wal_hook()] that causes any database on [database connection] D + /// to automatically [checkpoint] + /// after committing a transaction if there are N or + /// more frames in the [write-ahead log] file. ^Passing zero or + /// a negative value as the nFrame parameter disables automatic + /// checkpoints entirely. + /// + /// ^The callback registered by this function replaces any existing callback + /// registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback + /// using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism + /// configured by this function. + /// + /// ^The [wal_autocheckpoint pragma] can be used to invoke this interface + /// from SQL. + /// + /// ^Checkpoints initiated by this mechanism are + /// [sqlite3_wal_checkpoint_v2|PASSIVE]. + /// + /// ^Every new [database connection] defaults to having the auto-checkpoint + /// enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] + /// pages. The use of this interface + /// is only necessary if the default setting is found to be suboptimal + /// for a particular application. + int sqlite3_wal_autocheckpoint(ffi.Pointer db, int N) { + return _sqlite3_wal_autocheckpoint(db, N); + } - external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> - > - xSleep; + late final _sqlite3_wal_autocheckpointPtr = + _lookup< + ffi.NativeFunction, ffi.Int)> + >('sqlite3_wal_autocheckpoint'); + late final _sqlite3_wal_autocheckpoint = _sqlite3_wal_autocheckpointPtr + .asFunction, int)>(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - xCurrentTime; + /// CAPI3REF: Checkpoint a database + /// METHOD: sqlite3 + /// + /// ^(The sqlite3_wal_checkpoint(D,X) is equivalent to + /// [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^ + /// + /// In brief, sqlite3_wal_checkpoint(D,X) causes the content in the + /// [write-ahead log] for database X on [database connection] D to be + /// transferred into the database file and for the write-ahead log to + /// be reset. See the [checkpointing] documentation for addition + /// information. + /// + /// This interface used to be the only way to cause a checkpoint to + /// occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()] + /// interface was added. This interface is retained for backwards + /// compatibility and as a convenience for applications that need to manually + /// start a callback but which do not need the full power (and corresponding + /// complication) of [sqlite3_wal_checkpoint_v2()]. + int sqlite3_wal_checkpoint( + ffi.Pointer db, + ffi.Pointer zDb, + ) { + return _sqlite3_wal_checkpoint(db, zDb); + } - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Pointer) - > - > - xGetLastError; + late final _sqlite3_wal_checkpointPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + >('sqlite3_wal_checkpoint'); + late final _sqlite3_wal_checkpoint = _sqlite3_wal_checkpointPtr + .asFunction, ffi.Pointer)>(); - /// The methods above are in version 1 of the sqlite_vfs object - /// definition. Those that follow are added in version 2 or later - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - xCurrentTimeInt64; + /// CAPI3REF: Checkpoint a database + /// METHOD: sqlite3 + /// + /// ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint + /// operation on database X of [database connection] D in mode M. Status + /// information is written back into integers pointed to by L and C.)^ + /// ^(The M parameter must be a valid [checkpoint mode]:)^ + /// + ///
    + ///
    SQLITE_CHECKPOINT_PASSIVE
    + /// ^Checkpoint as many frames as possible without waiting for any database + /// readers or writers to finish, then sync the database file if all frames + /// in the log were checkpointed. ^The [busy-handler callback] + /// is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode. + /// ^On the other hand, passive mode might leave the checkpoint unfinished + /// if there are concurrent readers or writers. + /// + ///
    SQLITE_CHECKPOINT_FULL
    + /// ^This mode blocks (it invokes the + /// [sqlite3_busy_handler|busy-handler callback]) until there is no + /// database writer and all readers are reading from the most recent database + /// snapshot. ^It then checkpoints all frames in the log file and syncs the + /// database file. ^This mode blocks new database writers while it is pending, + /// but new database readers are allowed to continue unimpeded. + /// + ///
    SQLITE_CHECKPOINT_RESTART
    + /// ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition + /// that after checkpointing the log file it blocks (calls the + /// [busy-handler callback]) + /// until all readers are reading from the database file only. ^This ensures + /// that the next writer will restart the log file from the beginning. + /// ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new + /// database writer attempts while it is pending, but does not impede readers. + /// + ///
    SQLITE_CHECKPOINT_TRUNCATE
    + /// ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the + /// addition that it also truncates the log file to zero bytes just prior + /// to a successful return. + ///
    + /// + /// ^If pnLog is not NULL, then *pnLog is set to the total number of frames in + /// the log file or to -1 if the checkpoint could not run because + /// of an error or because the database is not in [WAL mode]. ^If pnCkpt is not + /// NULL,then *pnCkpt is set to the total number of checkpointed frames in the + /// log file (including any that were already checkpointed before the function + /// was called) or to -1 if the checkpoint could not run due to an error or + /// because the database is not in WAL mode. ^Note that upon successful + /// completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been + /// truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero. + /// + /// ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If + /// any other process is running a checkpoint operation at the same time, the + /// lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a + /// busy-handler configured, it will not be invoked in this case. + /// + /// ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the + /// exclusive "writer" lock on the database file. ^If the writer lock cannot be + /// obtained immediately, and a busy-handler is configured, it is invoked and + /// the writer lock retried until either the busy-handler returns 0 or the lock + /// is successfully obtained. ^The busy-handler is also invoked while waiting for + /// database readers as described above. ^If the busy-handler returns 0 before + /// the writer lock is obtained or while waiting for database readers, the + /// checkpoint operation proceeds from that point in the same way as + /// SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible + /// without blocking any further. ^SQLITE_BUSY is returned in this case. + /// + /// ^If parameter zDb is NULL or points to a zero length string, then the + /// specified operation is attempted on all WAL databases [attached] to + /// [database connection] db. In this case the + /// values written to output parameters *pnLog and *pnCkpt are undefined. ^If + /// an SQLITE_BUSY error is encountered when processing one or more of the + /// attached WAL databases, the operation is still attempted on any remaining + /// attached databases and SQLITE_BUSY is returned at the end. ^If any other + /// error occurs while processing an attached database, processing is abandoned + /// and the error code is returned to the caller immediately. ^If no error + /// (SQLITE_BUSY or otherwise) is encountered while processing the attached + /// databases, SQLITE_OK is returned. + /// + /// ^If database zDb is the name of an attached database that is not in WAL + /// mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If + /// zDb is not NULL (or a zero length string) and is not the name of any + /// attached database, SQLITE_ERROR is returned to the caller. + /// + /// ^Unless it returns SQLITE_MISUSE, + /// the sqlite3_wal_checkpoint_v2() interface + /// sets the error information that is queried by + /// [sqlite3_errcode()] and [sqlite3_errmsg()]. + /// + /// ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface + /// from SQL. + int sqlite3_wal_checkpoint_v2( + ffi.Pointer db, + ffi.Pointer zDb, + int eMode, + ffi.Pointer pnLog, + ffi.Pointer pnCkpt, + ) { + return _sqlite3_wal_checkpoint_v2(db, zDb, eMode, pnLog, pnCkpt); + } - /// The methods above are in versions 1 and 2 of the sqlite_vfs object. - /// Those below are for version 3 and greater. - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - sqlite3_syscall_ptr, - ) - > - > - xSetSystemCall; + late final _sqlite3_wal_checkpoint_v2Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) + > + >('sqlite3_wal_checkpoint_v2'); + late final _sqlite3_wal_checkpoint_v2 = _sqlite3_wal_checkpoint_v2Ptr + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ffi.Pointer, + ffi.Pointer, + ) + >(); - external ffi.Pointer< - ffi.NativeFunction< - sqlite3_syscall_ptr Function( - ffi.Pointer, - ffi.Pointer, - ) + /// CAPI3REF: Write-Ahead Log Commit Hook + /// METHOD: sqlite3 + /// + /// ^The [sqlite3_wal_hook()] function is used to register a callback that + /// is invoked each time data is committed to a database in wal mode. + /// + /// ^(The callback is invoked by SQLite after the commit has taken place and + /// the associated write-lock on the database released)^, so the implementation + /// may read, write or [checkpoint] the database as required. + /// + /// ^The first parameter passed to the callback function when it is invoked + /// is a copy of the third parameter passed to sqlite3_wal_hook() when + /// registering the callback. ^The second is a copy of the database handle. + /// ^The third parameter is the name of the database that was written to - + /// either "main" or the name of an [ATTACH]-ed database. ^The fourth parameter + /// is the number of pages currently in the write-ahead log file, + /// including those that were just committed. + /// + /// The callback function should normally return [SQLITE_OK]. ^If an error + /// code is returned, that error will propagate back up through the + /// SQLite code base to cause the statement that provoked the callback + /// to report an error, though the commit will have still occurred. If the + /// callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value + /// that does not correspond to any valid SQLite error code, the results + /// are undefined. + /// + /// A single database handle may have at most a single write-ahead log callback + /// registered at one time. ^Calling [sqlite3_wal_hook()] replaces any + /// previously registered write-ahead log callback. ^Note that the + /// [sqlite3_wal_autocheckpoint()] interface and the + /// [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will + /// overwrite any prior [sqlite3_wal_hook()] settings. + ffi.Pointer sqlite3_wal_hook( + ffi.Pointer arg0, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > > - > - xGetSystemCall; + arg1, + ffi.Pointer arg2, + ) { + return _sqlite3_wal_hook(arg0, arg1, arg2); + } + + late final _sqlite3_wal_hookPtr = + _lookup< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + >, + ffi.Pointer, + ) + > + >('sqlite3_wal_hook'); + late final _sqlite3_wal_hook = _sqlite3_wal_hookPtr + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + >, + ffi.Pointer, + ) + >(); - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - > - xNextSystemCall; -} + /// CAPI3REF: Win32 Specific Interface + /// + /// These interfaces are available only on Windows. The + /// [sqlite3_win32_set_directory] interface is used to set the value associated + /// with the [sqlite3_temp_directory] or [sqlite3_data_directory] variable, to + /// zValue, depending on the value of the type parameter. The zValue parameter + /// should be NULL to cause the previous value to be freed via [sqlite3_free]; + /// a non-NULL value will be copied into memory obtained from [sqlite3_malloc] + /// prior to being used. The [sqlite3_win32_set_directory] interface returns + /// [SQLITE_OK] to indicate success, [SQLITE_ERROR] if the type is unsupported, + /// or [SQLITE_NOMEM] if memory could not be allocated. The value of the + /// [sqlite3_data_directory] variable is intended to act as a replacement for + /// the current directory on the sub-platforms of Win32 where that concept is + /// not present, e.g. WinRT and UWP. The [sqlite3_win32_set_directory8] and + /// [sqlite3_win32_set_directory16] interfaces behave exactly the same as the + /// sqlite3_win32_set_directory interface except the string parameter must be + /// UTF-8 or UTF-16, respectively. + int sqlite3_win32_set_directory(int type, ffi.Pointer zValue) { + return _sqlite3_win32_set_directory(type, zValue); + } -final class sqlite3_mem_methods extends ffi.Struct { - /// Memory allocation function - external ffi.Pointer< - ffi.NativeFunction Function(ffi.Int)> - > - xMalloc; + late final _sqlite3_win32_set_directoryPtr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.UnsignedLong, ffi.Pointer) + > + >('sqlite3_win32_set_directory'); + late final _sqlite3_win32_set_directory = _sqlite3_win32_set_directoryPtr + .asFunction)>(); - /// Free a prior allocation - external ffi.Pointer< - ffi.NativeFunction)> - > - xFree; + int sqlite3_win32_set_directory16(int type, ffi.Pointer zValue) { + return _sqlite3_win32_set_directory16(type, zValue); + } - /// Resize an allocation - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - > - xRealloc; + late final _sqlite3_win32_set_directory16Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.UnsignedLong, ffi.Pointer) + > + >('sqlite3_win32_set_directory16'); + late final _sqlite3_win32_set_directory16 = _sqlite3_win32_set_directory16Ptr + .asFunction)>(); - /// Return the size of an allocation - external ffi.Pointer< - ffi.NativeFunction)> - > - xSize; + int sqlite3_win32_set_directory8(int type, ffi.Pointer zValue) { + return _sqlite3_win32_set_directory8(type, zValue); + } - /// Round up request size to allocation size - external ffi.Pointer> xRoundup; + late final _sqlite3_win32_set_directory8Ptr = + _lookup< + ffi.NativeFunction< + ffi.Int Function(ffi.UnsignedLong, ffi.Pointer) + > + >('sqlite3_win32_set_directory8'); + late final _sqlite3_win32_set_directory8 = _sqlite3_win32_set_directory8Ptr + .asFunction)>(); +} - /// Initialize the memory allocator - external ffi.Pointer< - ffi.NativeFunction)> - > - xInit; +const int FTS5_TOKENIZE_AUX = 8; - /// Deinitialize the memory allocator - external ffi.Pointer< - ffi.NativeFunction)> - > - xShutdown; +const int FTS5_TOKENIZE_DOCUMENT = 4; - /// Argument to xInit() and xShutdown() - external ffi.Pointer pAppData; -} +const int FTS5_TOKENIZE_PREFIX = 2; -final class sqlite3_stmt extends ffi.Opaque {} +const int FTS5_TOKENIZE_QUERY = 1; -final class sqlite3_value extends ffi.Opaque {} +const int FTS5_TOKEN_COLOCATED = 1; -final class sqlite3_context extends ffi.Opaque {} +const int FULLY_WITHIN = 2; -typedef sqlite3_destructor_typeFunction = - ffi.Void Function(ffi.Pointer); -typedef Dartsqlite3_destructor_typeFunction = - void Function(ffi.Pointer); +final class Fts5Context extends ffi.Opaque {} -/// CAPI3REF: Constants Defining Special Destructor Behavior +/// EXTENSION API FUNCTIONS +/// +/// xUserData(pFts): +/// Return a copy of the context pointer the extension function was +/// registered with. +/// +/// xColumnTotalSize(pFts, iCol, pnToken): +/// If parameter iCol is less than zero, set output variable *pnToken +/// to the total number of tokens in the FTS5 table. Or, if iCol is +/// non-negative but less than the number of columns in the table, return +/// the total number of tokens in column iCol, considering all rows in +/// the FTS5 table. +/// +/// If parameter iCol is greater than or equal to the number of columns +/// in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. +/// an OOM condition or IO error), an appropriate SQLite error code is +/// returned. +/// +/// xColumnCount(pFts): +/// Return the number of columns in the table. +/// +/// xColumnSize(pFts, iCol, pnToken): +/// If parameter iCol is less than zero, set output variable *pnToken +/// to the total number of tokens in the current row. Or, if iCol is +/// non-negative but less than the number of columns in the table, set +/// *pnToken to the number of tokens in column iCol of the current row. +/// +/// If parameter iCol is greater than or equal to the number of columns +/// in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. +/// an OOM condition or IO error), an appropriate SQLite error code is +/// returned. +/// +/// This function may be quite inefficient if used with an FTS5 table +/// created with the "columnsize=0" option. +/// +/// xColumnText: +/// This function attempts to retrieve the text of column iCol of the +/// current document. If successful, (*pz) is set to point to a buffer +/// containing the text in utf-8 encoding, (*pn) is set to the size in bytes +/// (not characters) of the buffer and SQLITE_OK is returned. Otherwise, +/// if an error occurs, an SQLite error code is returned and the final values +/// of (*pz) and (*pn) are undefined. +/// +/// xPhraseCount: +/// Returns the number of phrases in the current query expression. +/// +/// xPhraseSize: +/// Returns the number of tokens in phrase iPhrase of the query. Phrases +/// are numbered starting from zero. +/// +/// xInstCount: +/// Set *pnInst to the total number of occurrences of all phrases within +/// the query within the current row. Return SQLITE_OK if successful, or +/// an error code (i.e. SQLITE_NOMEM) if an error occurs. +/// +/// This API can be quite slow if used with an FTS5 table created with the +/// "detail=none" or "detail=column" option. If the FTS5 table is created +/// with either "detail=none" or "detail=column" and "content=" option +/// (i.e. if it is a contentless table), then this API always returns 0. +/// +/// xInst: +/// Query for the details of phrase match iIdx within the current row. +/// Phrase matches are numbered starting from zero, so the iIdx argument +/// should be greater than or equal to zero and smaller than the value +/// output by xInstCount(). +/// +/// Usually, output parameter *piPhrase is set to the phrase number, *piCol +/// to the column in which it occurs and *piOff the token offset of the +/// first token of the phrase. Returns SQLITE_OK if successful, or an error +/// code (i.e. SQLITE_NOMEM) if an error occurs. +/// +/// This API can be quite slow if used with an FTS5 table created with the +/// "detail=none" or "detail=column" option. +/// +/// xRowid: +/// Returns the rowid of the current row. +/// +/// xTokenize: +/// Tokenize text using the tokenizer belonging to the FTS5 table. +/// +/// xQueryPhrase(pFts5, iPhrase, pUserData, xCallback): +/// This API function is used to query the FTS table for phrase iPhrase +/// of the current query. Specifically, a query equivalent to: +/// +/// ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid +/// +/// with $p set to a phrase equivalent to the phrase iPhrase of the +/// current query is executed. Any column filter that applies to +/// phrase iPhrase of the current query is included in $p. For each +/// row visited, the callback function passed as the fourth argument +/// is invoked. The context and API objects passed to the callback +/// function may be used to access the properties of each matched row. +/// Invoking Api.xUserData() returns a copy of the pointer passed as +/// the third argument to pUserData. +/// +/// If the callback function returns any value other than SQLITE_OK, the +/// query is abandoned and the xQueryPhrase function returns immediately. +/// If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. +/// Otherwise, the error code is propagated upwards. +/// +/// If the query runs to completion without incident, SQLITE_OK is returned. +/// Or, if some error occurs before the query completes or is aborted by +/// the callback, an SQLite error code is returned. +/// +/// +/// xSetAuxdata(pFts5, pAux, xDelete) +/// +/// Save the pointer passed as the second argument as the extension function's +/// "auxiliary data". The pointer may then be retrieved by the current or any +/// future invocation of the same fts5 extension function made as part of +/// the same MATCH query using the xGetAuxdata() API. /// -/// These are special values for the destructor that is passed in as the -/// final argument to routines like [sqlite3_result_blob()]. ^If the destructor -/// argument is SQLITE_STATIC, it means that the content pointer is constant -/// and will never change. It does not need to be destroyed. ^The -/// SQLITE_TRANSIENT value means that the content will likely change in -/// the near future and that SQLite should make its own private copy of -/// the content before returning. +/// Each extension function is allocated a single auxiliary data slot for +/// each FTS query (MATCH expression). If the extension function is invoked +/// more than once for a single FTS query, then all invocations share a +/// single auxiliary data context. /// -/// The typedef is necessary to work around problems in certain -/// C++ compilers. -typedef sqlite3_destructor_type = - ffi.Pointer>; - -final class sqlite3_index_constraint extends ffi.Struct { - /// Column constrained. -1 for ROWID - @ffi.Int() - external int iColumn; - - /// Constraint operator - @ffi.UnsignedChar() - external int op; - - /// True if this constraint is usable - @ffi.UnsignedChar() - external int usable; - - /// Used internally - xBestIndex should ignore - @ffi.Int() - external int iTermOffset; -} - -final class sqlite3_index_orderby extends ffi.Struct { - /// Column number - @ffi.Int() - external int iColumn; - - /// True for DESC. False for ASC. - @ffi.UnsignedChar() - external int desc; -} - -/// Outputs -final class sqlite3_index_constraint_usage extends ffi.Struct { - /// if >0, constraint is part of argv to xFilter - @ffi.Int() - external int argvIndex; - - /// Do not code a test for this constraint - @ffi.UnsignedChar() - external int omit; -} - -/// CAPI3REF: Virtual Table Indexing Information -/// KEYWORDS: sqlite3_index_info +/// If there is already an auxiliary data pointer when this function is +/// invoked, then it is replaced by the new pointer. If an xDelete callback +/// was specified along with the original pointer, it is invoked at this +/// point. /// -/// The sqlite3_index_info structure and its substructures is used as part -/// of the [virtual table] interface to -/// pass information into and receive the reply from the [xBestIndex] -/// method of a [virtual table module]. The fields under **Inputs** are the -/// inputs to xBestIndex and are read-only. xBestIndex inserts its -/// results into the **Outputs** fields. +/// The xDelete callback, if one is specified, is also invoked on the +/// auxiliary data pointer after the FTS5 query has finished. /// -/// ^(The aConstraint[] array records WHERE clause constraints of the form: +/// If an error (e.g. an OOM condition) occurs within this function, +/// the auxiliary data is set to NULL and an error code returned. If the +/// xDelete parameter was not NULL, it is invoked on the auxiliary data +/// pointer before returning. /// -///
    column OP expr
    /// -/// where OP is =, <, <=, >, or >=.)^ ^(The particular operator is -/// stored in aConstraint[].op using one of the -/// [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ -/// ^(The index of the column is stored in -/// aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the -/// expr on the right-hand side can be evaluated (and thus the constraint -/// is usable) and false if it cannot.)^ +/// xGetAuxdata(pFts5, bClear) /// -/// ^The optimizer automatically inverts terms of the form "expr OP column" -/// and makes other simplifications to the WHERE clause in an attempt to -/// get as many WHERE clause terms into the form shown above as possible. -/// ^The aConstraint[] array only reports WHERE clause terms that are -/// relevant to the particular virtual table being queried. +/// Returns the current auxiliary data pointer for the fts5 extension +/// function. See the xSetAuxdata() method for details. /// -/// ^Information about the ORDER BY clause is stored in aOrderBy[]. -/// ^Each term of aOrderBy records a column of the ORDER BY clause. +/// If the bClear argument is non-zero, then the auxiliary data is cleared +/// (set to NULL) before this function returns. In this case the xDelete, +/// if any, is not invoked. /// -/// The colUsed field indicates which columns of the virtual table may be -/// required by the current scan. Virtual table columns are numbered from -/// zero in the order in which they appear within the CREATE TABLE statement -/// passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), -/// the corresponding bit is set within the colUsed mask if the column may be -/// required by SQLite. If the table has at least 64 columns and any column -/// to the right of the first 63 is required, then bit 63 of colUsed is also -/// set. In other words, column iCol may be required if the expression -/// (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to -/// non-zero. /// -/// The [xBestIndex] method must fill aConstraintUsage[] with information -/// about what parameters to pass to xFilter. ^If argvIndex>0 then -/// the right-hand side of the corresponding aConstraint[] is evaluated -/// and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit -/// is true, then the constraint is assumed to be fully handled by the -/// virtual table and might not be checked again by the byte code.)^ ^(The -/// aConstraintUsage[].omit flag is an optimization hint. When the omit flag -/// is left in its default setting of false, the constraint will always be -/// checked separately in byte code. If the omit flag is change to true, then -/// the constraint may or may not be checked in byte code. In other words, -/// when the omit flag is true there is no guarantee that the constraint will -/// not be checked again using byte code.)^ +/// xRowCount(pFts5, pnRow) /// -/// ^The idxNum and idxPtr values are recorded and passed into the -/// [xFilter] method. -/// ^[sqlite3_free()] is used to free idxPtr if and only if -/// needToFreeIdxPtr is true. +/// This function is used to retrieve the total number of rows in the table. +/// In other words, the same value that would be returned by: /// -/// ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in -/// the correct order to satisfy the ORDER BY clause so that no separate -/// sorting step is required. +/// SELECT count(*) FROM ftstable; /// -/// ^The estimatedCost value is an estimate of the cost of a particular -/// strategy. A cost of N indicates that the cost of the strategy is similar -/// to a linear scan of an SQLite table with N rows. A cost of log(N) -/// indicates that the expense of the operation is similar to that of a -/// binary search on a unique indexed field of an SQLite table with N rows. +/// xPhraseFirst() +/// This function is used, along with type Fts5PhraseIter and the xPhraseNext +/// method, to iterate through all instances of a single query phrase within +/// the current row. This is the same information as is accessible via the +/// xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient +/// to use, this API may be faster under some circumstances. To iterate +/// through instances of phrase iPhrase, use the following code: /// -/// ^The estimatedRows value is an estimate of the number of rows that -/// will be returned by the strategy. +/// Fts5PhraseIter iter; +/// int iCol, iOff; +/// for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff); +/// iCol>=0; +/// pApi->xPhraseNext(pFts, &iter, &iCol, &iOff) +/// ){ +/// // An instance of phrase iPhrase at offset iOff of column iCol +/// } /// -/// The xBestIndex method may optionally populate the idxFlags field with a -/// mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - -/// SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite -/// assumes that the strategy may visit at most one row. +/// The Fts5PhraseIter structure is defined above. Applications should not +/// modify this structure directly - it should only be used as shown above +/// with the xPhraseFirst() and xPhraseNext() API methods (and by +/// xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below). /// -/// Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then -/// SQLite also assumes that if a call to the xUpdate() method is made as -/// part of the same statement to delete or update a virtual table row and the -/// implementation returns SQLITE_CONSTRAINT, then there is no need to rollback -/// any database changes. In other words, if the xUpdate() returns -/// SQLITE_CONSTRAINT, the database contents must be exactly as they were -/// before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not -/// set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by -/// the xUpdate method are automatically rolled back by SQLite. +/// This API can be quite slow if used with an FTS5 table created with the +/// "detail=none" or "detail=column" option. If the FTS5 table is created +/// with either "detail=none" or "detail=column" and "content=" option +/// (i.e. if it is a contentless table), then this API always iterates +/// through an empty set (all calls to xPhraseFirst() set iCol to -1). /// -/// IMPORTANT: The estimatedRows field was added to the sqlite3_index_info -/// structure for SQLite [version 3.8.2] ([dateof:3.8.2]). -/// If a virtual table extension is -/// used with an SQLite version earlier than 3.8.2, the results of attempting -/// to read or write the estimatedRows field are undefined (but are likely -/// to include crashing the application). The estimatedRows field should -/// therefore only be used if [sqlite3_libversion_number()] returns a -/// value greater than or equal to 3008002. Similarly, the idxFlags field -/// was added for [version 3.9.0] ([dateof:3.9.0]). -/// It may therefore only be used if -/// sqlite3_libversion_number() returns a value greater than or equal to -/// 3009000. -final class sqlite3_index_info extends ffi.Struct { - /// Number of entries in aConstraint - @ffi.Int() - external int nConstraint; - - /// Table of WHERE clause constraints - external ffi.Pointer aConstraint; - - /// Number of terms in the ORDER BY clause - @ffi.Int() - external int nOrderBy; - - /// The ORDER BY clause - external ffi.Pointer aOrderBy; - - external ffi.Pointer aConstraintUsage; - - /// Number used to identify the index - @ffi.Int() - external int idxNum; - - /// String, possibly obtained from sqlite3_malloc - external ffi.Pointer idxStr; - - /// Free idxStr using sqlite3_free() if true - @ffi.Int() - external int needToFreeIdxStr; - - /// True if output is already ordered - @ffi.Int() - external int orderByConsumed; - - /// Estimated cost of using this index - @ffi.Double() - external double estimatedCost; - - /// Estimated number of rows returned - @sqlite3_int64() - external int estimatedRows; - - /// Mask of SQLITE_INDEX_SCAN_* flags - @ffi.Int() - external int idxFlags; - - /// Input: Mask of columns used by statement - @sqlite3_uint64() - external int colUsed; -} - -/// CAPI3REF: Virtual Table Cursor Object -/// KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} +/// xPhraseNext() +/// See xPhraseFirst above. /// -/// Every [virtual table module] implementation uses a subclass of the -/// following structure to describe cursors that point into the -/// [virtual table] and are used -/// to loop through the virtual table. Cursors are created using the -/// [sqlite3_module.xOpen | xOpen] method of the module and are destroyed -/// by the [sqlite3_module.xClose | xClose] method. Cursors are used -/// by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods -/// of the module. Each module implementation will define -/// the content of a cursor structure to suit its own needs. +/// xPhraseFirstColumn() +/// This function and xPhraseNextColumn() are similar to the xPhraseFirst() +/// and xPhraseNext() APIs described above. The difference is that instead +/// of iterating through all instances of a phrase in the current row, these +/// APIs are used to iterate through the set of columns in the current row +/// that contain one or more instances of a specified phrase. For example: /// -/// This superclass exists in order to define fields of the cursor that -/// are common to all implementations. -final class sqlite3_vtab_cursor extends ffi.Struct { - /// Virtual table of this cursor - external ffi.Pointer pVtab; -} - -/// CAPI3REF: Virtual Table Object -/// KEYWORDS: sqlite3_module {virtual table module} +/// Fts5PhraseIter iter; +/// int iCol; +/// for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol); +/// iCol>=0; +/// pApi->xPhraseNextColumn(pFts, &iter, &iCol) +/// ){ +/// // Column iCol contains at least one instance of phrase iPhrase +/// } /// -/// This structure, sometimes called a "virtual table module", -/// defines the implementation of a [virtual table]. -/// This structure consists mostly of methods for the module. +/// This API can be quite slow if used with an FTS5 table created with the +/// "detail=none" option. If the FTS5 table is created with either +/// "detail=none" "content=" option (i.e. if it is a contentless table), +/// then this API always iterates through an empty set (all calls to +/// xPhraseFirstColumn() set iCol to -1). /// -/// ^A virtual table module is created by filling in a persistent -/// instance of this structure and passing a pointer to that instance -/// to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. -/// ^The registration remains valid until it is replaced by a different -/// module or until the [database connection] closes. The content -/// of this structure must not change while it is registered with -/// any database connection. -final class sqlite3_module extends ffi.Struct { +/// The information accessed using this API and its companion +/// xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext +/// (or xInst/xInstCount). The chief advantage of this API is that it is +/// significantly more efficient than those alternatives when used with +/// "detail=column" tables. +/// +/// xPhraseNextColumn() +/// See xPhraseFirstColumn above. +final class Fts5ExtensionApi extends ffi.Struct { + /// Currently always set to 3 @ffi.Int() external int iVersion; external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer>, - ) - > - > - xCreate; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer>, - ffi.Pointer>, - ) - > - > - xConnect; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ) - > - > - xBestIndex; - - external ffi.Pointer< - ffi.NativeFunction pVTab)> - > - xDisconnect; - - external ffi.Pointer< - ffi.NativeFunction pVTab)> - > - xDestroy; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer pVTab, - ffi.Pointer> ppCursor, - ) - > + ffi.NativeFunction Function(ffi.Pointer)> > - xOpen; + xUserData; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction)> > - xClose; + xColumnCount; external ffi.Pointer< ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) + ffi.Int Function(ffi.Pointer, ffi.Pointer) > > - xFilter; - - external ffi.Pointer< - ffi.NativeFunction)> - > - xNext; - - external ffi.Pointer< - ffi.NativeFunction)> - > - xEof; + xRowCount; external ffi.Pointer< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, - ffi.Pointer, + ffi.Pointer, ffi.Int, - ) - > - > - xColumn; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, ffi.Pointer, ) > > - xRowid; + xColumnTotalSize; external ffi.Pointer< ffi.NativeFunction< ffi.Int Function( - ffi.Pointer, + ffi.Pointer, + ffi.Pointer, ffi.Int, - ffi.Pointer>, - ffi.Pointer, - ) - > - > - xUpdate; - - external ffi.Pointer< - ffi.NativeFunction pVTab)> - > - xBegin; - - external ffi.Pointer< - ffi.NativeFunction pVTab)> - > - xSync; - - external ffi.Pointer< - ffi.NativeFunction pVTab)> - > - xCommit; - - external ffi.Pointer< - ffi.NativeFunction pVTab)> - > - xRollback; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer pVtab, - ffi.Int nArg, - ffi.Pointer zName, + ffi.Pointer, ffi.Pointer< - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ) - > + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Int, + ) > - > - pxFunc, - ffi.Pointer> ppArg, - ) - > - > - xFindFunction; - - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer pVtab, - ffi.Pointer zNew, + >, ) > > - xRename; - - /// The methods above are in version 1 of the sqlite_module object. Those - /// below are for version 2 and greater. - external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> - > - xSavepoint; + xTokenize; external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> + ffi.NativeFunction)> > - xRelease; + xPhraseCount; external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> + ffi.NativeFunction, ffi.Int)> > - xRollbackTo; + xPhraseSize; - /// The methods above are in versions 1 and 2 of the sqlite_module object. - /// Those below are for version 3 and greater. external ffi.Pointer< - ffi.NativeFunction)> - > - xShadowName; -} - -/// CAPI3REF: Virtual Table Instance Object -/// KEYWORDS: sqlite3_vtab -/// -/// Every [virtual table module] implementation uses a subclass -/// of this object to describe a particular instance -/// of the [virtual table]. Each subclass will -/// be tailored to the specific needs of the module implementation. -/// The purpose of this superclass is to define certain fields that are -/// common to all module implementations. -/// -/// ^Virtual tables methods can set an error message by assigning a -/// string obtained from [sqlite3_mprintf()] to zErrMsg. The method should -/// take care that any prior string is freed by a call to [sqlite3_free()] -/// prior to assigning a new string to zErrMsg. ^After the error message -/// is delivered up to the client application, the string will be automatically -/// freed by sqlite3_free() and the zErrMsg field will be zeroed. -final class sqlite3_vtab extends ffi.Struct { - /// The module for this virtual table - external ffi.Pointer pModule; - - /// Number of open cursors - @ffi.Int() - external int nRef; + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xInstCount; - /// Error message from sqlite3_mprintf() - external ffi.Pointer zErrMsg; -} + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xInst; -final class sqlite3_blob extends ffi.Opaque {} + external ffi.Pointer< + ffi.NativeFunction)> + > + xRowid; -final class sqlite3_mutex_methods extends ffi.Struct { - external ffi.Pointer> xMutexInit; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer, + ) + > + > + xColumnText; - external ffi.Pointer> xMutexEnd; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Pointer) + > + > + xColumnSize; external ffi.Pointer< - ffi.NativeFunction Function(ffi.Int)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ) + > > - xMutexAlloc; + xQueryPhrase; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > > - xMutexFree; + xSetAuxdata; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > > - xMutexEnter; + xGetAuxdata; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > > - xMutexTry; + xPhraseFirst; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > > - xMutexLeave; + xPhraseNext; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) + > > - xMutexHeld; + xPhraseFirstColumn; external ffi.Pointer< - ffi.NativeFunction)> + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > > - xMutexNotheld; -} + xPhraseNextColumn; -final class sqlite3_str extends ffi.Opaque {} + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iVersion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer) + > + > + xUserData, + required ffi.Pointer< + ffi.NativeFunction)> + > + xColumnCount, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xRowCount, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xColumnTotalSize, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Int, + ) + > + >, + ) + > + > + xTokenize, + required ffi.Pointer< + ffi.NativeFunction)> + > + xPhraseCount, + required ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xPhraseSize, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xInstCount, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xInst, + required ffi.Pointer< + ffi.NativeFunction)> + > + xRowid, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer, + ) + > + > + xColumnText, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xColumnSize, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >, + ) + > + > + xQueryPhrase, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction)> + >, + ) + > + > + xSetAuxdata, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + > + xGetAuxdata, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xPhraseFirst, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xPhraseNext, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xPhraseFirstColumn, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xPhraseNextColumn, + }) => $allocator() + ..ref.iVersion = iVersion + ..ref.xUserData = xUserData + ..ref.xColumnCount = xColumnCount + ..ref.xRowCount = xRowCount + ..ref.xColumnTotalSize = xColumnTotalSize + ..ref.xTokenize = xTokenize + ..ref.xPhraseCount = xPhraseCount + ..ref.xPhraseSize = xPhraseSize + ..ref.xInstCount = xInstCount + ..ref.xInst = xInst + ..ref.xRowid = xRowid + ..ref.xColumnText = xColumnText + ..ref.xColumnSize = xColumnSize + ..ref.xQueryPhrase = xQueryPhrase + ..ref.xSetAuxdata = xSetAuxdata + ..ref.xGetAuxdata = xGetAuxdata + ..ref.xPhraseFirst = xPhraseFirst + ..ref.xPhraseNext = xPhraseNext + ..ref.xPhraseFirstColumn = xPhraseFirstColumn + ..ref.xPhraseNextColumn = xPhraseNextColumn; +} -final class sqlite3_pcache extends ffi.Opaque {} +final class Fts5PhraseIter extends ffi.Struct { + external ffi.Pointer a; -final class sqlite3_pcache_page extends ffi.Struct { - /// The content of the page - external ffi.Pointer pBuf; + external ffi.Pointer b; - /// Extra information associated with the page - external ffi.Pointer pExtra; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer a, + required ffi.Pointer b, + }) => $allocator() + ..ref.a = a + ..ref.b = b; } -final class sqlite3_pcache_methods2 extends ffi.Struct { - @ffi.Int() - external int iVersion; +final class Fts5Tokenizer extends ffi.Opaque {} + +const int NOT_WITHIN = 0; + +const int PARTLY_WITHIN = 1; - external ffi.Pointer pArg; +const int SQLITE3_TEXT = 3; - external ffi.Pointer< - ffi.NativeFunction)> - > - xInit; +const int SQLITE_ABORT = 4; - external ffi.Pointer< - ffi.NativeFunction)> - > - xShutdown; +const int SQLITE_ABORT_ROLLBACK = 516; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Int szPage, - ffi.Int szExtra, - ffi.Int bPurgeable, - ) - > - > - xCreate; +const int SQLITE_ACCESS_EXISTS = 0; - external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> - > - xCachesize; +const int SQLITE_ACCESS_READ = 2; - external ffi.Pointer< - ffi.NativeFunction)> - > - xPagecount; +const int SQLITE_ACCESS_READWRITE = 1; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.Int, - ) - > - > - xFetch; +const int SQLITE_ALTER_TABLE = 26; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - > - xUnpin; +const int SQLITE_ANALYZE = 28; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ) - > - > - xRekey; +const int SQLITE_ANY = 5; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) - > - > - xTruncate; +const int SQLITE_ATTACH = 24; - external ffi.Pointer< - ffi.NativeFunction)> - > - xDestroy; +const int SQLITE_AUTH = 23; - external ffi.Pointer< - ffi.NativeFunction)> - > - xShrink; -} +const int SQLITE_AUTH_USER = 279; -final class sqlite3_pcache_methods extends ffi.Struct { - external ffi.Pointer pArg; +const int SQLITE_BLOB = 4; - external ffi.Pointer< - ffi.NativeFunction)> - > - xInit; +const int SQLITE_BUSY = 5; - external ffi.Pointer< - ffi.NativeFunction)> - > - xShutdown; +const int SQLITE_BUSY_RECOVERY = 261; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Int szPage, ffi.Int bPurgeable) - > - > - xCreate; +const int SQLITE_BUSY_SNAPSHOT = 517; - external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> - > - xCachesize; +const int SQLITE_BUSY_TIMEOUT = 773; - external ffi.Pointer< - ffi.NativeFunction)> - > - xPagecount; +const int SQLITE_CANTOPEN = 14; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.UnsignedInt, - ffi.Int, - ) - > - > - xFetch; +const int SQLITE_CANTOPEN_CONVPATH = 1038; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ) - > - > - xUnpin; +const int SQLITE_CANTOPEN_DIRTYWAL = 1294; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedInt, - ffi.UnsignedInt, - ) - > - > - xRekey; +const int SQLITE_CANTOPEN_FULLPATH = 782; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) - > - > - xTruncate; +const int SQLITE_CANTOPEN_ISDIR = 526; - external ffi.Pointer< - ffi.NativeFunction)> - > - xDestroy; -} +const int SQLITE_CANTOPEN_NOTEMPDIR = 270; -final class sqlite3_backup extends ffi.Opaque {} +const int SQLITE_CANTOPEN_SYMLINK = 1550; -/// CAPI3REF: Database Snapshot -/// KEYWORDS: {snapshot} {sqlite3_snapshot} -/// -/// An instance of the snapshot object records the state of a [WAL mode] -/// database for some specific point in history. -/// -/// In [WAL mode], multiple [database connections] that are open on the -/// same database file can each be reading a different historical version -/// of the database file. When a [database connection] begins a read -/// transaction, that connection sees an unchanging copy of the database -/// as it existed for the point in time when the transaction first started. -/// Subsequent changes to the database from other connections are not seen -/// by the reader until a new read transaction is started. -/// -/// The sqlite3_snapshot object records state information about an historical -/// version of the database file so that it is possible to later open a new read -/// transaction that sees that historical version of the database rather than -/// the most recent version. -final class sqlite3_snapshot extends ffi.Struct { - @ffi.Array.multi([48]) - external ffi.Array hidden; -} +const int SQLITE_CHECKPOINT_FULL = 1; -typedef sqlite3_rtree_dbl = ffi.Double; -typedef Dartsqlite3_rtree_dbl = double; +const int SQLITE_CHECKPOINT_PASSIVE = 0; -/// A pointer to a structure of the following type is passed as the first -/// argument to callbacks registered using rtree_geometry_callback(). -final class sqlite3_rtree_geometry extends ffi.Struct { - /// Copy of pContext passed to s_r_g_c() - external ffi.Pointer pContext; +const int SQLITE_CHECKPOINT_RESTART = 2; - /// Size of array aParam[] - @ffi.Int() - external int nParam; +const int SQLITE_CHECKPOINT_TRUNCATE = 3; - /// Parameters passed to SQL geom function - external ffi.Pointer aParam; +const int SQLITE_CONFIG_COVERING_INDEX_SCAN = 20; - /// Callback implementation user data - external ffi.Pointer pUser; +const int SQLITE_CONFIG_GETMALLOC = 5; - /// Called by SQLite to clean up pUser - external ffi.Pointer< - ffi.NativeFunction)> - > - xDelUser; -} +const int SQLITE_CONFIG_GETMUTEX = 11; -/// A pointer to a structure of the following type is passed as the -/// argument to scored geometry callback registered using -/// sqlite3_rtree_query_callback(). -/// -/// Note that the first 5 fields of this structure are identical to -/// sqlite3_rtree_geometry. This structure is a subclass of -/// sqlite3_rtree_geometry. -final class sqlite3_rtree_query_info extends ffi.Struct { - /// pContext from when function registered - external ffi.Pointer pContext; +const int SQLITE_CONFIG_GETPCACHE = 15; - /// Number of function parameters - @ffi.Int() - external int nParam; +const int SQLITE_CONFIG_GETPCACHE2 = 19; - /// value of function parameters - external ffi.Pointer aParam; +const int SQLITE_CONFIG_HEAP = 8; - /// callback can use this, if desired - external ffi.Pointer pUser; +const int SQLITE_CONFIG_LOG = 16; - /// function to free pUser - external ffi.Pointer< - ffi.NativeFunction)> - > - xDelUser; +const int SQLITE_CONFIG_LOOKASIDE = 13; - /// Coordinates of node or entry to check - external ffi.Pointer aCoord; +const int SQLITE_CONFIG_MALLOC = 4; - /// Number of pending entries in the queue - external ffi.Pointer anQueue; +const int SQLITE_CONFIG_MEMDB_MAXSIZE = 29; - /// Number of coordinates - @ffi.Int() - external int nCoord; +const int SQLITE_CONFIG_MEMSTATUS = 9; + +const int SQLITE_CONFIG_MMAP_SIZE = 22; - /// Level of current node or entry - @ffi.Int() - external int iLevel; +const int SQLITE_CONFIG_MULTITHREAD = 2; - /// The largest iLevel value in the tree - @ffi.Int() - external int mxLevel; +const int SQLITE_CONFIG_MUTEX = 10; - /// Rowid for current entry - @sqlite3_int64() - external int iRowid; +const int SQLITE_CONFIG_PAGECACHE = 7; - /// Score of parent node - @sqlite3_rtree_dbl() - external double rParentScore; +const int SQLITE_CONFIG_PCACHE = 14; - /// Visibility of parent node - @ffi.Int() - external int eParentWithin; +const int SQLITE_CONFIG_PCACHE2 = 18; - /// OUT: Visibility - @ffi.Int() - external int eWithin; +const int SQLITE_CONFIG_PCACHE_HDRSZ = 24; - /// OUT: Write the score here - @sqlite3_rtree_dbl() - external double rScore; +const int SQLITE_CONFIG_PMASZ = 25; - /// Original SQL values of parameters - external ffi.Pointer> apSqlParam; -} +const int SQLITE_CONFIG_SCRATCH = 6; -final class Fts5Context extends ffi.Opaque {} +const int SQLITE_CONFIG_SERIALIZED = 3; -final class Fts5PhraseIter extends ffi.Struct { - external ffi.Pointer a; +const int SQLITE_CONFIG_SINGLETHREAD = 1; - external ffi.Pointer b; -} +const int SQLITE_CONFIG_SMALL_MALLOC = 27; -/// EXTENSION API FUNCTIONS -/// -/// xUserData(pFts): -/// Return a copy of the context pointer the extension function was -/// registered with. -/// -/// xColumnTotalSize(pFts, iCol, pnToken): -/// If parameter iCol is less than zero, set output variable *pnToken -/// to the total number of tokens in the FTS5 table. Or, if iCol is -/// non-negative but less than the number of columns in the table, return -/// the total number of tokens in column iCol, considering all rows in -/// the FTS5 table. -/// -/// If parameter iCol is greater than or equal to the number of columns -/// in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. -/// an OOM condition or IO error), an appropriate SQLite error code is -/// returned. -/// -/// xColumnCount(pFts): -/// Return the number of columns in the table. -/// -/// xColumnSize(pFts, iCol, pnToken): -/// If parameter iCol is less than zero, set output variable *pnToken -/// to the total number of tokens in the current row. Or, if iCol is -/// non-negative but less than the number of columns in the table, set -/// *pnToken to the number of tokens in column iCol of the current row. -/// -/// If parameter iCol is greater than or equal to the number of columns -/// in the table, SQLITE_RANGE is returned. Or, if an error occurs (e.g. -/// an OOM condition or IO error), an appropriate SQLite error code is -/// returned. -/// -/// This function may be quite inefficient if used with an FTS5 table -/// created with the "columnsize=0" option. -/// -/// xColumnText: -/// This function attempts to retrieve the text of column iCol of the -/// current document. If successful, (*pz) is set to point to a buffer -/// containing the text in utf-8 encoding, (*pn) is set to the size in bytes -/// (not characters) of the buffer and SQLITE_OK is returned. Otherwise, -/// if an error occurs, an SQLite error code is returned and the final values -/// of (*pz) and (*pn) are undefined. -/// -/// xPhraseCount: -/// Returns the number of phrases in the current query expression. -/// -/// xPhraseSize: -/// Returns the number of tokens in phrase iPhrase of the query. Phrases -/// are numbered starting from zero. -/// -/// xInstCount: -/// Set *pnInst to the total number of occurrences of all phrases within -/// the query within the current row. Return SQLITE_OK if successful, or -/// an error code (i.e. SQLITE_NOMEM) if an error occurs. -/// -/// This API can be quite slow if used with an FTS5 table created with the -/// "detail=none" or "detail=column" option. If the FTS5 table is created -/// with either "detail=none" or "detail=column" and "content=" option -/// (i.e. if it is a contentless table), then this API always returns 0. -/// -/// xInst: -/// Query for the details of phrase match iIdx within the current row. -/// Phrase matches are numbered starting from zero, so the iIdx argument -/// should be greater than or equal to zero and smaller than the value -/// output by xInstCount(). -/// -/// Usually, output parameter *piPhrase is set to the phrase number, *piCol -/// to the column in which it occurs and *piOff the token offset of the -/// first token of the phrase. Returns SQLITE_OK if successful, or an error -/// code (i.e. SQLITE_NOMEM) if an error occurs. -/// -/// This API can be quite slow if used with an FTS5 table created with the -/// "detail=none" or "detail=column" option. -/// -/// xRowid: -/// Returns the rowid of the current row. -/// -/// xTokenize: -/// Tokenize text using the tokenizer belonging to the FTS5 table. -/// -/// xQueryPhrase(pFts5, iPhrase, pUserData, xCallback): -/// This API function is used to query the FTS table for phrase iPhrase -/// of the current query. Specifically, a query equivalent to: -/// -/// ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid -/// -/// with $p set to a phrase equivalent to the phrase iPhrase of the -/// current query is executed. Any column filter that applies to -/// phrase iPhrase of the current query is included in $p. For each -/// row visited, the callback function passed as the fourth argument -/// is invoked. The context and API objects passed to the callback -/// function may be used to access the properties of each matched row. -/// Invoking Api.xUserData() returns a copy of the pointer passed as -/// the third argument to pUserData. -/// -/// If the callback function returns any value other than SQLITE_OK, the -/// query is abandoned and the xQueryPhrase function returns immediately. -/// If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK. -/// Otherwise, the error code is propagated upwards. -/// -/// If the query runs to completion without incident, SQLITE_OK is returned. -/// Or, if some error occurs before the query completes or is aborted by -/// the callback, an SQLite error code is returned. -/// -/// -/// xSetAuxdata(pFts5, pAux, xDelete) -/// -/// Save the pointer passed as the second argument as the extension function's -/// "auxiliary data". The pointer may then be retrieved by the current or any -/// future invocation of the same fts5 extension function made as part of -/// the same MATCH query using the xGetAuxdata() API. -/// -/// Each extension function is allocated a single auxiliary data slot for -/// each FTS query (MATCH expression). If the extension function is invoked -/// more than once for a single FTS query, then all invocations share a -/// single auxiliary data context. -/// -/// If there is already an auxiliary data pointer when this function is -/// invoked, then it is replaced by the new pointer. If an xDelete callback -/// was specified along with the original pointer, it is invoked at this -/// point. -/// -/// The xDelete callback, if one is specified, is also invoked on the -/// auxiliary data pointer after the FTS5 query has finished. -/// -/// If an error (e.g. an OOM condition) occurs within this function, -/// the auxiliary data is set to NULL and an error code returned. If the -/// xDelete parameter was not NULL, it is invoked on the auxiliary data -/// pointer before returning. -/// -/// -/// xGetAuxdata(pFts5, bClear) -/// -/// Returns the current auxiliary data pointer for the fts5 extension -/// function. See the xSetAuxdata() method for details. -/// -/// If the bClear argument is non-zero, then the auxiliary data is cleared -/// (set to NULL) before this function returns. In this case the xDelete, -/// if any, is not invoked. -/// -/// -/// xRowCount(pFts5, pnRow) -/// -/// This function is used to retrieve the total number of rows in the table. -/// In other words, the same value that would be returned by: -/// -/// SELECT count(*) FROM ftstable; -/// -/// xPhraseFirst() -/// This function is used, along with type Fts5PhraseIter and the xPhraseNext -/// method, to iterate through all instances of a single query phrase within -/// the current row. This is the same information as is accessible via the -/// xInstCount/xInst APIs. While the xInstCount/xInst APIs are more convenient -/// to use, this API may be faster under some circumstances. To iterate -/// through instances of phrase iPhrase, use the following code: -/// -/// Fts5PhraseIter iter; -/// int iCol, iOff; -/// for(pApi->xPhraseFirst(pFts, iPhrase, &iter, &iCol, &iOff); -/// iCol>=0; -/// pApi->xPhraseNext(pFts, &iter, &iCol, &iOff) -/// ){ -/// // An instance of phrase iPhrase at offset iOff of column iCol -/// } -/// -/// The Fts5PhraseIter structure is defined above. Applications should not -/// modify this structure directly - it should only be used as shown above -/// with the xPhraseFirst() and xPhraseNext() API methods (and by -/// xPhraseFirstColumn() and xPhraseNextColumn() as illustrated below). -/// -/// This API can be quite slow if used with an FTS5 table created with the -/// "detail=none" or "detail=column" option. If the FTS5 table is created -/// with either "detail=none" or "detail=column" and "content=" option -/// (i.e. if it is a contentless table), then this API always iterates -/// through an empty set (all calls to xPhraseFirst() set iCol to -1). -/// -/// xPhraseNext() -/// See xPhraseFirst above. -/// -/// xPhraseFirstColumn() -/// This function and xPhraseNextColumn() are similar to the xPhraseFirst() -/// and xPhraseNext() APIs described above. The difference is that instead -/// of iterating through all instances of a phrase in the current row, these -/// APIs are used to iterate through the set of columns in the current row -/// that contain one or more instances of a specified phrase. For example: -/// -/// Fts5PhraseIter iter; -/// int iCol; -/// for(pApi->xPhraseFirstColumn(pFts, iPhrase, &iter, &iCol); -/// iCol>=0; -/// pApi->xPhraseNextColumn(pFts, &iter, &iCol) -/// ){ -/// // Column iCol contains at least one instance of phrase iPhrase -/// } -/// -/// This API can be quite slow if used with an FTS5 table created with the -/// "detail=none" option. If the FTS5 table is created with either -/// "detail=none" "content=" option (i.e. if it is a contentless table), -/// then this API always iterates through an empty set (all calls to -/// xPhraseFirstColumn() set iCol to -1). -/// -/// The information accessed using this API and its companion -/// xPhraseFirstColumn() may also be obtained using xPhraseFirst/xPhraseNext -/// (or xInst/xInstCount). The chief advantage of this API is that it is -/// significantly more efficient than those alternatives when used with -/// "detail=column" tables. -/// -/// xPhraseNextColumn() -/// See xPhraseFirstColumn above. -final class Fts5ExtensionApi extends ffi.Struct { - /// Currently always set to 3 - @ffi.Int() - external int iVersion; +const int SQLITE_CONFIG_SORTERREF_SIZE = 28; + +const int SQLITE_CONFIG_SQLLOG = 21; - external ffi.Pointer< - ffi.NativeFunction Function(ffi.Pointer)> - > - xUserData; +const int SQLITE_CONFIG_STMTJRNL_SPILL = 26; - external ffi.Pointer< - ffi.NativeFunction)> - > - xColumnCount; +const int SQLITE_CONFIG_URI = 17; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - xRowCount; +const int SQLITE_CONFIG_WIN32_HEAPSIZE = 23; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ) - > - > - xColumnTotalSize; +const int SQLITE_CONSTRAINT = 19; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Int, - ) - > - >, - ) - > - > - xTokenize; +const int SQLITE_CONSTRAINT_CHECK = 275; - external ffi.Pointer< - ffi.NativeFunction)> - > - xPhraseCount; +const int SQLITE_CONSTRAINT_COMMITHOOK = 531; - external ffi.Pointer< - ffi.NativeFunction, ffi.Int)> - > - xPhraseSize; +const int SQLITE_CONSTRAINT_FOREIGNKEY = 787; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Pointer) - > - > - xInstCount; +const int SQLITE_CONSTRAINT_FUNCTION = 1043; + +const int SQLITE_CONSTRAINT_NOTNULL = 1299; + +const int SQLITE_CONSTRAINT_PINNED = 2835; + +const int SQLITE_CONSTRAINT_PRIMARYKEY = 1555; + +const int SQLITE_CONSTRAINT_ROWID = 2579; + +const int SQLITE_CONSTRAINT_TRIGGER = 1811; + +const int SQLITE_CONSTRAINT_UNIQUE = 2067; + +const int SQLITE_CONSTRAINT_VTAB = 2323; + +const int SQLITE_COPY = 0; + +const int SQLITE_CORRUPT = 11; + +const int SQLITE_CORRUPT_INDEX = 779; + +const int SQLITE_CORRUPT_SEQUENCE = 523; + +const int SQLITE_CORRUPT_VTAB = 267; + +const int SQLITE_CREATE_INDEX = 1; + +const int SQLITE_CREATE_TABLE = 2; + +const int SQLITE_CREATE_TEMP_INDEX = 3; + +const int SQLITE_CREATE_TEMP_TABLE = 4; + +const int SQLITE_CREATE_TEMP_TRIGGER = 5; + +const int SQLITE_CREATE_TEMP_VIEW = 6; + +const int SQLITE_CREATE_TRIGGER = 7; + +const int SQLITE_CREATE_VIEW = 8; + +const int SQLITE_CREATE_VTABLE = 29; + +const int SQLITE_DBCONFIG_DEFENSIVE = 1010; + +const int SQLITE_DBCONFIG_DQS_DDL = 1014; + +const int SQLITE_DBCONFIG_DQS_DML = 1013; + +const int SQLITE_DBCONFIG_ENABLE_FKEY = 1002; + +const int SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004; + +const int SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005; + +const int SQLITE_DBCONFIG_ENABLE_QPSG = 1007; + +const int SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; + +const int SQLITE_DBCONFIG_ENABLE_VIEW = 1015; + +const int SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012; + +const int SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016; + +const int SQLITE_DBCONFIG_LOOKASIDE = 1001; + +const int SQLITE_DBCONFIG_MAINDBNAME = 1000; + +const int SQLITE_DBCONFIG_MAX = 1017; + +const int SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006; + +const int SQLITE_DBCONFIG_RESET_DATABASE = 1009; + +const int SQLITE_DBCONFIG_TRIGGER_EQP = 1008; + +const int SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017; + +const int SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011; + +const int SQLITE_DBSTATUS_CACHE_HIT = 7; + +const int SQLITE_DBSTATUS_CACHE_MISS = 8; + +const int SQLITE_DBSTATUS_CACHE_SPILL = 12; + +const int SQLITE_DBSTATUS_CACHE_USED = 1; + +const int SQLITE_DBSTATUS_CACHE_USED_SHARED = 11; + +const int SQLITE_DBSTATUS_CACHE_WRITE = 9; + +const int SQLITE_DBSTATUS_DEFERRED_FKS = 10; + +const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4; + +const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6; + +const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5; + +const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0; + +const int SQLITE_DBSTATUS_MAX = 12; + +const int SQLITE_DBSTATUS_SCHEMA_USED = 2; + +const int SQLITE_DBSTATUS_STMT_USED = 3; + +const int SQLITE_DELETE = 9; + +const int SQLITE_DENY = 1; + +const int SQLITE_DESERIALIZE_FREEONCLOSE = 1; + +const int SQLITE_DESERIALIZE_READONLY = 4; + +const int SQLITE_DESERIALIZE_RESIZEABLE = 2; + +const int SQLITE_DETACH = 25; + +const int SQLITE_DETERMINISTIC = 2048; + +const int SQLITE_DIRECTONLY = 524288; + +const int SQLITE_DONE = 101; + +const int SQLITE_DROP_INDEX = 10; + +const int SQLITE_DROP_TABLE = 11; + +const int SQLITE_DROP_TEMP_INDEX = 12; + +const int SQLITE_DROP_TEMP_TABLE = 13; + +const int SQLITE_DROP_TEMP_TRIGGER = 14; + +const int SQLITE_DROP_TEMP_VIEW = 15; + +const int SQLITE_DROP_TRIGGER = 16; + +const int SQLITE_DROP_VIEW = 17; + +const int SQLITE_DROP_VTABLE = 30; + +const int SQLITE_EMPTY = 16; + +const int SQLITE_ERROR = 1; + +const int SQLITE_ERROR_MISSING_COLLSEQ = 257; + +const int SQLITE_ERROR_RETRY = 513; + +const int SQLITE_ERROR_SNAPSHOT = 769; + +const int SQLITE_FAIL = 3; + +const int SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31; + +const int SQLITE_FCNTL_BUSYHANDLER = 15; + +const int SQLITE_FCNTL_CHUNK_SIZE = 6; + +const int SQLITE_FCNTL_CKPT_DONE = 37; + +const int SQLITE_FCNTL_CKPT_START = 39; + +const int SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32; + +const int SQLITE_FCNTL_COMMIT_PHASETWO = 22; + +const int SQLITE_FCNTL_DATA_VERSION = 35; + +const int SQLITE_FCNTL_FILE_POINTER = 7; + +const int SQLITE_FCNTL_GET_LOCKPROXYFILE = 2; + +const int SQLITE_FCNTL_HAS_MOVED = 20; + +const int SQLITE_FCNTL_JOURNAL_POINTER = 28; + +const int SQLITE_FCNTL_LAST_ERRNO = 4; + +const int SQLITE_FCNTL_LOCKSTATE = 1; + +const int SQLITE_FCNTL_LOCK_TIMEOUT = 34; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xInst; +const int SQLITE_FCNTL_MMAP_SIZE = 18; - external ffi.Pointer< - ffi.NativeFunction)> - > - xRowid; +const int SQLITE_FCNTL_OVERWRITE = 11; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer>, - ffi.Pointer, - ) - > - > - xColumnText; +const int SQLITE_FCNTL_PDB = 30; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Pointer) - > - > - xColumnSize; +const int SQLITE_FCNTL_PERSIST_WAL = 10; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >, - ) - > - > - xQueryPhrase; +const int SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer< - ffi.NativeFunction)> - >, - ) - > - > - xSetAuxdata; +const int SQLITE_FCNTL_PRAGMA = 14; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function(ffi.Pointer, ffi.Int) - > - > - xGetAuxdata; +const int SQLITE_FCNTL_RBU = 26; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xPhraseFirst; +const int SQLITE_FCNTL_RESERVE_BYTES = 38; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xPhraseNext; +const int SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xPhraseFirstColumn; +const int SQLITE_FCNTL_SET_LOCKPROXYFILE = 3; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - > - xPhraseNextColumn; -} +const int SQLITE_FCNTL_SIZE_HINT = 5; -typedef fts5_extension_functionFunction = - ffi.Void Function( - ffi.Pointer pApi, - ffi.Pointer pFts, - ffi.Pointer pCtx, - ffi.Int nVal, - ffi.Pointer> apVal, - ); -typedef Dartfts5_extension_functionFunction = - void Function( - ffi.Pointer pApi, - ffi.Pointer pFts, - ffi.Pointer pCtx, - int nVal, - ffi.Pointer> apVal, - ); -typedef fts5_extension_function = - ffi.Pointer>; +const int SQLITE_FCNTL_SIZE_LIMIT = 36; -final class Fts5Tokenizer extends ffi.Opaque {} +const int SQLITE_FCNTL_SYNC = 21; -final class fts5_tokenizer extends ffi.Struct { - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer>, - ffi.Int, - ffi.Pointer>, - ) - > - > - xCreate; +const int SQLITE_FCNTL_SYNC_OMITTED = 8; - external ffi.Pointer< - ffi.NativeFunction)> - > - xDelete; +const int SQLITE_FCNTL_TEMPFILENAME = 16; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer, - ffi.Int, - ffi.Pointer, - ffi.Int, - ffi.Int, - ffi.Int, - ) - > - >, - ) - > - > - xTokenize; -} +const int SQLITE_FCNTL_TRACE = 19; -final class fts5_api extends ffi.Struct { - /// Currently always set to 2 - @ffi.Int() - external int iVersion; +const int SQLITE_FCNTL_VFSNAME = 12; - /// Create a new tokenizer - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer pApi, - ffi.Pointer zName, - ffi.Pointer pContext, - ffi.Pointer pTokenizer, - ffi.Pointer< - ffi.NativeFunction)> - > - xDestroy, - ) - > - > - xCreateTokenizer; +const int SQLITE_FCNTL_VFS_POINTER = 27; - /// Find an existing tokenizer - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer pApi, - ffi.Pointer zName, - ffi.Pointer> ppContext, - ffi.Pointer pTokenizer, - ) - > - > - xFindTokenizer; +const int SQLITE_FCNTL_WAL_BLOCK = 24; - /// Create a new auxiliary function - external ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer pApi, - ffi.Pointer zName, - ffi.Pointer pContext, - fts5_extension_function xFunction, - ffi.Pointer< - ffi.NativeFunction)> - > - xDestroy, - ) - > - > - xCreateFunction; -} +const int SQLITE_FCNTL_WIN32_AV_RETRY = 9; -const String SQLITE_VERSION = '3.32.3'; +const int SQLITE_FCNTL_WIN32_GET_HANDLE = 29; -const int SQLITE_VERSION_NUMBER = 3032003; +const int SQLITE_FCNTL_WIN32_SET_HANDLE = 23; -const String SQLITE_SOURCE_ID = - '2020-06-18 14:00:33 7ebdfa80be8e8e73324b8d66b3460222eb74c7e9dfd655b48d6ca7e1933cc8fd'; +const int SQLITE_FCNTL_ZIPVFS = 25; -const int SQLITE_OK = 0; +const int SQLITE_FLOAT = 2; -const int SQLITE_ERROR = 1; +const int SQLITE_FORMAT = 24; -const int SQLITE_INTERNAL = 2; +const int SQLITE_FULL = 13; -const int SQLITE_PERM = 3; +const int SQLITE_FUNCTION = 31; -const int SQLITE_ABORT = 4; +const int SQLITE_GET_LOCKPROXYFILE = 2; -const int SQLITE_BUSY = 5; +const int SQLITE_IGNORE = 2; -const int SQLITE_LOCKED = 6; +const int SQLITE_INDEX_CONSTRAINT_EQ = 2; -const int SQLITE_NOMEM = 7; +const int SQLITE_INDEX_CONSTRAINT_FUNCTION = 150; -const int SQLITE_READONLY = 8; +const int SQLITE_INDEX_CONSTRAINT_GE = 32; -const int SQLITE_INTERRUPT = 9; +const int SQLITE_INDEX_CONSTRAINT_GLOB = 66; -const int SQLITE_IOERR = 10; +const int SQLITE_INDEX_CONSTRAINT_GT = 4; -const int SQLITE_CORRUPT = 11; +const int SQLITE_INDEX_CONSTRAINT_IS = 72; -const int SQLITE_NOTFOUND = 12; +const int SQLITE_INDEX_CONSTRAINT_ISNOT = 69; -const int SQLITE_FULL = 13; +const int SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70; -const int SQLITE_CANTOPEN = 14; +const int SQLITE_INDEX_CONSTRAINT_ISNULL = 71; -const int SQLITE_PROTOCOL = 15; +const int SQLITE_INDEX_CONSTRAINT_LE = 8; -const int SQLITE_EMPTY = 16; +const int SQLITE_INDEX_CONSTRAINT_LIKE = 65; -const int SQLITE_SCHEMA = 17; +const int SQLITE_INDEX_CONSTRAINT_LT = 16; -const int SQLITE_TOOBIG = 18; +const int SQLITE_INDEX_CONSTRAINT_MATCH = 64; -const int SQLITE_CONSTRAINT = 19; +const int SQLITE_INDEX_CONSTRAINT_NE = 68; -const int SQLITE_MISMATCH = 20; +const int SQLITE_INDEX_CONSTRAINT_REGEXP = 67; -const int SQLITE_MISUSE = 21; +const int SQLITE_INDEX_SCAN_UNIQUE = 1; -const int SQLITE_NOLFS = 22; +const int SQLITE_INNOCUOUS = 2097152; -const int SQLITE_AUTH = 23; +const int SQLITE_INSERT = 18; -const int SQLITE_FORMAT = 24; +const int SQLITE_INTEGER = 1; -const int SQLITE_RANGE = 25; +const int SQLITE_INTERNAL = 2; -const int SQLITE_NOTADB = 26; +const int SQLITE_INTERRUPT = 9; -const int SQLITE_NOTICE = 27; +const int SQLITE_IOCAP_ATOMIC = 1; -const int SQLITE_WARNING = 28; +const int SQLITE_IOCAP_ATOMIC16K = 64; -const int SQLITE_ROW = 100; +const int SQLITE_IOCAP_ATOMIC1K = 4; -const int SQLITE_DONE = 101; +const int SQLITE_IOCAP_ATOMIC2K = 8; -const int SQLITE_ERROR_MISSING_COLLSEQ = 257; +const int SQLITE_IOCAP_ATOMIC32K = 128; -const int SQLITE_ERROR_RETRY = 513; +const int SQLITE_IOCAP_ATOMIC4K = 16; -const int SQLITE_ERROR_SNAPSHOT = 769; +const int SQLITE_IOCAP_ATOMIC512 = 2; -const int SQLITE_IOERR_READ = 266; +const int SQLITE_IOCAP_ATOMIC64K = 256; -const int SQLITE_IOERR_SHORT_READ = 522; +const int SQLITE_IOCAP_ATOMIC8K = 32; -const int SQLITE_IOERR_WRITE = 778; +const int SQLITE_IOCAP_BATCH_ATOMIC = 16384; -const int SQLITE_IOERR_FSYNC = 1034; +const int SQLITE_IOCAP_IMMUTABLE = 8192; -const int SQLITE_IOERR_DIR_FSYNC = 1290; +const int SQLITE_IOCAP_POWERSAFE_OVERWRITE = 4096; -const int SQLITE_IOERR_TRUNCATE = 1546; +const int SQLITE_IOCAP_SAFE_APPEND = 512; -const int SQLITE_IOERR_FSTAT = 1802; +const int SQLITE_IOCAP_SEQUENTIAL = 1024; -const int SQLITE_IOERR_UNLOCK = 2058; +const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 2048; -const int SQLITE_IOERR_RDLOCK = 2314; +const int SQLITE_IOERR = 10; -const int SQLITE_IOERR_DELETE = 2570; +const int SQLITE_IOERR_ACCESS = 3338; -const int SQLITE_IOERR_BLOCKED = 2826; +const int SQLITE_IOERR_AUTH = 7178; -const int SQLITE_IOERR_NOMEM = 3082; +const int SQLITE_IOERR_BEGIN_ATOMIC = 7434; -const int SQLITE_IOERR_ACCESS = 3338; +const int SQLITE_IOERR_BLOCKED = 2826; const int SQLITE_IOERR_CHECKRESERVEDLOCK = 3594; -const int SQLITE_IOERR_LOCK = 3850; - const int SQLITE_IOERR_CLOSE = 4106; -const int SQLITE_IOERR_DIR_CLOSE = 4362; +const int SQLITE_IOERR_COMMIT_ATOMIC = 7690; -const int SQLITE_IOERR_SHMOPEN = 4618; +const int SQLITE_IOERR_CONVPATH = 6666; -const int SQLITE_IOERR_SHMSIZE = 4874; +const int SQLITE_IOERR_DATA = 8202; -const int SQLITE_IOERR_SHMLOCK = 5130; +const int SQLITE_IOERR_DELETE = 2570; -const int SQLITE_IOERR_SHMMAP = 5386; +const int SQLITE_IOERR_DELETE_NOENT = 5898; -const int SQLITE_IOERR_SEEK = 5642; +const int SQLITE_IOERR_DIR_CLOSE = 4362; -const int SQLITE_IOERR_DELETE_NOENT = 5898; +const int SQLITE_IOERR_DIR_FSYNC = 1290; -const int SQLITE_IOERR_MMAP = 6154; +const int SQLITE_IOERR_FSTAT = 1802; + +const int SQLITE_IOERR_FSYNC = 1034; const int SQLITE_IOERR_GETTEMPPATH = 6410; -const int SQLITE_IOERR_CONVPATH = 6666; +const int SQLITE_IOERR_LOCK = 3850; -const int SQLITE_IOERR_VNODE = 6922; +const int SQLITE_IOERR_MMAP = 6154; -const int SQLITE_IOERR_AUTH = 7178; +const int SQLITE_IOERR_NOMEM = 3082; -const int SQLITE_IOERR_BEGIN_ATOMIC = 7434; +const int SQLITE_IOERR_RDLOCK = 2314; -const int SQLITE_IOERR_COMMIT_ATOMIC = 7690; +const int SQLITE_IOERR_READ = 266; const int SQLITE_IOERR_ROLLBACK_ATOMIC = 7946; -const int SQLITE_IOERR_DATA = 8202; - -const int SQLITE_LOCKED_SHAREDCACHE = 262; - -const int SQLITE_LOCKED_VTAB = 518; +const int SQLITE_IOERR_SEEK = 5642; -const int SQLITE_BUSY_RECOVERY = 261; +const int SQLITE_IOERR_SHMLOCK = 5130; -const int SQLITE_BUSY_SNAPSHOT = 517; +const int SQLITE_IOERR_SHMMAP = 5386; -const int SQLITE_BUSY_TIMEOUT = 773; +const int SQLITE_IOERR_SHMOPEN = 4618; -const int SQLITE_CANTOPEN_NOTEMPDIR = 270; +const int SQLITE_IOERR_SHMSIZE = 4874; -const int SQLITE_CANTOPEN_ISDIR = 526; +const int SQLITE_IOERR_SHORT_READ = 522; -const int SQLITE_CANTOPEN_FULLPATH = 782; +const int SQLITE_IOERR_TRUNCATE = 1546; -const int SQLITE_CANTOPEN_CONVPATH = 1038; +const int SQLITE_IOERR_UNLOCK = 2058; -const int SQLITE_CANTOPEN_DIRTYWAL = 1294; +const int SQLITE_IOERR_VNODE = 6922; -const int SQLITE_CANTOPEN_SYMLINK = 1550; +const int SQLITE_IOERR_WRITE = 778; -const int SQLITE_CORRUPT_VTAB = 267; +const int SQLITE_LAST_ERRNO = 4; -const int SQLITE_CORRUPT_SEQUENCE = 523; +const int SQLITE_LIMIT_ATTACHED = 7; -const int SQLITE_CORRUPT_INDEX = 779; +const int SQLITE_LIMIT_COLUMN = 2; -const int SQLITE_READONLY_RECOVERY = 264; +const int SQLITE_LIMIT_COMPOUND_SELECT = 4; -const int SQLITE_READONLY_CANTLOCK = 520; +const int SQLITE_LIMIT_EXPR_DEPTH = 3; -const int SQLITE_READONLY_ROLLBACK = 776; +const int SQLITE_LIMIT_FUNCTION_ARG = 6; -const int SQLITE_READONLY_DBMOVED = 1032; +const int SQLITE_LIMIT_LENGTH = 0; -const int SQLITE_READONLY_CANTINIT = 1288; +const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8; -const int SQLITE_READONLY_DIRECTORY = 1544; +const int SQLITE_LIMIT_SQL_LENGTH = 1; -const int SQLITE_ABORT_ROLLBACK = 516; +const int SQLITE_LIMIT_TRIGGER_DEPTH = 10; -const int SQLITE_CONSTRAINT_CHECK = 275; +const int SQLITE_LIMIT_VARIABLE_NUMBER = 9; -const int SQLITE_CONSTRAINT_COMMITHOOK = 531; +const int SQLITE_LIMIT_VDBE_OP = 5; -const int SQLITE_CONSTRAINT_FOREIGNKEY = 787; +const int SQLITE_LIMIT_WORKER_THREADS = 11; -const int SQLITE_CONSTRAINT_FUNCTION = 1043; +const int SQLITE_LOCKED = 6; -const int SQLITE_CONSTRAINT_NOTNULL = 1299; +const int SQLITE_LOCKED_SHAREDCACHE = 262; -const int SQLITE_CONSTRAINT_PRIMARYKEY = 1555; +const int SQLITE_LOCKED_VTAB = 518; -const int SQLITE_CONSTRAINT_TRIGGER = 1811; +const int SQLITE_LOCK_EXCLUSIVE = 4; -const int SQLITE_CONSTRAINT_UNIQUE = 2067; +const int SQLITE_LOCK_NONE = 0; -const int SQLITE_CONSTRAINT_VTAB = 2323; +const int SQLITE_LOCK_PENDING = 3; -const int SQLITE_CONSTRAINT_ROWID = 2579; +const int SQLITE_LOCK_RESERVED = 2; -const int SQLITE_CONSTRAINT_PINNED = 2835; +const int SQLITE_LOCK_SHARED = 1; -const int SQLITE_NOTICE_RECOVER_WAL = 283; +const int SQLITE_MISMATCH = 20; -const int SQLITE_NOTICE_RECOVER_ROLLBACK = 539; +const int SQLITE_MISUSE = 21; -const int SQLITE_WARNING_AUTOINDEX = 284; +const int SQLITE_MUTEX_FAST = 0; -const int SQLITE_AUTH_USER = 279; +const int SQLITE_MUTEX_RECURSIVE = 1; -const int SQLITE_OK_LOAD_PERMANENTLY = 256; +const int SQLITE_MUTEX_STATIC_APP1 = 8; -const int SQLITE_OK_SYMLINK = 512; +const int SQLITE_MUTEX_STATIC_APP2 = 9; -const int SQLITE_OPEN_READONLY = 1; +const int SQLITE_MUTEX_STATIC_APP3 = 10; -const int SQLITE_OPEN_READWRITE = 2; +const int SQLITE_MUTEX_STATIC_LRU = 6; -const int SQLITE_OPEN_CREATE = 4; +const int SQLITE_MUTEX_STATIC_LRU2 = 7; -const int SQLITE_OPEN_DELETEONCLOSE = 8; +const int SQLITE_MUTEX_STATIC_MASTER = 2; -const int SQLITE_OPEN_EXCLUSIVE = 16; +const int SQLITE_MUTEX_STATIC_MEM = 3; -const int SQLITE_OPEN_AUTOPROXY = 32; +const int SQLITE_MUTEX_STATIC_MEM2 = 4; -const int SQLITE_OPEN_URI = 64; +const int SQLITE_MUTEX_STATIC_OPEN = 4; -const int SQLITE_OPEN_MEMORY = 128; +const int SQLITE_MUTEX_STATIC_PMEM = 7; -const int SQLITE_OPEN_MAIN_DB = 256; +const int SQLITE_MUTEX_STATIC_PRNG = 5; -const int SQLITE_OPEN_TEMP_DB = 512; +const int SQLITE_MUTEX_STATIC_VFS1 = 11; -const int SQLITE_OPEN_TRANSIENT_DB = 1024; +const int SQLITE_MUTEX_STATIC_VFS2 = 12; -const int SQLITE_OPEN_MAIN_JOURNAL = 2048; +const int SQLITE_MUTEX_STATIC_VFS3 = 13; -const int SQLITE_OPEN_TEMP_JOURNAL = 4096; +const int SQLITE_NOLFS = 22; -const int SQLITE_OPEN_SUBJOURNAL = 8192; +const int SQLITE_NOMEM = 7; -const int SQLITE_OPEN_MASTER_JOURNAL = 16384; +const int SQLITE_NOTADB = 26; -const int SQLITE_OPEN_NOMUTEX = 32768; +const int SQLITE_NOTFOUND = 12; -const int SQLITE_OPEN_FULLMUTEX = 65536; +const int SQLITE_NOTICE = 27; -const int SQLITE_OPEN_SHAREDCACHE = 131072; +const int SQLITE_NOTICE_RECOVER_ROLLBACK = 539; -const int SQLITE_OPEN_PRIVATECACHE = 262144; +const int SQLITE_NOTICE_RECOVER_WAL = 283; -const int SQLITE_OPEN_WAL = 524288; +const int SQLITE_NULL = 5; -const int SQLITE_OPEN_NOFOLLOW = 16777216; +const int SQLITE_OK = 0; -const int SQLITE_IOCAP_ATOMIC = 1; +const int SQLITE_OK_LOAD_PERMANENTLY = 256; -const int SQLITE_IOCAP_ATOMIC512 = 2; +const int SQLITE_OK_SYMLINK = 512; -const int SQLITE_IOCAP_ATOMIC1K = 4; +const int SQLITE_OPEN_AUTOPROXY = 32; -const int SQLITE_IOCAP_ATOMIC2K = 8; +const int SQLITE_OPEN_CREATE = 4; -const int SQLITE_IOCAP_ATOMIC4K = 16; +const int SQLITE_OPEN_DELETEONCLOSE = 8; -const int SQLITE_IOCAP_ATOMIC8K = 32; +const int SQLITE_OPEN_EXCLUSIVE = 16; -const int SQLITE_IOCAP_ATOMIC16K = 64; +const int SQLITE_OPEN_FULLMUTEX = 65536; -const int SQLITE_IOCAP_ATOMIC32K = 128; +const int SQLITE_OPEN_MAIN_DB = 256; -const int SQLITE_IOCAP_ATOMIC64K = 256; +const int SQLITE_OPEN_MAIN_JOURNAL = 2048; -const int SQLITE_IOCAP_SAFE_APPEND = 512; +const int SQLITE_OPEN_MASTER_JOURNAL = 16384; -const int SQLITE_IOCAP_SEQUENTIAL = 1024; +const int SQLITE_OPEN_MEMORY = 128; -const int SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 2048; +const int SQLITE_OPEN_NOFOLLOW = 16777216; -const int SQLITE_IOCAP_POWERSAFE_OVERWRITE = 4096; +const int SQLITE_OPEN_NOMUTEX = 32768; -const int SQLITE_IOCAP_IMMUTABLE = 8192; +const int SQLITE_OPEN_PRIVATECACHE = 262144; -const int SQLITE_IOCAP_BATCH_ATOMIC = 16384; +const int SQLITE_OPEN_READONLY = 1; -const int SQLITE_LOCK_NONE = 0; +const int SQLITE_OPEN_READWRITE = 2; -const int SQLITE_LOCK_SHARED = 1; +const int SQLITE_OPEN_SHAREDCACHE = 131072; -const int SQLITE_LOCK_RESERVED = 2; +const int SQLITE_OPEN_SUBJOURNAL = 8192; -const int SQLITE_LOCK_PENDING = 3; +const int SQLITE_OPEN_TEMP_DB = 512; -const int SQLITE_LOCK_EXCLUSIVE = 4; +const int SQLITE_OPEN_TEMP_JOURNAL = 4096; -const int SQLITE_SYNC_NORMAL = 2; +const int SQLITE_OPEN_TRANSIENT_DB = 1024; -const int SQLITE_SYNC_FULL = 3; +const int SQLITE_OPEN_URI = 64; -const int SQLITE_SYNC_DATAONLY = 16; +const int SQLITE_OPEN_WAL = 524288; -const int SQLITE_FCNTL_LOCKSTATE = 1; +const int SQLITE_PERM = 3; -const int SQLITE_FCNTL_GET_LOCKPROXYFILE = 2; +const int SQLITE_PRAGMA = 19; -const int SQLITE_FCNTL_SET_LOCKPROXYFILE = 3; +const int SQLITE_PREPARE_NORMALIZE = 2; -const int SQLITE_FCNTL_LAST_ERRNO = 4; +const int SQLITE_PREPARE_NO_VTAB = 4; -const int SQLITE_FCNTL_SIZE_HINT = 5; +const int SQLITE_PREPARE_PERSISTENT = 1; -const int SQLITE_FCNTL_CHUNK_SIZE = 6; +const int SQLITE_PROTOCOL = 15; -const int SQLITE_FCNTL_FILE_POINTER = 7; +const int SQLITE_RANGE = 25; -const int SQLITE_FCNTL_SYNC_OMITTED = 8; +const int SQLITE_READ = 20; -const int SQLITE_FCNTL_WIN32_AV_RETRY = 9; +const int SQLITE_READONLY = 8; -const int SQLITE_FCNTL_PERSIST_WAL = 10; +const int SQLITE_READONLY_CANTINIT = 1288; -const int SQLITE_FCNTL_OVERWRITE = 11; +const int SQLITE_READONLY_CANTLOCK = 520; -const int SQLITE_FCNTL_VFSNAME = 12; +const int SQLITE_READONLY_DBMOVED = 1032; -const int SQLITE_FCNTL_POWERSAFE_OVERWRITE = 13; +const int SQLITE_READONLY_DIRECTORY = 1544; -const int SQLITE_FCNTL_PRAGMA = 14; +const int SQLITE_READONLY_RECOVERY = 264; -const int SQLITE_FCNTL_BUSYHANDLER = 15; +const int SQLITE_READONLY_ROLLBACK = 776; -const int SQLITE_FCNTL_TEMPFILENAME = 16; +const int SQLITE_RECURSIVE = 33; -const int SQLITE_FCNTL_MMAP_SIZE = 18; +const int SQLITE_REINDEX = 27; -const int SQLITE_FCNTL_TRACE = 19; +const int SQLITE_REPLACE = 5; -const int SQLITE_FCNTL_HAS_MOVED = 20; +const int SQLITE_ROLLBACK = 1; -const int SQLITE_FCNTL_SYNC = 21; +const int SQLITE_ROW = 100; -const int SQLITE_FCNTL_COMMIT_PHASETWO = 22; +const int SQLITE_SAVEPOINT = 32; -const int SQLITE_FCNTL_WIN32_SET_HANDLE = 23; +const int SQLITE_SCANSTAT_EST = 2; -const int SQLITE_FCNTL_WAL_BLOCK = 24; +const int SQLITE_SCANSTAT_EXPLAIN = 4; -const int SQLITE_FCNTL_ZIPVFS = 25; +const int SQLITE_SCANSTAT_NAME = 3; -const int SQLITE_FCNTL_RBU = 26; +const int SQLITE_SCANSTAT_NLOOP = 0; -const int SQLITE_FCNTL_VFS_POINTER = 27; +const int SQLITE_SCANSTAT_NVISIT = 1; -const int SQLITE_FCNTL_JOURNAL_POINTER = 28; +const int SQLITE_SCANSTAT_SELECTID = 5; -const int SQLITE_FCNTL_WIN32_GET_HANDLE = 29; +const int SQLITE_SCHEMA = 17; -const int SQLITE_FCNTL_PDB = 30; +const int SQLITE_SELECT = 21; -const int SQLITE_FCNTL_BEGIN_ATOMIC_WRITE = 31; +const int SQLITE_SERIALIZE_NOCOPY = 1; -const int SQLITE_FCNTL_COMMIT_ATOMIC_WRITE = 32; +const int SQLITE_SET_LOCKPROXYFILE = 3; -const int SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE = 33; +const int SQLITE_SHM_EXCLUSIVE = 8; -const int SQLITE_FCNTL_LOCK_TIMEOUT = 34; +const int SQLITE_SHM_LOCK = 2; -const int SQLITE_FCNTL_DATA_VERSION = 35; +const int SQLITE_SHM_NLOCK = 8; -const int SQLITE_FCNTL_SIZE_LIMIT = 36; +const int SQLITE_SHM_SHARED = 4; -const int SQLITE_FCNTL_CKPT_DONE = 37; +const int SQLITE_SHM_UNLOCK = 1; -const int SQLITE_FCNTL_RESERVE_BYTES = 38; +const String SQLITE_SOURCE_ID = + '2020-06-18 14:00:33 7ebdfa80be8e8e73324b8d66b3460222eb74c7e9dfd655b48d6ca7e1933cc8fd'; -const int SQLITE_FCNTL_CKPT_START = 39; +const int SQLITE_STATUS_MALLOC_COUNT = 9; -const int SQLITE_GET_LOCKPROXYFILE = 2; +const int SQLITE_STATUS_MALLOC_SIZE = 5; -const int SQLITE_SET_LOCKPROXYFILE = 3; +const int SQLITE_STATUS_MEMORY_USED = 0; -const int SQLITE_LAST_ERRNO = 4; +const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2; -const int SQLITE_ACCESS_EXISTS = 0; +const int SQLITE_STATUS_PAGECACHE_SIZE = 7; -const int SQLITE_ACCESS_READWRITE = 1; +const int SQLITE_STATUS_PAGECACHE_USED = 1; -const int SQLITE_ACCESS_READ = 2; +const int SQLITE_STATUS_PARSER_STACK = 6; -const int SQLITE_SHM_UNLOCK = 1; +const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4; -const int SQLITE_SHM_LOCK = 2; +const int SQLITE_STATUS_SCRATCH_SIZE = 8; -const int SQLITE_SHM_SHARED = 4; +const int SQLITE_STATUS_SCRATCH_USED = 3; -const int SQLITE_SHM_EXCLUSIVE = 8; +const int SQLITE_STMTSTATUS_AUTOINDEX = 3; -const int SQLITE_SHM_NLOCK = 8; +const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1; -const int SQLITE_CONFIG_SINGLETHREAD = 1; +const int SQLITE_STMTSTATUS_MEMUSED = 99; -const int SQLITE_CONFIG_MULTITHREAD = 2; +const int SQLITE_STMTSTATUS_REPREPARE = 5; -const int SQLITE_CONFIG_SERIALIZED = 3; +const int SQLITE_STMTSTATUS_RUN = 6; -const int SQLITE_CONFIG_MALLOC = 4; +const int SQLITE_STMTSTATUS_SORT = 2; -const int SQLITE_CONFIG_GETMALLOC = 5; +const int SQLITE_STMTSTATUS_VM_STEP = 4; -const int SQLITE_CONFIG_SCRATCH = 6; +const int SQLITE_SUBTYPE = 1048576; -const int SQLITE_CONFIG_PAGECACHE = 7; +const int SQLITE_SYNC_DATAONLY = 16; -const int SQLITE_CONFIG_HEAP = 8; +const int SQLITE_SYNC_FULL = 3; -const int SQLITE_CONFIG_MEMSTATUS = 9; +const int SQLITE_SYNC_NORMAL = 2; -const int SQLITE_CONFIG_MUTEX = 10; +const int SQLITE_TESTCTRL_ALWAYS = 13; -const int SQLITE_CONFIG_GETMUTEX = 11; +const int SQLITE_TESTCTRL_ASSERT = 12; -const int SQLITE_CONFIG_LOOKASIDE = 13; +const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10; -const int SQLITE_CONFIG_PCACHE = 14; +const int SQLITE_TESTCTRL_BITVEC_TEST = 8; -const int SQLITE_CONFIG_GETPCACHE = 15; +const int SQLITE_TESTCTRL_BYTEORDER = 22; -const int SQLITE_CONFIG_LOG = 16; +const int SQLITE_TESTCTRL_EXPLAIN_STMT = 19; -const int SQLITE_CONFIG_URI = 17; +const int SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29; -const int SQLITE_CONFIG_PCACHE2 = 18; +const int SQLITE_TESTCTRL_FAULT_INSTALL = 9; -const int SQLITE_CONFIG_GETPCACHE2 = 19; +const int SQLITE_TESTCTRL_FIRST = 5; -const int SQLITE_CONFIG_COVERING_INDEX_SCAN = 20; +const int SQLITE_TESTCTRL_IMPOSTER = 25; -const int SQLITE_CONFIG_SQLLOG = 21; +const int SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17; -const int SQLITE_CONFIG_MMAP_SIZE = 22; +const int SQLITE_TESTCTRL_ISINIT = 23; -const int SQLITE_CONFIG_WIN32_HEAPSIZE = 23; +const int SQLITE_TESTCTRL_ISKEYWORD = 16; -const int SQLITE_CONFIG_PCACHE_HDRSZ = 24; +const int SQLITE_TESTCTRL_LAST = 29; -const int SQLITE_CONFIG_PMASZ = 25; +const int SQLITE_TESTCTRL_LOCALTIME_FAULT = 18; -const int SQLITE_CONFIG_STMTJRNL_SPILL = 26; +const int SQLITE_TESTCTRL_NEVER_CORRUPT = 20; -const int SQLITE_CONFIG_SMALL_MALLOC = 27; +const int SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19; -const int SQLITE_CONFIG_SORTERREF_SIZE = 28; +const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15; -const int SQLITE_CONFIG_MEMDB_MAXSIZE = 29; +const int SQLITE_TESTCTRL_PARSER_COVERAGE = 26; -const int SQLITE_DBCONFIG_MAINDBNAME = 1000; +const int SQLITE_TESTCTRL_PENDING_BYTE = 11; -const int SQLITE_DBCONFIG_LOOKASIDE = 1001; +const int SQLITE_TESTCTRL_PRNG_RESET = 7; -const int SQLITE_DBCONFIG_ENABLE_FKEY = 1002; +const int SQLITE_TESTCTRL_PRNG_RESTORE = 6; -const int SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003; +const int SQLITE_TESTCTRL_PRNG_SAVE = 5; -const int SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004; +const int SQLITE_TESTCTRL_PRNG_SEED = 28; -const int SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005; +const int SQLITE_TESTCTRL_RESERVE = 14; -const int SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE = 1006; +const int SQLITE_TESTCTRL_RESULT_INTREAL = 27; -const int SQLITE_DBCONFIG_ENABLE_QPSG = 1007; +const int SQLITE_TESTCTRL_SCRATCHMALLOC = 17; -const int SQLITE_DBCONFIG_TRIGGER_EQP = 1008; +const int SQLITE_TESTCTRL_SORTER_MMAP = 24; -const int SQLITE_DBCONFIG_RESET_DATABASE = 1009; +const int SQLITE_TESTCTRL_VDBE_COVERAGE = 21; -const int SQLITE_DBCONFIG_DEFENSIVE = 1010; +const int SQLITE_TEXT = 3; -const int SQLITE_DBCONFIG_WRITABLE_SCHEMA = 1011; +const int SQLITE_TOOBIG = 18; -const int SQLITE_DBCONFIG_LEGACY_ALTER_TABLE = 1012; +const int SQLITE_TRACE_CLOSE = 8; -const int SQLITE_DBCONFIG_DQS_DML = 1013; +const int SQLITE_TRACE_PROFILE = 2; -const int SQLITE_DBCONFIG_DQS_DDL = 1014; +const int SQLITE_TRACE_ROW = 4; -const int SQLITE_DBCONFIG_ENABLE_VIEW = 1015; +const int SQLITE_TRACE_STMT = 1; -const int SQLITE_DBCONFIG_LEGACY_FILE_FORMAT = 1016; +const int SQLITE_TRANSACTION = 22; -const int SQLITE_DBCONFIG_TRUSTED_SCHEMA = 1017; +const int SQLITE_UPDATE = 23; -const int SQLITE_DBCONFIG_MAX = 1017; +const int SQLITE_UTF16 = 4; -const int SQLITE_DENY = 1; +const int SQLITE_UTF16BE = 3; -const int SQLITE_IGNORE = 2; +const int SQLITE_UTF16LE = 2; -const int SQLITE_CREATE_INDEX = 1; +const int SQLITE_UTF16_ALIGNED = 8; -const int SQLITE_CREATE_TABLE = 2; +const int SQLITE_UTF8 = 1; -const int SQLITE_CREATE_TEMP_INDEX = 3; +const String SQLITE_VERSION = '3.32.3'; -const int SQLITE_CREATE_TEMP_TABLE = 4; +const int SQLITE_VERSION_NUMBER = 3032003; -const int SQLITE_CREATE_TEMP_TRIGGER = 5; +const int SQLITE_VTAB_CONSTRAINT_SUPPORT = 1; -const int SQLITE_CREATE_TEMP_VIEW = 6; +const int SQLITE_VTAB_DIRECTONLY = 3; -const int SQLITE_CREATE_TRIGGER = 7; +const int SQLITE_VTAB_INNOCUOUS = 2; -const int SQLITE_CREATE_VIEW = 8; +const int SQLITE_WARNING = 28; -const int SQLITE_DELETE = 9; +const int SQLITE_WARNING_AUTOINDEX = 284; -const int SQLITE_DROP_INDEX = 10; +const int SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1; -const int SQLITE_DROP_TABLE = 11; +const int SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2; -const int SQLITE_DROP_TEMP_INDEX = 12; +final class fts5_api extends ffi.Struct { + /// Currently always set to 2 + @ffi.Int() + external int iVersion; -const int SQLITE_DROP_TEMP_TABLE = 13; + /// Create a new tokenizer + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pApi, + ffi.Pointer zName, + ffi.Pointer pContext, + ffi.Pointer pTokenizer, + ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy, + ) + > + > + xCreateTokenizer; -const int SQLITE_DROP_TEMP_TRIGGER = 14; + /// Find an existing tokenizer + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pApi, + ffi.Pointer zName, + ffi.Pointer> ppContext, + ffi.Pointer pTokenizer, + ) + > + > + xFindTokenizer; -const int SQLITE_DROP_TEMP_VIEW = 15; + /// Create a new auxiliary function + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pApi, + ffi.Pointer zName, + ffi.Pointer pContext, + fts5_extension_function xFunction, + ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy, + ) + > + > + xCreateFunction; -const int SQLITE_DROP_TRIGGER = 16; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iVersion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pApi, + ffi.Pointer zName, + ffi.Pointer pContext, + ffi.Pointer pTokenizer, + ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy, + ) + > + > + xCreateTokenizer, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pApi, + ffi.Pointer zName, + ffi.Pointer> ppContext, + ffi.Pointer pTokenizer, + ) + > + > + xFindTokenizer, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pApi, + ffi.Pointer zName, + ffi.Pointer pContext, + fts5_extension_function xFunction, + ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy, + ) + > + > + xCreateFunction, + }) => $allocator() + ..ref.iVersion = iVersion + ..ref.xCreateTokenizer = xCreateTokenizer + ..ref.xFindTokenizer = xFindTokenizer + ..ref.xCreateFunction = xCreateFunction; +} -const int SQLITE_DROP_VIEW = 17; +typedef fts5_extension_function = + ffi.Pointer>; +typedef fts5_extension_functionFunction = + ffi.Void Function( + ffi.Pointer pApi, + ffi.Pointer pFts, + ffi.Pointer pCtx, + ffi.Int nVal, + ffi.Pointer> apVal, + ); +typedef Dartfts5_extension_functionFunction = + void Function( + ffi.Pointer pApi, + ffi.Pointer pFts, + ffi.Pointer pCtx, + int nVal, + ffi.Pointer> apVal, + ); -const int SQLITE_INSERT = 18; +final class fts5_tokenizer extends ffi.Struct { + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer>, + ) + > + > + xCreate; -const int SQLITE_PRAGMA = 19; + external ffi.Pointer< + ffi.NativeFunction)> + > + xDelete; -const int SQLITE_READ = 20; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Int, + ) + > + >, + ) + > + > + xTokenize; -const int SQLITE_SELECT = 21; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer>, + ffi.Int, + ffi.Pointer>, + ) + > + > + xCreate, + required ffi.Pointer< + ffi.NativeFunction)> + > + xDelete, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Int, + ) + > + >, + ) + > + > + xTokenize, + }) => $allocator() + ..ref.xCreate = xCreate + ..ref.xDelete = xDelete + ..ref.xTokenize = xTokenize; +} -const int SQLITE_TRANSACTION = 22; +final class sqlite3 extends ffi.Opaque {} -const int SQLITE_UPDATE = 23; +final class sqlite3_api_routines extends ffi.Opaque {} -const int SQLITE_ATTACH = 24; +final class sqlite3_backup extends ffi.Opaque {} -const int SQLITE_DETACH = 25; +final class sqlite3_blob extends ffi.Opaque {} -const int SQLITE_ALTER_TABLE = 26; +/// The type for a callback function. +/// This is legacy and deprecated. It is included for historical +/// compatibility and is not documented. +typedef sqlite3_callback = + ffi.Pointer>; +typedef sqlite3_callbackFunction = + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ); +typedef Dartsqlite3_callbackFunction = + int Function( + ffi.Pointer, + int, + ffi.Pointer>, + ffi.Pointer>, + ); -const int SQLITE_REINDEX = 27; +final class sqlite3_context extends ffi.Opaque {} -const int SQLITE_ANALYZE = 28; +/// CAPI3REF: Constants Defining Special Destructor Behavior +/// +/// These are special values for the destructor that is passed in as the +/// final argument to routines like [sqlite3_result_blob()]. ^If the destructor +/// argument is SQLITE_STATIC, it means that the content pointer is constant +/// and will never change. It does not need to be destroyed. ^The +/// SQLITE_TRANSIENT value means that the content will likely change in +/// the near future and that SQLite should make its own private copy of +/// the content before returning. +/// +/// The typedef is necessary to work around problems in certain +/// C++ compilers. +typedef sqlite3_destructor_type = + ffi.Pointer>; +typedef sqlite3_destructor_typeFunction = + ffi.Void Function(ffi.Pointer); +typedef Dartsqlite3_destructor_typeFunction = + void Function(ffi.Pointer); -const int SQLITE_CREATE_VTABLE = 29; +final class sqlite3_file extends ffi.Struct { + /// Methods for an open file + external ffi.Pointer pMethods; -const int SQLITE_DROP_VTABLE = 30; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pMethods, + }) => $allocator()..ref.pMethods = pMethods; +} -const int SQLITE_FUNCTION = 31; +final class sqlite3_index_constraint extends ffi.Struct { + /// Column constrained. -1 for ROWID + @ffi.Int() + external int iColumn; -const int SQLITE_SAVEPOINT = 32; + /// Constraint operator + @ffi.UnsignedChar() + external int op; -const int SQLITE_COPY = 0; + /// True if this constraint is usable + @ffi.UnsignedChar() + external int usable; -const int SQLITE_RECURSIVE = 33; + /// Used internally - xBestIndex should ignore + @ffi.Int() + external int iTermOffset; -const int SQLITE_TRACE_STMT = 1; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iColumn, + required int op, + required int usable, + required int iTermOffset, + }) => $allocator() + ..ref.iColumn = iColumn + ..ref.op = op + ..ref.usable = usable + ..ref.iTermOffset = iTermOffset; +} -const int SQLITE_TRACE_PROFILE = 2; +/// Outputs +final class sqlite3_index_constraint_usage extends ffi.Struct { + /// if >0, constraint is part of argv to xFilter + @ffi.Int() + external int argvIndex; -const int SQLITE_TRACE_ROW = 4; + /// Do not code a test for this constraint + @ffi.UnsignedChar() + external int omit; -const int SQLITE_TRACE_CLOSE = 8; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int argvIndex, + required int omit, + }) => $allocator() + ..ref.argvIndex = argvIndex + ..ref.omit = omit; +} -const int SQLITE_LIMIT_LENGTH = 0; +/// CAPI3REF: Virtual Table Indexing Information +/// KEYWORDS: sqlite3_index_info +/// +/// The sqlite3_index_info structure and its substructures is used as part +/// of the [virtual table] interface to +/// pass information into and receive the reply from the [xBestIndex] +/// method of a [virtual table module]. The fields under **Inputs** are the +/// inputs to xBestIndex and are read-only. xBestIndex inserts its +/// results into the **Outputs** fields. +/// +/// ^(The aConstraint[] array records WHERE clause constraints of the form: +/// +///
    column OP expr
    +/// +/// where OP is =, <, <=, >, or >=.)^ ^(The particular operator is +/// stored in aConstraint[].op using one of the +/// [SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_ values].)^ +/// ^(The index of the column is stored in +/// aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the +/// expr on the right-hand side can be evaluated (and thus the constraint +/// is usable) and false if it cannot.)^ +/// +/// ^The optimizer automatically inverts terms of the form "expr OP column" +/// and makes other simplifications to the WHERE clause in an attempt to +/// get as many WHERE clause terms into the form shown above as possible. +/// ^The aConstraint[] array only reports WHERE clause terms that are +/// relevant to the particular virtual table being queried. +/// +/// ^Information about the ORDER BY clause is stored in aOrderBy[]. +/// ^Each term of aOrderBy records a column of the ORDER BY clause. +/// +/// The colUsed field indicates which columns of the virtual table may be +/// required by the current scan. Virtual table columns are numbered from +/// zero in the order in which they appear within the CREATE TABLE statement +/// passed to sqlite3_declare_vtab(). For the first 63 columns (columns 0-62), +/// the corresponding bit is set within the colUsed mask if the column may be +/// required by SQLite. If the table has at least 64 columns and any column +/// to the right of the first 63 is required, then bit 63 of colUsed is also +/// set. In other words, column iCol may be required if the expression +/// (colUsed & ((sqlite3_uint64)1 << (iCol>=63 ? 63 : iCol))) evaluates to +/// non-zero. +/// +/// The [xBestIndex] method must fill aConstraintUsage[] with information +/// about what parameters to pass to xFilter. ^If argvIndex>0 then +/// the right-hand side of the corresponding aConstraint[] is evaluated +/// and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit +/// is true, then the constraint is assumed to be fully handled by the +/// virtual table and might not be checked again by the byte code.)^ ^(The +/// aConstraintUsage[].omit flag is an optimization hint. When the omit flag +/// is left in its default setting of false, the constraint will always be +/// checked separately in byte code. If the omit flag is change to true, then +/// the constraint may or may not be checked in byte code. In other words, +/// when the omit flag is true there is no guarantee that the constraint will +/// not be checked again using byte code.)^ +/// +/// ^The idxNum and idxPtr values are recorded and passed into the +/// [xFilter] method. +/// ^[sqlite3_free()] is used to free idxPtr if and only if +/// needToFreeIdxPtr is true. +/// +/// ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in +/// the correct order to satisfy the ORDER BY clause so that no separate +/// sorting step is required. +/// +/// ^The estimatedCost value is an estimate of the cost of a particular +/// strategy. A cost of N indicates that the cost of the strategy is similar +/// to a linear scan of an SQLite table with N rows. A cost of log(N) +/// indicates that the expense of the operation is similar to that of a +/// binary search on a unique indexed field of an SQLite table with N rows. +/// +/// ^The estimatedRows value is an estimate of the number of rows that +/// will be returned by the strategy. +/// +/// The xBestIndex method may optionally populate the idxFlags field with a +/// mask of SQLITE_INDEX_SCAN_* flags. Currently there is only one such flag - +/// SQLITE_INDEX_SCAN_UNIQUE. If the xBestIndex method sets this flag, SQLite +/// assumes that the strategy may visit at most one row. +/// +/// Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then +/// SQLite also assumes that if a call to the xUpdate() method is made as +/// part of the same statement to delete or update a virtual table row and the +/// implementation returns SQLITE_CONSTRAINT, then there is no need to rollback +/// any database changes. In other words, if the xUpdate() returns +/// SQLITE_CONSTRAINT, the database contents must be exactly as they were +/// before xUpdate was called. By contrast, if SQLITE_INDEX_SCAN_UNIQUE is not +/// set and xUpdate returns SQLITE_CONSTRAINT, any database changes made by +/// the xUpdate method are automatically rolled back by SQLite. +/// +/// IMPORTANT: The estimatedRows field was added to the sqlite3_index_info +/// structure for SQLite [version 3.8.2] ([dateof:3.8.2]). +/// If a virtual table extension is +/// used with an SQLite version earlier than 3.8.2, the results of attempting +/// to read or write the estimatedRows field are undefined (but are likely +/// to include crashing the application). The estimatedRows field should +/// therefore only be used if [sqlite3_libversion_number()] returns a +/// value greater than or equal to 3008002. Similarly, the idxFlags field +/// was added for [version 3.9.0] ([dateof:3.9.0]). +/// It may therefore only be used if +/// sqlite3_libversion_number() returns a value greater than or equal to +/// 3009000. +final class sqlite3_index_info extends ffi.Struct { + /// Number of entries in aConstraint + @ffi.Int() + external int nConstraint; -const int SQLITE_LIMIT_SQL_LENGTH = 1; + /// Table of WHERE clause constraints + external ffi.Pointer aConstraint; -const int SQLITE_LIMIT_COLUMN = 2; + /// Number of terms in the ORDER BY clause + @ffi.Int() + external int nOrderBy; -const int SQLITE_LIMIT_EXPR_DEPTH = 3; + /// The ORDER BY clause + external ffi.Pointer aOrderBy; -const int SQLITE_LIMIT_COMPOUND_SELECT = 4; + external ffi.Pointer aConstraintUsage; -const int SQLITE_LIMIT_VDBE_OP = 5; + /// Number used to identify the index + @ffi.Int() + external int idxNum; -const int SQLITE_LIMIT_FUNCTION_ARG = 6; + /// String, possibly obtained from sqlite3_malloc + external ffi.Pointer idxStr; -const int SQLITE_LIMIT_ATTACHED = 7; + /// Free idxStr using sqlite3_free() if true + @ffi.Int() + external int needToFreeIdxStr; -const int SQLITE_LIMIT_LIKE_PATTERN_LENGTH = 8; + /// True if output is already ordered + @ffi.Int() + external int orderByConsumed; -const int SQLITE_LIMIT_VARIABLE_NUMBER = 9; + /// Estimated cost of using this index + @ffi.Double() + external double estimatedCost; -const int SQLITE_LIMIT_TRIGGER_DEPTH = 10; + /// Estimated number of rows returned + @sqlite3_int64() + external int estimatedRows; -const int SQLITE_LIMIT_WORKER_THREADS = 11; + /// Mask of SQLITE_INDEX_SCAN_* flags + @ffi.Int() + external int idxFlags; -const int SQLITE_PREPARE_PERSISTENT = 1; + /// Input: Mask of columns used by statement + @sqlite3_uint64() + external int colUsed; -const int SQLITE_PREPARE_NORMALIZE = 2; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int nConstraint, + required ffi.Pointer aConstraint, + required int nOrderBy, + required ffi.Pointer aOrderBy, + required ffi.Pointer aConstraintUsage, + required int idxNum, + required ffi.Pointer idxStr, + required int needToFreeIdxStr, + required int orderByConsumed, + required double estimatedCost, + required int estimatedRows, + required int idxFlags, + required int colUsed, + }) => $allocator() + ..ref.nConstraint = nConstraint + ..ref.aConstraint = aConstraint + ..ref.nOrderBy = nOrderBy + ..ref.aOrderBy = aOrderBy + ..ref.aConstraintUsage = aConstraintUsage + ..ref.idxNum = idxNum + ..ref.idxStr = idxStr + ..ref.needToFreeIdxStr = needToFreeIdxStr + ..ref.orderByConsumed = orderByConsumed + ..ref.estimatedCost = estimatedCost + ..ref.estimatedRows = estimatedRows + ..ref.idxFlags = idxFlags + ..ref.colUsed = colUsed; +} -const int SQLITE_PREPARE_NO_VTAB = 4; +final class sqlite3_index_orderby extends ffi.Struct { + /// Column number + @ffi.Int() + external int iColumn; -const int SQLITE_INTEGER = 1; + /// True for DESC. False for ASC. + @ffi.UnsignedChar() + external int desc; -const int SQLITE_FLOAT = 2; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iColumn, + required int desc, + }) => $allocator() + ..ref.iColumn = iColumn + ..ref.desc = desc; +} -const int SQLITE_BLOB = 4; +typedef sqlite3_int64 = sqlite_int64; -const int SQLITE_NULL = 5; +final class sqlite3_io_methods extends ffi.Opaque {} -const int SQLITE_TEXT = 3; +final class sqlite3_mem_methods extends ffi.Struct { + /// Memory allocation function + external ffi.Pointer< + ffi.NativeFunction Function(ffi.Int)> + > + xMalloc; -const int SQLITE3_TEXT = 3; + /// Free a prior allocation + external ffi.Pointer< + ffi.NativeFunction)> + > + xFree; -const int SQLITE_UTF8 = 1; + /// Resize an allocation + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + > + xRealloc; -const int SQLITE_UTF16LE = 2; + /// Return the size of an allocation + external ffi.Pointer< + ffi.NativeFunction)> + > + xSize; -const int SQLITE_UTF16BE = 3; + /// Round up request size to allocation size + external ffi.Pointer> xRoundup; -const int SQLITE_UTF16 = 4; + /// Initialize the memory allocator + external ffi.Pointer< + ffi.NativeFunction)> + > + xInit; -const int SQLITE_ANY = 5; + /// Deinitialize the memory allocator + external ffi.Pointer< + ffi.NativeFunction)> + > + xShutdown; -const int SQLITE_UTF16_ALIGNED = 8; + /// Argument to xInit() and xShutdown() + external ffi.Pointer pAppData; -const int SQLITE_DETERMINISTIC = 2048; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer< + ffi.NativeFunction Function(ffi.Int)> + > + xMalloc, + required ffi.Pointer< + ffi.NativeFunction)> + > + xFree, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer, ffi.Int) + > + > + xRealloc, + required ffi.Pointer< + ffi.NativeFunction)> + > + xSize, + required ffi.Pointer> + xRoundup, + required ffi.Pointer< + ffi.NativeFunction)> + > + xInit, + required ffi.Pointer< + ffi.NativeFunction)> + > + xShutdown, + required ffi.Pointer pAppData, + }) => $allocator() + ..ref.xMalloc = xMalloc + ..ref.xFree = xFree + ..ref.xRealloc = xRealloc + ..ref.xSize = xSize + ..ref.xRoundup = xRoundup + ..ref.xInit = xInit + ..ref.xShutdown = xShutdown + ..ref.pAppData = pAppData; +} -const int SQLITE_DIRECTONLY = 524288; +/// CAPI3REF: Virtual Table Object +/// KEYWORDS: sqlite3_module {virtual table module} +/// +/// This structure, sometimes called a "virtual table module", +/// defines the implementation of a [virtual table]. +/// This structure consists mostly of methods for the module. +/// +/// ^A virtual table module is created by filling in a persistent +/// instance of this structure and passing a pointer to that instance +/// to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. +/// ^The registration remains valid until it is replaced by a different +/// module or until the [database connection] closes. The content +/// of this structure must not change while it is registered with +/// any database connection. +final class sqlite3_module extends ffi.Struct { + @ffi.Int() + external int iVersion; -const int SQLITE_SUBTYPE = 1048576; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, + ) + > + > + xCreate; -const int SQLITE_INNOCUOUS = 2097152; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, + ) + > + > + xConnect; -const int SQLITE_WIN32_DATA_DIRECTORY_TYPE = 1; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xBestIndex; -const int SQLITE_WIN32_TEMP_DIRECTORY_TYPE = 2; + external ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xDisconnect; -const int SQLITE_INDEX_SCAN_UNIQUE = 1; + external ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xDestroy; -const int SQLITE_INDEX_CONSTRAINT_EQ = 2; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pVTab, + ffi.Pointer> ppCursor, + ) + > + > + xOpen; -const int SQLITE_INDEX_CONSTRAINT_GT = 4; + external ffi.Pointer< + ffi.NativeFunction)> + > + xClose; -const int SQLITE_INDEX_CONSTRAINT_LE = 8; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xFilter; -const int SQLITE_INDEX_CONSTRAINT_LT = 16; + external ffi.Pointer< + ffi.NativeFunction)> + > + xNext; -const int SQLITE_INDEX_CONSTRAINT_GE = 32; + external ffi.Pointer< + ffi.NativeFunction)> + > + xEof; -const int SQLITE_INDEX_CONSTRAINT_MATCH = 64; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xColumn; -const int SQLITE_INDEX_CONSTRAINT_LIKE = 65; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xRowid; -const int SQLITE_INDEX_CONSTRAINT_GLOB = 66; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer, + ) + > + > + xUpdate; -const int SQLITE_INDEX_CONSTRAINT_REGEXP = 67; + external ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xBegin; -const int SQLITE_INDEX_CONSTRAINT_NE = 68; + external ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xSync; -const int SQLITE_INDEX_CONSTRAINT_ISNOT = 69; + external ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xCommit; -const int SQLITE_INDEX_CONSTRAINT_ISNOTNULL = 70; + external ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xRollback; -const int SQLITE_INDEX_CONSTRAINT_ISNULL = 71; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pVtab, + ffi.Int nArg, + ffi.Pointer zName, + ffi.Pointer< + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + > + pxFunc, + ffi.Pointer> ppArg, + ) + > + > + xFindFunction; -const int SQLITE_INDEX_CONSTRAINT_IS = 72; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pVtab, + ffi.Pointer zNew, + ) + > + > + xRename; -const int SQLITE_INDEX_CONSTRAINT_FUNCTION = 150; + /// The methods above are in version 1 of the sqlite_module object. Those + /// below are for version 2 and greater. + external ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xSavepoint; -const int SQLITE_MUTEX_FAST = 0; + external ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xRelease; -const int SQLITE_MUTEX_RECURSIVE = 1; + external ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xRollbackTo; -const int SQLITE_MUTEX_STATIC_MASTER = 2; + /// The methods above are in versions 1 and 2 of the sqlite_module object. + /// Those below are for version 3 and greater. + external ffi.Pointer< + ffi.NativeFunction)> + > + xShadowName; -const int SQLITE_MUTEX_STATIC_MEM = 3; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iVersion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, + ) + > + > + xCreate, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer>, + ffi.Pointer>, + ) + > + > + xConnect, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xBestIndex, + required ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xDisconnect, + required ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xDestroy, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pVTab, + ffi.Pointer> ppCursor, + ) + > + > + xOpen, + required ffi.Pointer< + ffi.NativeFunction)> + > + xClose, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + xFilter, + required ffi.Pointer< + ffi.NativeFunction)> + > + xNext, + required ffi.Pointer< + ffi.NativeFunction)> + > + xEof, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xColumn, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xRowid, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ffi.Pointer, + ) + > + > + xUpdate, + required ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xBegin, + required ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xSync, + required ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xCommit, + required ffi.Pointer< + ffi.NativeFunction pVTab)> + > + xRollback, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pVtab, + ffi.Int nArg, + ffi.Pointer zName, + ffi.Pointer< + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer>, + ) + > + > + > + pxFunc, + ffi.Pointer> ppArg, + ) + > + > + xFindFunction, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer pVtab, + ffi.Pointer zNew, + ) + > + > + xRename, + required ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xSavepoint, + required ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xRelease, + required ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xRollbackTo, + required ffi.Pointer< + ffi.NativeFunction)> + > + xShadowName, + }) => $allocator() + ..ref.iVersion = iVersion + ..ref.xCreate = xCreate + ..ref.xConnect = xConnect + ..ref.xBestIndex = xBestIndex + ..ref.xDisconnect = xDisconnect + ..ref.xDestroy = xDestroy + ..ref.xOpen = xOpen + ..ref.xClose = xClose + ..ref.xFilter = xFilter + ..ref.xNext = xNext + ..ref.xEof = xEof + ..ref.xColumn = xColumn + ..ref.xRowid = xRowid + ..ref.xUpdate = xUpdate + ..ref.xBegin = xBegin + ..ref.xSync = xSync + ..ref.xCommit = xCommit + ..ref.xRollback = xRollback + ..ref.xFindFunction = xFindFunction + ..ref.xRename = xRename + ..ref.xSavepoint = xSavepoint + ..ref.xRelease = xRelease + ..ref.xRollbackTo = xRollbackTo + ..ref.xShadowName = xShadowName; +} -const int SQLITE_MUTEX_STATIC_MEM2 = 4; +final class sqlite3_mutex extends ffi.Opaque {} -const int SQLITE_MUTEX_STATIC_OPEN = 4; +final class sqlite3_mutex_methods extends ffi.Struct { + external ffi.Pointer> xMutexInit; -const int SQLITE_MUTEX_STATIC_PRNG = 5; + external ffi.Pointer> xMutexEnd; -const int SQLITE_MUTEX_STATIC_LRU = 6; + external ffi.Pointer< + ffi.NativeFunction Function(ffi.Int)> + > + xMutexAlloc; -const int SQLITE_MUTEX_STATIC_LRU2 = 7; + external ffi.Pointer< + ffi.NativeFunction)> + > + xMutexFree; -const int SQLITE_MUTEX_STATIC_PMEM = 7; + external ffi.Pointer< + ffi.NativeFunction)> + > + xMutexEnter; -const int SQLITE_MUTEX_STATIC_APP1 = 8; + external ffi.Pointer< + ffi.NativeFunction)> + > + xMutexTry; -const int SQLITE_MUTEX_STATIC_APP2 = 9; + external ffi.Pointer< + ffi.NativeFunction)> + > + xMutexLeave; -const int SQLITE_MUTEX_STATIC_APP3 = 10; + external ffi.Pointer< + ffi.NativeFunction)> + > + xMutexHeld; -const int SQLITE_MUTEX_STATIC_VFS1 = 11; + external ffi.Pointer< + ffi.NativeFunction)> + > + xMutexNotheld; -const int SQLITE_MUTEX_STATIC_VFS2 = 12; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer> xMutexInit, + required ffi.Pointer> xMutexEnd, + required ffi.Pointer< + ffi.NativeFunction Function(ffi.Int)> + > + xMutexAlloc, + required ffi.Pointer< + ffi.NativeFunction)> + > + xMutexFree, + required ffi.Pointer< + ffi.NativeFunction)> + > + xMutexEnter, + required ffi.Pointer< + ffi.NativeFunction)> + > + xMutexTry, + required ffi.Pointer< + ffi.NativeFunction)> + > + xMutexLeave, + required ffi.Pointer< + ffi.NativeFunction)> + > + xMutexHeld, + required ffi.Pointer< + ffi.NativeFunction)> + > + xMutexNotheld, + }) => $allocator() + ..ref.xMutexInit = xMutexInit + ..ref.xMutexEnd = xMutexEnd + ..ref.xMutexAlloc = xMutexAlloc + ..ref.xMutexFree = xMutexFree + ..ref.xMutexEnter = xMutexEnter + ..ref.xMutexTry = xMutexTry + ..ref.xMutexLeave = xMutexLeave + ..ref.xMutexHeld = xMutexHeld + ..ref.xMutexNotheld = xMutexNotheld; +} -const int SQLITE_MUTEX_STATIC_VFS3 = 13; +final class sqlite3_pcache extends ffi.Opaque {} -const int SQLITE_TESTCTRL_FIRST = 5; +final class sqlite3_pcache_methods extends ffi.Struct { + external ffi.Pointer pArg; -const int SQLITE_TESTCTRL_PRNG_SAVE = 5; + external ffi.Pointer< + ffi.NativeFunction)> + > + xInit; -const int SQLITE_TESTCTRL_PRNG_RESTORE = 6; + external ffi.Pointer< + ffi.NativeFunction)> + > + xShutdown; -const int SQLITE_TESTCTRL_PRNG_RESET = 7; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Int szPage, ffi.Int bPurgeable) + > + > + xCreate; -const int SQLITE_TESTCTRL_BITVEC_TEST = 8; + external ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xCachesize; -const int SQLITE_TESTCTRL_FAULT_INSTALL = 9; + external ffi.Pointer< + ffi.NativeFunction)> + > + xPagecount; -const int SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS = 10; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.UnsignedInt, + ffi.Int, + ) + > + > + xFetch; -const int SQLITE_TESTCTRL_PENDING_BYTE = 11; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xUnpin; -const int SQLITE_TESTCTRL_ASSERT = 12; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ) + > + > + xRekey; -const int SQLITE_TESTCTRL_ALWAYS = 13; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) + > + > + xTruncate; -const int SQLITE_TESTCTRL_RESERVE = 14; + external ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy; -const int SQLITE_TESTCTRL_OPTIMIZATIONS = 15; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pArg, + required ffi.Pointer< + ffi.NativeFunction)> + > + xInit, + required ffi.Pointer< + ffi.NativeFunction)> + > + xShutdown, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Int szPage, ffi.Int bPurgeable) + > + > + xCreate, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int) + > + > + xCachesize, + required ffi.Pointer< + ffi.NativeFunction)> + > + xPagecount, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.UnsignedInt, + ffi.Int, + ) + > + > + xFetch, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xUnpin, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ) + > + > + xRekey, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) + > + > + xTruncate, + required ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy, + }) => $allocator() + ..ref.pArg = pArg + ..ref.xInit = xInit + ..ref.xShutdown = xShutdown + ..ref.xCreate = xCreate + ..ref.xCachesize = xCachesize + ..ref.xPagecount = xPagecount + ..ref.xFetch = xFetch + ..ref.xUnpin = xUnpin + ..ref.xRekey = xRekey + ..ref.xTruncate = xTruncate + ..ref.xDestroy = xDestroy; +} -const int SQLITE_TESTCTRL_ISKEYWORD = 16; +final class sqlite3_pcache_methods2 extends ffi.Struct { + @ffi.Int() + external int iVersion; -const int SQLITE_TESTCTRL_SCRATCHMALLOC = 17; + external ffi.Pointer pArg; -const int SQLITE_TESTCTRL_INTERNAL_FUNCTIONS = 17; + external ffi.Pointer< + ffi.NativeFunction)> + > + xInit; -const int SQLITE_TESTCTRL_LOCALTIME_FAULT = 18; + external ffi.Pointer< + ffi.NativeFunction)> + > + xShutdown; -const int SQLITE_TESTCTRL_EXPLAIN_STMT = 19; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int szPage, + ffi.Int szExtra, + ffi.Int bPurgeable, + ) + > + > + xCreate; -const int SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD = 19; + external ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xCachesize; -const int SQLITE_TESTCTRL_NEVER_CORRUPT = 20; + external ffi.Pointer< + ffi.NativeFunction)> + > + xPagecount; -const int SQLITE_TESTCTRL_VDBE_COVERAGE = 21; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.UnsignedInt, + ffi.Int, + ) + > + > + xFetch; -const int SQLITE_TESTCTRL_BYTEORDER = 22; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xUnpin; -const int SQLITE_TESTCTRL_ISINIT = 23; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ) + > + > + xRekey; -const int SQLITE_TESTCTRL_SORTER_MMAP = 24; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) + > + > + xTruncate; -const int SQLITE_TESTCTRL_IMPOSTER = 25; + external ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy; -const int SQLITE_TESTCTRL_PARSER_COVERAGE = 26; + external ffi.Pointer< + ffi.NativeFunction)> + > + xShrink; -const int SQLITE_TESTCTRL_RESULT_INTREAL = 27; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iVersion, + required ffi.Pointer pArg, + required ffi.Pointer< + ffi.NativeFunction)> + > + xInit, + required ffi.Pointer< + ffi.NativeFunction)> + > + xShutdown, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Int szPage, + ffi.Int szExtra, + ffi.Int bPurgeable, + ) + > + > + xCreate, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int) + > + > + xCachesize, + required ffi.Pointer< + ffi.NativeFunction)> + > + xPagecount, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.UnsignedInt, + ffi.Int, + ) + > + > + xFetch, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xUnpin, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, + ffi.UnsignedInt, + ) + > + > + xRekey, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.UnsignedInt) + > + > + xTruncate, + required ffi.Pointer< + ffi.NativeFunction)> + > + xDestroy, + required ffi.Pointer< + ffi.NativeFunction)> + > + xShrink, + }) => $allocator() + ..ref.iVersion = iVersion + ..ref.pArg = pArg + ..ref.xInit = xInit + ..ref.xShutdown = xShutdown + ..ref.xCreate = xCreate + ..ref.xCachesize = xCachesize + ..ref.xPagecount = xPagecount + ..ref.xFetch = xFetch + ..ref.xUnpin = xUnpin + ..ref.xRekey = xRekey + ..ref.xTruncate = xTruncate + ..ref.xDestroy = xDestroy + ..ref.xShrink = xShrink; +} -const int SQLITE_TESTCTRL_PRNG_SEED = 28; +final class sqlite3_pcache_page extends ffi.Struct { + /// The content of the page + external ffi.Pointer pBuf; -const int SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS = 29; + /// Extra information associated with the page + external ffi.Pointer pExtra; -const int SQLITE_TESTCTRL_LAST = 29; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pBuf, + required ffi.Pointer pExtra, + }) => $allocator() + ..ref.pBuf = pBuf + ..ref.pExtra = pExtra; +} -const int SQLITE_STATUS_MEMORY_USED = 0; +typedef sqlite3_rtree_dbl = ffi.Double; +typedef Dartsqlite3_rtree_dbl = double; -const int SQLITE_STATUS_PAGECACHE_USED = 1; +/// A pointer to a structure of the following type is passed as the first +/// argument to callbacks registered using rtree_geometry_callback(). +final class sqlite3_rtree_geometry extends ffi.Struct { + /// Copy of pContext passed to s_r_g_c() + external ffi.Pointer pContext; -const int SQLITE_STATUS_PAGECACHE_OVERFLOW = 2; + /// Size of array aParam[] + @ffi.Int() + external int nParam; -const int SQLITE_STATUS_SCRATCH_USED = 3; + /// Parameters passed to SQL geom function + external ffi.Pointer aParam; -const int SQLITE_STATUS_SCRATCH_OVERFLOW = 4; + /// Callback implementation user data + external ffi.Pointer pUser; -const int SQLITE_STATUS_MALLOC_SIZE = 5; + /// Called by SQLite to clean up pUser + external ffi.Pointer< + ffi.NativeFunction)> + > + xDelUser; -const int SQLITE_STATUS_PARSER_STACK = 6; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pContext, + required int nParam, + required ffi.Pointer aParam, + required ffi.Pointer pUser, + required ffi.Pointer< + ffi.NativeFunction)> + > + xDelUser, + }) => $allocator() + ..ref.pContext = pContext + ..ref.nParam = nParam + ..ref.aParam = aParam + ..ref.pUser = pUser + ..ref.xDelUser = xDelUser; +} -const int SQLITE_STATUS_PAGECACHE_SIZE = 7; +/// A pointer to a structure of the following type is passed as the +/// argument to scored geometry callback registered using +/// sqlite3_rtree_query_callback(). +/// +/// Note that the first 5 fields of this structure are identical to +/// sqlite3_rtree_geometry. This structure is a subclass of +/// sqlite3_rtree_geometry. +final class sqlite3_rtree_query_info extends ffi.Struct { + /// pContext from when function registered + external ffi.Pointer pContext; -const int SQLITE_STATUS_SCRATCH_SIZE = 8; + /// Number of function parameters + @ffi.Int() + external int nParam; -const int SQLITE_STATUS_MALLOC_COUNT = 9; + /// value of function parameters + external ffi.Pointer aParam; -const int SQLITE_DBSTATUS_LOOKASIDE_USED = 0; + /// callback can use this, if desired + external ffi.Pointer pUser; -const int SQLITE_DBSTATUS_CACHE_USED = 1; + /// function to free pUser + external ffi.Pointer< + ffi.NativeFunction)> + > + xDelUser; -const int SQLITE_DBSTATUS_SCHEMA_USED = 2; + /// Coordinates of node or entry to check + external ffi.Pointer aCoord; -const int SQLITE_DBSTATUS_STMT_USED = 3; + /// Number of pending entries in the queue + external ffi.Pointer anQueue; -const int SQLITE_DBSTATUS_LOOKASIDE_HIT = 4; + /// Number of coordinates + @ffi.Int() + external int nCoord; -const int SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5; + /// Level of current node or entry + @ffi.Int() + external int iLevel; -const int SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6; + /// The largest iLevel value in the tree + @ffi.Int() + external int mxLevel; -const int SQLITE_DBSTATUS_CACHE_HIT = 7; + /// Rowid for current entry + @sqlite3_int64() + external int iRowid; -const int SQLITE_DBSTATUS_CACHE_MISS = 8; + /// Score of parent node + @sqlite3_rtree_dbl() + external double rParentScore; -const int SQLITE_DBSTATUS_CACHE_WRITE = 9; + /// Visibility of parent node + @ffi.Int() + external int eParentWithin; -const int SQLITE_DBSTATUS_DEFERRED_FKS = 10; + /// OUT: Visibility + @ffi.Int() + external int eWithin; -const int SQLITE_DBSTATUS_CACHE_USED_SHARED = 11; + /// OUT: Write the score here + @sqlite3_rtree_dbl() + external double rScore; -const int SQLITE_DBSTATUS_CACHE_SPILL = 12; + /// Original SQL values of parameters + external ffi.Pointer> apSqlParam; -const int SQLITE_DBSTATUS_MAX = 12; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pContext, + required int nParam, + required ffi.Pointer aParam, + required ffi.Pointer pUser, + required ffi.Pointer< + ffi.NativeFunction)> + > + xDelUser, + required ffi.Pointer aCoord, + required ffi.Pointer anQueue, + required int nCoord, + required int iLevel, + required int mxLevel, + required int iRowid, + required double rParentScore, + required int eParentWithin, + required int eWithin, + required double rScore, + required ffi.Pointer> apSqlParam, + }) => $allocator() + ..ref.pContext = pContext + ..ref.nParam = nParam + ..ref.aParam = aParam + ..ref.pUser = pUser + ..ref.xDelUser = xDelUser + ..ref.aCoord = aCoord + ..ref.anQueue = anQueue + ..ref.nCoord = nCoord + ..ref.iLevel = iLevel + ..ref.mxLevel = mxLevel + ..ref.iRowid = iRowid + ..ref.rParentScore = rParentScore + ..ref.eParentWithin = eParentWithin + ..ref.eWithin = eWithin + ..ref.rScore = rScore + ..ref.apSqlParam = apSqlParam; +} -const int SQLITE_STMTSTATUS_FULLSCAN_STEP = 1; +/// CAPI3REF: Database Snapshot +/// KEYWORDS: {snapshot} {sqlite3_snapshot} +/// +/// An instance of the snapshot object records the state of a [WAL mode] +/// database for some specific point in history. +/// +/// In [WAL mode], multiple [database connections] that are open on the +/// same database file can each be reading a different historical version +/// of the database file. When a [database connection] begins a read +/// transaction, that connection sees an unchanging copy of the database +/// as it existed for the point in time when the transaction first started. +/// Subsequent changes to the database from other connections are not seen +/// by the reader until a new read transaction is started. +/// +/// The sqlite3_snapshot object records state information about an historical +/// version of the database file so that it is possible to later open a new read +/// transaction that sees that historical version of the database rather than +/// the most recent version. +final class sqlite3_snapshot extends ffi.Struct { + @ffi.Array.multi([48]) + external ffi.Array hidden; +} -const int SQLITE_STMTSTATUS_SORT = 2; +final class sqlite3_stmt extends ffi.Opaque {} -const int SQLITE_STMTSTATUS_AUTOINDEX = 3; +final class sqlite3_str extends ffi.Opaque {} -const int SQLITE_STMTSTATUS_VM_STEP = 4; +typedef sqlite3_syscall_ptr = + ffi.Pointer>; +typedef sqlite3_syscall_ptrFunction = ffi.Void Function(); +typedef Dartsqlite3_syscall_ptrFunction = void Function(); +typedef sqlite3_uint64 = sqlite_uint64; -const int SQLITE_STMTSTATUS_REPREPARE = 5; +final class sqlite3_value extends ffi.Opaque {} -const int SQLITE_STMTSTATUS_RUN = 6; +final class sqlite3_vfs extends ffi.Struct { + /// Structure version number (currently 3) + @ffi.Int() + external int iVersion; -const int SQLITE_STMTSTATUS_MEMUSED = 99; + /// Size of subclassed sqlite3_file + @ffi.Int() + external int szOsFile; -const int SQLITE_CHECKPOINT_PASSIVE = 0; + /// Maximum file pathname length + @ffi.Int() + external int mxPathname; -const int SQLITE_CHECKPOINT_FULL = 1; + /// Next registered VFS + external ffi.Pointer pNext; -const int SQLITE_CHECKPOINT_RESTART = 2; + /// Name of this virtual file system + external ffi.Pointer zName; -const int SQLITE_CHECKPOINT_TRUNCATE = 3; + /// Pointer to application-specific data + external ffi.Pointer pAppData; -const int SQLITE_VTAB_CONSTRAINT_SUPPORT = 1; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xOpen; -const int SQLITE_VTAB_INNOCUOUS = 2; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer, ffi.Int) + > + > + xDelete; -const int SQLITE_VTAB_DIRECTONLY = 3; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xAccess; -const int SQLITE_ROLLBACK = 1; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xFullPathname; -const int SQLITE_FAIL = 3; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xDlOpen; -const int SQLITE_REPLACE = 5; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xDlError; -const int SQLITE_SCANSTAT_NLOOP = 0; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer> Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xDlSym; -const int SQLITE_SCANSTAT_NVISIT = 1; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + > + xDlClose; -const int SQLITE_SCANSTAT_EST = 2; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Pointer) + > + > + xRandomness; -const int SQLITE_SCANSTAT_NAME = 3; + external ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xSleep; -const int SQLITE_SCANSTAT_EXPLAIN = 4; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xCurrentTime; -const int SQLITE_SCANSTAT_SELECTID = 5; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Int, ffi.Pointer) + > + > + xGetLastError; -const int SQLITE_SERIALIZE_NOCOPY = 1; + /// The methods above are in version 1 of the sqlite_vfs object + /// definition. Those that follow are added in version 2 or later + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xCurrentTimeInt64; -const int SQLITE_DESERIALIZE_FREEONCLOSE = 1; + /// The methods above are in versions 1 and 2 of the sqlite_vfs object. + /// Those below are for version 3 and greater. + external ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + sqlite3_syscall_ptr, + ) + > + > + xSetSystemCall; -const int SQLITE_DESERIALIZE_RESIZEABLE = 2; + external ffi.Pointer< + ffi.NativeFunction< + sqlite3_syscall_ptr Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xGetSystemCall; -const int SQLITE_DESERIALIZE_READONLY = 4; + external ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xNextSystemCall; -const int NOT_WITHIN = 0; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int iVersion, + required int szOsFile, + required int mxPathname, + required ffi.Pointer pNext, + required ffi.Pointer zName, + required ffi.Pointer pAppData, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xOpen, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ) + > + > + xDelete, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xAccess, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xFullPathname, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xDlOpen, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xDlError, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer> Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + > + xDlSym, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Pointer) + > + > + xDlClose, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xRandomness, + required ffi.Pointer< + ffi.NativeFunction, ffi.Int)> + > + xSleep, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xCurrentTime, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ) + > + > + xGetLastError, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function(ffi.Pointer, ffi.Pointer) + > + > + xCurrentTimeInt64, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Int Function( + ffi.Pointer, + ffi.Pointer, + sqlite3_syscall_ptr, + ) + > + > + xSetSystemCall, + required ffi.Pointer< + ffi.NativeFunction< + sqlite3_syscall_ptr Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xGetSystemCall, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + > + xNextSystemCall, + }) => $allocator() + ..ref.iVersion = iVersion + ..ref.szOsFile = szOsFile + ..ref.mxPathname = mxPathname + ..ref.pNext = pNext + ..ref.zName = zName + ..ref.pAppData = pAppData + ..ref.xOpen = xOpen + ..ref.xDelete = xDelete + ..ref.xAccess = xAccess + ..ref.xFullPathname = xFullPathname + ..ref.xDlOpen = xDlOpen + ..ref.xDlError = xDlError + ..ref.xDlSym = xDlSym + ..ref.xDlClose = xDlClose + ..ref.xRandomness = xRandomness + ..ref.xSleep = xSleep + ..ref.xCurrentTime = xCurrentTime + ..ref.xGetLastError = xGetLastError + ..ref.xCurrentTimeInt64 = xCurrentTimeInt64 + ..ref.xSetSystemCall = xSetSystemCall + ..ref.xGetSystemCall = xGetSystemCall + ..ref.xNextSystemCall = xNextSystemCall; +} -const int PARTLY_WITHIN = 1; +/// CAPI3REF: Virtual Table Instance Object +/// KEYWORDS: sqlite3_vtab +/// +/// Every [virtual table module] implementation uses a subclass +/// of this object to describe a particular instance +/// of the [virtual table]. Each subclass will +/// be tailored to the specific needs of the module implementation. +/// The purpose of this superclass is to define certain fields that are +/// common to all module implementations. +/// +/// ^Virtual tables methods can set an error message by assigning a +/// string obtained from [sqlite3_mprintf()] to zErrMsg. The method should +/// take care that any prior string is freed by a call to [sqlite3_free()] +/// prior to assigning a new string to zErrMsg. ^After the error message +/// is delivered up to the client application, the string will be automatically +/// freed by sqlite3_free() and the zErrMsg field will be zeroed. +final class sqlite3_vtab extends ffi.Struct { + /// The module for this virtual table + external ffi.Pointer pModule; -const int FULLY_WITHIN = 2; + /// Number of open cursors + @ffi.Int() + external int nRef; -const int FTS5_TOKENIZE_QUERY = 1; + /// Error message from sqlite3_mprintf() + external ffi.Pointer zErrMsg; -const int FTS5_TOKENIZE_PREFIX = 2; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pModule, + required int nRef, + required ffi.Pointer zErrMsg, + }) => $allocator() + ..ref.pModule = pModule + ..ref.nRef = nRef + ..ref.zErrMsg = zErrMsg; +} -const int FTS5_TOKENIZE_DOCUMENT = 4; +/// CAPI3REF: Virtual Table Cursor Object +/// KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} +/// +/// Every [virtual table module] implementation uses a subclass of the +/// following structure to describe cursors that point into the +/// [virtual table] and are used +/// to loop through the virtual table. Cursors are created using the +/// [sqlite3_module.xOpen | xOpen] method of the module and are destroyed +/// by the [sqlite3_module.xClose | xClose] method. Cursors are used +/// by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods +/// of the module. Each module implementation will define +/// the content of a cursor structure to suit its own needs. +/// +/// This superclass exists in order to define fields of the cursor that +/// are common to all implementations. +final class sqlite3_vtab_cursor extends ffi.Struct { + /// Virtual table of this cursor + external ffi.Pointer pVtab; -const int FTS5_TOKENIZE_AUX = 8; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer pVtab, + }) => $allocator()..ref.pVtab = pVtab; +} -const int FTS5_TOKEN_COLOCATED = 1; +typedef sqlite_int64 = ffi.LongLong; +typedef Dartsqlite_int64 = int; +typedef sqlite_uint64 = ffi.UnsignedLongLong; +typedef Dartsqlite_uint64 = int; diff --git a/pkgs/ffigen/test/large_integration_tests/large_test.dart b/pkgs/ffigen/test/large_integration_tests/large_test.dart index aa227b20e6..e2d52b6289 100644 --- a/pkgs/ffigen/test/large_integration_tests/large_test.dart +++ b/pkgs/ffigen/test/large_integration_tests/large_test.dart @@ -74,8 +74,10 @@ void main() { ), ); final library = parse(Context(logger, generator)); + final context = testContext(); matchLibraryWithExpected( + context, library, 'large_test_libclang.dart', ['test', 'large_integration_tests', '_expected_libclang_bindings.dart'], @@ -151,9 +153,10 @@ void main() { macros: Macros.includeAll, typedefs: Typedefs.includeAll, ); - final library = parse(testContext(generator)); + final context = testContext(generator); + final library = parse(context); - matchLibraryWithExpected(library, 'large_test_cjson.dart', [ + matchLibraryWithExpected(context, library, 'large_test_cjson.dart', [ 'test', 'large_integration_tests', '_expected_cjson_bindings.dart', @@ -161,8 +164,9 @@ void main() { }); test('SQLite test', () { - // Excluding functions that use 'va_list' because it can either be a + // Excluding functions etc that use 'va_list' because it can either be a // Pointer<__va_list_tag> or int depending on the OS. + final vaRegex = RegExp(r'(^|[^a-z])va($|[^a-z])'); final generator = FfiGenerator( output: Output( dartFile: Uri.file('unused'), @@ -192,14 +196,19 @@ void main() { 'sqlite3_str_vappendf', }.contains(declaration.originalName), ), - structs: Structs.includeAll, + structs: Structs( + include: (declaration) => !vaRegex.hasMatch(declaration.originalName), + ), globals: Globals.includeAll, macros: Macros.includeAll, - typedefs: Typedefs.includeAll, + typedefs: Typedefs( + include: (declaration) => !vaRegex.hasMatch(declaration.originalName), + ), ); - final library = parse(testContext(generator)); + final context = testContext(generator); + final library = parse(context); - matchLibraryWithExpected(library, 'large_test_sqlite.dart', [ + matchLibraryWithExpected(context, library, 'large_test_sqlite.dart', [ 'test', 'large_integration_tests', '_expected_sqlite_bindings.dart', diff --git a/pkgs/ffigen/test/native_objc_test/category_test.dart b/pkgs/ffigen/test/native_objc_test/category_test.dart index e05ab426f1..346220f8fa 100644 --- a/pkgs/ffigen/test/native_objc_test/category_test.dart +++ b/pkgs/ffigen/test/native_objc_test/category_test.dart @@ -83,7 +83,7 @@ void main() { test('Transitive category on built-in type', () { // Regression test for https://github.com/dart-lang/native/issues/1820. - // Include transitive category of explicitly included buit-in type. + // Include transitive category of explicitly included built-in type. expect(objc.NSURL.alloc().extensionMethod(), 555); // Don't include transitive category of built-in type that hasn't been diff --git a/pkgs/ffigen/test/native_objc_test/is_instance_test.dart b/pkgs/ffigen/test/native_objc_test/is_instance_test.dart index f315c2b3a5..d403a04ed9 100644 --- a/pkgs/ffigen/test/native_objc_test/is_instance_test.dart +++ b/pkgs/ffigen/test/native_objc_test/is_instance_test.dart @@ -48,5 +48,11 @@ void main() { expect(IsInstanceChildClass.isA(base), isFalse); expect(IsInstanceChildClass.isA(child), isTrue); }); + + test('Null input', () { + expect(IsInstanceBaseClass.isA(null), isFalse); + expect(IsInstanceChildClass.isA(null), isFalse); + expect(IsInstanceUnrelatedClass.isA(null), isFalse); + }); }); } diff --git a/pkgs/ffigen/test/native_objc_test/transitive_test.dart b/pkgs/ffigen/test/native_objc_test/transitive_test.dart index 548436b4e1..aec4a21cbd 100644 --- a/pkgs/ffigen/test/native_objc_test/transitive_test.dart +++ b/pkgs/ffigen/test/native_objc_test/transitive_test.dart @@ -53,6 +53,7 @@ String generate({ 'DirectlyIncluded', 'DirectlyIncludedWithProtocol', 'DirectlyIncludedIntForCat', + 'Bug2935DirectInterface', }.contains(decl.originalName), includeTransitive: includeTransitiveObjCInterfaces, ), @@ -141,6 +142,9 @@ void main() { expect(incItf('NotIncludedSuperType'), Inclusion.omitted); expect(incItf('NotIncludedTransitive'), Inclusion.omitted); expect(incItf('NotIncludedSuperType'), Inclusion.omitted); + expect(incItf('Bug2935DirectInterface'), Inclusion.included); + expect(incItf('Bug2935TransitiveInterface'), Inclusion.included); + expect(incItf('Bug2935TransitiveBlockInterface'), Inclusion.included); expect(bindings.contains('doubleMethod'), isTrue); expect(bindings.contains('transitiveSuperMethod'), isTrue); @@ -153,6 +157,12 @@ void main() { expect(bindings.contains('notIncludedSuperMethod'), isFalse); expect(bindings.contains('notIncludedTransitiveMethod'), isFalse); expect(bindings.contains('notIncludedMethod'), isFalse); + expect(bindings.contains('bug2935DirectInterfaceMethod'), isTrue); + expect(bindings.contains('bug2935TransitiveInterfaceMethod'), isTrue); + expect( + bindings.contains('bug2935TransitiveBlockInterfaceMethod'), + isTrue, + ); }); test('stubbed', () { @@ -169,6 +179,9 @@ void main() { expect(incItf('NotIncludedSuperType'), Inclusion.omitted); expect(incItf('NotIncludedTransitive'), Inclusion.omitted); expect(incItf('NotIncludedSuperType'), Inclusion.omitted); + expect(incItf('Bug2935DirectInterface'), Inclusion.included); + expect(incItf('Bug2935TransitiveInterface'), Inclusion.stubbed); + expect(incItf('Bug2935TransitiveBlockInterface'), Inclusion.omitted); expect(bindings.contains('doubleMethod'), isFalse); expect(bindings.contains('transitiveSuperMethod'), isFalse); @@ -181,6 +194,12 @@ void main() { expect(bindings.contains('notIncludedSuperMethod'), isFalse); expect(bindings.contains('notIncludedTransitiveMethod'), isFalse); expect(bindings.contains('notIncludedMethod'), isFalse); + expect(bindings.contains('bug2935DirectInterfaceMethod'), isTrue); + expect(bindings.contains('bug2935TransitiveInterfaceMethod'), isFalse); + expect( + bindings.contains('bug2935TransitiveBlockInterfaceMethod'), + isFalse, + ); }); }); @@ -203,6 +222,7 @@ void main() { expect(incProto('SuperFromInterfaceProtocol'), Inclusion.included); expect(incProto('TransitiveFromInterfaceProtocol'), Inclusion.included); expect(incItf('DirectlyIncludedWithProtocol'), Inclusion.included); + expect(incProto('Bug2935TransitiveProtocol'), Inclusion.included); expect(bindings.contains('doubleProtoMethod'), isTrue); expect(bindings.contains('transitiveSuperProtoMethod'), isTrue); @@ -219,6 +239,7 @@ void main() { expect(bindings.contains('superFromInterfaceProtoMethod'), isTrue); expect(bindings.contains('transitiveFromInterfaceProtoMethod'), isTrue); expect(bindings.contains('directlyIncludedWithProtoMethod'), isTrue); + expect(bindings.contains('bug2935TransitiveProtocolMethod'), isTrue); }); test('not included', () { @@ -239,6 +260,7 @@ void main() { expect(incProto('SuperFromInterfaceProtocol'), Inclusion.stubbed); expect(incProto('TransitiveFromInterfaceProtocol'), Inclusion.stubbed); expect(incItf('DirectlyIncludedWithProtocol'), Inclusion.included); + expect(incProto('Bug2935TransitiveProtocol'), Inclusion.stubbed); expect(bindings.contains('doubleProtoMethod'), isFalse); expect(bindings.contains('transitiveSuperProtoMethod'), isFalse); @@ -258,6 +280,7 @@ void main() { isFalse, ); expect(bindings.contains('directlyIncludedWithProtoMethod'), isTrue); + expect(bindings.contains('bug2935TransitiveProtocolMethod'), isFalse); }); }); diff --git a/pkgs/ffigen/test/native_objc_test/transitive_test.h b/pkgs/ffigen/test/native_objc_test/transitive_test.h index 3f81685366..9d234559ab 100644 --- a/pkgs/ffigen/test/native_objc_test/transitive_test.h +++ b/pkgs/ffigen/test/native_objc_test/transitive_test.h @@ -153,3 +153,23 @@ @interface NotIncluded (NotIncludedCategory) -(int)notIncludedCategoryMethod; @end + + +// === Regression test for https://github.com/dart-lang/native/issues/2935 === + +@interface Bug2935TransitiveBlockInterface {} +-(int)bug2935TransitiveBlockInterfaceMethod; +@end + +@protocol Bug2935TransitiveProtocol {} +-(void)bug2935TransitiveProtocolMethod: + (void (^)(Bug2935TransitiveBlockInterface* itf)) block; +@end + +@interface Bug2935TransitiveInterface : NSObject {} +-(int)bug2935TransitiveInterfaceMethod; +@end + +@interface Bug2935DirectInterface {} +-(Bug2935TransitiveInterface*)bug2935DirectInterfaceMethod; +@end diff --git a/pkgs/ffigen/test/native_test/_expected_native_test_bindings.dart b/pkgs/ffigen/test/native_test/_expected_native_test_bindings.dart index 2557b980e0..090b9f5226 100644 --- a/pkgs/ffigen/test/native_test/_expected_native_test_bindings.dart +++ b/pkgs/ffigen/test/native_test/_expected_native_test_bindings.dart @@ -28,57 +28,27 @@ class NativeLibrary { late final _Function1Bool = _Function1BoolPtr.asFunction(); - int Function1Uint8(int x) { - return _Function1Uint8(x); - } - - late final _Function1Uint8Ptr = - _lookup>( - 'Function1Uint8', - ); - late final _Function1Uint8 = - _Function1Uint8Ptr.asFunction(); - - int Function1Uint16(int x) { - return _Function1Uint16(x); - } - - late final _Function1Uint16Ptr = - _lookup>( - 'Function1Uint16', - ); - late final _Function1Uint16 = - _Function1Uint16Ptr.asFunction(); - - int Function1Uint32(int x) { - return _Function1Uint32(x); + double Function1Double(double x) { + return _Function1Double(x); } - late final _Function1Uint32Ptr = - _lookup>( - 'Function1Uint32', + late final _Function1DoublePtr = + _lookup>( + 'Function1Double', ); - late final _Function1Uint32 = - _Function1Uint32Ptr.asFunction(); + late final _Function1Double = + _Function1DoublePtr.asFunction(); - int Function1Uint64(int x) { - return _Function1Uint64(x); + double Function1Float(double x) { + return _Function1Float(x); } - late final _Function1Uint64Ptr = - _lookup>( - 'Function1Uint64', + late final _Function1FloatPtr = + _lookup>( + 'Function1Float', ); - late final _Function1Uint64 = - _Function1Uint64Ptr.asFunction(); - - int Function1Int8(int x) { - return _Function1Int8(x); - } - - late final _Function1Int8Ptr = - _lookup>('Function1Int8'); - late final _Function1Int8 = _Function1Int8Ptr.asFunction(); + late final _Function1Float = + _Function1FloatPtr.asFunction(); int Function1Int16(int x) { return _Function1Int16(x); @@ -113,6 +83,14 @@ class NativeLibrary { late final _Function1Int64 = _Function1Int64Ptr.asFunction(); + int Function1Int8(int x) { + return _Function1Int8(x); + } + + late final _Function1Int8Ptr = + _lookup>('Function1Int8'); + late final _Function1Int8 = _Function1Int8Ptr.asFunction(); + int Function1IntPtr(int x) { return _Function1IntPtr(x); } @@ -124,73 +102,84 @@ class NativeLibrary { late final _Function1IntPtr = _Function1IntPtrPtr.asFunction(); - int Function1UintPtr(int x) { - return _Function1UintPtr(x); + int Function1StructPassByValue(Struct3 sum_a_b_c) { + return _Function1StructPassByValue(sum_a_b_c); } - late final _Function1UintPtrPtr = - _lookup>( - 'Function1UintPtr', + late final _Function1StructPassByValuePtr = + _lookup>( + 'Function1StructPassByValue', ); - late final _Function1UintPtr = - _Function1UintPtrPtr.asFunction(); + late final _Function1StructPassByValue = + _Function1StructPassByValuePtr.asFunction(); - double Function1Float(double x) { - return _Function1Float(x); + Struct3 Function1StructReturnByValue(int a, int b, int c) { + return _Function1StructReturnByValue(a, b, c); } - late final _Function1FloatPtr = - _lookup>( - 'Function1Float', + late final _Function1StructReturnByValuePtr = + _lookup>( + 'Function1StructReturnByValue', ); - late final _Function1Float = - _Function1FloatPtr.asFunction(); + late final _Function1StructReturnByValue = + _Function1StructReturnByValuePtr.asFunction< + Struct3 Function(int, int, int) + >(); - double Function1Double(double x) { - return _Function1Double(x); + int Function1Uint16(int x) { + return _Function1Uint16(x); } - late final _Function1DoublePtr = - _lookup>( - 'Function1Double', + late final _Function1Uint16Ptr = + _lookup>( + 'Function1Uint16', ); - late final _Function1Double = - _Function1DoublePtr.asFunction(); + late final _Function1Uint16 = + _Function1Uint16Ptr.asFunction(); - ffi.Pointer getStruct1() { - return _getStruct1(); + int Function1Uint32(int x) { + return _Function1Uint32(x); } - late final _getStruct1Ptr = - _lookup Function()>>( - 'getStruct1', + late final _Function1Uint32Ptr = + _lookup>( + 'Function1Uint32', ); - late final _getStruct1 = _getStruct1Ptr - .asFunction Function()>(); + late final _Function1Uint32 = + _Function1Uint32Ptr.asFunction(); - Struct3 Function1StructReturnByValue(int a, int b, int c) { - return _Function1StructReturnByValue(a, b, c); + int Function1Uint64(int x) { + return _Function1Uint64(x); } - late final _Function1StructReturnByValuePtr = - _lookup>( - 'Function1StructReturnByValue', + late final _Function1Uint64Ptr = + _lookup>( + 'Function1Uint64', ); - late final _Function1StructReturnByValue = - _Function1StructReturnByValuePtr.asFunction< - Struct3 Function(int, int, int) - >(); + late final _Function1Uint64 = + _Function1Uint64Ptr.asFunction(); - int Function1StructPassByValue(Struct3 sum_a_b_c) { - return _Function1StructPassByValue(sum_a_b_c); + int Function1Uint8(int x) { + return _Function1Uint8(x); } - late final _Function1StructPassByValuePtr = - _lookup>( - 'Function1StructPassByValue', + late final _Function1Uint8Ptr = + _lookup>( + 'Function1Uint8', ); - late final _Function1StructPassByValue = - _Function1StructPassByValuePtr.asFunction(); + late final _Function1Uint8 = + _Function1Uint8Ptr.asFunction(); + + int Function1UintPtr(int x) { + return _Function1UintPtr(x); + } + + late final _Function1UintPtrPtr = + _lookup>( + 'Function1UintPtr', + ); + late final _Function1UintPtr = + _Function1UintPtrPtr.asFunction(); Enum1 funcWithEnum1(Enum1 value) { return Enum1.fromValue(_funcWithEnum1(value.value)); @@ -212,6 +201,17 @@ class NativeLibrary { ); late final _funcWithEnum2 = _funcWithEnum2Ptr.asFunction(); + ffi.Pointer getStruct1() { + return _getStruct1(); + } + + late final _getStruct1Ptr = + _lookup Function()>>( + 'getStruct1', + ); + late final _getStruct1 = _getStruct1Ptr + .asFunction Function()>(); + StructWithEnums getStructWithEnums() { return _getStructWithEnums(); } @@ -230,25 +230,6 @@ class NativeLibrary { ffi.Pointer get globalArray => _globalArray; } -final class Struct1 extends ffi.Struct { - @ffi.Int8() - external int a; - - @ffi.Array.multi([3, 1, 2]) - external ffi.Array>> data; -} - -final class Struct3 extends ffi.Struct { - @ffi.Int() - external int a; - - @ffi.Int() - external int b; - - @ffi.Int() - external int c; -} - enum Enum1 { enum1Value1(0), enum1Value2(1), @@ -271,6 +252,35 @@ sealed class Enum2 { static const enum2Value3 = 2; } +final class Struct1 extends ffi.Struct { + @ffi.Int8() + external int a; + + @ffi.Array.multi([3, 1, 2]) + external ffi.Array>> data; +} + +final class Struct3 extends ffi.Struct { + @ffi.Int() + external int a; + + @ffi.Int() + external int b; + + @ffi.Int() + external int c; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int a, + required int b, + required int c, + }) => $allocator() + ..ref.a = a + ..ref.b = b + ..ref.c = c; +} + final class StructWithEnums extends ffi.Struct { @ffi.UnsignedInt() external int enum1AsInt; diff --git a/pkgs/ffigen/test/test_utils.dart b/pkgs/ffigen/test/test_utils.dart index d5665b1c89..ec32a3098f 100644 --- a/pkgs/ffigen/test/test_utils.dart +++ b/pkgs/ffigen/test/test_utils.dart @@ -27,7 +27,7 @@ Context testContext([FfiGenerator? generator]) => Context( Logger createTestLogger({ List? capturedMessages, - Level level = Level.ALL, + Level level = Level.WARNING, }) => Logger.detached('') ..level = level ..onRecord.listen((record) { @@ -110,6 +110,7 @@ String _normalizeGeneratedCode( /// /// This will not delete the actual debug file incase [expect] throws an error. void matchLibraryWithExpected( + Context context, Library library, String pathForActual, List pathToExpected, { @@ -117,6 +118,7 @@ void matchLibraryWithExpected( bool format = true, }) { _matchFileWithExpected( + context: context, library: library, pathForActual: pathForActual, pathToExpected: pathToExpected, @@ -130,12 +132,14 @@ void matchLibraryWithExpected( /// /// This will not delete the actual debug file incase [expect] throws an error. void matchLibrarySymbolFileWithExpected( + Context context, Library library, String pathForActual, List pathToExpected, String importPath, ) { _matchFileWithExpected( + context: context, library: library, pathForActual: pathForActual, pathToExpected: pathToExpected, @@ -155,13 +159,11 @@ String absPath(String p) => path.join(packagePathForTests, p); String configPath(String directory, String file) => absPath(configPathForTest(directory, file)); -/// Returns the temp directory used to store bindings generated by tests. -String tmpDir = path.join(packagePathForTests, 'test', '.temp'); - /// Generates actual file using library and tests using [expect] with expected. /// /// This will not delete the actual debug file incase [expect] throws an error. void _matchFileWithExpected({ + required Context context, required Library library, required String pathForActual, required List pathToExpected, @@ -170,7 +172,9 @@ void _matchFileWithExpected({ String Function(String)? codeNormalizer, }) { final expectedPath = path.joinAll([packagePathForTests, ...pathToExpected]); - final file = File(path.join(tmpDir, pathForActual)); + final tmpDirPath = context.tmpDir; + final file = File(path.join(tmpDirPath, pathForActual)); + fileWriter(library: library, file: file); try { final actual = _normalizeGeneratedCode( diff --git a/pkgs/ffigen/test_flutter/flutter_template_tests/flutter_plugin_ffi_test.dart b/pkgs/ffigen/test_flutter/flutter_template_tests/flutter_plugin_ffi_test.dart index acee4848db..4ae4f7ffd2 100644 --- a/pkgs/ffigen/test_flutter/flutter_template_tests/flutter_plugin_ffi_test.dart +++ b/pkgs/ffigen/test_flutter/flutter_template_tests/flutter_plugin_ffi_test.dart @@ -51,8 +51,8 @@ void main() { target: bindingsGeneratedCopyUri, ); await runProcess( - executable: 'flutter', - arguments: ['pub', 'run', 'ffigen', '--config', 'ffigen.yaml'], + executable: 'dart', + arguments: ['run', 'ffigen', '--config', 'ffigen.yaml'], workingDirectory: projectDirUri, ); diff --git a/pkgs/hooks/.gitignore b/pkgs/hooks/.gitignore index 71860a75db..e080e9249e 100644 --- a/pkgs/hooks/.gitignore +++ b/pkgs/hooks/.gitignore @@ -1 +1,2 @@ !build +.dart_tool/ diff --git a/pkgs/hooks/CHANGELOG.md b/pkgs/hooks/CHANGELOG.md index 0a543f1c7a..81796de4ec 100644 --- a/pkgs/hooks/CHANGELOG.md +++ b/pkgs/hooks/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.0.2 + +- Update documentation about `CCACHE_` environment variables. + +## 1.0.1 + +- Update documentation about environment variables. + ## 1.0.0 - Stable release. diff --git a/pkgs/hooks/analysis_options.yaml b/pkgs/hooks/analysis_options.yaml index a366861354..1af54d8810 100644 --- a/pkgs/hooks/analysis_options.yaml +++ b/pkgs/hooks/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -14,7 +12,3 @@ linter: - prefer_expression_function_bodies - prefer_final_in_for_each - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/hooks/example/api/build_snippet_2.dart b/pkgs/hooks/example/api/build_snippet_2.dart index 8af090650c..3a8df33cdf 100644 --- a/pkgs/hooks/example/api/build_snippet_2.dart +++ b/pkgs/hooks/example/api/build_snippet_2.dart @@ -15,7 +15,7 @@ final packageAssetPath = Uri.file('data/$assetName'); void main(List args) async { await build(args, (input, output) async { - if (input.config.code.linkModePreference == LinkModePreference.static) { + if (input.config.code.linkModePreference == .static) { // Simulate that this hook only supports dynamic libraries. throw UnsupportedError('LinkModePreference.static is not supported.'); } diff --git a/pkgs/hooks/example/build/download_asset/ffigen.yaml b/pkgs/hooks/example/build/download_asset/ffigen.yaml index f54281512b..64fdcd065e 100644 --- a/pkgs/hooks/example/build/download_asset/ffigen.yaml +++ b/pkgs/hooks/example/build/download_asset/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeAddBindings description: | Bindings for `src/native_add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/native_add.dart' headers: entry-points: diff --git a/pkgs/hooks/example/build/download_asset/lib/src/hook_helpers/targets.dart b/pkgs/hooks/example/build/download_asset/lib/src/hook_helpers/targets.dart index 42131f76a3..fb3e0e6303 100644 --- a/pkgs/hooks/example/build/download_asset/lib/src/hook_helpers/targets.dart +++ b/pkgs/hooks/example/build/download_asset/lib/src/hook_helpers/targets.dart @@ -1,11 +1,6 @@ -// Copyright (c, null) 2025, the Dart project authors. Please see the AUTHORS -// file for details. All rights reserved. Use of this source code is governed by -// a BSD-style license that can be found in the LICENSE file. - -// THIS FILE IS AUTOGENERATED. TO UPDATE, RUN -// -// dart --enable-experiment=native-assets tool/generate_asset_hashes.dart -// +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. import 'package:code_assets/code_assets.dart'; diff --git a/pkgs/hooks/example/build/download_asset/pubspec.yaml b/pkgs/hooks/example/build/download_asset/pubspec.yaml index 85ccb935be..315d0ff582 100644 --- a/pkgs/hooks/example/build/download_asset/pubspec.yaml +++ b/pkgs/hooks/example/build/download_asset/pubspec.yaml @@ -8,7 +8,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/bui resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks/example/build/local_asset/hook/build.dart b/pkgs/hooks/example/build/local_asset/hook/build.dart index 17a996705b..55fd12f8a3 100644 --- a/pkgs/hooks/example/build/local_asset/hook/build.dart +++ b/pkgs/hooks/example/build/local_asset/hook/build.dart @@ -12,7 +12,7 @@ final packageAssetPath = Uri.file('assets/$assetName'); Future main(List args) async { await build(args, (input, output) async { - if (input.config.code.linkModePreference == LinkModePreference.static) { + if (input.config.code.linkModePreference == .static) { // Simulate that this build hook only supports dynamic libraries. throw UnsupportedError('LinkModePreference.static is not supported.'); } diff --git a/pkgs/hooks/example/build/local_asset/pubspec.yaml b/pkgs/hooks/example/build/local_asset/pubspec.yaml index 74c118b4c4..57727a3b38 100644 --- a/pkgs/hooks/example/build/local_asset/pubspec.yaml +++ b/pkgs/hooks/example/build/local_asset/pubspec.yaml @@ -8,7 +8,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/bui resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks/example/build/native_add_app/pubspec.yaml b/pkgs/hooks/example/build/native_add_app/pubspec.yaml index ae7de0464c..5b0f416f08 100644 --- a/pkgs/hooks/example/build/native_add_app/pubspec.yaml +++ b/pkgs/hooks/example/build/native_add_app/pubspec.yaml @@ -8,7 +8,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/bui resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: native_add_library: diff --git a/pkgs/hooks/example/build/native_add_library/ffigen.yaml b/pkgs/hooks/example/build/native_add_library/ffigen.yaml index 11e58af753..ab5214d0c9 100644 --- a/pkgs/hooks/example/build/native_add_library/ffigen.yaml +++ b/pkgs/hooks/example/build/native_add_library/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeAddBindings description: | Bindings for `src/native_add_library.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/native_add_library.dart' headers: entry-points: diff --git a/pkgs/hooks/example/build/native_add_library/pubspec.yaml b/pkgs/hooks/example/build/native_add_library/pubspec.yaml index 2ac0ac53e7..d1745367aa 100644 --- a/pkgs/hooks/example/build/native_add_library/pubspec.yaml +++ b/pkgs/hooks/example/build/native_add_library/pubspec.yaml @@ -8,7 +8,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/bui resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks/example/build/native_dynamic_linking/ffigen.yaml b/pkgs/hooks/example/build/native_dynamic_linking/ffigen.yaml index 71f7b4f62b..ef69658bf0 100644 --- a/pkgs/hooks/example/build/native_dynamic_linking/ffigen.yaml +++ b/pkgs/hooks/example/build/native_dynamic_linking/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: AddBindings description: | Bindings for `src/add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/add.dart' headers: entry-points: diff --git a/pkgs/hooks/example/build/native_dynamic_linking/pubspec.yaml b/pkgs/hooks/example/build/native_dynamic_linking/pubspec.yaml index d80e727522..6b9080b57c 100644 --- a/pkgs/hooks/example/build/native_dynamic_linking/pubspec.yaml +++ b/pkgs/hooks/example/build/native_dynamic_linking/pubspec.yaml @@ -8,7 +8,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/bui resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks/example/build/system_library/hook/build.dart b/pkgs/hooks/example/build/system_library/hook/build.dart index bfa0e33085..1bf451830b 100644 --- a/pkgs/hooks/example/build/system_library/hook/build.dart +++ b/pkgs/hooks/example/build/system_library/hook/build.dart @@ -14,11 +14,11 @@ void main(List arguments) async { name: 'memory.dart', linkMode: DynamicLoadingSystem( Uri.file(switch (targetOS) { - OS.android => 'libc.so.6', - OS.iOS => 'libc.dylib', - OS.linux => 'libc.so.6', - OS.macOS => 'libc.dylib', - OS.windows => 'ole32.dll', + .android => 'libc.so.6', + .iOS => 'libc.dylib', + .linux => 'libc.so.6', + .macOS => 'libc.dylib', + .windows => 'ole32.dll', _ => throw UnsupportedError('Unknown operating system: $targetOS'), }), ), diff --git a/pkgs/hooks/example/build/system_library/pubspec.yaml b/pkgs/hooks/example/build/system_library/pubspec.yaml index 98796805d6..07c49d07e4 100644 --- a/pkgs/hooks/example/build/system_library/pubspec.yaml +++ b/pkgs/hooks/example/build/system_library/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks/example/build/use_dart_api/ffigen.yaml b/pkgs/hooks/example/build/use_dart_api/ffigen.yaml index 43100ce048..70a7c2de4d 100644 --- a/pkgs/hooks/example/build/use_dart_api/ffigen.yaml +++ b/pkgs/hooks/example/build/use_dart_api/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeAddBindings description: | Bindings for `src/use_dart_api.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: "lib/src/use_dart_api_bindings_generated.dart" headers: entry-points: diff --git a/pkgs/hooks/example/build/use_dart_api/pubspec.yaml b/pkgs/hooks/example/build/use_dart_api/pubspec.yaml index 378cac101b..fd57ada56a 100644 --- a/pkgs/hooks/example/build/use_dart_api/pubspec.yaml +++ b/pkgs/hooks/example/build/use_dart_api/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks/example/link/app_with_asset_treeshaking/pubspec.yaml b/pkgs/hooks/example/link/app_with_asset_treeshaking/pubspec.yaml index df9a844950..3ff0fc7eb1 100644 --- a/pkgs/hooks/example/link/app_with_asset_treeshaking/pubspec.yaml +++ b/pkgs/hooks/example/link/app_with_asset_treeshaking/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: logging: ^1.3.0 diff --git a/pkgs/hooks/example/link/package_with_assets/hook/link.dart b/pkgs/hooks/example/link/package_with_assets/hook/link.dart index 0ea25382e3..9cab968518 100644 --- a/pkgs/hooks/example/link/package_with_assets/hook/link.dart +++ b/pkgs/hooks/example/link/package_with_assets/hook/link.dart @@ -11,18 +11,29 @@ import 'package:data_assets/data_assets.dart'; import 'package:hooks/hooks.dart'; import 'package:record_use/record_use.dart'; -const multiplyIdentifier = Identifier( - importUri: 'package:package_with_assets/package_with_assets.dart', - name: 'AssetUsed', +const someMethodDefinition = Definition( + 'package:package_with_assets/package_with_assets.dart', + [Name(kind: .methodKind, 'someMethod')], ); +const someOtherMethodDefinition = Definition( + 'package:package_with_assets/package_with_assets.dart', + [Name(kind: .methodKind, 'someOtherMethod')], +); + +final assetMapping = { + someMethodDefinition: 'assets/used_asset.json', + someOtherMethodDefinition: 'assets/unused_asset.json', +}; + void main(List args) async { await link(args, (input, output) async { final usages = input.usages; - final usedAssets = usages - .constantsOf(multiplyIdentifier) - .map((e) => e['assetName'] as String); + final usedAssets = [ + for (final entry in assetMapping.entries) + if (usages.calls.containsKey(entry.key)) entry.value, + ]; output.assets.data.addAll( input.assets.data.where( @@ -33,11 +44,11 @@ void main(List args) async { } extension on LinkInput { - RecordedUsages get usages { + Recordings get usages { final usagesFile = recordedUsagesFile; final usagesContent = File.fromUri(usagesFile!).readAsStringSync(); final usagesJson = jsonDecode(usagesContent) as Map; - final usages = RecordedUsages.fromJson(usagesJson); + final usages = Recordings.fromJson(usagesJson); return usages; } } diff --git a/pkgs/hooks/example/link/package_with_assets/lib/package_with_assets.dart b/pkgs/hooks/example/link/package_with_assets/lib/package_with_assets.dart index a96b024631..cc7a6242e9 100644 --- a/pkgs/hooks/example/link/package_with_assets/lib/package_with_assets.dart +++ b/pkgs/hooks/example/link/package_with_assets/lib/package_with_assets.dart @@ -10,19 +10,9 @@ import 'package:meta/meta.dart'; //also https://github.com/dart-lang/sdk/issues/54003. /// A method that uses an asset. -@AssetUsed('assets/used_asset.json') +@RecordUse() String someMethod() => 'Using used_asset'; /// Another method that uses an asset. -@AssetUsed('assets/unused_asset.json') -String someOtherMethod() => 'Using unused_asset'; - -/// An annotation to mark that an asset is used. @RecordUse() -class AssetUsed { - /// The name of the asset being used. - final String assetName; - - /// Creates an [AssetUsed] annotation. - const AssetUsed(this.assetName); -} +String someOtherMethod() => 'Using unused_asset'; diff --git a/pkgs/hooks/example/link/package_with_assets/pubspec.yaml b/pkgs/hooks/example/link/package_with_assets/pubspec.yaml index bc7946d7c9..4b70189418 100644 --- a/pkgs/hooks/example/link/package_with_assets/pubspec.yaml +++ b/pkgs/hooks/example/link/package_with_assets/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks/lib/hooks.dart b/pkgs/hooks/lib/hooks.dart index 5e42bcfdf2..26a7410692 100644 --- a/pkgs/hooks/lib/hooks.dart +++ b/pkgs/hooks/lib/hooks.dart @@ -72,6 +72,44 @@ /// /// For more information see /// [dart.dev/tools/hooks](https://dart.dev/tools/hooks). +/// +/// ## Environment +/// +/// Hooks are executed in a semi-hermetic environment. This means that +/// `Platform.environment` does not expose all environment variables from the +/// parent process. This ensures that hook invocations are reproducible and +/// cacheable, and do not depend on accidental environment variables. +/// +/// However, some environment variables are necessary for locating tools (like +/// compilers) or configuring network access. The following environment +/// variables are passed through to the hook process: +/// +/// * **Path and system roots:** +/// * `PATH`: Invoke native tools. +/// * `HOME`, `USERPROFILE`: Find tools in default install locations. +/// * `SYSTEMDRIVE`, `SYSTEMROOT`, `WINDIR`: Process invocations and CMake +/// on Windows. +/// * `PROGRAMDATA`: For `vswhere.exe` on Windows. +/// * **Temporary directories:** +/// * `TEMP`, `TMP`, `TMPDIR`: Temporary directories. +/// * **HTTP proxies:** +/// * `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`: Network access behind +/// proxies. +/// * **Clang/LLVM:** +/// * `LIBCLANG_PATH`: Rust's `bindgen` + `clang-sys`. +/// * **Android NDK:** +/// * `ANDROID_HOME`: Standard location for the Android SDK/NDK. +/// * `ANDROID_NDK`, `ANDROID_NDK_HOME`, `ANDROID_NDK_LATEST_HOME`, +/// `ANDROID_NDK_ROOT`: Alternative locations for the NDK. +/// * **Ccache:** +/// * Any variable starting with `CCACHE_`. +/// * **Nix:** +/// * Any variable starting with `NIX_`. +/// +/// Any changes to these environment variables will cause cache invalidation for +/// hooks. +/// +/// All other environment variables are stripped. library; export 'src/api/build_and_link.dart' show build, link; diff --git a/pkgs/hooks/lib/src/api/build_and_link.dart b/pkgs/hooks/lib/src/api/build_and_link.dart index 0c6a04ef65..48bd7d615c 100644 --- a/pkgs/hooks/lib/src/api/build_and_link.dart +++ b/pkgs/hooks/lib/src/api/build_and_link.dart @@ -52,7 +52,7 @@ import '../validation.dart'; /// /// void main(List args) async { /// await build(args, (input, output) async { -/// if (input.config.code.linkModePreference == LinkModePreference.static) { +/// if (input.config.code.linkModePreference == .static) { /// // Simulate that this hook only supports dynamic libraries. /// throw UnsupportedError('LinkModePreference.static is not supported.'); /// } @@ -78,10 +78,43 @@ import '../validation.dart'; /// } /// ``` /// -/// If the [builder] fails, it must `throw` a [HookError]. Build hooks are -/// guaranteed to be invoked with a process invocation and should return a -/// non-zero exit code on failure. Throwing will lead to an uncaught exception, -/// causing a non-zero exit code. +/// ## Environment +/// +/// Build hooks are executed in a semi-hermetic environment. This means that +/// `Platform.environment` does not expose all environment variables from the +/// parent process. This ensures that hook invocations are reproducible and +/// cacheable, and do not depend on accidental environment variables. +/// +/// However, some environment variables are necessary for locating tools (like +/// compilers) or configuring network access. The following environment +/// variables are passed through to the hook process: +/// +/// * **Path and system roots:** +/// * `PATH`: Invoke native tools. +/// * `HOME`, `USERPROFILE`: Find tools in default install locations. +/// * `SYSTEMDRIVE`, `SYSTEMROOT`, `WINDIR`: Process invocations and CMake +/// on Windows. +/// * `PROGRAMDATA`: For `vswhere.exe` on Windows. +/// * **Temporary directories:** +/// * `TEMP`, `TMP`, `TMPDIR`: Temporary directories. +/// * **HTTP proxies:** +/// * `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`: Network access behind +/// proxies. +/// * **Clang/LLVM:** +/// * `LIBCLANG_PATH`: Rust's `bindgen` + `clang-sys`. +/// * **Android NDK:** +/// * `ANDROID_HOME`: Standard location for the Android SDK/NDK. +/// * `ANDROID_NDK`, `ANDROID_NDK_HOME`, `ANDROID_NDK_LATEST_HOME`, +/// `ANDROID_NDK_ROOT`: Alternative locations for the NDK. +/// * **Ccache:** +/// * Any variable starting with `CCACHE_`. +/// * **Nix:** +/// * Any variable starting with `NIX_`. +/// +/// Any changes to these environment variables will cause cache invalidation for +/// hooks. +/// +/// All other environment variables are stripped. /// /// ## Debugging /// @@ -172,7 +205,7 @@ Future build( for (final error in errors) '- $error', ].join('\n'); stderr.writeln(message); - output.setFailure(FailureType.build); + output.setFailure(.build); await _writeOutput(output, outputFile); exit(BuildError(message: message).exitCode); } @@ -213,6 +246,44 @@ Future build( /// non-zero exit code on failure. Throwing will lead to an uncaught exception, /// causing a non-zero exit code. /// +/// ## Environment +/// +/// Link hooks are executed in a semi-hermetic environment. This means that +/// `Platform.environment` does not expose all environment variables from the +/// parent process. This ensures that hook invocations are reproducible and +/// cacheable, and do not depend on accidental environment variables. +/// +/// However, some environment variables are necessary for locating tools (like +/// compilers) or configuring network access. The following environment +/// variables are passed through to the hook process: +/// +/// * **Path and system roots:** +/// * `PATH`: Invoke native tools. +/// * `HOME`, `USERPROFILE`: Find tools in default install locations. +/// * `SYSTEMDRIVE`, `SYSTEMROOT`, `WINDIR`: Process invocations and CMake +/// on Windows. +/// * `PROGRAMDATA`: For `vswhere.exe` on Windows. +/// * **Temporary directories:** +/// * `TEMP`, `TMP`, `TMPDIR`: Temporary directories. +/// * **HTTP proxies:** +/// * `HTTP_PROXY`, `HTTPS_PROXY`, `NO_PROXY`: Network access behind +/// proxies. +/// * **Clang/LLVM:** +/// * `LIBCLANG_PATH`: Rust's `bindgen` + `clang-sys`. +/// * **Android NDK:** +/// * `ANDROID_HOME`: Standard location for the Android SDK/NDK. +/// * `ANDROID_NDK`, `ANDROID_NDK_HOME`, `ANDROID_NDK_LATEST_HOME`, +/// `ANDROID_NDK_ROOT`: Alternative locations for the NDK. +/// * **Ccache:** +/// * Any variable starting with `CCACHE_`. +/// * **Nix:** +/// * Any variable starting with `NIX_`. +/// +/// Any changes to these environment variables will cause cache invalidation for +/// hooks. +/// +/// All other environment variables are stripped. +/// /// ## Debugging /// /// When a link hook doesn't work as expected, you can investigate the @@ -302,7 +373,7 @@ Future link( for (final error in errors) '- $error', ].join('\n'); stderr.writeln(message); - output.setFailure(FailureType.build); + output.setFailure(.build); await _writeOutput(output, outputFile); exit(BuildError(message: message).exitCode); } diff --git a/pkgs/hooks/lib/src/config.dart b/pkgs/hooks/lib/src/config.dart index 1b3d4d62c7..2a29946db2 100644 --- a/pkgs/hooks/lib/src/config.dart +++ b/pkgs/hooks/lib/src/config.dart @@ -495,7 +495,7 @@ sealed class HookOutputBuilder { timestamp: DateTime.now().roundDownToSeconds().toString(), assets: null, dependencies: null, - status: OutputStatusSyntax.success, + status: .success, failureDetails: null, assetsForLinking: {}, ); @@ -529,13 +529,13 @@ sealed class HookOutputBuilder { /// Sets the failure of this output. void setFailure(FailureType value) { - _syntax.status = OutputStatusSyntax.failure; + _syntax.status = .failure; _syntax.failureDetails = FailureSyntax( type: switch (value) { - FailureType.build => FailureTypeSyntax.build, - FailureType.infra => FailureTypeSyntax.infra, - FailureType.uncategorized => FailureTypeSyntax.uncategorized, - _ => FailureTypeSyntax.uncategorized, + FailureType.build => .build, + FailureType.infra => .infra, + FailureType.uncategorized => .uncategorized, + _ => .uncategorized, }, ); } @@ -1217,9 +1217,9 @@ final class HookOutputFailure { /// This helps in categorizing the error and determining the appropriate /// response or fix. FailureType get type => switch (_syntax.failureDetails?.type) { - FailureTypeSyntax.build => FailureType.build, - FailureTypeSyntax.infra => FailureType.infra, - FailureTypeSyntax.uncategorized => FailureType.uncategorized, + .build => FailureType.build, + .infra => FailureType.infra, + .uncategorized => FailureType.uncategorized, _ => FailureType.uncategorized, }; } @@ -1250,9 +1250,9 @@ sealed class BuildOutputMaybeFailure { final status = syntax.status; switch (status) { case null: // backwards compatibility. - case OutputStatusSyntax.success: + case .success: return BuildOutput(json); - case OutputStatusSyntax.failure: + case .failure: return BuildOutputFailure._(json); } throw StateError('Unknown status: $status.'); @@ -1269,9 +1269,9 @@ sealed class LinkOutputMaybeFailure { final status = syntax.status; switch (status) { case null: // backwards compatibility. - case OutputStatusSyntax.success: + case .success: return LinkOutput(json); - case OutputStatusSyntax.failure: + case .failure: return LinkOutputFailure._(json); } throw StateError('Unknown status: $status.'); diff --git a/pkgs/hooks/pubspec.yaml b/pkgs/hooks/pubspec.yaml index fbda872693..5c05673668 100644 --- a/pkgs/hooks/pubspec.yaml +++ b/pkgs/hooks/pubspec.yaml @@ -3,7 +3,7 @@ description: >- A library that contains a Dart API for the JSON-based protocol for `hook/build.dart` and `hook/link.dart`. -version: 1.0.0 +version: 1.0.2 repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks @@ -17,7 +17,7 @@ topics: resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: collection: ^1.19.1 @@ -30,7 +30,6 @@ dependencies: dev_dependencies: args: ^2.6.0 code_assets: ^1.0.0 # Used for running tests with real asset types. - custom_lint: ^0.7.5 dart_flutter_team_lints: ^3.5.2 data_assets: any # Used for running tests with real asset types. file_testing: ^3.0.2 @@ -41,6 +40,4 @@ dev_dependencies: native_test_helpers: path: ../native_test_helpers/ path: ^1.9.1 - repo_lint_rules: - path: ../repo_lint_rules/ test: ^1.25.15 diff --git a/pkgs/hooks/tool/update_snippets.dart b/pkgs/hooks/tool/update_snippets.dart index 0ae7ee8f06..354ecd36d0 100644 --- a/pkgs/hooks/tool/update_snippets.dart +++ b/pkgs/hooks/tool/update_snippets.dart @@ -21,7 +21,7 @@ void main(List args) { final counts = Counts(); final errors = []; final hooksPackageRoot = findPackageRoot('hooks'); - for (final package in ['hooks', 'code_assets', 'data_assets']) { + for (final package in ['hooks', 'code_assets', 'data_assets', 'record_use']) { final packageRoot = hooksPackageRoot.resolve('../$package/'); final files = Directory.fromUri(packageRoot) @@ -141,7 +141,7 @@ String updateSnippets(String oldContent, Uri fileUri, List errors) { final lineBeforeText = oldContent.split('\n')[lastLineOfContentBefore]; final fileLineMatch = RegExp( - r'^(.*?)\s*$', + r'^(.*?)\s*$', ).firstMatch(lineBeforeText); if (fileLineMatch == null) { @@ -163,7 +163,8 @@ String updateSnippets(String oldContent, Uri fileUri, List errors) { } final filePath = fileLineMatch.group(2); - final noSourceFile = fileLineMatch.group(3) != null; + final anchor = fileLineMatch.group(3); + final noSourceFile = fileLineMatch.group(4) != null; if (noSourceFile || filePath == null) continue; @@ -179,14 +180,42 @@ String updateSnippets(String oldContent, Uri fileUri, List errors) { ); var newSnippetText = snippetContent; + final String startMarker; + final String endMarker; + if (anchor == null) { + startMarker = '// snippet-start'; + endMarker = '// snippet-end'; + } else { + startMarker = '// snippet-start#$anchor'; + endMarker = '// snippet-end#$anchor'; + } + final anchorRegex = RegExp( - r'// snippet-start\n([\s\S]*?)// snippet-end', + '${RegExp.escape(startMarker)}\\n([\\s\\S]*?)${RegExp.escape(endMarker)}', multiLine: true, ); final extractedMatch = anchorRegex.firstMatch(snippetContent); if (extractedMatch != null) { newSnippetText = extractedMatch.group(1)!; + } else { + if (anchor != null) { + errors.add('Error: Anchor "$anchor" not found in $snippetUri.'); + continue; + } + // If no anchor was specified and // snippet-start wasn't found, + // we use the whole file (original behavior). } + + // Strip any (nested) snippet markers from the extracted content. + final markerRegex = RegExp( + r'^[ \t]*// snippet-(?:start|end)(?:#\S+)?[ \t]*\n?', + multiLine: true, + ); + newSnippetText = newSnippetText.replaceAll(markerRegex, ''); + + newSnippetText = _dedent(newSnippetText); + newSnippetText = newSnippetText.trim(); + final copyrightRegex = RegExp(r''' // Copyright \(c\) [0-9]*, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a @@ -216,3 +245,27 @@ String updateSnippets(String oldContent, Uri fileUri, List errors) { return newContent; } + +String _dedent(String text) { + final lines = text.split('\n'); + if (lines.isEmpty) return text; + + // Find minimum indentation of non-empty lines. + int? minIndent; + for (final line in lines) { + if (line.trim().isEmpty) continue; + final indent = line.length - line.trimLeft().length; + if (minIndent == null || indent < minIndent) { + minIndent = indent; + } + } + + if (minIndent == null || minIndent == 0) return text; + + return lines + .map((line) { + if (line.trim().isEmpty) return ''; + return line.substring(minIndent!); + }) + .join('\n'); +} diff --git a/pkgs/hooks_runner/CHANGELOG.md b/pkgs/hooks_runner/CHANGELOG.md index 08cde6bce8..793e4c115b 100644 --- a/pkgs/hooks_runner/CHANGELOG.md +++ b/pkgs/hooks_runner/CHANGELOG.md @@ -1,4 +1,14 @@ -## 1.0.2-wip +## 1.1.1-wip + +- Nothing yet. + +## 1.1.0 + +- Filter `recorded_uses.json` passed to link hooks based on the + package name of the definition. +- Add `CCACHE_` to the environment variables allowlist. + +## 1.0.2 - Pass `HTTP(S)_PROXY` and related environment variables to hooks. - Add `ANDROID_NDK`, `ANDROID_NDK_HOME`, `ANDROID_NDK_LATEST_HOME` and diff --git a/pkgs/hooks_runner/analysis_options.yaml b/pkgs/hooks_runner/analysis_options.yaml index c0462a3a77..6423864d34 100644 --- a/pkgs/hooks_runner/analysis_options.yaml +++ b/pkgs/hooks_runner/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -14,6 +12,5 @@ linter: - prefer_final_in_for_each - prefer_final_locals -custom_lint: - rules: - - avoid_import_outside_src +formatter: + trailing_commas: preserve diff --git a/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart b/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart index 9376815817..f9ebbb505a 100644 --- a/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart +++ b/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart @@ -76,8 +76,8 @@ class NativeAssetsBuildPlanner { 'BuildPlanner.packagesWithHook', arguments: {'hook': hook.toString()}, () async => switch (hook) { - Hook.build => _packagesWithBuildHook ??= await _runPackagesWithHook(hook), - Hook.link => _packagesWithLinkHook ??= await _runPackagesWithHook(hook), + .build => _packagesWithBuildHook ??= await _runPackagesWithHook(hook), + .link => _packagesWithLinkHook ??= await _runPackagesWithHook(hook), }, ); diff --git a/pkgs/hooks_runner/lib/src/build_runner/build_runner.dart b/pkgs/hooks_runner/lib/src/build_runner/build_runner.dart index 46c01c1ab7..1370869ddc 100644 --- a/pkgs/hooks_runner/lib/src/build_runner/build_runner.dart +++ b/pkgs/hooks_runner/lib/src/build_runner/build_runner.dart @@ -13,6 +13,7 @@ import 'package:hooks/hooks.dart'; import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; import 'package:package_config/package_config.dart'; +import 'package:record_use/record_use.dart'; import 'package:yaml/yaml.dart'; import '../dependencies_hash_file/dependencies_hash_file.dart'; @@ -27,6 +28,8 @@ import 'failure.dart'; import 'result.dart'; import 'tracing_file_system.dart'; +const _jsonEncoder = JsonEncoder.withIndent(' '); + typedef InputCreator = HookInputBuilder Function(); typedef BuildInputCreator = BuildInputBuilder Function(); @@ -133,7 +136,7 @@ class NativeAssetsBuildRunner { required List extensions, required bool linkingEnabled, }) async => _timeAsync('BuildRunner.build', () async { - final planResult = await _makePlan(hook: Hook.build, buildResult: null); + final planResult = await _makePlan(hook: .build, buildResult: null); if (planResult.isFailure) { return planResult.asFailure; } @@ -249,10 +252,7 @@ class NativeAssetsBuildRunner { Uri? resourceIdentifiers, required BuildResult buildResult, }) async => _timeAsync('BuildRunner.link', () async { - final planResult = await _makePlan( - hook: Hook.link, - buildResult: buildResult, - ); + final planResult = await _makePlan(hook: .link, buildResult: buildResult); if (planResult.isFailure) return planResult.asFailure; final (buildPlan, packageGraph) = planResult.success; if (buildPlan.isEmpty) { @@ -267,12 +267,29 @@ class NativeAssetsBuildRunner { } var linkResult = hookResultUserDefines.success; + Recordings? packageRecordings; + if (resourceIdentifiers != null) { + final file = _fileSystem.file(resourceIdentifiers); + try { + final content = await file.readAsString(); + packageRecordings = Recordings.fromJson( + jsonDecode(content) as Map, + ); + } on FormatException catch (e) { + logger.severe( + 'Failed to parse resource identifiers from $resourceIdentifiers: $e', + ); + return const Failure(HooksRunnerFailure.internal); + } + } + /// The key is the package name of the destination package. final globalAssetsForLink = >>{}; for (final package in buildPlan) { - final dependencies = packageGraph! - .inverseNeighborsOf(package.name) - .toSet(); + final dependencies = { + ...packageGraph!.inverseNeighborsOf(package.name), + package.name, + }; final assetsFromLinking = (globalAssetsForLink[package.name] ?? {}) .entries @@ -292,10 +309,17 @@ class NativeAssetsBuildRunner { ); File? resourcesFile; - if (resourceIdentifiers != null) { - resourcesFile = _fileSystem.file(buildDirUri.resolve('resources.json')); + if (packageRecordings != null) { + resourcesFile = _fileSystem.file( + buildDirUri.resolve('recorded_uses.json'), + ); await resourcesFile.create(); - await _fileSystem.file(resourceIdentifiers).copy(resourcesFile.path); + final filteredRecordings = packageRecordings.filter( + definitionPackageName: package.name, + ); + await resourcesFile.writeAsString( + _jsonEncoder.convert(filteredRecordings.toJson()), + ); } inputBuilder.setupShared( @@ -496,7 +520,10 @@ class NativeAssetsBuildRunner { ' in ${buildDirUri.toFilePath()}.' ' Last build on ${output.timestamp}.', ); - return Success((output, hookHashes.fileSystemEntities)); + return Success(( + output, + [...hookHashes.fileSystemEntities, ?resources], + )); } } } @@ -525,14 +552,17 @@ class NativeAssetsBuildRunner { } else { final success = result.success; final modifiedDuringBuild = await dependenciesHashes.hashDependencies( - [...success.dependencies], + [...success.dependencies, ?resources], lastModifiedCutoffTime, hookEnvironment, ); if (modifiedDuringBuild != null) { logger.severe('File modified during build. Build must be rerun.'); } - return Success((success, hookHashes.fileSystemEntities)); + return Success(( + success, + [...hookHashes.fileSystemEntities, ?resources], + )); } }, ), @@ -584,6 +614,7 @@ class NativeAssetsBuildRunner { ..._httpProxyEnvironmentVariables, }; const variablePrefixesFilter = { + 'CCACHE_', // Needed for Ccache. 'NIX_', // Needed for Nix-installed toolchains. }; @@ -602,9 +633,7 @@ class NativeAssetsBuildRunner { Uri outputDirectory, ) => _timeAsync('_runHookForPackage', () async { final inputFile = buildDirUri.resolve('input.json'); - final inputFileContents = const JsonEncoder.withIndent( - ' ', - ).convert(input.json); + final inputFileContents = _jsonEncoder.convert(input.json); logger.info('input.json contents:\n$inputFileContents'); await _fileSystem.file(inputFile).writeAsString(inputFileContents); final hookOutputUri = input.outputFile; @@ -898,7 +927,7 @@ ${compileResult.stdout} if (input is BuildInput) { final planner = await _planner; final packagesWithLink = (await planner.packagesWithHook( - Hook.link, + .link, )).map((p) => p.name); for (final targetPackage in (output as BuildOutput).assets.encodedAssetsForLinking.keys) { @@ -934,14 +963,14 @@ ${compileResult.stdout} _makePlan({required Hook hook, BuildResult? buildResult}) async => _timeAsync('_makePlan', () async { switch (hook) { - case Hook.build: + case .build: final planner = await _planner; final planResult = await planner.makeBuildHookPlan(); if (planResult.isFailure) { return planResult.asFailure; } return Success((planResult.success, planner.packageGraph)); - case Hook.link: + case .link: final planner = await _planner; final planResult = await planner.makeLinkHookPlan(); if (planResult.isFailure) { @@ -972,10 +1001,10 @@ ${e.message}'''); return const Failure(HooksRunnerFailure.hookRun); } switch (hook) { - case Hook.build: + case .build: final buildInput = BuildInput(hookInputJson); return Success(buildInput); - case Hook.link: + case .link: final linkInput = LinkInput(hookInputJson); return Success(linkInput); } @@ -1012,7 +1041,7 @@ ${e.message}'''); return const Failure(HooksRunnerFailure.hookRun); } switch (hook) { - case Hook.build: + case .build: final output = BuildOutputMaybeFailure(hookOutputJson); switch (output) { case BuildOutput _: @@ -1022,7 +1051,7 @@ ${e.message}'''); case BuildOutputFailure _: return const Failure(HooksRunnerFailure.hookRun); } - case Hook.link: + case .link: final output = LinkOutputMaybeFailure(hookOutputJson); switch (output) { case LinkOutput _: diff --git a/pkgs/hooks_runner/lib/src/locking/locking.dart b/pkgs/hooks_runner/lib/src/locking/locking.dart index 46cdff9ccf..9b6b99901d 100644 --- a/pkgs/hooks_runner/lib/src/locking/locking.dart +++ b/pkgs/hooks_runner/lib/src/locking/locking.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:async'; -import 'dart:io' show Platform, pid; +import 'dart:io' show FileLock, Platform, pid; import 'package:file/file.dart'; import 'package:logging/logging.dart'; @@ -85,7 +85,7 @@ Future _runUnderFileLock( Logger? logger, }) async { if (!await file.exists()) await file.create(recursive: true); - final randomAccessFile = await file.open(mode: FileMode.write); + final randomAccessFile = await file.open(mode: .write); var printed = false; var errorFromCallback = false; final stopwatch = Stopwatch()..start(); diff --git a/pkgs/hooks_runner/lib/src/model/target.dart b/pkgs/hooks_runner/lib/src/model/target.dart index 6c9bb76e27..a485a46fbd 100644 --- a/pkgs/hooks_runner/lib/src/model/target.dart +++ b/pkgs/hooks_runner/lib/src/model/target.dart @@ -145,7 +145,7 @@ final class Target implements Comparable { /// Compares `this` to [other]. /// - /// If [other] is also an [Target], consistent with sorting on [toString]. + /// If [other] is also a [Target], consistent with sorting on [toString]. @override int compareTo(Target other) => toString().compareTo(other.toString()); diff --git a/pkgs/hooks_runner/lib/src/utils/run_process.dart b/pkgs/hooks_runner/lib/src/utils/run_process.dart index a0df5b9cb7..6f5707c793 100644 --- a/pkgs/hooks_runner/lib/src/utils/run_process.dart +++ b/pkgs/hooks_runner/lib/src/utils/run_process.dart @@ -45,9 +45,8 @@ Future runProcess({ arguments: { 'executable': executable.toFilePath(), 'arguments': arguments, - if (workingDirectory != null) - 'workingDirectory': workingDirectory.toFilePath(), - if (environment != null) 'environment': environment, + 'workingDirectory': ?workingDirectory?.toFilePath(), + 'environment': ?environment, }, ); try { diff --git a/pkgs/hooks_runner/pubspec.yaml b/pkgs/hooks_runner/pubspec.yaml index 7f113d1647..aab81a8677 100644 --- a/pkgs/hooks_runner/pubspec.yaml +++ b/pkgs/hooks_runner/pubspec.yaml @@ -2,14 +2,14 @@ name: hooks_runner description: >- This package is the backend that invokes build hooks. -version: 1.0.2-wip +version: 1.1.1-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks_runner resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: ^1.0.0 # Needed for OS for Target for KernelAssets. @@ -22,11 +22,11 @@ dependencies: meta: ^1.16.0 package_config: ^2.1.0 pub_semver: ^2.2.0 + record_use: ^0.6.0-wip yaml: ^3.1.3 dev_dependencies: args: any - custom_lint: ^0.7.5 dart_flutter_team_lints: ^3.5.2 data_assets: any # Used in tests. file_testing: ^3.0.2 @@ -34,6 +34,4 @@ dev_dependencies: path: ../native_test_helpers/ pub_formats: # Used in tests. path: ../pub_formats/ - repo_lint_rules: - path: ../repo_lint_rules/ test: ^1.25.15 diff --git a/pkgs/hooks_runner/test/build_runner/absolute_path_test.dart b/pkgs/hooks_runner/test/build_runner/absolute_path_test.dart index 40f9daf51b..c23418152d 100644 --- a/pkgs/hooks_runner/test/build_runner/absolute_path_test.dart +++ b/pkgs/hooks_runner/test/build_runner/absolute_path_test.dart @@ -7,8 +7,10 @@ import 'package:test/test.dart'; import '../helpers.dart'; import 'helpers.dart'; +const Timeout longTimeout = Timeout(Duration(minutes: 5)); + void main() async { - test('relative path', () async { + test('relative path', timeout: longTimeout, () async { await inTempDir((tempUri) async { await copyTestProjects(targetUri: tempUri); final packageUri = tempUri.resolve('relative_path/'); diff --git a/pkgs/hooks_runner/test/build_runner/build_dependencies_test.dart b/pkgs/hooks_runner/test/build_runner/build_dependencies_test.dart index 608e60d238..95d529eeb2 100644 --- a/pkgs/hooks_runner/test/build_runner/build_dependencies_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_dependencies_test.dart @@ -28,7 +28,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect( logMessages.join('\n'), diff --git a/pkgs/hooks_runner/test/build_runner/build_planner_test.dart b/pkgs/hooks_runner/test/build_runner/build_planner_test.dart index b49e6460ec..6232cefb8e 100644 --- a/pkgs/hooks_runner/test/build_runner/build_planner_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_planner_test.dart @@ -38,7 +38,7 @@ void main() async { fileSystem: const LocalFileSystem(), ); final packagesWithHook = await nativeAssetsBuildPlanner.packagesWithHook( - Hook.build, + .build, ); expect(packagesWithHook.length, 1); final buildPlan = await nativeAssetsBuildPlanner.makeBuildHookPlan(); diff --git a/pkgs/hooks_runner/test/build_runner/build_process_helper.dart b/pkgs/hooks_runner/test/build_runner/build_process_helper.dart index 64ef38a4b6..113bac7589 100644 --- a/pkgs/hooks_runner/test/build_runner/build_process_helper.dart +++ b/pkgs/hooks_runner/test/build_runner/build_process_helper.dart @@ -20,7 +20,7 @@ void main(List args) async { final target = Target.fromString(args[1]); final logger = Logger('') - ..level = Level.ALL + ..level = .ALL ..onRecord.listen((event) => print(event.message)); final targetOS = target.os; @@ -43,13 +43,13 @@ void main(List args) async { CodeAssetExtension( targetArchitecture: target.architecture, targetOS: targetOS, - macOS: targetOS == OS.macOS + macOS: targetOS == .macOS ? MacOSCodeConfig(targetVersion: defaultMacOSVersion) : null, - android: targetOS == OS.android + android: targetOS == .android ? AndroidCodeConfig(targetNdkApi: 30) : null, - linkModePreference: LinkModePreference.dynamic, + linkModePreference: .dynamic, ), DataAssetsExtension(), ], diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_asset_id_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_asset_id_test.dart index f88b906386..20bedb2985 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_asset_id_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_asset_id_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:logging/logging.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -22,9 +21,9 @@ void main() async { final logMessages = []; final result = await build( packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], ); final fullLog = logMessages.join('\n'); expect(result.isFailure, isTrue); @@ -52,7 +51,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], ); expect(result, isNotNull); } diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_build_output_format_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_build_output_format_test.dart index be62f2a397..c995df97d5 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_build_output_format_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_build_output_format_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:logging/logging.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -28,7 +27,7 @@ void main() async { final logMessages = []; final result = await build( packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, buildAssetTypes: [], ); diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_caching_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_caching_test.dart index bbfd7ff6ae..84e972344f 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_caching_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_caching_test.dart @@ -34,7 +34,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], userDefines: userDefines, )).success; expect( @@ -78,7 +78,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], userDefines: userDefines, )).success; final hookUri = packageUri.resolve('hook/build.dart'); @@ -128,7 +128,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], userDefines: userDefines, )).success; expect( @@ -156,7 +156,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; await expectSymbols( asset: CodeAsset.fromEncoded(result.encodedAssets.single), @@ -175,7 +175,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; final cUri = packageUri.resolve('src/').resolve('native_add.c'); @@ -238,7 +238,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; final hookUri = packageUri.resolve('hook/build.dart'); @@ -272,7 +272,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], hookEnvironment: modifiedEnvKey == 'PATH' ? null : filteredEnvironment( @@ -307,7 +307,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(logMessages.join('\n'), contains('hook.dill')); expect( diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_cycle_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_cycle_test.dart index 088a0e7411..b6eccda2c7 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_cycle_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_cycle_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'package:hooks_runner/src/model/hook_result.dart' show HookResult; -import 'package:logging/logging.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -23,7 +22,7 @@ void main() async { final logMessages = []; final result = await build( packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, buildAssetTypes: [], ); @@ -52,7 +51,7 @@ void main() async { final result = await link( buildResult: HookResult(), packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, buildAssetTypes: [], ); diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_failure_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_failure_test.dart index 90626244f2..02993f5857 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_failure_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_failure_test.dart @@ -27,7 +27,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets.length, 1); await expectSymbols( @@ -80,7 +80,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets.length, 1); await expectSymbols( @@ -111,7 +111,7 @@ void main() async { logger, capturedLogs: logMessages, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], ); Matcher stringContainsBuildHookCompilation(String packageName) => stringContainsInOrder([ diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_non_root_package_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_non_root_package_test.dart index 00745c7fc4..264cf3ee47 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_non_root_package_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_non_root_package_test.dart @@ -27,7 +27,7 @@ void main() async { dartExecutable, capturedLogs: logMessages, runPackageName: 'some_dev_dep', - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets, isEmpty); expect(result.dependencies, isEmpty); @@ -41,7 +41,7 @@ void main() async { dartExecutable, capturedLogs: logMessages, runPackageName: 'native_add', - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets, isNotEmpty); expect( diff --git a/pkgs/hooks_runner/test/build_runner/build_runner_test.dart b/pkgs/hooks_runner/test/build_runner/build_runner_test.dart index 33f12bf711..e01a52e3a5 100644 --- a/pkgs/hooks_runner/test/build_runner/build_runner_test.dart +++ b/pkgs/hooks_runner/test/build_runner/build_runner_test.dart @@ -29,7 +29,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect( logMessages.join('\n'), @@ -72,7 +72,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect( false, diff --git a/pkgs/hooks_runner/test/build_runner/concurrency_test.dart b/pkgs/hooks_runner/test/build_runner/concurrency_test.dart index d91b4513f4..c520d46dfd 100644 --- a/pkgs/hooks_runner/test/build_runner/concurrency_test.dart +++ b/pkgs/hooks_runner/test/build_runner/concurrency_test.dart @@ -114,11 +114,15 @@ void main() async { // Simulate hitting ctrl+c on `dart` and `flutter` commands at different // time intervals. var milliseconds = 200; - while (findLockFile(packageUri, packageName) == null) { + bool lockFileDoesNotExist() => + findLockFile(packageUri, packageName) == null; + while (lockFileDoesNotExist()) { final result = await runBuildInProcess( killAfter: Duration(milliseconds: milliseconds), ); - expect(result, isNot(0)); + if (lockFileDoesNotExist()) { + expect(result, isNot(0)); + } milliseconds = max((milliseconds * 1.2).round(), milliseconds + 200); } expect(findLockFile(packageUri, packageName), isNotNull); @@ -190,7 +194,7 @@ void main() async { ].toString(), ); - final randomAccessFile = await lockFile.open(mode: FileMode.write); + final randomAccessFile = await lockFile.open(mode: .write); final lock = await randomAccessFile.lock(FileLock.exclusive); var helperCompletedFirst = false; var timeoutCompletedFirst = false; diff --git a/pkgs/hooks_runner/test/build_runner/concurrency_test_helper.dart b/pkgs/hooks_runner/test/build_runner/concurrency_test_helper.dart index efae133177..531eced339 100644 --- a/pkgs/hooks_runner/test/build_runner/concurrency_test_helper.dart +++ b/pkgs/hooks_runner/test/build_runner/concurrency_test_helper.dart @@ -21,7 +21,7 @@ void main(List args) async { } final logger = Logger('') - ..level = Level.ALL + ..level = .ALL ..onRecord.listen((event) => print(event.message)); final targetOS = OS.current; @@ -45,7 +45,7 @@ void main(List args) async { targetOS: targetOS, linkModePreference: LinkModePreference.dynamic, cCompiler: dartCICompilerConfig, - macOS: targetOS == OS.macOS + macOS: targetOS == .macOS ? MacOSCodeConfig(targetVersion: defaultMacOSVersion) : null, ), diff --git a/pkgs/hooks_runner/test/build_runner/conflicting_dylib_test.dart b/pkgs/hooks_runner/test/build_runner/conflicting_dylib_test.dart index 253dc81160..601d3d380e 100644 --- a/pkgs/hooks_runner/test/build_runner/conflicting_dylib_test.dart +++ b/pkgs/hooks_runner/test/build_runner/conflicting_dylib_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:logging/logging.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -22,9 +21,9 @@ void main() async { final logMessages = []; final result = await build( packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], ); final fullLog = logMessages.join('\n'); expect(result.isFailure, isTrue); @@ -48,7 +47,7 @@ void main() async { logger, linkingEnabled: true, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; final linkResult = await link( @@ -56,7 +55,7 @@ void main() async { logger, dartExecutable, buildResult: buildResult, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], ); // Application validation error due to conflicting dylib name. expect(linkResult.isFailure, isTrue); diff --git a/pkgs/hooks_runner/test/build_runner/environment_filter_test.dart b/pkgs/hooks_runner/test/build_runner/environment_filter_test.dart index 5d6964c020..2126d18388 100644 --- a/pkgs/hooks_runner/test/build_runner/environment_filter_test.dart +++ b/pkgs/hooks_runner/test/build_runner/environment_filter_test.dart @@ -47,4 +47,41 @@ void main() { expect(result.exitCode, 0); }); }); + + test('includeHookEnvironmentVariable allows Ccache variables', () { + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('CCACHE_DIR'), + isTrue, + ); + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('CCACHE_DISABLE'), + isTrue, + ); + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('NOT_CCACHE'), + isFalse, + ); + }); + + test('includeHookEnvironmentVariable allows standard variables', () { + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('PATH'), + isTrue, + ); + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('HOME'), + isTrue, + ); + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('ANDROID_HOME'), + isTrue, + ); + }); + + test('includeHookEnvironmentVariable allows NIX_ variables', () { + expect( + NativeAssetsBuildRunner.includeHookEnvironmentVariable('NIX_CC'), + isTrue, + ); + }); } diff --git a/pkgs/hooks_runner/test/build_runner/link_caching_test.dart b/pkgs/hooks_runner/test/build_runner/link_caching_test.dart index 345edcc644..61d40a7803 100644 --- a/pkgs/hooks_runner/test/build_runner/link_caching_test.dart +++ b/pkgs/hooks_runner/test/build_runner/link_caching_test.dart @@ -40,7 +40,7 @@ void main() async { logger, dartExecutable, buildResult: buildResult, - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], capturedLogs: logMessages, )).success; } diff --git a/pkgs/hooks_runner/test/build_runner/link_test.dart b/pkgs/hooks_runner/test/build_runner/link_test.dart index efe053bc85..556b547807 100644 --- a/pkgs/hooks_runner/test/build_runner/link_test.dart +++ b/pkgs/hooks_runner/test/build_runner/link_test.dart @@ -36,7 +36,7 @@ void main() async { logger, dartExecutable, buildResult: buildResult, - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], )).success; expect(linkResult.encodedAssets.length, 2); @@ -91,7 +91,7 @@ void main() async { logger, dartExecutable, buildResult: buildResult, - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], )).success; expect( @@ -127,7 +127,7 @@ void main() async { logger, dartExecutable, buildResult: buildResult, - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], )).success; expect( @@ -155,7 +155,7 @@ void main() async { dartExecutable, capturedLogs: logMessages, buildResult: HookResult(), - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], ); final fullLog = logMessages.join('\n'); @@ -186,7 +186,7 @@ void main() async { logger, dartExecutable, linkingEnabled: true, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(buildResult.encodedAssets.length, 0); expect(buildResult.encodedAssetsForLinking.length, 1); @@ -198,7 +198,7 @@ void main() async { dartExecutable, buildResult: buildResult, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(linkResult.encodedAssets.length, 1); expect(linkResult.encodedAssets.first.isCodeAsset, isTrue); diff --git a/pkgs/hooks_runner/test/build_runner/no_build_output_test.dart b/pkgs/hooks_runner/test/build_runner/no_build_output_test.dart index 4c8ebedd33..a41fc44701 100644 --- a/pkgs/hooks_runner/test/build_runner/no_build_output_test.dart +++ b/pkgs/hooks_runner/test/build_runner/no_build_output_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:logging/logging.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -21,7 +20,7 @@ void main() async { final logMessages = []; final result = await build( packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, buildAssetTypes: [], ); diff --git a/pkgs/hooks_runner/test/build_runner/packaging_preference_test.dart b/pkgs/hooks_runner/test/build_runner/packaging_preference_test.dart index 2db989e82c..07c8d58e7a 100644 --- a/pkgs/hooks_runner/test/build_runner/packaging_preference_test.dart +++ b/pkgs/hooks_runner/test/build_runner/packaging_preference_test.dart @@ -23,32 +23,32 @@ void main() async { packageUri, logger, dartExecutable, - linkModePreference: LinkModePreference.dynamic, - buildAssetTypes: [BuildAssetType.code], + linkModePreference: .dynamic, + buildAssetTypes: [.code], )).success; final resultPreferDynamic = (await build( packageUri, logger, dartExecutable, - linkModePreference: LinkModePreference.preferDynamic, - buildAssetTypes: [BuildAssetType.code], + linkModePreference: .preferDynamic, + buildAssetTypes: [.code], )).success; final resultStatic = (await build( packageUri, logger, dartExecutable, - linkModePreference: LinkModePreference.static, - buildAssetTypes: [BuildAssetType.code], + linkModePreference: .static, + buildAssetTypes: [.code], )).success; final resultPreferStatic = (await build( packageUri, logger, dartExecutable, - linkModePreference: LinkModePreference.preferStatic, - buildAssetTypes: [BuildAssetType.code], + linkModePreference: .preferStatic, + buildAssetTypes: [.code], )).success; // This package honors preferences. diff --git a/pkgs/hooks_runner/test/build_runner/pub_workspace_test.dart b/pkgs/hooks_runner/test/build_runner/pub_workspace_test.dart index c5d114c024..bf9b89f5a8 100644 --- a/pkgs/hooks_runner/test/build_runner/pub_workspace_test.dart +++ b/pkgs/hooks_runner/test/build_runner/pub_workspace_test.dart @@ -11,6 +11,8 @@ import 'package:test/test.dart'; import '../helpers.dart'; import 'helpers.dart'; +const Timeout longTimeout = Timeout(Duration(minutes: 5)); + void main() async { late Uri tempUri; setUp(() async { @@ -35,7 +37,7 @@ resolution: workspace name: dart_lang_native_workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' workspace: '''; @@ -70,7 +72,7 @@ dependency_overrides: await runPubGet(workingDirectory: tempUri, logger: logger); } - test('pub workspaces', () async { + test('pub workspaces', timeout: longTimeout, () async { final packageUri = tempUri.resolve('named_add_renamed/'); await Directory.fromUri( tempUri.resolve('native_add/'), @@ -107,7 +109,7 @@ dependency_overrides: expect(logs.join('\n'), contains('Skipping build for native_add')); }); - test('packagesWithBuildHooks', () async { + test('packagesWithBuildHooks', timeout: longTimeout, () async { const fileSystem = LocalFileSystem(); final packageUri = tempUri.resolve('no_hook/'); await makePubWorkspace([ diff --git a/pkgs/hooks_runner/test/build_runner/resources_test.dart b/pkgs/hooks_runner/test/build_runner/resources_test.dart index 76624147e8..75ac843177 100644 --- a/pkgs/hooks_runner/test/build_runner/resources_test.dart +++ b/pkgs/hooks_runner/test/build_runner/resources_test.dart @@ -2,8 +2,12 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:convert'; import 'dart:io'; +import 'package:data_assets/data_assets.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:record_use/record_use.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -11,6 +15,8 @@ import 'helpers.dart'; const Timeout longTimeout = Timeout(Duration(minutes: 5)); +const loadingUnitRoot = LoadingUnit('root'); + void main() async { test('simple_link linking', timeout: longTimeout, () async { await inTempDir((tempUri) async { @@ -18,7 +24,14 @@ void main() async { final packageUri = tempUri.resolve('simple_link/'); final resourcesUri = tempUri.resolve('treeshaking_info.json'); - await File.fromUri(resourcesUri).create(); + final recordings = Recordings( + metadata: Metadata(version: Version(1, 0, 0), comment: 'Empty'), + calls: {}, + instances: {}, + ); + await File.fromUri( + resourcesUri, + ).writeAsString(jsonEncode(recordings.toJson())); // First, run `pub get`, we need pub to resolve our dependencies. await runPubGet(workingDirectory: packageUri, logger: logger); @@ -32,7 +45,7 @@ void main() async { packageUri.resolve('.dart_tool/hooks_runner/'), ).listSync(recursive: true).map((file) => file.path); - expect(buildFiles(), isNot(anyElement(endsWith('resources.json')))); + expect(buildFiles(), isNot(anyElement(endsWith('recorded_uses.json')))); await link( packageUri, @@ -40,9 +53,178 @@ void main() async { dartExecutable, buildResult: buildResult, resourceIdentifiers: resourcesUri, - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], + ); + expect(buildFiles(), anyElement(endsWith('recorded_uses.json'))); + }); + }); + + test('record_use_filtering linking', timeout: longTimeout, () async { + await inTempDir((tempUri) async { + await copyTestProjects(targetUri: tempUri); + final packageUri = tempUri.resolve('pirate_adventure/'); + + final resourcesUri = tempUri.resolve('treeshaking_info.json'); + await File.fromUri( + resourcesUri, + ).writeAsString(jsonEncode(_pirateAdventureRecordings.toJson())); + + // First, run `pub get`, we need pub to resolve our dependencies. + await runPubGet(workingDirectory: packageUri, logger: logger); + + final buildResult = (await buildDataAssets( + packageUri, + linkingEnabled: true, + )).success; + + final linkResult = (await link( + packageUri, + logger, + dartExecutable, + buildResult: buildResult, + resourceIdentifiers: resourcesUri, + buildAssetTypes: [.data], + )).success; + + // Verify outputs + final pirateSpeakAssets = linkResult.encodedAssets + .where((a) => a.asDataAsset.package == 'pirate_speak') + .toList(); + expect(pirateSpeakAssets, hasLength(1)); + final pirateSpeakFile = pirateSpeakAssets.first.asDataAsset.file; + final pirateSpeakContent = jsonDecode( + await File.fromUri(pirateSpeakFile).readAsString(), + ); + expect( + pirateSpeakContent, + equals({'Hello': 'Ahoy', 'Money': 'Doubloons'}), + ); + + final pirateTechAssets = linkResult.encodedAssets + .where((a) => a.asDataAsset.package == 'pirate_technology') + .toList(); + expect(pirateTechAssets, hasLength(1)); + final pirateTechFile = pirateTechAssets.first.asDataAsset.file; + final pirateTechContent = jsonDecode( + await File.fromUri(pirateTechFile).readAsString(), + ); + expect( + pirateTechContent, + equals({ + 'Cannon': {'range': 100, 'damage': 50}, + }), + ); + }); + }); + + test('record_use_filtering caching', timeout: longTimeout, () async { + await inTempDir((tempUri) async { + await copyTestProjects(targetUri: tempUri); + final packageUri = tempUri.resolve('pirate_adventure/'); + + final resourcesUri = tempUri.resolve('treeshaking_info.json'); + await File.fromUri( + resourcesUri, + ).writeAsString(jsonEncode(_pirateAdventureRecordings.toJson())); + + // First, run `pub get`, we need pub to resolve our dependencies. + await runPubGet(workingDirectory: packageUri, logger: logger); + + final buildResult = (await buildDataAssets( + packageUri, + linkingEnabled: true, + )).success; + + final logMessages = []; + Future runLink() async { + logMessages.clear(); + await link( + packageUri, + logger, + dartExecutable, + buildResult: buildResult, + resourceIdentifiers: resourcesUri, + buildAssetTypes: [.data], + capturedLogs: logMessages, + ); + } + + // Initial run: should run hooks. + await runLink(); + expect( + logMessages.join('\n'), + stringContainsInOrder(['pirate_speak', 'hook.dill']), + ); + + // Second run: should be cached. + await runLink(); + expect( + logMessages.join('\n'), + contains('Skipping link for pirate_speak'), + ); + + // Change resources: should re-run hooks. + final newRecordings = Recordings( + metadata: Metadata(version: Version(1, 0, 0), comment: 'Changed'), + calls: _pirateAdventureRecordings.calls, + instances: {}, + ); + await File.fromUri( + resourcesUri, + ).writeAsString(jsonEncode(newRecordings.toJson())); + + await runLink(); + expect( + logMessages.join('\n'), + stringContainsInOrder(['pirate_speak', 'hook.dill']), + ); + + // Run again: should be cached again. + await runLink(); + expect( + logMessages.join('\n'), + contains('Skipping link for pirate_speak'), ); - expect(buildFiles(), anyElement(endsWith('resources.json'))); }); }); } + +/// Expected result of the compiler when running from pirate_adventure +/// bin/pirate_adventure.dart. +final _pirateAdventureRecordings = Recordings( + metadata: Metadata(version: Version(1, 0, 0), comment: 'Filtering test'), + calls: { + Definition('package:pirate_speak/src/definitions.dart', [ + Name( + kind: .methodKind, + 'pirateSpeak', + disambiguators: {.staticDisambiguator}, + ), + ]): [ + const CallWithArguments( + loadingUnit: loadingUnitRoot, + positionalArguments: [StringConstant('Hello')], + namedArguments: {}, + ), + const CallWithArguments( + loadingUnit: loadingUnitRoot, + positionalArguments: [StringConstant('Money')], + namedArguments: {}, + ), + ], + Definition('package:pirate_technology/src/definitions.dart', [ + Name( + kind: .methodKind, + 'useCannon', + disambiguators: {.staticDisambiguator}, + ), + ]): [ + const CallWithArguments( + loadingUnit: loadingUnitRoot, + positionalArguments: [], + namedArguments: {}, + ), + ], + }, + instances: {}, +); diff --git a/pkgs/hooks_runner/test/build_runner/system_library_test.dart b/pkgs/hooks_runner/test/build_runner/system_library_test.dart index c09a731b54..4b0dd9547d 100644 --- a/pkgs/hooks_runner/test/build_runner/system_library_test.dart +++ b/pkgs/hooks_runner/test/build_runner/system_library_test.dart @@ -23,7 +23,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets.length, 3); }); diff --git a/pkgs/hooks_runner/test/build_runner/version_skew_test.dart b/pkgs/hooks_runner/test/build_runner/version_skew_test.dart index d783a2ac44..683407b839 100644 --- a/pkgs/hooks_runner/test/build_runner/version_skew_test.dart +++ b/pkgs/hooks_runner/test/build_runner/version_skew_test.dart @@ -26,7 +26,7 @@ void main() async { packageUri, logger, dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets.length, 1); } diff --git a/pkgs/hooks_runner/test/build_runner/wrong_linker_test.dart b/pkgs/hooks_runner/test/build_runner/wrong_linker_test.dart index c2c67345fb..880273752c 100644 --- a/pkgs/hooks_runner/test/build_runner/wrong_linker_test.dart +++ b/pkgs/hooks_runner/test/build_runner/wrong_linker_test.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:logging/logging.dart'; import 'package:test/test.dart'; import '../helpers.dart'; @@ -22,9 +21,9 @@ void main() async { final logMessages = []; final result = await build( packageUri, - createCapturingLogger(logMessages, level: Level.SEVERE), + createCapturingLogger(logMessages, level: .SEVERE), dartExecutable, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], linkingEnabled: true, ); final fullLog = logMessages.join('\n'); diff --git a/pkgs/hooks_runner/test/helpers.dart b/pkgs/hooks_runner/test/helpers.dart index 9ec799c851..bb783a5295 100644 --- a/pkgs/hooks_runner/test/helpers.dart +++ b/pkgs/hooks_runner/test/helpers.dart @@ -246,6 +246,7 @@ dependency_overrides: 'data_assets', 'hooks', 'native_toolchain_c', + 'record_use', ]; for (final package in packagesToOverride) { sourceString += @@ -281,12 +282,12 @@ Logger? _logger; Logger createCapturingLogger( List capturedMessages, { - Level level = Level.ALL, + Level level = .ALL, }) => _createTestLogger(capturedMessages: capturedMessages, level: level); Logger _createTestLogger({ List? capturedMessages, - Level level = Level.ALL, + Level level = .ALL, }) => Logger.detached('') ..level = level ..onRecord.listen((record) { diff --git a/pkgs/hooks_runner/test/locking/locking_test.dart b/pkgs/hooks_runner/test/locking/locking_test.dart index 218a9a4c95..e52770081e 100644 --- a/pkgs/hooks_runner/test/locking/locking_test.dart +++ b/pkgs/hooks_runner/test/locking/locking_test.dart @@ -161,7 +161,7 @@ void main() async { final timerTimeout = oneTimeRun * 10; printOnFailure('timerTimeout: $timerTimeout'); - final randomAccessFile = await lockFile.open(mode: FileMode.write); + final randomAccessFile = await lockFile.open(mode: .write); final lock = await randomAccessFile.lock(FileLock.exclusive); var helperCompletedFirst = false; var timeoutCompletedFirst = false; diff --git a/pkgs/hooks_runner/test/model/kernel_assets_test.dart b/pkgs/hooks_runner/test/model/kernel_assets_test.dart index b24781356b..5c801c095c 100644 --- a/pkgs/hooks_runner/test/model/kernel_assets_test.dart +++ b/pkgs/hooks_runner/test/model/kernel_assets_test.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'package:hooks_runner/src/model/kernel_assets.dart'; -import 'package:hooks_runner/src/model/target.dart'; import 'package:test/test.dart'; void main() { @@ -16,37 +15,37 @@ void main() { KernelAsset( id: 'foo', path: KernelAssetAbsolutePath(fooUri), - target: Target.androidX64, + target: .androidX64, ), KernelAsset( id: 'foo2', path: KernelAssetRelativePath(foo2Uri), - target: Target.androidX64, + target: .androidX64, ), KernelAsset( id: 'foo3', path: KernelAssetSystemPath(foo3Uri), - target: Target.androidX64, + target: .androidX64, ), KernelAsset( id: 'foo4', path: KernelAssetInExecutable(), - target: Target.androidX64, + target: .androidX64, ), KernelAsset( id: 'foo5', path: KernelAssetInProcess(), - target: Target.androidX64, + target: .androidX64, ), KernelAsset( id: 'bar', path: KernelAssetAbsolutePath(barUri), - target: Target.linuxArm64, + target: .linuxArm64, ), KernelAsset( id: 'bla', path: KernelAssetAbsolutePath(blaUri), - target: Target.windowsX64, + target: .windowsX64, ), ]); diff --git a/pkgs/hooks_runner/test/test_data/reusable_dynamic_library_test.dart b/pkgs/hooks_runner/test/test_data/reusable_dynamic_library_test.dart index ac0c656cc1..5381295136 100644 --- a/pkgs/hooks_runner/test/test_data/reusable_dynamic_library_test.dart +++ b/pkgs/hooks_runner/test/test_data/reusable_dynamic_library_test.dart @@ -27,7 +27,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.code], + buildAssetTypes: [.code], )).success; expect(result.encodedAssets.length, 2); diff --git a/pkgs/hooks_runner/test/test_data/user_defines_test.dart b/pkgs/hooks_runner/test/test_data/user_defines_test.dart index 1a66e5dd53..9f506afbbd 100644 --- a/pkgs/hooks_runner/test/test_data/user_defines_test.dart +++ b/pkgs/hooks_runner/test/test_data/user_defines_test.dart @@ -30,7 +30,7 @@ void main() async { logger, dartExecutable, capturedLogs: logMessages, - buildAssetTypes: [BuildAssetType.data], + buildAssetTypes: [.data], userDefines: UserDefines(workspacePubspec: pubspecUri), )).success; diff --git a/pkgs/hooks_runner/test_data/add_asset_link/pubspec.yaml b/pkgs/hooks_runner/test_data/add_asset_link/pubspec.yaml index 65a89787a3..a728d040e7 100644 --- a/pkgs/hooks_runner/test_data/add_asset_link/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/add_asset_link/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/complex_link/pubspec.yaml b/pkgs/hooks_runner/test_data/complex_link/pubspec.yaml index 88c6c46341..fda31ae2c9 100644 --- a/pkgs/hooks_runner/test_data/complex_link/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/complex_link/pubspec.yaml @@ -7,10 +7,9 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: - cli_config: ^0.2.0 complex_link_helper: path: ../complex_link_helper/ data_assets: any diff --git a/pkgs/hooks_runner/test_data/complex_link_helper/pubspec.yaml b/pkgs/hooks_runner/test_data/complex_link_helper/pubspec.yaml index 8cbf2980a8..f815eb6515 100644 --- a/pkgs/hooks_runner/test_data/complex_link_helper/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/complex_link_helper/pubspec.yaml @@ -7,10 +7,9 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: - cli_config: ^0.2.0 data_assets: any hooks: any logging: ^1.3.0 diff --git a/pkgs/hooks_runner/test_data/cyclic_link_package_1/pubspec.yaml b/pkgs/hooks_runner/test_data/cyclic_link_package_1/pubspec.yaml index c4ca96803d..417788d26e 100644 --- a/pkgs/hooks_runner/test_data/cyclic_link_package_1/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/cyclic_link_package_1/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: cyclic_link_package_2: diff --git a/pkgs/hooks_runner/test_data/cyclic_link_package_2/pubspec.yaml b/pkgs/hooks_runner/test_data/cyclic_link_package_2/pubspec.yaml index 3a64d5d3ab..3576d70f26 100644 --- a/pkgs/hooks_runner/test_data/cyclic_link_package_2/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/cyclic_link_package_2/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: cyclic_link_package_1: diff --git a/pkgs/hooks_runner/test_data/cyclic_package_1/pubspec.yaml b/pkgs/hooks_runner/test_data/cyclic_package_1/pubspec.yaml index df22d99acc..95e99ad013 100644 --- a/pkgs/hooks_runner/test_data/cyclic_package_1/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/cyclic_package_1/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: cyclic_package_2: diff --git a/pkgs/hooks_runner/test_data/cyclic_package_2/pubspec.yaml b/pkgs/hooks_runner/test_data/cyclic_package_2/pubspec.yaml index ab02ba4caa..b93bb2883d 100644 --- a/pkgs/hooks_runner/test_data/cyclic_package_2/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/cyclic_package_2/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: cyclic_package_1: diff --git a/pkgs/hooks_runner/test_data/dart_app/pubspec.yaml b/pkgs/hooks_runner/test_data/dart_app/pubspec.yaml index d942f7bd70..e06324a30d 100644 --- a/pkgs/hooks_runner/test_data/dart_app/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/dart_app/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: native_add: diff --git a/pkgs/hooks_runner/test_data/depend_on_fail_build/pubspec.yaml b/pkgs/hooks_runner/test_data/depend_on_fail_build/pubspec.yaml index 416798e037..68aff712c1 100644 --- a/pkgs/hooks_runner/test_data/depend_on_fail_build/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/depend_on_fail_build/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: fail_build: diff --git a/pkgs/hooks_runner/test_data/depend_on_fail_build_app/pubspec.yaml b/pkgs/hooks_runner/test_data/depend_on_fail_build_app/pubspec.yaml index db953a34ac..4206b352ab 100644 --- a/pkgs/hooks_runner/test_data/depend_on_fail_build_app/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/depend_on_fail_build_app/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: depend_on_fail_build: diff --git a/pkgs/hooks_runner/test_data/dev_dependency_with_hook/pubspec.yaml b/pkgs/hooks_runner/test_data/dev_dependency_with_hook/pubspec.yaml index 67743f8913..91d2e250d4 100644 --- a/pkgs/hooks_runner/test_data/dev_dependency_with_hook/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/dev_dependency_with_hook/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: {} diff --git a/pkgs/hooks_runner/test_data/download_assets/hook/build.dart b/pkgs/hooks_runner/test_data/download_assets/hook/build.dart index fa62b2bdba..575b74a500 100644 --- a/pkgs/hooks_runner/test_data/download_assets/hook/build.dart +++ b/pkgs/hooks_runner/test_data/download_assets/hook/build.dart @@ -1,3 +1,7 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + import 'dart:io'; import 'package:hooks/hooks.dart'; diff --git a/pkgs/hooks_runner/test_data/download_assets/pubspec.yaml b/pkgs/hooks_runner/test_data/download_assets/pubspec.yaml index cdd5a7b0e1..f300b71eff 100644 --- a/pkgs/hooks_runner/test_data/download_assets/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/download_assets/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: hooks: any diff --git a/pkgs/hooks_runner/test_data/drop_dylib_link/pubspec.yaml b/pkgs/hooks_runner/test_data/drop_dylib_link/pubspec.yaml index 0944200d41..8a29f42c6d 100644 --- a/pkgs/hooks_runner/test_data/drop_dylib_link/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/drop_dylib_link/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/fail_build/pubspec.yaml b/pkgs/hooks_runner/test_data/fail_build/pubspec.yaml index 5c4884fa41..bfb06c8295 100644 --- a/pkgs/hooks_runner/test_data/fail_build/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/fail_build/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/fail_on_os_sdk_version/pubspec.yaml b/pkgs/hooks_runner/test_data/fail_on_os_sdk_version/pubspec.yaml index 421e8271ac..65b3bf4125 100644 --- a/pkgs/hooks_runner/test_data/fail_on_os_sdk_version/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/fail_on_os_sdk_version/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_link/pubspec.yaml b/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_link/pubspec.yaml index 5440197d39..d5c3478b12 100644 --- a/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_link/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_link/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_linker/pubspec.yaml b/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_linker/pubspec.yaml index 2889f4ba7a..dda84d2cd7 100644 --- a/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_linker/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/fail_on_os_sdk_version_linker/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/flag_app/pubspec.yaml b/pkgs/hooks_runner/test_data/flag_app/pubspec.yaml index b0c9ecbca4..1ab864eb8a 100644 --- a/pkgs/hooks_runner/test_data/flag_app/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/flag_app/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: flag_enthusiast_1: diff --git a/pkgs/hooks_runner/test_data/flag_enthusiast_1/pubspec.yaml b/pkgs/hooks_runner/test_data/flag_enthusiast_1/pubspec.yaml index c6b909d707..c144bef7ba 100644 --- a/pkgs/hooks_runner/test_data/flag_enthusiast_1/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/flag_enthusiast_1/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/flag_enthusiast_2/pubspec.yaml b/pkgs/hooks_runner/test_data/flag_enthusiast_2/pubspec.yaml index e57d716cb4..9096fddecc 100644 --- a/pkgs/hooks_runner/test_data/flag_enthusiast_2/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/flag_enthusiast_2/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/fun_with_flags/pubspec.yaml b/pkgs/hooks_runner/test_data/fun_with_flags/pubspec.yaml index 5c4a1a448b..f3ded18e14 100644 --- a/pkgs/hooks_runner/test_data/fun_with_flags/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/fun_with_flags/pubspec.yaml @@ -6,7 +6,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/infra_failure/pubspec.yaml b/pkgs/hooks_runner/test_data/infra_failure/pubspec.yaml index 682d2b39ff..85082b3bfd 100644 --- a/pkgs/hooks_runner/test_data/infra_failure/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/infra_failure/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/link_inverse_app/pubspec.yaml b/pkgs/hooks_runner/test_data/link_inverse_app/pubspec.yaml index af3971e9d4..56b45e7e12 100644 --- a/pkgs/hooks_runner/test_data/link_inverse_app/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/link_inverse_app/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/link_inverse_package/pubspec.yaml b/pkgs/hooks_runner/test_data/link_inverse_package/pubspec.yaml index 160e57813c..c36ae81e93 100644 --- a/pkgs/hooks_runner/test_data/link_inverse_package/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/link_inverse_package/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: hooks: any diff --git a/pkgs/hooks_runner/test_data/manifest.yaml b/pkgs/hooks_runner/test_data/manifest.yaml index 45a4cef2b2..3f9fa447f2 100644 --- a/pkgs/hooks_runner/test_data/manifest.yaml +++ b/pkgs/hooks_runner/test_data/manifest.yaml @@ -149,6 +149,20 @@ - package_reading_metadata/pubspec.yaml - package_with_metadata/hook/build.dart - package_with_metadata/pubspec.yaml +- pirate_adventure/bin/pirate_adventure.dart +- pirate_adventure/pubspec.yaml +- pirate_speak/data/translations.json +- pirate_speak/hook/build.dart +- pirate_speak/hook/link.dart +- pirate_speak/lib/pirate_speak.dart +- pirate_speak/lib/src/definitions.dart +- pirate_speak/pubspec.yaml +- pirate_technology/data/tech.json +- pirate_technology/hook/build.dart +- pirate_technology/hook/link.dart +- pirate_technology/lib/pirate_technology.dart +- pirate_technology/lib/src/definitions.dart +- pirate_technology/pubspec.yaml - recursive_invocation/bin/subprocess.dart - recursive_invocation/hook/build.dart - recursive_invocation/lib/recursive_invocation.dart diff --git a/pkgs/hooks_runner/test_data/manifest_generator.dart b/pkgs/hooks_runner/test_data/manifest_generator.dart index 82136035a8..465a5e0423 100644 --- a/pkgs/hooks_runner/test_data/manifest_generator.dart +++ b/pkgs/hooks_runner/test_data/manifest_generator.dart @@ -39,14 +39,19 @@ class Counts { } void updateManifests(Counts counts) async { - final packageUri = findPackageRoot('hooks_runner'); - final testDataUri = packageUri.resolve('test_data/'); - final testDataDirectory = Directory.fromUri(testDataUri); - updateManifest(testDataDirectory, counts, allowPartialProjects: false); - final all = testDataDirectory.listSync(recursive: true); - all.whereType().forEach( - (e) => updateManifest(e, counts, allowPartialProjects: true), - ); + final packageUris = [ + findPackageRoot('hooks_runner'), + findPackageRoot('hooks_runner').resolve('../record_use/'), + ]; + for (final packageUri in packageUris) { + final testDataUri = packageUri.resolve('test_data/'); + final testDataDirectory = Directory.fromUri(testDataUri); + updateManifest(testDataDirectory, counts, allowPartialProjects: false); + final all = testDataDirectory.listSync(recursive: true); + all.whereType().forEach( + (e) => updateManifest(e, counts, allowPartialProjects: true), + ); + } } const denyList = [ @@ -55,6 +60,9 @@ const denyList = [ 'manifest', 'README.md', '.gitignore', + 'out.js', + 'json/', + 'json_dart2js/', ]; /// These just modify other test projects. diff --git a/pkgs/hooks_runner/test_data/native_add/ffigen.yaml b/pkgs/hooks_runner/test_data/native_add/ffigen.yaml index b8716bd2d5..3c4c35bc1a 100644 --- a/pkgs/hooks_runner/test_data/native_add/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/native_add/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeAddBindings description: | Bindings for `src/native_add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: "lib/src/native_add_bindings_generated.dart" headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/native_add/pubspec.yaml b/pkgs/hooks_runner/test_data/native_add/pubspec.yaml index ed9ae66f88..a8c0a2df78 100644 --- a/pkgs/hooks_runner/test_data/native_add/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/native_add/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/native_add_add_source/pubspec.yaml b/pkgs/hooks_runner/test_data/native_add_add_source/pubspec.yaml index 652ec1f0e5..5421f7490e 100644 --- a/pkgs/hooks_runner/test_data/native_add_add_source/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/native_add_add_source/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/native_add_duplicate/pubspec.yaml b/pkgs/hooks_runner/test_data/native_add_duplicate/pubspec.yaml index 4e6665aebc..73bea7dea8 100644 --- a/pkgs/hooks_runner/test_data/native_add_duplicate/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/native_add_duplicate/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/native_add_version_skew/ffigen.yaml b/pkgs/hooks_runner/test_data/native_add_version_skew/ffigen.yaml index fca739879d..a535029472 100644 --- a/pkgs/hooks_runner/test_data/native_add_version_skew/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/native_add_version_skew/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeAddBindings description: | Bindings for `src/native_add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/src/native_add_bindings_generated.dart' headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/native_dynamic_linking/ffigen.yaml b/pkgs/hooks_runner/test_data/native_dynamic_linking/ffigen.yaml index 71f7b4f62b..ef69658bf0 100644 --- a/pkgs/hooks_runner/test_data/native_dynamic_linking/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/native_dynamic_linking/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: AddBindings description: | Bindings for `src/add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/add.dart' headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/native_dynamic_linking/pubspec.yaml b/pkgs/hooks_runner/test_data/native_dynamic_linking/pubspec.yaml index b499b626f3..8474df4fe7 100644 --- a/pkgs/hooks_runner/test_data/native_dynamic_linking/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/native_dynamic_linking/pubspec.yaml @@ -8,7 +8,7 @@ repository: https://github.com/dart-lang/native/tree/main/pkgs/hooks/example/bui resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/native_subtract/ffigen.yaml b/pkgs/hooks_runner/test_data/native_subtract/ffigen.yaml index 5f79dbe5a5..0cc9df3b21 100644 --- a/pkgs/hooks_runner/test_data/native_subtract/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/native_subtract/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeAddBindings description: | Bindings for `src/native_subtract.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: "lib/src/native_subtract_bindings_generated.dart" headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/native_subtract/pubspec.yaml b/pkgs/hooks_runner/test_data/native_subtract/pubspec.yaml index 445648db15..a41b0e579a 100644 --- a/pkgs/hooks_runner/test_data/native_subtract/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/native_subtract/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/no_asset_for_link/pubspec.yaml b/pkgs/hooks_runner/test_data/no_asset_for_link/pubspec.yaml index a35433d293..e5d87902a0 100644 --- a/pkgs/hooks_runner/test_data/no_asset_for_link/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/no_asset_for_link/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/no_build_output/pubspec.yaml b/pkgs/hooks_runner/test_data/no_build_output/pubspec.yaml index d4e4ee83a0..bffe09b55d 100644 --- a/pkgs/hooks_runner/test_data/no_build_output/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/no_build_output/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: hooks: any diff --git a/pkgs/hooks_runner/test_data/no_hook/pubspec.yaml b/pkgs/hooks_runner/test_data/no_hook/pubspec.yaml index 1584324d10..80ec5a5368 100644 --- a/pkgs/hooks_runner/test_data/no_hook/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/no_hook/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/package_reading_metadata/pubspec.yaml b/pkgs/hooks_runner/test_data/package_reading_metadata/pubspec.yaml index dfaf1f0e60..3bb4152d19 100644 --- a/pkgs/hooks_runner/test_data/package_reading_metadata/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/package_reading_metadata/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/package_with_metadata/pubspec.yaml b/pkgs/hooks_runner/test_data/package_with_metadata/pubspec.yaml index de7f2f9ffc..dfee46786f 100644 --- a/pkgs/hooks_runner/test_data/package_with_metadata/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/package_with_metadata/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/pirate_adventure/bin/pirate_adventure.dart b/pkgs/hooks_runner/test_data/pirate_adventure/bin/pirate_adventure.dart new file mode 100644 index 0000000000..e16432cfb4 --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_adventure/bin/pirate_adventure.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:pirate_speak/pirate_speak.dart'; +import 'package:pirate_technology/pirate_technology.dart'; + +void main() { + print(pirateSpeak('Hello')); + print(pirateSpeak('Money')); + useCannon(); +} diff --git a/pkgs/hooks_runner/test_data/pirate_adventure/pubspec.yaml b/pkgs/hooks_runner/test_data/pirate_adventure/pubspec.yaml new file mode 100644 index 0000000000..61b8ac757a --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_adventure/pubspec.yaml @@ -0,0 +1,15 @@ +name: pirate_adventure +description: Test application for record_use filtering using pirate_speak and pirate_technology. + +publish_to: none + +resolution: workspace + +environment: + sdk: '>=3.10.0 <4.0.0' + +dependencies: + pirate_speak: + path: ../pirate_speak + pirate_technology: + path: ../pirate_technology diff --git a/pkgs/hooks_runner/test_data/pirate_speak/data/translations.json b/pkgs/hooks_runner/test_data/pirate_speak/data/translations.json new file mode 100644 index 0000000000..35078c366d --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_speak/data/translations.json @@ -0,0 +1,7 @@ +{ + "Hello": "Ahoy", + "Yes": "Aye", + "No": "Nay", + "Friend": "Matey", + "Money": "Doubloons" +} diff --git a/pkgs/hooks_runner/test_data/pirate_speak/hook/build.dart b/pkgs/hooks_runner/test_data/pirate_speak/hook/build.dart new file mode 100644 index 0000000000..bb6bed70f3 --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_speak/hook/build.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:data_assets/data_assets.dart'; +import 'package:hooks/hooks.dart'; + +void main(List args) async { + await build(args, (input, output) async { + final dataFile = input.packageRoot.resolve('data/translations.json'); + final translations = jsonDecode( + await File.fromUri(dataFile).readAsString(), + ); + + final translationsFile = input.outputDirectoryShared.resolve( + 'translations.json', + ); + await File.fromUri( + translationsFile, + ).writeAsString(jsonEncode(translations)); + + output.assets.data.add( + DataAsset( + package: input.packageName, + name: 'translations', + file: translationsFile, + ), + routing: input.config.linkingEnabled + ? const ToLinkHook('pirate_speak') + : const ToAppBundle(), + ); + }); +} diff --git a/pkgs/hooks_runner/test_data/pirate_speak/hook/link.dart b/pkgs/hooks_runner/test_data/pirate_speak/hook/link.dart new file mode 100644 index 0000000000..3af7e48f14 --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_speak/hook/link.dart @@ -0,0 +1,109 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:data_assets/data_assets.dart'; +import 'package:hooks/hooks.dart'; +import 'package:record_use/record_use.dart'; + +void main(List args) async { + await link(args, (input, output) async { + final translationAsset = _findTranslationAsset(input); + + if (translationAsset == null) return; + + // ignore: experimental_member_use + final recordedUsagesFile = input.recordedUsagesFile; + if (recordedUsagesFile == null) { + output.assets.data.add(translationAsset.asDataAsset); + return; + } + + final recordings = await _loadRecordings(recordedUsagesFile); + final usedPhrases = _extractUsedPhrases(recordings); + final allTranslations = await _loadTranslations(translationAsset); + final filteredTranslations = _filterTranslations( + allTranslations, + usedPhrases, + ); + + await _writeOutputAsset(input, output, filteredTranslations); + }); +} + +EncodedAsset? _findTranslationAsset(LinkInput input) => input + .assets + .encodedAssets + .where( + (a) => + a.isDataAsset && + a.asDataAsset.id == 'package:pirate_speak/translations', + ) + .firstOrNull; + +Future _loadRecordings(Uri file) async { + final content = await File.fromUri(file).readAsString(); + return Recordings.fromJson(jsonDecode(content) as Map); +} + +Set _extractUsedPhrases(Recordings recordings) { + final usedPhrases = {}; + final pirateSpeakDef = Definition( + 'package:pirate_speak/src/definitions.dart', + [ + Name( + kind: DefinitionKind.methodKind, + 'pirateSpeak', + disambiguators: {DefinitionDisambiguator.staticDisambiguator}, + ), + ], + ); + + for (final call in recordings.calls[pirateSpeakDef] ?? const []) { + switch (call) { + case CallWithArguments( + positionalArguments: [StringConstant(:final value), ...], + ): + usedPhrases.add(value); + case _: + throw UnsupportedError('Cannot determine which translations are used.'); + } + } + return usedPhrases; +} + +Future> _loadTranslations(EncodedAsset asset) async { + final file = asset.asDataAsset.file; + return jsonDecode(await File.fromUri(file).readAsString()) + as Map; +} + +Map _filterTranslations( + Map allTranslations, + Set usedPhrases, +) => { + for (final entry in allTranslations.entries) + if (usedPhrases.contains(entry.key)) entry.key: entry.value, +}; + +Future _writeOutputAsset( + LinkInput input, + LinkOutputBuilder output, + Map content, +) async { + final filteredFile = input.outputDirectory.resolve( + 'filtered_translations.json', + ); + await File.fromUri(filteredFile).writeAsString(jsonEncode(content)); + + output.assets.data.add( + DataAsset( + package: input.packageName, + name: 'translations', + file: filteredFile, + ), + ); +} diff --git a/pkgs/hooks_runner/test_data/pirate_speak/lib/pirate_speak.dart b/pkgs/hooks_runner/test_data/pirate_speak/lib/pirate_speak.dart new file mode 100644 index 0000000000..7529c9942e --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_speak/lib/pirate_speak.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/definitions.dart'; diff --git a/pkgs/hooks_runner/test_data/pirate_speak/lib/src/definitions.dart b/pkgs/hooks_runner/test_data/pirate_speak/lib/src/definitions.dart new file mode 100644 index 0000000000..71a3aa9ee1 --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_speak/lib/src/definitions.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:meta/meta.dart'; + +// TODO: Use data assets when they are supported. +const Map _translations = { + 'Hello': 'Ahoy', + 'Yes': 'Aye', + 'No': 'Nay', + 'Friend': 'Matey', + 'Money': 'Doubloons', +}; + +// ignore: experimental_member_use +@RecordUse() +String pirateSpeak(String english) => _translations[english] ?? english; diff --git a/pkgs/hooks_runner/test_data/pirate_speak/pubspec.yaml b/pkgs/hooks_runner/test_data/pirate_speak/pubspec.yaml new file mode 100644 index 0000000000..9d29ad6d7b --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_speak/pubspec.yaml @@ -0,0 +1,19 @@ +name: pirate_speak +description: > + Test data for record_use filtering. This package simulates a translation library. + The build hook produces a JSON asset with translations. + The link hook filters the JSON to only include translations for phrases used in the code, + identified via @RecordUse on the `pirateSpeak` function. + +publish_to: none + +resolution: workspace + +environment: + sdk: '>=3.10.0 <4.0.0' + +dependencies: + data_assets: any + hooks: any + meta: ^1.17.0 + record_use: any diff --git a/pkgs/hooks_runner/test_data/pirate_technology/data/tech.json b/pkgs/hooks_runner/test_data/pirate_technology/data/tech.json new file mode 100644 index 0000000000..bbab64932d --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_technology/data/tech.json @@ -0,0 +1,6 @@ +{ + "Cannon": {"range": 100, "damage": 50}, + "Compass": {"accuracy": 0.9}, + "Telescope": {"zoom": 10}, + "PegLeg": {"comfort": 2} +} diff --git a/pkgs/hooks_runner/test_data/pirate_technology/hook/build.dart b/pkgs/hooks_runner/test_data/pirate_technology/hook/build.dart new file mode 100644 index 0000000000..847ff028de --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_technology/hook/build.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:data_assets/data_assets.dart'; +import 'package:hooks/hooks.dart'; + +void main(List args) async { + await build(args, (input, output) async { + final dataFile = input.packageRoot.resolve('data/tech.json'); + final techFile = input.outputDirectoryShared.resolve('tech.json'); + await File.fromUri(dataFile).copy(techFile.toFilePath()); + + output.assets.data.add( + DataAsset( + package: input.packageName, + name: 'technologies', + file: techFile, + ), + routing: input.config.linkingEnabled + ? const ToLinkHook('pirate_technology') + : const ToAppBundle(), + ); + }); +} diff --git a/pkgs/hooks_runner/test_data/pirate_technology/hook/link.dart b/pkgs/hooks_runner/test_data/pirate_technology/hook/link.dart new file mode 100644 index 0000000000..e55b1d364e --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_technology/hook/link.dart @@ -0,0 +1,95 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:data_assets/data_assets.dart'; +import 'package:hooks/hooks.dart'; +import 'package:record_use/record_use.dart'; + +void main(List args) async { + await link(args, (input, output) async { + final techAsset = _findTechAsset(input); + + if (techAsset == null) { + throw StateError('Could not find technologies asset.'); + } + + // ignore: experimental_member_use + final recordedUsagesFile = input.recordedUsagesFile; + + if (recordedUsagesFile == null) { + output.assets.data.add(techAsset.asDataAsset); + return; + } + + final recordings = await _loadRecordings(recordedUsagesFile); + final usedTechnologies = _extractUsedTechnologies(recordings); + final allTech = await _loadTechnologies(techAsset); + final filteredTech = _filterTechnologies(allTech, usedTechnologies); + + await _writeOutputAsset(input, output, filteredTech); + }); +} + +EncodedAsset? _findTechAsset(LinkInput input) => input.assets.encodedAssets + .where( + (a) => + a.isDataAsset && + a.asDataAsset.id == 'package:pirate_technology/technologies', + ) + .firstOrNull; + +Future _loadRecordings(Uri file) async { + final content = await File.fromUri(file).readAsString(); + return Recordings.fromJson(jsonDecode(content) as Map); +} + +Set _extractUsedTechnologies(Recordings recordings) { + final usedTechnologies = {}; + for (final definition in recordings.calls.keys) { + if (definition.library == + 'package:pirate_technology/src/definitions.dart') { + // Map function name to tech key (simple capitalization) + // e.g. useCannon -> Cannon + final name = definition.path.last.name; + if (name.startsWith('use')) { + usedTechnologies.add(name.substring(3)); + } + } + } + return usedTechnologies; +} + +Future> _loadTechnologies(EncodedAsset asset) async { + final file = asset.asDataAsset.file; + return jsonDecode(await File.fromUri(file).readAsString()) + as Map; +} + +Map _filterTechnologies( + Map allTech, + Set usedTechnologies, +) => { + for (final entry in allTech.entries) + if (usedTechnologies.contains(entry.key)) entry.key: entry.value, +}; + +Future _writeOutputAsset( + LinkInput input, + LinkOutputBuilder output, + Map content, +) async { + final filteredFile = input.outputDirectory.resolve('filtered_tech.json'); + await File.fromUri(filteredFile).writeAsString(jsonEncode(content)); + + output.assets.data.add( + DataAsset( + package: input.packageName, + name: 'technologies', + file: filteredFile, + ), + ); +} diff --git a/pkgs/hooks_runner/test_data/pirate_technology/lib/pirate_technology.dart b/pkgs/hooks_runner/test_data/pirate_technology/lib/pirate_technology.dart new file mode 100644 index 0000000000..7529c9942e --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_technology/lib/pirate_technology.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/definitions.dart'; diff --git a/pkgs/hooks_runner/test_data/pirate_technology/lib/src/definitions.dart b/pkgs/hooks_runner/test_data/pirate_technology/lib/src/definitions.dart new file mode 100644 index 0000000000..6bd994ace1 --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_technology/lib/src/definitions.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:meta/meta.dart'; + +// TODO: Use data assets when they are supported. +const Map> _technologies = { + 'Cannon': {'range': 100, 'damage': 50}, + 'Compass': {'accuracy': 0.9}, + 'Telescope': {'zoom': 10}, + 'PegLeg': {'comfort': 2}, +}; + +// ignore: experimental_member_use +@RecordUse() +void useCannon() { + final damage = _technologies['Cannon']!['damage']; + print('Boom! (Damage: $damage)'); +} + +// ignore: experimental_member_use +@RecordUse() +void useCompass() { + final accuracy = _technologies['Compass']!['accuracy']; + print('North! (Accuracy: $accuracy)'); +} + +// ignore: experimental_member_use +@RecordUse() +void useTelescope() { + final zoom = _technologies['Telescope']!['zoom']; + print('I see you! (Zoom: x$zoom)'); +} + +// ignore: experimental_member_use +@RecordUse() +void usePegLeg() { + final comfort = _technologies['PegLeg']!['comfort']; + print('Clunk! (Comfort: $comfort)'); +} diff --git a/pkgs/hooks_runner/test_data/pirate_technology/pubspec.yaml b/pkgs/hooks_runner/test_data/pirate_technology/pubspec.yaml new file mode 100644 index 0000000000..13caa67db6 --- /dev/null +++ b/pkgs/hooks_runner/test_data/pirate_technology/pubspec.yaml @@ -0,0 +1,19 @@ +name: pirate_technology +description: > + Test data for record_use filtering. This package simulates a tech library. + The build hook produces a JSON asset with tech specs. + The link hook includes tech specs if the corresponding method is called, + identified via @RecordUse on the tech methods. The content of the call doesn't matter, just presence. + +publish_to: none + +resolution: workspace + +environment: + sdk: '>=3.10.0 <4.0.0' + +dependencies: + data_assets: any + hooks: any + meta: ^1.17.0 + record_use: any diff --git a/pkgs/hooks_runner/test_data/recursive_invocation/pubspec.yaml b/pkgs/hooks_runner/test_data/recursive_invocation/pubspec.yaml index 4223983847..8ecb888bf1 100644 --- a/pkgs/hooks_runner/test_data/recursive_invocation/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/recursive_invocation/pubspec.yaml @@ -13,7 +13,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/relative_path/pubspec.yaml b/pkgs/hooks_runner/test_data/relative_path/pubspec.yaml index 7ad2a4c50b..1c5b0f6aad 100644 --- a/pkgs/hooks_runner/test_data/relative_path/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/relative_path/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/reusable_dynamic_library/ffigen.yaml b/pkgs/hooks_runner/test_data/reusable_dynamic_library/ffigen.yaml index c8aba3eaa2..aff3fdca4e 100644 --- a/pkgs/hooks_runner/test_data/reusable_dynamic_library/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/reusable_dynamic_library/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: AddBindings description: | Bindings for `src/add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/add.dart' headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/reusable_dynamic_library/pubspec.yaml b/pkgs/hooks_runner/test_data/reusable_dynamic_library/pubspec.yaml index 84c65fef28..b0bddc1df9 100644 --- a/pkgs/hooks_runner/test_data/reusable_dynamic_library/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/reusable_dynamic_library/pubspec.yaml @@ -9,7 +9,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/reuse_dynamic_library/ffigen.yaml b/pkgs/hooks_runner/test_data/reuse_dynamic_library/ffigen.yaml index f056629b49..7ac621d8b8 100644 --- a/pkgs/hooks_runner/test_data/reuse_dynamic_library/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/reuse_dynamic_library/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: AddBindings description: | Bindings for `src/my_add.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/my_add.dart' headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/reuse_dynamic_library/pubspec.yaml b/pkgs/hooks_runner/test_data/reuse_dynamic_library/pubspec.yaml index e482e4da68..8c95f66848 100644 --- a/pkgs/hooks_runner/test_data/reuse_dynamic_library/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/reuse_dynamic_library/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/simple_data_asset/pubspec.yaml b/pkgs/hooks_runner/test_data/simple_data_asset/pubspec.yaml index 5e609e5dba..df5ce45d4a 100644 --- a/pkgs/hooks_runner/test_data/simple_data_asset/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/simple_data_asset/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/simple_link/pubspec.yaml b/pkgs/hooks_runner/test_data/simple_link/pubspec.yaml index af501a168c..b609e05696 100644 --- a/pkgs/hooks_runner/test_data/simple_link/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/simple_link/pubspec.yaml @@ -7,10 +7,9 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: - cli_config: ^0.2.0 data_assets: any hooks: any logging: ^1.3.0 diff --git a/pkgs/hooks_runner/test_data/some_dev_dep/pubspec.yaml b/pkgs/hooks_runner/test_data/some_dev_dep/pubspec.yaml index 645cd3487a..1bbdc3f037 100644 --- a/pkgs/hooks_runner/test_data/some_dev_dep/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/some_dev_dep/pubspec.yaml @@ -7,4 +7,4 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' diff --git a/pkgs/hooks_runner/test_data/system_library/pubspec.yaml b/pkgs/hooks_runner/test_data/system_library/pubspec.yaml index 74c933cabf..f2c401289b 100644 --- a/pkgs/hooks_runner/test_data/system_library/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/system_library/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/transformer/pubspec.yaml b/pkgs/hooks_runner/test_data/transformer/pubspec.yaml index a0404a3114..7cbc7eea97 100644 --- a/pkgs/hooks_runner/test_data/transformer/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/transformer/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: crypto: ^3.0.6 diff --git a/pkgs/hooks_runner/test_data/treeshaking_native_libs/ffigen.yaml b/pkgs/hooks_runner/test_data/treeshaking_native_libs/ffigen.yaml index bbcc0b94b5..ec4c884f7f 100644 --- a/pkgs/hooks_runner/test_data/treeshaking_native_libs/ffigen.yaml +++ b/pkgs/hooks_runner/test_data/treeshaking_native_libs/ffigen.yaml @@ -1,9 +1,9 @@ -# Run with `flutter pub run ffigen --config ffigen.yaml`. +# Run with `dart run ffigen --config ffigen.yaml`. name: NativeCalcBindings description: | Bindings for `src/native_add.h` and `src/native_multiply.h`. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: "lib/src/treeshaking_native_libs_bindings_generated.dart" headers: entry-points: diff --git a/pkgs/hooks_runner/test_data/treeshaking_native_libs/pubspec.yaml b/pkgs/hooks_runner/test_data/treeshaking_native_libs/pubspec.yaml index ff992fc648..bdf4d22111 100644 --- a/pkgs/hooks_runner/test_data/treeshaking_native_libs/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/treeshaking_native_libs/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/use_all_api/pubspec.yaml b/pkgs/hooks_runner/test_data/use_all_api/pubspec.yaml index 33cf3032b2..1c5e3d7f1e 100644 --- a/pkgs/hooks_runner/test_data/use_all_api/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/use_all_api/pubspec.yaml @@ -8,10 +8,9 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: - cli_config: ^0.2.0 code_assets: any data_assets: any hooks: any diff --git a/pkgs/hooks_runner/test_data/user_defines/pubspec.yaml b/pkgs/hooks_runner/test_data/user_defines/pubspec.yaml index 956bedb2d3..1d0fb35239 100644 --- a/pkgs/hooks_runner/test_data/user_defines/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/user_defines/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: data_assets: any diff --git a/pkgs/hooks_runner/test_data/wrong_build_output/pubspec.yaml b/pkgs/hooks_runner/test_data/wrong_build_output/pubspec.yaml index 1f381ad61d..3ce18b34e9 100644 --- a/pkgs/hooks_runner/test_data/wrong_build_output/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/wrong_build_output/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/wrong_build_output_2/pubspec.yaml b/pkgs/hooks_runner/test_data/wrong_build_output_2/pubspec.yaml index dac0d0825f..eeddf3bb5a 100644 --- a/pkgs/hooks_runner/test_data/wrong_build_output_2/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/wrong_build_output_2/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/wrong_build_output_3/pubspec.yaml b/pkgs/hooks_runner/test_data/wrong_build_output_3/pubspec.yaml index b61c9f51e6..646c104304 100644 --- a/pkgs/hooks_runner/test_data/wrong_build_output_3/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/wrong_build_output_3/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/wrong_linker/pubspec.yaml b/pkgs/hooks_runner/test_data/wrong_linker/pubspec.yaml index 28bc0d09c1..d14ddc2bfc 100644 --- a/pkgs/hooks_runner/test_data/wrong_linker/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/wrong_linker/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/hooks_runner/test_data/wrong_namespace_asset/pubspec.yaml b/pkgs/hooks_runner/test_data/wrong_namespace_asset/pubspec.yaml index d925e34638..984e84c61a 100644 --- a/pkgs/hooks_runner/test_data/wrong_namespace_asset/pubspec.yaml +++ b/pkgs/hooks_runner/test_data/wrong_namespace_asset/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: any diff --git a/pkgs/jni/CHANGELOG.md b/pkgs/jni/CHANGELOG.md index 95f96d1a2a..25b49987a3 100644 --- a/pkgs/jni/CHANGELOG.md +++ b/pkgs/jni/CHANGELOG.md @@ -1,5 +1,14 @@ -## 0.15.3-wip - +## 0.16.0-wip + +- **Breaking Change**: All Java wrapper classes have been migrated to extension + types. The main effects are: + - All collections (`JList`, `JMap` etc) are now direct code generated wrappers + around the Java objects, so are less Darty. Instead there are now Darty + adapter classes you can access via `asDart()`. + - No more nullable `JType` classes, only `JType` classes, and the `JType` + class is simplified. + - It is no longer necessary to pass around the `JType` in many cases where it + used to be required. - Added `Jni.captureStackTraceOnRelease` which defaults to `false`. When this is set, the stack traces of the release points will be stored for `JObject`s to help debug `DoubleReleaseError` and `UseAfterReleaseError`s. This includes the @@ -8,6 +17,13 @@ - Changed the behavior of `JObject.releasedBy`. It now does not throw a `DoubleReleaseError` if the object was manually released before the end of arena. +- Added `JThrowable` class which inherits from `JObject` and implements + `Exception`. +- **Breaking Change**: `JniException` has been deleted. Java exceptions are now + thrown as `JThrowable` instead. `JThrowable` holds an actual Java exception, + instead of just holding a string message. It's a `JObject`, so the usual + `.isA` and `.as` methods work to cast the `JThrowable` to the underlying Java + exception. ## 0.15.2 diff --git a/pkgs/jni/example/integration_test/on_device_jni_test.dart b/pkgs/jni/example/integration_test/on_device_jni_test.dart index c8e5f5954a..08da5ff829 100644 --- a/pkgs/jni/example/integration_test/on_device_jni_test.dart +++ b/pkgs/jni/example/integration_test/on_device_jni_test.dart @@ -13,7 +13,6 @@ import '../../test/jstring_test.dart' as jstring_test; import '../../test/jset_test.dart' as jset_test; import '../../test/jarray_test.dart' as jarray_test; import '../../test/boxed_test.dart' as boxed_test; -import '../../test/type_test.dart' as type_test; import '../../test/load_test.dart' as load_test; import '../../test/isolate_test.dart' as isolate_test; @@ -34,7 +33,6 @@ void main() { jset_test.run, jarray_test.run, boxed_test.run, - type_test.run, load_test.run, isolate_test.run, ]; diff --git a/pkgs/jni/ffigen.yaml b/pkgs/jni/ffigen.yaml index 4533307c3f..41c2e39be8 100644 --- a/pkgs/jni/ffigen.yaml +++ b/pkgs/jni/ffigen.yaml @@ -7,7 +7,7 @@ description: | However, functions prefixed JNI_ are not usable because they are in a different shared library. - Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. + Regenerate bindings with `dart run ffigen --config ffigen.yaml`. output: 'lib/src/third_party/jni_bindings_generated.dart' headers: entry-points: diff --git a/pkgs/jni/lib/_internal.dart b/pkgs/jni/lib/_internal.dart index 2e6fcb4a06..05efe573f9 100644 --- a/pkgs/jni/lib/_internal.dart +++ b/pkgs/jni/lib/_internal.dart @@ -28,28 +28,8 @@ export 'dart:isolate' show RawReceivePort, ReceivePort; export 'package:meta/meta.dart' show internal; export 'src/accessors.dart'; -export 'src/jarray.dart' - show - $JArray$NullableType$, - $JArray$Type$, - $JBooleanArray$NullableType$, - $JBooleanArray$Type$, - $JByteArray$NullableType$, - $JByteArray$Type$, - $JCharArray$NullableType$, - $JCharArray$Type$, - $JDoubleArray$NullableType$, - $JDoubleArray$Type$, - $JFloatArray$NullableType$, - $JFloatArray$Type$, - $JIntArray$NullableType$, - $JIntArray$Type$, - $JLongArray$NullableType$, - $JLongArray$Type$, - $JShortArray$NullableType$, - $JShortArray$Type$; export 'src/jni.dart' show ProtectedJniExtensions; -export 'src/jobject.dart' show $JObject$NullableType$, $JObject$Type$; +export 'src/jobject.dart' show $JObject$Type$; export 'src/jreference.dart'; export 'src/kotlin.dart' show @@ -59,29 +39,26 @@ export 'src/kotlin.dart' result$Class, result$FailureClass, resultValueField; -export 'src/lang/jboolean.dart' show $JBoolean$NullableType$, $JBoolean$Type$; -export 'src/lang/jbyte.dart' show $JByte$NullableType$, $JByte$Type$; -export 'src/lang/jcharacter.dart' - show $JCharacter$NullableType$, $JCharacter$Type$; -export 'src/lang/jdouble.dart' show $JDouble$NullableType$, $JDouble$Type$; -export 'src/lang/jfloat.dart' show $JFloat$NullableType$, $JFloat$Type$; -export 'src/lang/jinteger.dart' show $JInteger$NullableType$, $JInteger$Type$; -export 'src/lang/jlong.dart' show $JLong$NullableType$, $JLong$Type$; -export 'src/lang/jnumber.dart' show $JNumber$NullableType$, $JNumber$Type$; -export 'src/lang/jshort.dart' show $JShort$NullableType$, $JShort$Type$; -export 'src/lang/jstring.dart' show $JString$NullableType$, $JString$Type$; +export 'src/lang/jboolean.dart'; +export 'src/lang/jbyte.dart'; +export 'src/lang/jcharacter.dart'; +export 'src/lang/jdouble.dart'; +export 'src/lang/jfloat.dart'; +export 'src/lang/jinteger.dart'; +export 'src/lang/jlong.dart'; +export 'src/lang/jnumber.dart'; +export 'src/lang/jshort.dart'; +export 'src/lang/jstring.dart'; export 'src/method_invocation.dart'; -export 'src/nio/jbuffer.dart' show $JBuffer$NullableType$, $JBuffer$Type$; -export 'src/nio/jbyte_buffer.dart' - show $JByteBuffer$NullableType$, $JByteBuffer$Type$; +export 'src/nio/jbuffer.dart'; +export 'src/nio/jbyte_buffer.dart'; export 'src/third_party/generated_bindings.dart' show JFieldIDPtr, JMethodIDPtr, JObjectPtr, JThrowablePtr, JniResult; -export 'src/types.dart' show JTypeBase, lowestCommonSuperType, referenceType; -export 'src/util/jiterator.dart' - show $JIterator$NullableType$, $JIterator$Type$; -export 'src/util/jlist.dart' show $JList$NullableType$, $JList$Type$; -export 'src/util/jmap.dart' show $JMap$NullableType$, $JMap$Type$; -export 'src/util/jset.dart' show $JSet$NullableType$, $JSet$Type$; +export 'src/types.dart' show JTypeBase; +export 'src/util/jiterator.dart'; +export 'src/util/jlist.dart'; +export 'src/util/jmap.dart'; +export 'src/util/jset.dart'; /// Temporary fix for the macOS arm64 varargs problem. /// diff --git a/pkgs/jni/lib/jni.dart b/pkgs/jni/lib/jni.dart index 49ce91ddd8..2a0b9785ae 100644 --- a/pkgs/jni/lib/jni.dart +++ b/pkgs/jni/lib/jni.dart @@ -62,34 +62,25 @@ library; export 'package:ffi/ffi.dart' show Arena, using; +export 'src/core_bindings.dart' + show + JArrayList, + JCollection, + JHashMap, + JHashSet, + JIterator, + JList, + JMap, + JSet; export 'src/errors.dart'; -export 'src/jarray.dart' - hide - $JArray$NullableType$, - $JArray$Type$, - $JBooleanArray$NullableType$, - $JBooleanArray$Type$, - $JByteArray$NullableType$, - $JByteArray$Type$, - $JCharArray$NullableType$, - $JCharArray$Type$, - $JDoubleArray$NullableType$, - $JDoubleArray$Type$, - $JFloatArray$NullableType$, - $JFloatArray$Type$, - $JIntArray$NullableType$, - $JIntArray$Type$, - $JLongArray$NullableType$, - $JLongArray$Type$, - $JShortArray$NullableType$, - $JShortArray$Type$; +export 'src/jarray.dart'; export 'src/jimplementer.dart'; export 'src/jni.dart' hide InternalJniExtension, ProtectedJniExtensions, StringMethodsForJni; -export 'src/jobject.dart' hide $JObject$NullableType$, $JObject$Type$; +export 'src/jobject.dart' hide $JObject$Type$; export 'src/jreference.dart' hide ProtectedJReference; export 'src/jvalues.dart'; export 'src/lang/lang.dart'; export 'src/nio/nio.dart'; -export 'src/types.dart' hide JTypeBase, lowestCommonSuperType; -export 'src/util/util.dart'; +export 'src/types.dart' hide JTypeBase; +export 'src/util/util.dart' hide JIteratorAdapter; diff --git a/pkgs/jni/lib/src/accessors.dart b/pkgs/jni/lib/src/accessors.dart index 704caac349..762b2d69f4 100644 --- a/pkgs/jni/lib/src/accessors.dart +++ b/pkgs/jni/lib/src/accessors.dart @@ -10,7 +10,6 @@ import 'jni.dart'; import 'jobject.dart'; import 'jreference.dart'; import 'third_party/generated_bindings.dart'; -import 'types.dart'; void _check(JThrowablePtr exception) { if (exception != nullptr) { @@ -72,8 +71,9 @@ extension JniResultMethods on JniResult { return pointer == nullptr ? jNullReference : JGlobalReference(pointer); } - T object(JType type) { - return type.fromReference(reference); + T object() { + final ref = reference; + return (ref == jNullReference ? null : JObject.fromReference(ref)) as T; } bool get boolean { diff --git a/pkgs/jni/lib/src/core_bindings.dart b/pkgs/jni/lib/src/core_bindings.dart new file mode 100644 index 0000000000..d734915041 --- /dev/null +++ b/pkgs/jni/lib/src/core_bindings.dart @@ -0,0 +1,14950 @@ +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! + +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: prefer_relative_imports +// ignore_for_file: annotate_overrides +// ignore_for_file: argument_type_not_assignable +// ignore_for_file: camel_case_extensions +// ignore_for_file: camel_case_types +// ignore_for_file: constant_identifier_names +// ignore_for_file: comment_references +// ignore_for_file: doc_directive_unknown +// ignore_for_file: file_names +// ignore_for_file: inference_failure_on_untyped_parameter +// ignore_for_file: invalid_internal_annotation +// ignore_for_file: invalid_use_of_internal_member +// ignore_for_file: library_prefixes +// ignore_for_file: lines_longer_than_80_chars +// ignore_for_file: no_leading_underscores_for_library_prefixes +// ignore_for_file: no_leading_underscores_for_local_identifiers +// ignore_for_file: non_constant_identifier_names +// ignore_for_file: only_throw_errors +// ignore_for_file: overridden_fields +// ignore_for_file: prefer_double_quotes +// ignore_for_file: unintended_html_in_doc_comment +// ignore_for_file: unnecessary_cast +// ignore_for_file: unnecessary_non_null_assertion +// ignore_for_file: unnecessary_parenthesis +// ignore_for_file: unused_element +// ignore_for_file: unused_field +// ignore_for_file: unused_import +// ignore_for_file: unused_local_variable +// ignore_for_file: unused_shown_name +// ignore_for_file: use_super_parameters + +import 'dart:core' as core$_; +import 'dart:core' show Object, String, double, int; + +import 'package:jni/_internal.dart' as jni$_; +import 'package:jni/jni.dart' as jni$_; + +/// from: `java.util.ArrayList` +extension type JArrayList<$E extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject, JList<$E?> { + static final _class = jni$_.JClass.forName(r'java/util/ArrayList'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JArrayList$Type$(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JArrayList() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); + } + + static final _id_new$1 = _class.constructorId( + r'(I)V', + ); + + static final _new$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void (int i)` + /// The returned object must be released after use, by calling the [release] method. + factory JArrayList.new$1( + int i, + ) { + return _new$1(_class.reference.pointer, _id_new$1.pointer, i) + .object>(); + } + + static final _id_new$2 = _class.constructorId( + r'(Ljava/util/Collection;)V', + ); + + static final _new$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void (java.util.Collection collection)` + /// The returned object must be released after use, by calling the [release] method. + factory JArrayList.new$2( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _new$2( + _class.reference.pointer, _id_new$2.pointer, _$collection.pointer) + .object>(); + } + + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Collection;)Ljava/util/List;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.List copyOf(java.util.Collection collection)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? copyOf<$E extends jni$_.JObject?>( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _copyOf( + _class.reference.pointer, _id_copyOf.pointer, _$collection.pointer) + .object?>(); + } + + static final _id_of = _class.staticMethodId( + r'of', + r'()Ljava/util/List;', + ); + + static final _of = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.List of()` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of<$E extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer).object?>(); + } + + static final _id_of$1 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$1<$E extends jni$_.JObject?>( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer) + .object?>(); + } + + static final _id_of$2 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$2<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of$3 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$3<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + return _of$3(_class.reference.pointer, _id_of$3.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer) + .object?>(); + } + + static final _id_of$4 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$4<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + return _of$4(_class.reference.pointer, _id_of$4.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer, _$object3.pointer) + .object?>(); + } + + static final _id_of$5 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$5<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + return _of$5( + _class.reference.pointer, + _id_of$5.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer) + .object?>(); + } + + static final _id_of$6 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$6<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + return _of$6( + _class.reference.pointer, + _id_of$6.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer) + .object?>(); + } + + static final _id_of$7 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$7 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$7<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + return _of$7( + _class.reference.pointer, + _id_of$7.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer) + .object?>(); + } + + static final _id_of$8 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$8 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$8<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + return _of$8( + _class.reference.pointer, + _id_of$8.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer) + .object?>(); + } + + static final _id_of$9 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$9 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$9<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + return _of$9( + _class.reference.pointer, + _id_of$9.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer) + .object?>(); + } + + static final _id_of$10 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$10 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8, E object9)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$10<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + $E? object9, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + return _of$10( + _class.reference.pointer, + _id_of$10.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer) + .object?>(); + } + + static final _id_of$11 = _class.staticMethodId( + r'of', + r'([Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$11 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E[] objects)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$11<$E extends jni$_.JObject?>( + jni$_.JArray<$E?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _of$11( + _class.reference.pointer, _id_of$11.pointer, _$objects.pointer) + .object?>(); + } +} + +extension JArrayList$$Methods<$E extends jni$_.JObject?> on JArrayList<$E> { + static final _id_add = JArrayList._class.instanceMethodId( + r'add', + r'(Ljava/lang/Object;)Z', + ); + + static final _add = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean add(E object)` + core$_.bool add( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _add(reference.pointer, _id_add.pointer, _$object.pointer).boolean; + } + + static final _id_add$1 = JArrayList._class.instanceMethodId( + r'add', + r'(ILjava/lang/Object;)V', + ); + + static final _add$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public void add(int i, E object)` + void add$1( + int i, + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + _add$1(reference.pointer, _id_add$1.pointer, i, _$object.pointer).check(); + } + + static final _id_addAll = JArrayList._class.instanceMethodId( + r'addAll', + r'(ILjava/util/Collection;)Z', + ); + + static final _addAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public boolean addAll(int i, java.util.Collection collection)` + core$_.bool addAll( + int i, + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll( + reference.pointer, _id_addAll.pointer, i, _$collection.pointer) + .boolean; + } + + static final _id_addAll$1 = JArrayList._class.instanceMethodId( + r'addAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _addAll$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean addAll(java.util.Collection collection)` + core$_.bool addAll$1( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll$1( + reference.pointer, _id_addAll$1.pointer, _$collection.pointer) + .boolean; + } + + static final _id_addFirst = JArrayList._class.instanceMethodId( + r'addFirst', + r'(Ljava/lang/Object;)V', + ); + + static final _addFirst = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void addFirst(E object)` + void addFirst( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + _addFirst(reference.pointer, _id_addFirst.pointer, _$object.pointer) + .check(); + } + + static final _id_addLast = JArrayList._class.instanceMethodId( + r'addLast', + r'(Ljava/lang/Object;)V', + ); + + static final _addLast = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void addLast(E object)` + void addLast( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + _addLast(reference.pointer, _id_addLast.pointer, _$object.pointer).check(); + } + + static final _id_clear = JArrayList._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_clone = JArrayList._class.instanceMethodId( + r'clone', + r'()Ljava/lang/Object;', + ); + + static final _clone = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.Object clone()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? clone() { + return _clone(reference.pointer, _id_clone.pointer) + .object(); + } + + static final _id_contains = JArrayList._class.instanceMethodId( + r'contains', + r'(Ljava/lang/Object;)Z', + ); + + static final _contains = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean contains(java.lang.Object object)` + core$_.bool contains( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _contains(reference.pointer, _id_contains.pointer, _$object.pointer) + .boolean; + } + + static final _id_ensureCapacity = JArrayList._class.instanceMethodId( + r'ensureCapacity', + r'(I)V', + ); + + static final _ensureCapacity = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void ensureCapacity(int i)` + void ensureCapacity( + int i, + ) { + _ensureCapacity(reference.pointer, _id_ensureCapacity.pointer, i).check(); + } + + static final _id_equals = JArrayList._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_forEach = JArrayList._class.instanceMethodId( + r'forEach', + r'(Ljava/util/function/Consumer;)V', + ); + + static final _forEach = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void forEach(java.util.function.Consumer consumer)` + void forEach( + jni$_.JObject? consumer, + ) { + final _$consumer = consumer?.reference ?? jni$_.jNullReference; + _forEach(reference.pointer, _id_forEach.pointer, _$consumer.pointer) + .check(); + } + + static final _id_get = JArrayList._class.instanceMethodId( + r'get', + r'(I)Ljava/lang/Object;', + ); + + static final _get = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public E get(int i)` + /// The returned object must be released after use, by calling the [release] method. + $E? get( + int i, + ) { + return _get(reference.pointer, _id_get.pointer, i).object<$E?>(); + } + + static final _id_getFirst = JArrayList._class.instanceMethodId( + r'getFirst', + r'()Ljava/lang/Object;', + ); + + static final _getFirst = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E getFirst()` + /// The returned object must be released after use, by calling the [release] method. + $E? getFirst() { + return _getFirst(reference.pointer, _id_getFirst.pointer).object<$E?>(); + } + + static final _id_getLast = JArrayList._class.instanceMethodId( + r'getLast', + r'()Ljava/lang/Object;', + ); + + static final _getLast = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E getLast()` + /// The returned object must be released after use, by calling the [release] method. + $E? getLast() { + return _getLast(reference.pointer, _id_getLast.pointer).object<$E?>(); + } + + static final _id_hashCode$1 = JArrayList._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_indexOf = JArrayList._class.instanceMethodId( + r'indexOf', + r'(Ljava/lang/Object;)I', + ); + + static final _indexOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public int indexOf(java.lang.Object object)` + int indexOf( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _indexOf(reference.pointer, _id_indexOf.pointer, _$object.pointer) + .integer; + } + + static final _id_isEmpty = JArrayList._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_iterator = JArrayList._class.instanceMethodId( + r'iterator', + r'()Ljava/util/Iterator;', + ); + + static final _iterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Iterator iterator()` + /// The returned object must be released after use, by calling the [release] method. + JIterator<$E?>? iterator() { + return _iterator(reference.pointer, _id_iterator.pointer) + .object?>(); + } + + static final _id_lastIndexOf = JArrayList._class.instanceMethodId( + r'lastIndexOf', + r'(Ljava/lang/Object;)I', + ); + + static final _lastIndexOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public int lastIndexOf(java.lang.Object object)` + int lastIndexOf( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _lastIndexOf( + reference.pointer, _id_lastIndexOf.pointer, _$object.pointer) + .integer; + } + + static final _id_listIterator = JArrayList._class.instanceMethodId( + r'listIterator', + r'()Ljava/util/ListIterator;', + ); + + static final _listIterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.ListIterator listIterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? listIterator() { + return _listIterator(reference.pointer, _id_listIterator.pointer) + .object(); + } + + static final _id_listIterator$1 = JArrayList._class.instanceMethodId( + r'listIterator', + r'(I)Ljava/util/ListIterator;', + ); + + static final _listIterator$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public java.util.ListIterator listIterator(int i)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? listIterator$1( + int i, + ) { + return _listIterator$1(reference.pointer, _id_listIterator$1.pointer, i) + .object(); + } + + static final _id_remove = JArrayList._class.instanceMethodId( + r'remove', + r'(I)Ljava/lang/Object;', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public E remove(int i)` + /// The returned object must be released after use, by calling the [release] method. + $E? remove( + int i, + ) { + return _remove(reference.pointer, _id_remove.pointer, i).object<$E?>(); + } + + static final _id_remove$1 = JArrayList._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Z', + ); + + static final _remove$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean remove(java.lang.Object object)` + core$_.bool remove$1( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove$1(reference.pointer, _id_remove$1.pointer, _$object.pointer) + .boolean; + } + + static final _id_removeAll = JArrayList._class.instanceMethodId( + r'removeAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _removeAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean removeAll(java.util.Collection collection)` + core$_.bool removeAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _removeAll( + reference.pointer, _id_removeAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_removeFirst = JArrayList._class.instanceMethodId( + r'removeFirst', + r'()Ljava/lang/Object;', + ); + + static final _removeFirst = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E removeFirst()` + /// The returned object must be released after use, by calling the [release] method. + $E? removeFirst() { + return _removeFirst(reference.pointer, _id_removeFirst.pointer) + .object<$E?>(); + } + + static final _id_removeIf = JArrayList._class.instanceMethodId( + r'removeIf', + r'(Ljava/util/function/Predicate;)Z', + ); + + static final _removeIf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean removeIf(java.util.function.Predicate predicate)` + core$_.bool removeIf( + jni$_.JObject? predicate, + ) { + final _$predicate = predicate?.reference ?? jni$_.jNullReference; + return _removeIf( + reference.pointer, _id_removeIf.pointer, _$predicate.pointer) + .boolean; + } + + static final _id_removeLast = JArrayList._class.instanceMethodId( + r'removeLast', + r'()Ljava/lang/Object;', + ); + + static final _removeLast = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E removeLast()` + /// The returned object must be released after use, by calling the [release] method. + $E? removeLast() { + return _removeLast(reference.pointer, _id_removeLast.pointer).object<$E?>(); + } + + static final _id_replaceAll = JArrayList._class.instanceMethodId( + r'replaceAll', + r'(Ljava/util/function/UnaryOperator;)V', + ); + + static final _replaceAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void replaceAll(java.util.function.UnaryOperator unaryOperator)` + void replaceAll( + jni$_.JObject? unaryOperator, + ) { + final _$unaryOperator = unaryOperator?.reference ?? jni$_.jNullReference; + _replaceAll( + reference.pointer, _id_replaceAll.pointer, _$unaryOperator.pointer) + .check(); + } + + static final _id_retainAll = JArrayList._class.instanceMethodId( + r'retainAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _retainAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean retainAll(java.util.Collection collection)` + core$_.bool retainAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _retainAll( + reference.pointer, _id_retainAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_set = JArrayList._class.instanceMethodId( + r'set', + r'(ILjava/lang/Object;)Ljava/lang/Object;', + ); + + static final _set = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public E set(int i, E object)` + /// The returned object must be released after use, by calling the [release] method. + $E? set( + int i, + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _set(reference.pointer, _id_set.pointer, i, _$object.pointer) + .object<$E?>(); + } + + static final _id_size = JArrayList._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_sort = JArrayList._class.instanceMethodId( + r'sort', + r'(Ljava/util/Comparator;)V', + ); + + static final _sort = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void sort(java.util.Comparator comparator)` + void sort( + jni$_.JObject? comparator, + ) { + final _$comparator = comparator?.reference ?? jni$_.jNullReference; + _sort(reference.pointer, _id_sort.pointer, _$comparator.pointer).check(); + } + + static final _id_spliterator = JArrayList._class.instanceMethodId( + r'spliterator', + r'()Ljava/util/Spliterator;', + ); + + static final _spliterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Spliterator spliterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? spliterator() { + return _spliterator(reference.pointer, _id_spliterator.pointer) + .object(); + } + + static final _id_subList = JArrayList._class.instanceMethodId( + r'subList', + r'(II)Ljava/util/List;', + ); + + static final _subList = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int, int)>(); + + /// from: `public java.util.List subList(int i, int i1)` + /// The returned object must be released after use, by calling the [release] method. + JList<$E?>? subList( + int i, + int i1, + ) { + return _subList(reference.pointer, _id_subList.pointer, i, i1) + .object?>(); + } + + static final _id_toArray = JArrayList._class.instanceMethodId( + r'toArray', + r'()[Ljava/lang/Object;', + ); + + static final _toArray = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.Object[] toArray()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray? toArray() { + return _toArray(reference.pointer, _id_toArray.pointer) + .object?>(); + } + + static final _id_toArray$1 = JArrayList._class.instanceMethodId( + r'toArray', + r'([Ljava/lang/Object;)[Ljava/lang/Object;', + ); + + static final _toArray$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(T[] objects)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$1<$T extends jni$_.JObject?>( + jni$_.JArray<$T?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _toArray$1( + reference.pointer, _id_toArray$1.pointer, _$objects.pointer) + .object?>(); + } + + static final _id_trimToSize = JArrayList._class.instanceMethodId( + r'trimToSize', + r'()V', + ); + + static final _trimToSize = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void trimToSize()` + void trimToSize() { + _trimToSize(reference.pointer, _id_trimToSize.pointer).check(); + } + + static final _id_containsAll = JArrayList._class.instanceMethodId( + r'containsAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _containsAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsAll(java.util.Collection collection)` + core$_.bool containsAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _containsAll( + reference.pointer, _id_containsAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_reversed = JArrayList._class.instanceMethodId( + r'reversed', + r'()Ljava/util/List;', + ); + + static final _reversed = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.List reversed()` + /// The returned object must be released after use, by calling the [release] method. + JList<$E?>? reversed() { + return _reversed(reference.pointer, _id_reversed.pointer) + .object?>(); + } + + static final _id_parallelStream = JArrayList._class.instanceMethodId( + r'parallelStream', + r'()Ljava/util/stream/Stream;', + ); + + static final _parallelStream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream parallelStream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? parallelStream() { + return _parallelStream(reference.pointer, _id_parallelStream.pointer) + .object(); + } + + static final _id_stream = JArrayList._class.instanceMethodId( + r'stream', + r'()Ljava/util/stream/Stream;', + ); + + static final _stream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream stream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? stream() { + return _stream(reference.pointer, _id_stream.pointer) + .object(); + } + + static final _id_toArray$2 = JArrayList._class.instanceMethodId( + r'toArray', + r'(Ljava/util/function/IntFunction;)[Ljava/lang/Object;', + ); + + static final _toArray$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(java.util.function.IntFunction intFunction)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$2<$T extends jni$_.JObject?>( + jni$_.JObject? intFunction, + ) { + final _$intFunction = intFunction?.reference ?? jni$_.jNullReference; + return _toArray$2( + reference.pointer, _id_toArray$2.pointer, _$intFunction.pointer) + .object?>(); + } +} + +final class $JArrayList$Type$ extends jni$_.JType { + @jni$_.internal + const $JArrayList$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/ArrayList;'; +} + +/// from: `java.util.Collection` +extension type JCollection<$E extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = jni$_.JClass.forName(r'java/util/Collection'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JCollection$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'add(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.add( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'addAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.addAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'clear()V') { + _$impls[$p]!.clear(); + return jni$_.nullptr; + } + if ($d == r'contains(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.contains( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'containsAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.containsAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'equals(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.equals( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'hashCode()I') { + final $r = _$impls[$p]!.hashCode$1(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'isEmpty()Z') { + final $r = _$impls[$p]!.isEmpty(); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'iterator()Ljava/util/Iterator;') { + final $r = _$impls[$p]!.iterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'parallelStream()Ljava/util/stream/Stream;') { + final $r = _$impls[$p]!.parallelStream(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.remove( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'removeAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.removeAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'removeIf(Ljava/util/function/Predicate;)Z') { + final $r = _$impls[$p]!.removeIf( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'retainAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.retainAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'size()I') { + final $r = _$impls[$p]!.size(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'spliterator()Ljava/util/Spliterator;') { + final $r = _$impls[$p]!.spliterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'stream()Ljava/util/stream/Stream;') { + final $r = _$impls[$p]!.stream(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'toArray()[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'toArray(Ljava/util/function/IntFunction;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray$1( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'toArray([Ljava/lang/Object;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray$2( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$E extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $JCollection<$E> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'java.util.Collection', + $p, + _$invokePointer, + [ + if ($impl.clear$async) r'clear()V', + ], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory JCollection.implement( + $JCollection<$E> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension JCollection$$Methods<$E extends jni$_.JObject?> on JCollection<$E> { + static final _id_add = JCollection._class.instanceMethodId( + r'add', + r'(Ljava/lang/Object;)Z', + ); + + static final _add = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean add(E object)` + core$_.bool add( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _add(reference.pointer, _id_add.pointer, _$object.pointer).boolean; + } + + static final _id_addAll = JCollection._class.instanceMethodId( + r'addAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _addAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean addAll(java.util.Collection collection)` + core$_.bool addAll( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll(reference.pointer, _id_addAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_clear = JCollection._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_contains = JCollection._class.instanceMethodId( + r'contains', + r'(Ljava/lang/Object;)Z', + ); + + static final _contains = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean contains(java.lang.Object object)` + core$_.bool contains( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _contains(reference.pointer, _id_contains.pointer, _$object.pointer) + .boolean; + } + + static final _id_containsAll = JCollection._class.instanceMethodId( + r'containsAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _containsAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsAll(java.util.Collection collection)` + core$_.bool containsAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _containsAll( + reference.pointer, _id_containsAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_equals = JCollection._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_hashCode$1 = JCollection._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_isEmpty = JCollection._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_iterator = JCollection._class.instanceMethodId( + r'iterator', + r'()Ljava/util/Iterator;', + ); + + static final _iterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.Iterator iterator()` + /// The returned object must be released after use, by calling the [release] method. + JIterator<$E?>? iterator() { + return _iterator(reference.pointer, _id_iterator.pointer) + .object?>(); + } + + static final _id_parallelStream = JCollection._class.instanceMethodId( + r'parallelStream', + r'()Ljava/util/stream/Stream;', + ); + + static final _parallelStream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream parallelStream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? parallelStream() { + return _parallelStream(reference.pointer, _id_parallelStream.pointer) + .object(); + } + + static final _id_remove = JCollection._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Z', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean remove(java.lang.Object object)` + core$_.bool remove( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove(reference.pointer, _id_remove.pointer, _$object.pointer) + .boolean; + } + + static final _id_removeAll = JCollection._class.instanceMethodId( + r'removeAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _removeAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean removeAll(java.util.Collection collection)` + core$_.bool removeAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _removeAll( + reference.pointer, _id_removeAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_removeIf = JCollection._class.instanceMethodId( + r'removeIf', + r'(Ljava/util/function/Predicate;)Z', + ); + + static final _removeIf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean removeIf(java.util.function.Predicate predicate)` + core$_.bool removeIf( + jni$_.JObject? predicate, + ) { + final _$predicate = predicate?.reference ?? jni$_.jNullReference; + return _removeIf( + reference.pointer, _id_removeIf.pointer, _$predicate.pointer) + .boolean; + } + + static final _id_retainAll = JCollection._class.instanceMethodId( + r'retainAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _retainAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean retainAll(java.util.Collection collection)` + core$_.bool retainAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _retainAll( + reference.pointer, _id_retainAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_size = JCollection._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_spliterator = JCollection._class.instanceMethodId( + r'spliterator', + r'()Ljava/util/Spliterator;', + ); + + static final _spliterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Spliterator spliterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? spliterator() { + return _spliterator(reference.pointer, _id_spliterator.pointer) + .object(); + } + + static final _id_stream = JCollection._class.instanceMethodId( + r'stream', + r'()Ljava/util/stream/Stream;', + ); + + static final _stream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream stream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? stream() { + return _stream(reference.pointer, _id_stream.pointer) + .object(); + } + + static final _id_toArray = JCollection._class.instanceMethodId( + r'toArray', + r'()[Ljava/lang/Object;', + ); + + static final _toArray = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.lang.Object[] toArray()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray? toArray() { + return _toArray(reference.pointer, _id_toArray.pointer) + .object?>(); + } + + static final _id_toArray$1 = JCollection._class.instanceMethodId( + r'toArray', + r'(Ljava/util/function/IntFunction;)[Ljava/lang/Object;', + ); + + static final _toArray$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(java.util.function.IntFunction intFunction)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$1<$T extends jni$_.JObject?>( + jni$_.JObject? intFunction, + ) { + final _$intFunction = intFunction?.reference ?? jni$_.jNullReference; + return _toArray$1( + reference.pointer, _id_toArray$1.pointer, _$intFunction.pointer) + .object?>(); + } + + static final _id_toArray$2 = JCollection._class.instanceMethodId( + r'toArray', + r'([Ljava/lang/Object;)[Ljava/lang/Object;', + ); + + static final _toArray$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract T[] toArray(T[] objects)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$2<$T extends jni$_.JObject?>( + jni$_.JArray<$T?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _toArray$2( + reference.pointer, _id_toArray$2.pointer, _$objects.pointer) + .object?>(); + } +} + +abstract base mixin class $JCollection<$E extends jni$_.JObject?> { + factory $JCollection({ + required core$_.bool Function($E? object) add, + required core$_.bool Function(JCollection? collection) + addAll, + required void Function() clear, + core$_.bool clear$async, + required core$_.bool Function(jni$_.JObject? object) contains, + required core$_.bool Function(JCollection? collection) + containsAll, + required core$_.bool Function(jni$_.JObject? object) equals, + required int Function() hashCode$1, + required core$_.bool Function() isEmpty, + required JIterator? Function() iterator, + required jni$_.JObject? Function() parallelStream, + required core$_.bool Function(jni$_.JObject? object) remove, + required core$_.bool Function(JCollection? collection) + removeAll, + required core$_.bool Function(jni$_.JObject? predicate) removeIf, + required core$_.bool Function(JCollection? collection) + retainAll, + required int Function() size, + required jni$_.JObject? Function() spliterator, + required jni$_.JObject? Function() stream, + required jni$_.JArray? Function() toArray, + required jni$_.JArray? Function(jni$_.JObject? intFunction) + toArray$1, + required jni$_.JArray? Function( + jni$_.JArray? objects) + toArray$2, + }) = _$JCollection<$E>; + + core$_.bool add($E? object); + core$_.bool addAll(JCollection? collection); + void clear(); + core$_.bool get clear$async => false; + core$_.bool contains(jni$_.JObject? object); + core$_.bool containsAll(JCollection? collection); + core$_.bool equals(jni$_.JObject? object); + int hashCode$1(); + core$_.bool isEmpty(); + JIterator? iterator(); + jni$_.JObject? parallelStream(); + core$_.bool remove(jni$_.JObject? object); + core$_.bool removeAll(JCollection? collection); + core$_.bool removeIf(jni$_.JObject? predicate); + core$_.bool retainAll(JCollection? collection); + int size(); + jni$_.JObject? spliterator(); + jni$_.JObject? stream(); + jni$_.JArray? toArray(); + jni$_.JArray? toArray$1(jni$_.JObject? intFunction); + jni$_.JArray? toArray$2( + jni$_.JArray? objects); +} + +final class _$JCollection<$E extends jni$_.JObject?> with $JCollection<$E> { + _$JCollection({ + required core$_.bool Function($E? object) add, + required core$_.bool Function(JCollection? collection) + addAll, + required void Function() clear, + this.clear$async = false, + required core$_.bool Function(jni$_.JObject? object) contains, + required core$_.bool Function(JCollection? collection) + containsAll, + required core$_.bool Function(jni$_.JObject? object) equals, + required int Function() hashCode$1, + required core$_.bool Function() isEmpty, + required JIterator? Function() iterator, + required jni$_.JObject? Function() parallelStream, + required core$_.bool Function(jni$_.JObject? object) remove, + required core$_.bool Function(JCollection? collection) + removeAll, + required core$_.bool Function(jni$_.JObject? predicate) removeIf, + required core$_.bool Function(JCollection? collection) + retainAll, + required int Function() size, + required jni$_.JObject? Function() spliterator, + required jni$_.JObject? Function() stream, + required jni$_.JArray? Function() toArray, + required jni$_.JArray? Function(jni$_.JObject? intFunction) + toArray$1, + required jni$_.JArray? Function( + jni$_.JArray? objects) + toArray$2, + }) : _add = add, + _addAll = addAll, + _clear = clear, + _contains = contains, + _containsAll = containsAll, + _equals = equals, + _hashCode$1 = hashCode$1, + _isEmpty = isEmpty, + _iterator = iterator, + _parallelStream = parallelStream, + _remove = remove, + _removeAll = removeAll, + _removeIf = removeIf, + _retainAll = retainAll, + _size = size, + _spliterator = spliterator, + _stream = stream, + _toArray = toArray, + _toArray$1 = toArray$1, + _toArray$2 = toArray$2; + + final core$_.bool Function($E? object) _add; + final core$_.bool Function(JCollection? collection) _addAll; + final void Function() _clear; + final core$_.bool clear$async; + final core$_.bool Function(jni$_.JObject? object) _contains; + final core$_.bool Function(JCollection? collection) + _containsAll; + final core$_.bool Function(jni$_.JObject? object) _equals; + final int Function() _hashCode$1; + final core$_.bool Function() _isEmpty; + final JIterator? Function() _iterator; + final jni$_.JObject? Function() _parallelStream; + final core$_.bool Function(jni$_.JObject? object) _remove; + final core$_.bool Function(JCollection? collection) + _removeAll; + final core$_.bool Function(jni$_.JObject? predicate) _removeIf; + final core$_.bool Function(JCollection? collection) + _retainAll; + final int Function() _size; + final jni$_.JObject? Function() _spliterator; + final jni$_.JObject? Function() _stream; + final jni$_.JArray? Function() _toArray; + final jni$_.JArray? Function(jni$_.JObject? intFunction) + _toArray$1; + final jni$_.JArray? Function( + jni$_.JArray? objects) _toArray$2; + + core$_.bool add($E? object) { + return _add(object); + } + + core$_.bool addAll(JCollection? collection) { + return _addAll(collection); + } + + void clear() { + return _clear(); + } + + core$_.bool contains(jni$_.JObject? object) { + return _contains(object); + } + + core$_.bool containsAll(JCollection? collection) { + return _containsAll(collection); + } + + core$_.bool equals(jni$_.JObject? object) { + return _equals(object); + } + + int hashCode$1() { + return _hashCode$1(); + } + + core$_.bool isEmpty() { + return _isEmpty(); + } + + JIterator? iterator() { + return _iterator(); + } + + jni$_.JObject? parallelStream() { + return _parallelStream(); + } + + core$_.bool remove(jni$_.JObject? object) { + return _remove(object); + } + + core$_.bool removeAll(JCollection? collection) { + return _removeAll(collection); + } + + core$_.bool removeIf(jni$_.JObject? predicate) { + return _removeIf(predicate); + } + + core$_.bool retainAll(JCollection? collection) { + return _retainAll(collection); + } + + int size() { + return _size(); + } + + jni$_.JObject? spliterator() { + return _spliterator(); + } + + jni$_.JObject? stream() { + return _stream(); + } + + jni$_.JArray? toArray() { + return _toArray(); + } + + jni$_.JArray? toArray$1(jni$_.JObject? intFunction) { + return _toArray$1(intFunction); + } + + jni$_.JArray? toArray$2( + jni$_.JArray? objects) { + return _toArray$2(objects); + } +} + +final class $JCollection$Type$ extends jni$_.JType { + @jni$_.internal + const $JCollection$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/Collection;'; +} + +/// from: `java.util.HashMap` +extension type JHashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject, JMap<$K?, $V?> { + static final _class = jni$_.JClass.forName(r'java/util/HashMap'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JHashMap$Type$(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JHashMap() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); + } + + static final _id_new$1 = _class.constructorId( + r'(I)V', + ); + + static final _new$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void (int i)` + /// The returned object must be released after use, by calling the [release] method. + factory JHashMap.new$1( + int i, + ) { + return _new$1(_class.reference.pointer, _id_new$1.pointer, i) + .object>(); + } + + static final _id_new$2 = _class.constructorId( + r'(IF)V', + ); + + static final _new$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Double)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int, double)>(); + + /// from: `public void (int i, float f)` + /// The returned object must be released after use, by calling the [release] method. + factory JHashMap.new$2( + int i, + double f, + ) { + return _new$2(_class.reference.pointer, _id_new$2.pointer, i, f) + .object>(); + } + + static final _id_new$3 = _class.constructorId( + r'(Ljava/util/Map;)V', + ); + + static final _new$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void (java.util.Map map)` + /// The returned object must be released after use, by calling the [release] method. + factory JHashMap.new$3( + JMap<$K?, $V?>? map, + ) { + final _$map = map?.reference ?? jni$_.jNullReference; + return _new$3(_class.reference.pointer, _id_new$3.pointer, _$map.pointer) + .object>(); + } + + static final _id_newHashMap = _class.staticMethodId( + r'newHashMap', + r'(I)Ljava/util/HashMap;', + ); + + static final _newHashMap = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Int32,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `static public java.util.HashMap newHashMap(int i)` + /// The returned object must be released after use, by calling the [release] method. + static JHashMap<$K?, $V?>? + newHashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + int i, + ) { + return _newHashMap(_class.reference.pointer, _id_newHashMap.pointer, i) + .object?>(); + } + + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Map;)Ljava/util/Map;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Map copyOf(java.util.Map map)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + copyOf<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + JMap<$K?, $V?>? map, + ) { + final _$map = map?.reference ?? jni$_.jNullReference; + return _copyOf(_class.reference.pointer, _id_copyOf.pointer, _$map.pointer) + .object?>(); + } + + static final _id_entry = _class.staticMethodId( + r'entry', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map$Entry;', + ); + + static final _entry = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map$Entry entry(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + static JMap$JEntry<$K?, $V?>? + entry<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _entry(_class.reference.pointer, _id_entry.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of = _class.staticMethodId( + r'of', + r'()Ljava/util/Map;', + ); + + static final _of = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.Map of()` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of<$K extends jni$_.JObject?, $V extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer) + .object?>(); + } + + static final _id_of$1 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$1<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of$2 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$2<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer, _$object3.pointer) + .object?>(); + } + + static final _id_of$3 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$3<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + return _of$3( + _class.reference.pointer, + _id_of$3.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer) + .object?>(); + } + + static final _id_of$4 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$4<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + return _of$4( + _class.reference.pointer, + _id_of$4.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer) + .object?>(); + } + + static final _id_of$5 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$5<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + return _of$5( + _class.reference.pointer, + _id_of$5.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer) + .object?>(); + } + + static final _id_of$6 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$6<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + return _of$6( + _class.reference.pointer, + _id_of$6.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer) + .object?>(); + } + + static final _id_of$7 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$7 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$7<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + return _of$7( + _class.reference.pointer, + _id_of$7.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer) + .object?>(); + } + + static final _id_of$8 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$8 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13, K object14, V object15)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$8<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + $K? object14, + $V? object15, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + final _$object14 = object14?.reference ?? jni$_.jNullReference; + final _$object15 = object15?.reference ?? jni$_.jNullReference; + return _of$8( + _class.reference.pointer, + _id_of$8.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer, + _$object14.pointer, + _$object15.pointer) + .object?>(); + } + + static final _id_of$9 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$9 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13, K object14, V object15, K object16, V object17)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$9<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + $K? object14, + $V? object15, + $K? object16, + $V? object17, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + final _$object14 = object14?.reference ?? jni$_.jNullReference; + final _$object15 = object15?.reference ?? jni$_.jNullReference; + final _$object16 = object16?.reference ?? jni$_.jNullReference; + final _$object17 = object17?.reference ?? jni$_.jNullReference; + return _of$9( + _class.reference.pointer, + _id_of$9.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer, + _$object14.pointer, + _$object15.pointer, + _$object16.pointer, + _$object17.pointer) + .object?>(); + } + + static final _id_of$10 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$10 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13, K object14, V object15, K object16, V object17, K object18, V object19)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$10<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + $K? object14, + $V? object15, + $K? object16, + $V? object17, + $K? object18, + $V? object19, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + final _$object14 = object14?.reference ?? jni$_.jNullReference; + final _$object15 = object15?.reference ?? jni$_.jNullReference; + final _$object16 = object16?.reference ?? jni$_.jNullReference; + final _$object17 = object17?.reference ?? jni$_.jNullReference; + final _$object18 = object18?.reference ?? jni$_.jNullReference; + final _$object19 = object19?.reference ?? jni$_.jNullReference; + return _of$10( + _class.reference.pointer, + _id_of$10.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer, + _$object14.pointer, + _$object15.pointer, + _$object16.pointer, + _$object17.pointer, + _$object18.pointer, + _$object19.pointer) + .object?>(); + } + + static final _id_ofEntries = _class.staticMethodId( + r'ofEntries', + r'([Ljava/util/Map$Entry;)Ljava/util/Map;', + ); + + static final _ofEntries = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Map ofEntries(java.util.Map$Entry[] entrys)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + ofEntries<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + jni$_.JArray?>? entrys, + ) { + final _$entrys = entrys?.reference ?? jni$_.jNullReference; + return _ofEntries( + _class.reference.pointer, _id_ofEntries.pointer, _$entrys.pointer) + .object?>(); + } +} + +extension JHashMap$$Methods<$K extends jni$_.JObject?, + $V extends jni$_.JObject?> on JHashMap<$K, $V> { + static final _id_clear = JHashMap._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_clone = JHashMap._class.instanceMethodId( + r'clone', + r'()Ljava/lang/Object;', + ); + + static final _clone = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.Object clone()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? clone() { + return _clone(reference.pointer, _id_clone.pointer) + .object(); + } + + static final _id_compute = JHashMap._class.instanceMethodId( + r'compute', + r'(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', + ); + + static final _compute = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V compute(K object, java.util.function.BiFunction biFunction)` + /// The returned object must be released after use, by calling the [release] method. + $V? compute( + $K? object, + jni$_.JObject? biFunction, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + return _compute(reference.pointer, _id_compute.pointer, _$object.pointer, + _$biFunction.pointer) + .object<$V?>(); + } + + static final _id_computeIfAbsent = JHashMap._class.instanceMethodId( + r'computeIfAbsent', + r'(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;', + ); + + static final _computeIfAbsent = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V computeIfAbsent(K object, java.util.function.Function function)` + /// The returned object must be released after use, by calling the [release] method. + $V? computeIfAbsent( + $K? object, + jni$_.JObject? function, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$function = function?.reference ?? jni$_.jNullReference; + return _computeIfAbsent(reference.pointer, _id_computeIfAbsent.pointer, + _$object.pointer, _$function.pointer) + .object<$V?>(); + } + + static final _id_computeIfPresent = JHashMap._class.instanceMethodId( + r'computeIfPresent', + r'(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', + ); + + static final _computeIfPresent = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V computeIfPresent(K object, java.util.function.BiFunction biFunction)` + /// The returned object must be released after use, by calling the [release] method. + $V? computeIfPresent( + $K? object, + jni$_.JObject? biFunction, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + return _computeIfPresent(reference.pointer, _id_computeIfPresent.pointer, + _$object.pointer, _$biFunction.pointer) + .object<$V?>(); + } + + static final _id_containsKey = JHashMap._class.instanceMethodId( + r'containsKey', + r'(Ljava/lang/Object;)Z', + ); + + static final _containsKey = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean containsKey(java.lang.Object object)` + core$_.bool containsKey( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _containsKey( + reference.pointer, _id_containsKey.pointer, _$object.pointer) + .boolean; + } + + static final _id_containsValue = JHashMap._class.instanceMethodId( + r'containsValue', + r'(Ljava/lang/Object;)Z', + ); + + static final _containsValue = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean containsValue(java.lang.Object object)` + core$_.bool containsValue( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _containsValue( + reference.pointer, _id_containsValue.pointer, _$object.pointer) + .boolean; + } + + static final _id_entrySet = JHashMap._class.instanceMethodId( + r'entrySet', + r'()Ljava/util/Set;', + ); + + static final _entrySet = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Set> entrySet()` + /// The returned object must be released after use, by calling the [release] method. + JSet?>? entrySet() { + return _entrySet(reference.pointer, _id_entrySet.pointer) + .object?>?>(); + } + + static final _id_forEach = JHashMap._class.instanceMethodId( + r'forEach', + r'(Ljava/util/function/BiConsumer;)V', + ); + + static final _forEach = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void forEach(java.util.function.BiConsumer biConsumer)` + void forEach( + jni$_.JObject? biConsumer, + ) { + final _$biConsumer = biConsumer?.reference ?? jni$_.jNullReference; + _forEach(reference.pointer, _id_forEach.pointer, _$biConsumer.pointer) + .check(); + } + + static final _id_get = JHashMap._class.instanceMethodId( + r'get', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _get = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public V get(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + $V? get( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _get(reference.pointer, _id_get.pointer, _$object.pointer) + .object<$V?>(); + } + + static final _id_getOrDefault = JHashMap._class.instanceMethodId( + r'getOrDefault', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _getOrDefault = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V getOrDefault(java.lang.Object object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? getOrDefault( + jni$_.JObject? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _getOrDefault(reference.pointer, _id_getOrDefault.pointer, + _$object.pointer, _$object1.pointer) + .object<$V?>(); + } + + static final _id_isEmpty = JHashMap._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_keySet = JHashMap._class.instanceMethodId( + r'keySet', + r'()Ljava/util/Set;', + ); + + static final _keySet = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Set keySet()` + /// The returned object must be released after use, by calling the [release] method. + JSet<$K?>? keySet() { + return _keySet(reference.pointer, _id_keySet.pointer).object?>(); + } + + static final _id_merge = JHashMap._class.instanceMethodId( + r'merge', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', + ); + + static final _merge = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V merge(K object, V object1, java.util.function.BiFunction biFunction)` + /// The returned object must be released after use, by calling the [release] method. + $V? merge( + $K? object, + $V? object1, + jni$_.JObject? biFunction, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + return _merge(reference.pointer, _id_merge.pointer, _$object.pointer, + _$object1.pointer, _$biFunction.pointer) + .object<$V?>(); + } + + static final _id_put = JHashMap._class.instanceMethodId( + r'put', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _put = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V put(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? put( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _put(reference.pointer, _id_put.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); + } + + static final _id_putAll = JHashMap._class.instanceMethodId( + r'putAll', + r'(Ljava/util/Map;)V', + ); + + static final _putAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void putAll(java.util.Map map)` + void putAll( + JMap<$K?, $V?>? map, + ) { + final _$map = map?.reference ?? jni$_.jNullReference; + _putAll(reference.pointer, _id_putAll.pointer, _$map.pointer).check(); + } + + static final _id_putIfAbsent = JHashMap._class.instanceMethodId( + r'putIfAbsent', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _putIfAbsent = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V putIfAbsent(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? putIfAbsent( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _putIfAbsent(reference.pointer, _id_putIfAbsent.pointer, + _$object.pointer, _$object1.pointer) + .object<$V?>(); + } + + static final _id_remove = JHashMap._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public V remove(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + $V? remove( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove(reference.pointer, _id_remove.pointer, _$object.pointer) + .object<$V?>(); + } + + static final _id_remove$1 = JHashMap._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;Ljava/lang/Object;)Z', + ); + + static final _remove$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public boolean remove(java.lang.Object object, java.lang.Object object1)` + core$_.bool remove$1( + jni$_.JObject? object, + jni$_.JObject? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _remove$1(reference.pointer, _id_remove$1.pointer, _$object.pointer, + _$object1.pointer) + .boolean; + } + + static final _id_replace = JHashMap._class.instanceMethodId( + r'replace', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _replace = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V replace(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? replace( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _replace(reference.pointer, _id_replace.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); + } + + static final _id_replace$1 = JHashMap._class.instanceMethodId( + r'replace', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z', + ); + + static final _replace$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public boolean replace(K object, V object1, V object2)` + core$_.bool replace$1( + $K? object, + $V? object1, + $V? object2, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + return _replace$1(reference.pointer, _id_replace$1.pointer, + _$object.pointer, _$object1.pointer, _$object2.pointer) + .boolean; + } + + static final _id_replaceAll = JHashMap._class.instanceMethodId( + r'replaceAll', + r'(Ljava/util/function/BiFunction;)V', + ); + + static final _replaceAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void replaceAll(java.util.function.BiFunction biFunction)` + void replaceAll( + jni$_.JObject? biFunction, + ) { + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + _replaceAll(reference.pointer, _id_replaceAll.pointer, _$biFunction.pointer) + .check(); + } + + static final _id_size = JHashMap._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_values = JHashMap._class.instanceMethodId( + r'values', + r'()Ljava/util/Collection;', + ); + + static final _values = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Collection values()` + /// The returned object must be released after use, by calling the [release] method. + JCollection<$V?>? values() { + return _values(reference.pointer, _id_values.pointer) + .object?>(); + } + + static final _id_equals = JHashMap._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_hashCode$1 = JHashMap._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } +} + +final class $JHashMap$Type$ extends jni$_.JType { + @jni$_.internal + const $JHashMap$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/HashMap;'; +} + +/// from: `java.util.HashSet` +extension type JHashSet<$E extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject, JSet<$E?> { + static final _class = jni$_.JClass.forName(r'java/util/HashSet'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JHashSet$Type$(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory JHashSet() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); + } + + static final _id_new$1 = _class.constructorId( + r'(I)V', + ); + + static final _new$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void (int i)` + /// The returned object must be released after use, by calling the [release] method. + factory JHashSet.new$1( + int i, + ) { + return _new$1(_class.reference.pointer, _id_new$1.pointer, i) + .object>(); + } + + static final _id_new$2 = _class.constructorId( + r'(IF)V', + ); + + static final _new$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Double)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int, double)>(); + + /// from: `public void (int i, float f)` + /// The returned object must be released after use, by calling the [release] method. + factory JHashSet.new$2( + int i, + double f, + ) { + return _new$2(_class.reference.pointer, _id_new$2.pointer, i, f) + .object>(); + } + + static final _id_new$3 = _class.constructorId( + r'(Ljava/util/Collection;)V', + ); + + static final _new$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void (java.util.Collection collection)` + /// The returned object must be released after use, by calling the [release] method. + factory JHashSet.new$3( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _new$3( + _class.reference.pointer, _id_new$3.pointer, _$collection.pointer) + .object>(); + } + + static final _id_newHashSet = _class.staticMethodId( + r'newHashSet', + r'(I)Ljava/util/HashSet;', + ); + + static final _newHashSet = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Int32,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `static public java.util.HashSet newHashSet(int i)` + /// The returned object must be released after use, by calling the [release] method. + static JHashSet<$T?>? newHashSet<$T extends jni$_.JObject?>( + int i, + ) { + return _newHashSet(_class.reference.pointer, _id_newHashSet.pointer, i) + .object?>(); + } + + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Collection;)Ljava/util/Set;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Set copyOf(java.util.Collection collection)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? copyOf<$E extends jni$_.JObject?>( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _copyOf( + _class.reference.pointer, _id_copyOf.pointer, _$collection.pointer) + .object?>(); + } + + static final _id_of = _class.staticMethodId( + r'of', + r'()Ljava/util/Set;', + ); + + static final _of = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.Set of()` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of<$E extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer).object?>(); + } + + static final _id_of$1 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$1<$E extends jni$_.JObject?>( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer) + .object?>(); + } + + static final _id_of$2 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$2<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of$3 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$3<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + return _of$3(_class.reference.pointer, _id_of$3.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer) + .object?>(); + } + + static final _id_of$4 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$4<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + return _of$4(_class.reference.pointer, _id_of$4.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer, _$object3.pointer) + .object?>(); + } + + static final _id_of$5 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$5<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + return _of$5( + _class.reference.pointer, + _id_of$5.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer) + .object?>(); + } + + static final _id_of$6 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$6<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + return _of$6( + _class.reference.pointer, + _id_of$6.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer) + .object?>(); + } + + static final _id_of$7 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$7 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$7<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + return _of$7( + _class.reference.pointer, + _id_of$7.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer) + .object?>(); + } + + static final _id_of$8 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$8 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$8<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + return _of$8( + _class.reference.pointer, + _id_of$8.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer) + .object?>(); + } + + static final _id_of$9 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$9 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$9<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + return _of$9( + _class.reference.pointer, + _id_of$9.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer) + .object?>(); + } + + static final _id_of$10 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$10 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8, E object9)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$10<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + $E? object9, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + return _of$10( + _class.reference.pointer, + _id_of$10.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer) + .object?>(); + } + + static final _id_of$11 = _class.staticMethodId( + r'of', + r'([Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$11 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E[] objects)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$11<$E extends jni$_.JObject?>( + jni$_.JArray<$E?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _of$11( + _class.reference.pointer, _id_of$11.pointer, _$objects.pointer) + .object?>(); + } +} + +extension JHashSet$$Methods<$E extends jni$_.JObject?> on JHashSet<$E> { + static final _id_add = JHashSet._class.instanceMethodId( + r'add', + r'(Ljava/lang/Object;)Z', + ); + + static final _add = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean add(E object)` + core$_.bool add( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _add(reference.pointer, _id_add.pointer, _$object.pointer).boolean; + } + + static final _id_clear = JHashSet._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_clone = JHashSet._class.instanceMethodId( + r'clone', + r'()Ljava/lang/Object;', + ); + + static final _clone = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.Object clone()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? clone() { + return _clone(reference.pointer, _id_clone.pointer) + .object(); + } + + static final _id_contains = JHashSet._class.instanceMethodId( + r'contains', + r'(Ljava/lang/Object;)Z', + ); + + static final _contains = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean contains(java.lang.Object object)` + core$_.bool contains( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _contains(reference.pointer, _id_contains.pointer, _$object.pointer) + .boolean; + } + + static final _id_isEmpty = JHashSet._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_iterator = JHashSet._class.instanceMethodId( + r'iterator', + r'()Ljava/util/Iterator;', + ); + + static final _iterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Iterator iterator()` + /// The returned object must be released after use, by calling the [release] method. + JIterator<$E?>? iterator() { + return _iterator(reference.pointer, _id_iterator.pointer) + .object?>(); + } + + static final _id_remove = JHashSet._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Z', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean remove(java.lang.Object object)` + core$_.bool remove( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove(reference.pointer, _id_remove.pointer, _$object.pointer) + .boolean; + } + + static final _id_size = JHashSet._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_spliterator = JHashSet._class.instanceMethodId( + r'spliterator', + r'()Ljava/util/Spliterator;', + ); + + static final _spliterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Spliterator spliterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? spliterator() { + return _spliterator(reference.pointer, _id_spliterator.pointer) + .object(); + } + + static final _id_toArray = JHashSet._class.instanceMethodId( + r'toArray', + r'()[Ljava/lang/Object;', + ); + + static final _toArray = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.Object[] toArray()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray? toArray() { + return _toArray(reference.pointer, _id_toArray.pointer) + .object?>(); + } + + static final _id_toArray$1 = JHashSet._class.instanceMethodId( + r'toArray', + r'([Ljava/lang/Object;)[Ljava/lang/Object;', + ); + + static final _toArray$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(T[] objects)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$1<$T extends jni$_.JObject?>( + jni$_.JArray<$T?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _toArray$1( + reference.pointer, _id_toArray$1.pointer, _$objects.pointer) + .object?>(); + } + + static final _id_addAll = JHashSet._class.instanceMethodId( + r'addAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _addAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean addAll(java.util.Collection collection)` + core$_.bool addAll( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll(reference.pointer, _id_addAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_containsAll = JHashSet._class.instanceMethodId( + r'containsAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _containsAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsAll(java.util.Collection collection)` + core$_.bool containsAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _containsAll( + reference.pointer, _id_containsAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_equals = JHashSet._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_hashCode$1 = JHashSet._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_removeAll = JHashSet._class.instanceMethodId( + r'removeAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _removeAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean removeAll(java.util.Collection collection)` + core$_.bool removeAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _removeAll( + reference.pointer, _id_removeAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_retainAll = JHashSet._class.instanceMethodId( + r'retainAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _retainAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean retainAll(java.util.Collection collection)` + core$_.bool retainAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _retainAll( + reference.pointer, _id_retainAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_parallelStream = JHashSet._class.instanceMethodId( + r'parallelStream', + r'()Ljava/util/stream/Stream;', + ); + + static final _parallelStream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream parallelStream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? parallelStream() { + return _parallelStream(reference.pointer, _id_parallelStream.pointer) + .object(); + } + + static final _id_removeIf = JHashSet._class.instanceMethodId( + r'removeIf', + r'(Ljava/util/function/Predicate;)Z', + ); + + static final _removeIf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean removeIf(java.util.function.Predicate predicate)` + core$_.bool removeIf( + jni$_.JObject? predicate, + ) { + final _$predicate = predicate?.reference ?? jni$_.jNullReference; + return _removeIf( + reference.pointer, _id_removeIf.pointer, _$predicate.pointer) + .boolean; + } + + static final _id_stream = JHashSet._class.instanceMethodId( + r'stream', + r'()Ljava/util/stream/Stream;', + ); + + static final _stream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream stream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? stream() { + return _stream(reference.pointer, _id_stream.pointer) + .object(); + } + + static final _id_toArray$2 = JHashSet._class.instanceMethodId( + r'toArray', + r'(Ljava/util/function/IntFunction;)[Ljava/lang/Object;', + ); + + static final _toArray$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(java.util.function.IntFunction intFunction)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$2<$T extends jni$_.JObject?>( + jni$_.JObject? intFunction, + ) { + final _$intFunction = intFunction?.reference ?? jni$_.jNullReference; + return _toArray$2( + reference.pointer, _id_toArray$2.pointer, _$intFunction.pointer) + .object?>(); + } +} + +final class $JHashSet$Type$ extends jni$_.JType { + @jni$_.internal + const $JHashSet$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/HashSet;'; +} + +/// from: `java.util.Iterator` +extension type JIterator<$E extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = jni$_.JClass.forName(r'java/util/Iterator'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JIterator$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'forEachRemaining(Ljava/util/function/Consumer;)V') { + _$impls[$p]!.forEachRemaining( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'hasNext()Z') { + final $r = _$impls[$p]!.hasNext(); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'next()Ljava/lang/Object;') { + final $r = _$impls[$p]!.next(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove()V') { + _$impls[$p]!.remove(); + return jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$E extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $JIterator<$E> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'java.util.Iterator', + $p, + _$invokePointer, + [ + if ($impl.forEachRemaining$async) + r'forEachRemaining(Ljava/util/function/Consumer;)V', + if ($impl.remove$async) r'remove()V', + ], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory JIterator.implement( + $JIterator<$E> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension JIterator$$Methods<$E extends jni$_.JObject?> on JIterator<$E> { + static final _id_forEachRemaining = JIterator._class.instanceMethodId( + r'forEachRemaining', + r'(Ljava/util/function/Consumer;)V', + ); + + static final _forEachRemaining = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void forEachRemaining(java.util.function.Consumer consumer)` + void forEachRemaining( + jni$_.JObject? consumer, + ) { + final _$consumer = consumer?.reference ?? jni$_.jNullReference; + _forEachRemaining( + reference.pointer, _id_forEachRemaining.pointer, _$consumer.pointer) + .check(); + } + + static final _id_hasNext = JIterator._class.instanceMethodId( + r'hasNext', + r'()Z', + ); + + static final _hasNext = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract boolean hasNext()` + core$_.bool hasNext() { + return _hasNext(reference.pointer, _id_hasNext.pointer).boolean; + } + + static final _id_next = JIterator._class.instanceMethodId( + r'next', + r'()Ljava/lang/Object;', + ); + + static final _next = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract E next()` + /// The returned object must be released after use, by calling the [release] method. + $E? next() { + return _next(reference.pointer, _id_next.pointer).object<$E?>(); + } + + static final _id_remove = JIterator._class.instanceMethodId( + r'remove', + r'()V', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void remove()` + void remove() { + _remove(reference.pointer, _id_remove.pointer).check(); + } +} + +abstract base mixin class $JIterator<$E extends jni$_.JObject?> { + factory $JIterator({ + required void Function(jni$_.JObject? consumer) forEachRemaining, + core$_.bool forEachRemaining$async, + required core$_.bool Function() hasNext, + required $E? Function() next, + required void Function() remove, + core$_.bool remove$async, + }) = _$JIterator<$E>; + + void forEachRemaining(jni$_.JObject? consumer); + core$_.bool get forEachRemaining$async => false; + core$_.bool hasNext(); + $E? next(); + void remove(); + core$_.bool get remove$async => false; +} + +final class _$JIterator<$E extends jni$_.JObject?> with $JIterator<$E> { + _$JIterator({ + required void Function(jni$_.JObject? consumer) forEachRemaining, + this.forEachRemaining$async = false, + required core$_.bool Function() hasNext, + required $E? Function() next, + required void Function() remove, + this.remove$async = false, + }) : _forEachRemaining = forEachRemaining, + _hasNext = hasNext, + _next = next, + _remove = remove; + + final void Function(jni$_.JObject? consumer) _forEachRemaining; + final core$_.bool forEachRemaining$async; + final core$_.bool Function() _hasNext; + final $E? Function() _next; + final void Function() _remove; + final core$_.bool remove$async; + + void forEachRemaining(jni$_.JObject? consumer) { + return _forEachRemaining(consumer); + } + + core$_.bool hasNext() { + return _hasNext(); + } + + $E? next() { + return _next(); + } + + void remove() { + return _remove(); + } +} + +final class $JIterator$Type$ extends jni$_.JType { + @jni$_.internal + const $JIterator$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/Iterator;'; +} + +/// from: `java.util.List` +extension type JList<$E extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject, JCollection<$E?> { + static final _class = jni$_.JClass.forName(r'java/util/List'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JList$Type$(); + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Collection;)Ljava/util/List;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.List copyOf(java.util.Collection collection)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? copyOf<$E extends jni$_.JObject?>( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _copyOf( + _class.reference.pointer, _id_copyOf.pointer, _$collection.pointer) + .object?>(); + } + + static final _id_of = _class.staticMethodId( + r'of', + r'()Ljava/util/List;', + ); + + static final _of = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.List of()` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of<$E extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer).object?>(); + } + + static final _id_of$1 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$1<$E extends jni$_.JObject?>( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer) + .object?>(); + } + + static final _id_of$2 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$2<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of$3 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$3<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + return _of$3(_class.reference.pointer, _id_of$3.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer) + .object?>(); + } + + static final _id_of$4 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$4<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + return _of$4(_class.reference.pointer, _id_of$4.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer, _$object3.pointer) + .object?>(); + } + + static final _id_of$5 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$5<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + return _of$5( + _class.reference.pointer, + _id_of$5.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer) + .object?>(); + } + + static final _id_of$6 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$6<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + return _of$6( + _class.reference.pointer, + _id_of$6.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer) + .object?>(); + } + + static final _id_of$7 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$7 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$7<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + return _of$7( + _class.reference.pointer, + _id_of$7.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer) + .object?>(); + } + + static final _id_of$8 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$8 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$8<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + return _of$8( + _class.reference.pointer, + _id_of$8.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer) + .object?>(); + } + + static final _id_of$9 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$9 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$9<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + return _of$9( + _class.reference.pointer, + _id_of$9.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer) + .object?>(); + } + + static final _id_of$10 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$10 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8, E object9)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$10<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + $E? object9, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + return _of$10( + _class.reference.pointer, + _id_of$10.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer) + .object?>(); + } + + static final _id_of$11 = _class.staticMethodId( + r'of', + r'([Ljava/lang/Object;)Ljava/util/List;', + ); + + static final _of$11 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.List of(E[] objects)` + /// The returned object must be released after use, by calling the [release] method. + static JList<$E?>? of$11<$E extends jni$_.JObject?>( + jni$_.JArray<$E?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _of$11( + _class.reference.pointer, _id_of$11.pointer, _$objects.pointer) + .object?>(); + } + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'add(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.add( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'add(ILjava/lang/Object;)V') { + _$impls[$p]!.add$1( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![1] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'addAll(ILjava/util/Collection;)Z') { + final $r = _$impls[$p]!.addAll( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![1] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'addAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.addAll$1( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'addFirst(Ljava/lang/Object;)V') { + _$impls[$p]!.addFirst( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'addLast(Ljava/lang/Object;)V') { + _$impls[$p]!.addLast( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'clear()V') { + _$impls[$p]!.clear(); + return jni$_.nullptr; + } + if ($d == r'contains(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.contains( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'containsAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.containsAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'copyOf(Ljava/util/Collection;)Ljava/util/List;') { + final $r = _$impls[$p]!.copyOf( + ($a![0] as JCollection?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'equals(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.equals( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'get(I)Ljava/lang/Object;') { + final $r = _$impls[$p]!.get( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'getFirst()Ljava/lang/Object;') { + final $r = _$impls[$p]!.getFirst(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'getLast()Ljava/lang/Object;') { + final $r = _$impls[$p]!.getLast(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'hashCode()I') { + final $r = _$impls[$p]!.hashCode$1(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'indexOf(Ljava/lang/Object;)I') { + final $r = _$impls[$p]!.indexOf( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'isEmpty()Z') { + final $r = _$impls[$p]!.isEmpty(); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'iterator()Ljava/util/Iterator;') { + final $r = _$impls[$p]!.iterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'lastIndexOf(Ljava/lang/Object;)I') { + final $r = _$impls[$p]!.lastIndexOf( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'listIterator()Ljava/util/ListIterator;') { + final $r = _$impls[$p]!.listIterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'listIterator(I)Ljava/util/ListIterator;') { + final $r = _$impls[$p]!.listIterator$1( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of()Ljava/util/List;') { + final $r = _$impls[$p]!.of(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of(Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$1( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$2( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$3( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$4( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$5( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$6( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$7( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$8( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$9( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$10( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of([Ljava/lang/Object;)Ljava/util/List;') { + final $r = _$impls[$p]!.of$11( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove(I)Ljava/lang/Object;') { + final $r = _$impls[$p]!.remove( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.remove$1( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'removeAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.removeAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'removeFirst()Ljava/lang/Object;') { + final $r = _$impls[$p]!.removeFirst(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'removeLast()Ljava/lang/Object;') { + final $r = _$impls[$p]!.removeLast(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'replaceAll(Ljava/util/function/UnaryOperator;)V') { + _$impls[$p]!.replaceAll( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'retainAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.retainAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'reversed()Ljava/util/List;') { + final $r = _$impls[$p]!.reversed(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'set(ILjava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.set( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'size()I') { + final $r = _$impls[$p]!.size(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'sort(Ljava/util/Comparator;)V') { + _$impls[$p]!.sort( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'spliterator()Ljava/util/Spliterator;') { + final $r = _$impls[$p]!.spliterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'subList(II)Ljava/util/List;') { + final $r = _$impls[$p]!.subList( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![1] as jni$_.JInteger).intValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'toArray()[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'toArray([Ljava/lang/Object;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray$1( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'parallelStream()Ljava/util/stream/Stream;') { + final $r = _$impls[$p]!.parallelStream(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'removeIf(Ljava/util/function/Predicate;)Z') { + final $r = _$impls[$p]!.removeIf( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'stream()Ljava/util/stream/Stream;') { + final $r = _$impls[$p]!.stream(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'toArray(Ljava/util/function/IntFunction;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray$2( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$E extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $JList<$E> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'java.util.List', + $p, + _$invokePointer, + [ + if ($impl.add$1$async) r'add(ILjava/lang/Object;)V', + if ($impl.addFirst$async) r'addFirst(Ljava/lang/Object;)V', + if ($impl.addLast$async) r'addLast(Ljava/lang/Object;)V', + if ($impl.clear$async) r'clear()V', + if ($impl.replaceAll$async) + r'replaceAll(Ljava/util/function/UnaryOperator;)V', + if ($impl.sort$async) r'sort(Ljava/util/Comparator;)V', + ], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory JList.implement( + $JList<$E> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension JList$$Methods<$E extends jni$_.JObject?> on JList<$E> { + static final _id_add = JList._class.instanceMethodId( + r'add', + r'(Ljava/lang/Object;)Z', + ); + + static final _add = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean add(E object)` + core$_.bool add( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _add(reference.pointer, _id_add.pointer, _$object.pointer).boolean; + } + + static final _id_add$1 = JList._class.instanceMethodId( + r'add', + r'(ILjava/lang/Object;)V', + ); + + static final _add$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public abstract void add(int i, E object)` + void add$1( + int i, + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + _add$1(reference.pointer, _id_add$1.pointer, i, _$object.pointer).check(); + } + + static final _id_addAll = JList._class.instanceMethodId( + r'addAll', + r'(ILjava/util/Collection;)Z', + ); + + static final _addAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public abstract boolean addAll(int i, java.util.Collection collection)` + core$_.bool addAll( + int i, + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll( + reference.pointer, _id_addAll.pointer, i, _$collection.pointer) + .boolean; + } + + static final _id_addAll$1 = JList._class.instanceMethodId( + r'addAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _addAll$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean addAll(java.util.Collection collection)` + core$_.bool addAll$1( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll$1( + reference.pointer, _id_addAll$1.pointer, _$collection.pointer) + .boolean; + } + + static final _id_addFirst = JList._class.instanceMethodId( + r'addFirst', + r'(Ljava/lang/Object;)V', + ); + + static final _addFirst = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void addFirst(E object)` + void addFirst( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + _addFirst(reference.pointer, _id_addFirst.pointer, _$object.pointer) + .check(); + } + + static final _id_addLast = JList._class.instanceMethodId( + r'addLast', + r'(Ljava/lang/Object;)V', + ); + + static final _addLast = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void addLast(E object)` + void addLast( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + _addLast(reference.pointer, _id_addLast.pointer, _$object.pointer).check(); + } + + static final _id_clear = JList._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_contains = JList._class.instanceMethodId( + r'contains', + r'(Ljava/lang/Object;)Z', + ); + + static final _contains = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean contains(java.lang.Object object)` + core$_.bool contains( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _contains(reference.pointer, _id_contains.pointer, _$object.pointer) + .boolean; + } + + static final _id_containsAll = JList._class.instanceMethodId( + r'containsAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _containsAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsAll(java.util.Collection collection)` + core$_.bool containsAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _containsAll( + reference.pointer, _id_containsAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_equals = JList._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_get = JList._class.instanceMethodId( + r'get', + r'(I)Ljava/lang/Object;', + ); + + static final _get = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public abstract E get(int i)` + /// The returned object must be released after use, by calling the [release] method. + $E? get( + int i, + ) { + return _get(reference.pointer, _id_get.pointer, i).object<$E?>(); + } + + static final _id_getFirst = JList._class.instanceMethodId( + r'getFirst', + r'()Ljava/lang/Object;', + ); + + static final _getFirst = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E getFirst()` + /// The returned object must be released after use, by calling the [release] method. + $E? getFirst() { + return _getFirst(reference.pointer, _id_getFirst.pointer).object<$E?>(); + } + + static final _id_getLast = JList._class.instanceMethodId( + r'getLast', + r'()Ljava/lang/Object;', + ); + + static final _getLast = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E getLast()` + /// The returned object must be released after use, by calling the [release] method. + $E? getLast() { + return _getLast(reference.pointer, _id_getLast.pointer).object<$E?>(); + } + + static final _id_hashCode$1 = JList._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_indexOf = JList._class.instanceMethodId( + r'indexOf', + r'(Ljava/lang/Object;)I', + ); + + static final _indexOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract int indexOf(java.lang.Object object)` + int indexOf( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _indexOf(reference.pointer, _id_indexOf.pointer, _$object.pointer) + .integer; + } + + static final _id_isEmpty = JList._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_iterator = JList._class.instanceMethodId( + r'iterator', + r'()Ljava/util/Iterator;', + ); + + static final _iterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.Iterator iterator()` + /// The returned object must be released after use, by calling the [release] method. + JIterator<$E?>? iterator() { + return _iterator(reference.pointer, _id_iterator.pointer) + .object?>(); + } + + static final _id_lastIndexOf = JList._class.instanceMethodId( + r'lastIndexOf', + r'(Ljava/lang/Object;)I', + ); + + static final _lastIndexOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract int lastIndexOf(java.lang.Object object)` + int lastIndexOf( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _lastIndexOf( + reference.pointer, _id_lastIndexOf.pointer, _$object.pointer) + .integer; + } + + static final _id_listIterator = JList._class.instanceMethodId( + r'listIterator', + r'()Ljava/util/ListIterator;', + ); + + static final _listIterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.ListIterator listIterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? listIterator() { + return _listIterator(reference.pointer, _id_listIterator.pointer) + .object(); + } + + static final _id_listIterator$1 = JList._class.instanceMethodId( + r'listIterator', + r'(I)Ljava/util/ListIterator;', + ); + + static final _listIterator$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public abstract java.util.ListIterator listIterator(int i)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? listIterator$1( + int i, + ) { + return _listIterator$1(reference.pointer, _id_listIterator$1.pointer, i) + .object(); + } + + static final _id_remove = JList._class.instanceMethodId( + r'remove', + r'(I)Ljava/lang/Object;', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public abstract E remove(int i)` + /// The returned object must be released after use, by calling the [release] method. + $E? remove( + int i, + ) { + return _remove(reference.pointer, _id_remove.pointer, i).object<$E?>(); + } + + static final _id_remove$1 = JList._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Z', + ); + + static final _remove$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean remove(java.lang.Object object)` + core$_.bool remove$1( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove$1(reference.pointer, _id_remove$1.pointer, _$object.pointer) + .boolean; + } + + static final _id_removeAll = JList._class.instanceMethodId( + r'removeAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _removeAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean removeAll(java.util.Collection collection)` + core$_.bool removeAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _removeAll( + reference.pointer, _id_removeAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_removeFirst = JList._class.instanceMethodId( + r'removeFirst', + r'()Ljava/lang/Object;', + ); + + static final _removeFirst = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E removeFirst()` + /// The returned object must be released after use, by calling the [release] method. + $E? removeFirst() { + return _removeFirst(reference.pointer, _id_removeFirst.pointer) + .object<$E?>(); + } + + static final _id_removeLast = JList._class.instanceMethodId( + r'removeLast', + r'()Ljava/lang/Object;', + ); + + static final _removeLast = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public E removeLast()` + /// The returned object must be released after use, by calling the [release] method. + $E? removeLast() { + return _removeLast(reference.pointer, _id_removeLast.pointer).object<$E?>(); + } + + static final _id_replaceAll = JList._class.instanceMethodId( + r'replaceAll', + r'(Ljava/util/function/UnaryOperator;)V', + ); + + static final _replaceAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void replaceAll(java.util.function.UnaryOperator unaryOperator)` + void replaceAll( + jni$_.JObject? unaryOperator, + ) { + final _$unaryOperator = unaryOperator?.reference ?? jni$_.jNullReference; + _replaceAll( + reference.pointer, _id_replaceAll.pointer, _$unaryOperator.pointer) + .check(); + } + + static final _id_retainAll = JList._class.instanceMethodId( + r'retainAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _retainAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean retainAll(java.util.Collection collection)` + core$_.bool retainAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _retainAll( + reference.pointer, _id_retainAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_reversed = JList._class.instanceMethodId( + r'reversed', + r'()Ljava/util/List;', + ); + + static final _reversed = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.List reversed()` + /// The returned object must be released after use, by calling the [release] method. + JList<$E?>? reversed() { + return _reversed(reference.pointer, _id_reversed.pointer) + .object?>(); + } + + static final _id_set = JList._class.instanceMethodId( + r'set', + r'(ILjava/lang/Object;)Ljava/lang/Object;', + ); + + static final _set = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Int32, jni$_.Pointer)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, jni$_.Pointer)>(); + + /// from: `public abstract E set(int i, E object)` + /// The returned object must be released after use, by calling the [release] method. + $E? set( + int i, + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _set(reference.pointer, _id_set.pointer, i, _$object.pointer) + .object<$E?>(); + } + + static final _id_size = JList._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_sort = JList._class.instanceMethodId( + r'sort', + r'(Ljava/util/Comparator;)V', + ); + + static final _sort = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void sort(java.util.Comparator comparator)` + void sort( + jni$_.JObject? comparator, + ) { + final _$comparator = comparator?.reference ?? jni$_.jNullReference; + _sort(reference.pointer, _id_sort.pointer, _$comparator.pointer).check(); + } + + static final _id_spliterator = JList._class.instanceMethodId( + r'spliterator', + r'()Ljava/util/Spliterator;', + ); + + static final _spliterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Spliterator spliterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? spliterator() { + return _spliterator(reference.pointer, _id_spliterator.pointer) + .object(); + } + + static final _id_subList = JList._class.instanceMethodId( + r'subList', + r'(II)Ljava/util/List;', + ); + + static final _subList = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int, int)>(); + + /// from: `public abstract java.util.List subList(int i, int i1)` + /// The returned object must be released after use, by calling the [release] method. + JList<$E?>? subList( + int i, + int i1, + ) { + return _subList(reference.pointer, _id_subList.pointer, i, i1) + .object?>(); + } + + static final _id_toArray = JList._class.instanceMethodId( + r'toArray', + r'()[Ljava/lang/Object;', + ); + + static final _toArray = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.lang.Object[] toArray()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray? toArray() { + return _toArray(reference.pointer, _id_toArray.pointer) + .object?>(); + } + + static final _id_toArray$1 = JList._class.instanceMethodId( + r'toArray', + r'([Ljava/lang/Object;)[Ljava/lang/Object;', + ); + + static final _toArray$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract T[] toArray(T[] objects)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$1<$T extends jni$_.JObject?>( + jni$_.JArray<$T?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _toArray$1( + reference.pointer, _id_toArray$1.pointer, _$objects.pointer) + .object?>(); + } + + static final _id_parallelStream = JList._class.instanceMethodId( + r'parallelStream', + r'()Ljava/util/stream/Stream;', + ); + + static final _parallelStream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream parallelStream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? parallelStream() { + return _parallelStream(reference.pointer, _id_parallelStream.pointer) + .object(); + } + + static final _id_removeIf = JList._class.instanceMethodId( + r'removeIf', + r'(Ljava/util/function/Predicate;)Z', + ); + + static final _removeIf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean removeIf(java.util.function.Predicate predicate)` + core$_.bool removeIf( + jni$_.JObject? predicate, + ) { + final _$predicate = predicate?.reference ?? jni$_.jNullReference; + return _removeIf( + reference.pointer, _id_removeIf.pointer, _$predicate.pointer) + .boolean; + } + + static final _id_stream = JList._class.instanceMethodId( + r'stream', + r'()Ljava/util/stream/Stream;', + ); + + static final _stream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream stream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? stream() { + return _stream(reference.pointer, _id_stream.pointer) + .object(); + } + + static final _id_toArray$2 = JList._class.instanceMethodId( + r'toArray', + r'(Ljava/util/function/IntFunction;)[Ljava/lang/Object;', + ); + + static final _toArray$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(java.util.function.IntFunction intFunction)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$2<$T extends jni$_.JObject?>( + jni$_.JObject? intFunction, + ) { + final _$intFunction = intFunction?.reference ?? jni$_.jNullReference; + return _toArray$2( + reference.pointer, _id_toArray$2.pointer, _$intFunction.pointer) + .object?>(); + } +} + +abstract base mixin class $JList<$E extends jni$_.JObject?> { + factory $JList({ + required core$_.bool Function($E? object) add, + required void Function(int i, $E? object) add$1, + core$_.bool add$1$async, + required core$_.bool Function( + int i, JCollection? collection) + addAll, + required core$_.bool Function(JCollection? collection) + addAll$1, + required void Function($E? object) addFirst, + core$_.bool addFirst$async, + required void Function($E? object) addLast, + core$_.bool addLast$async, + required void Function() clear, + core$_.bool clear$async, + required core$_.bool Function(jni$_.JObject? object) contains, + required core$_.bool Function(JCollection? collection) + containsAll, + required JList? Function( + JCollection? collection) + copyOf, + required core$_.bool Function(jni$_.JObject? object) equals, + required jni$_.JObject? Function(int i) get, + required jni$_.JObject? Function() getFirst, + required jni$_.JObject? Function() getLast, + required int Function() hashCode$1, + required int Function(jni$_.JObject? object) indexOf, + required core$_.bool Function() isEmpty, + required JIterator? Function() iterator, + required int Function(jni$_.JObject? object) lastIndexOf, + required jni$_.JObject? Function() listIterator, + required jni$_.JObject? Function(int i) listIterator$1, + required JList? Function() of, + required JList? Function(jni$_.JObject? object) of$1, + required JList? Function( + jni$_.JObject? object, jni$_.JObject? object1) + of$2, + required JList? Function(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? object2) + of$3, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) + of$4, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4) + of$5, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) + of$6, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) + of$7, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) + of$8, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) + of$9, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) + of$10, + required JList? Function( + jni$_.JArray? objects) + of$11, + required jni$_.JObject? Function(int i) remove, + required core$_.bool Function(jni$_.JObject? object) remove$1, + required core$_.bool Function(JCollection? collection) + removeAll, + required jni$_.JObject? Function() removeFirst, + required jni$_.JObject? Function() removeLast, + required void Function(jni$_.JObject? unaryOperator) replaceAll, + core$_.bool replaceAll$async, + required core$_.bool Function(JCollection? collection) + retainAll, + required JList? Function() reversed, + required jni$_.JObject? Function(int i, jni$_.JObject? object) set, + required int Function() size, + required void Function(jni$_.JObject? comparator) sort, + core$_.bool sort$async, + required jni$_.JObject? Function() spliterator, + required JList? Function(int i, int i1) subList, + required jni$_.JArray? Function() toArray, + required jni$_.JArray? Function( + jni$_.JArray? objects) + toArray$1, + required jni$_.JObject? Function() parallelStream, + required core$_.bool Function(jni$_.JObject? predicate) removeIf, + required jni$_.JObject? Function() stream, + required jni$_.JArray? Function(jni$_.JObject? intFunction) + toArray$2, + }) = _$JList<$E>; + + core$_.bool add($E? object); + void add$1(int i, $E? object); + core$_.bool get add$1$async => false; + core$_.bool addAll(int i, JCollection? collection); + core$_.bool addAll$1(JCollection? collection); + void addFirst($E? object); + core$_.bool get addFirst$async => false; + void addLast($E? object); + core$_.bool get addLast$async => false; + void clear(); + core$_.bool get clear$async => false; + core$_.bool contains(jni$_.JObject? object); + core$_.bool containsAll(JCollection? collection); + JList? copyOf(JCollection? collection); + core$_.bool equals(jni$_.JObject? object); + jni$_.JObject? get(int i); + jni$_.JObject? getFirst(); + jni$_.JObject? getLast(); + int hashCode$1(); + int indexOf(jni$_.JObject? object); + core$_.bool isEmpty(); + JIterator? iterator(); + int lastIndexOf(jni$_.JObject? object); + jni$_.JObject? listIterator(); + jni$_.JObject? listIterator$1(int i); + JList? of(); + JList? of$1(jni$_.JObject? object); + JList? of$2(jni$_.JObject? object, jni$_.JObject? object1); + JList? of$3( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2); + JList? of$4(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3); + JList? of$5(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3, jni$_.JObject? object4); + JList? of$6( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5); + JList? of$7( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6); + JList? of$8( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7); + JList? of$9( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8); + JList? of$10( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9); + JList? of$11(jni$_.JArray? objects); + jni$_.JObject? remove(int i); + core$_.bool remove$1(jni$_.JObject? object); + core$_.bool removeAll(JCollection? collection); + jni$_.JObject? removeFirst(); + jni$_.JObject? removeLast(); + void replaceAll(jni$_.JObject? unaryOperator); + core$_.bool get replaceAll$async => false; + core$_.bool retainAll(JCollection? collection); + JList? reversed(); + jni$_.JObject? set(int i, jni$_.JObject? object); + int size(); + void sort(jni$_.JObject? comparator); + core$_.bool get sort$async => false; + jni$_.JObject? spliterator(); + JList? subList(int i, int i1); + jni$_.JArray? toArray(); + jni$_.JArray? toArray$1( + jni$_.JArray? objects); + jni$_.JObject? parallelStream(); + core$_.bool removeIf(jni$_.JObject? predicate); + jni$_.JObject? stream(); + jni$_.JArray? toArray$2(jni$_.JObject? intFunction); +} + +final class _$JList<$E extends jni$_.JObject?> with $JList<$E> { + _$JList({ + required core$_.bool Function($E? object) add, + required void Function(int i, $E? object) add$1, + this.add$1$async = false, + required core$_.bool Function( + int i, JCollection? collection) + addAll, + required core$_.bool Function(JCollection? collection) + addAll$1, + required void Function($E? object) addFirst, + this.addFirst$async = false, + required void Function($E? object) addLast, + this.addLast$async = false, + required void Function() clear, + this.clear$async = false, + required core$_.bool Function(jni$_.JObject? object) contains, + required core$_.bool Function(JCollection? collection) + containsAll, + required JList? Function( + JCollection? collection) + copyOf, + required core$_.bool Function(jni$_.JObject? object) equals, + required jni$_.JObject? Function(int i) get, + required jni$_.JObject? Function() getFirst, + required jni$_.JObject? Function() getLast, + required int Function() hashCode$1, + required int Function(jni$_.JObject? object) indexOf, + required core$_.bool Function() isEmpty, + required JIterator? Function() iterator, + required int Function(jni$_.JObject? object) lastIndexOf, + required jni$_.JObject? Function() listIterator, + required jni$_.JObject? Function(int i) listIterator$1, + required JList? Function() of, + required JList? Function(jni$_.JObject? object) of$1, + required JList? Function( + jni$_.JObject? object, jni$_.JObject? object1) + of$2, + required JList? Function(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? object2) + of$3, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) + of$4, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4) + of$5, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) + of$6, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) + of$7, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) + of$8, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) + of$9, + required JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) + of$10, + required JList? Function( + jni$_.JArray? objects) + of$11, + required jni$_.JObject? Function(int i) remove, + required core$_.bool Function(jni$_.JObject? object) remove$1, + required core$_.bool Function(JCollection? collection) + removeAll, + required jni$_.JObject? Function() removeFirst, + required jni$_.JObject? Function() removeLast, + required void Function(jni$_.JObject? unaryOperator) replaceAll, + this.replaceAll$async = false, + required core$_.bool Function(JCollection? collection) + retainAll, + required JList? Function() reversed, + required jni$_.JObject? Function(int i, jni$_.JObject? object) set, + required int Function() size, + required void Function(jni$_.JObject? comparator) sort, + this.sort$async = false, + required jni$_.JObject? Function() spliterator, + required JList? Function(int i, int i1) subList, + required jni$_.JArray? Function() toArray, + required jni$_.JArray? Function( + jni$_.JArray? objects) + toArray$1, + required jni$_.JObject? Function() parallelStream, + required core$_.bool Function(jni$_.JObject? predicate) removeIf, + required jni$_.JObject? Function() stream, + required jni$_.JArray? Function(jni$_.JObject? intFunction) + toArray$2, + }) : _add = add, + _add$1 = add$1, + _addAll = addAll, + _addAll$1 = addAll$1, + _addFirst = addFirst, + _addLast = addLast, + _clear = clear, + _contains = contains, + _containsAll = containsAll, + _copyOf = copyOf, + _equals = equals, + _get = get, + _getFirst = getFirst, + _getLast = getLast, + _hashCode$1 = hashCode$1, + _indexOf = indexOf, + _isEmpty = isEmpty, + _iterator = iterator, + _lastIndexOf = lastIndexOf, + _listIterator = listIterator, + _listIterator$1 = listIterator$1, + _of = of, + _of$1 = of$1, + _of$2 = of$2, + _of$3 = of$3, + _of$4 = of$4, + _of$5 = of$5, + _of$6 = of$6, + _of$7 = of$7, + _of$8 = of$8, + _of$9 = of$9, + _of$10 = of$10, + _of$11 = of$11, + _remove = remove, + _remove$1 = remove$1, + _removeAll = removeAll, + _removeFirst = removeFirst, + _removeLast = removeLast, + _replaceAll = replaceAll, + _retainAll = retainAll, + _reversed = reversed, + _set = set, + _size = size, + _sort = sort, + _spliterator = spliterator, + _subList = subList, + _toArray = toArray, + _toArray$1 = toArray$1, + _parallelStream = parallelStream, + _removeIf = removeIf, + _stream = stream, + _toArray$2 = toArray$2; + + final core$_.bool Function($E? object) _add; + final void Function(int i, $E? object) _add$1; + final core$_.bool add$1$async; + final core$_.bool Function(int i, JCollection? collection) + _addAll; + final core$_.bool Function(JCollection? collection) _addAll$1; + final void Function($E? object) _addFirst; + final core$_.bool addFirst$async; + final void Function($E? object) _addLast; + final core$_.bool addLast$async; + final void Function() _clear; + final core$_.bool clear$async; + final core$_.bool Function(jni$_.JObject? object) _contains; + final core$_.bool Function(JCollection? collection) + _containsAll; + final JList? Function(JCollection? collection) + _copyOf; + final core$_.bool Function(jni$_.JObject? object) _equals; + final jni$_.JObject? Function(int i) _get; + final jni$_.JObject? Function() _getFirst; + final jni$_.JObject? Function() _getLast; + final int Function() _hashCode$1; + final int Function(jni$_.JObject? object) _indexOf; + final core$_.bool Function() _isEmpty; + final JIterator? Function() _iterator; + final int Function(jni$_.JObject? object) _lastIndexOf; + final jni$_.JObject? Function() _listIterator; + final jni$_.JObject? Function(int i) _listIterator$1; + final JList? Function() _of; + final JList? Function(jni$_.JObject? object) _of$1; + final JList? Function( + jni$_.JObject? object, jni$_.JObject? object1) _of$2; + final JList? Function( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2) + _of$3; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) _of$4; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4) _of$5; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) _of$6; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) _of$7; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) _of$8; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) _of$9; + final JList? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) _of$10; + final JList? Function(jni$_.JArray? objects) + _of$11; + final jni$_.JObject? Function(int i) _remove; + final core$_.bool Function(jni$_.JObject? object) _remove$1; + final core$_.bool Function(JCollection? collection) + _removeAll; + final jni$_.JObject? Function() _removeFirst; + final jni$_.JObject? Function() _removeLast; + final void Function(jni$_.JObject? unaryOperator) _replaceAll; + final core$_.bool replaceAll$async; + final core$_.bool Function(JCollection? collection) + _retainAll; + final JList? Function() _reversed; + final jni$_.JObject? Function(int i, jni$_.JObject? object) _set; + final int Function() _size; + final void Function(jni$_.JObject? comparator) _sort; + final core$_.bool sort$async; + final jni$_.JObject? Function() _spliterator; + final JList? Function(int i, int i1) _subList; + final jni$_.JArray? Function() _toArray; + final jni$_.JArray? Function( + jni$_.JArray? objects) _toArray$1; + final jni$_.JObject? Function() _parallelStream; + final core$_.bool Function(jni$_.JObject? predicate) _removeIf; + final jni$_.JObject? Function() _stream; + final jni$_.JArray? Function(jni$_.JObject? intFunction) + _toArray$2; + + core$_.bool add($E? object) { + return _add(object); + } + + void add$1(int i, $E? object) { + return _add$1(i, object); + } + + core$_.bool addAll(int i, JCollection? collection) { + return _addAll(i, collection); + } + + core$_.bool addAll$1(JCollection? collection) { + return _addAll$1(collection); + } + + void addFirst($E? object) { + return _addFirst(object); + } + + void addLast($E? object) { + return _addLast(object); + } + + void clear() { + return _clear(); + } + + core$_.bool contains(jni$_.JObject? object) { + return _contains(object); + } + + core$_.bool containsAll(JCollection? collection) { + return _containsAll(collection); + } + + JList? copyOf(JCollection? collection) { + return _copyOf(collection); + } + + core$_.bool equals(jni$_.JObject? object) { + return _equals(object); + } + + jni$_.JObject? get(int i) { + return _get(i); + } + + jni$_.JObject? getFirst() { + return _getFirst(); + } + + jni$_.JObject? getLast() { + return _getLast(); + } + + int hashCode$1() { + return _hashCode$1(); + } + + int indexOf(jni$_.JObject? object) { + return _indexOf(object); + } + + core$_.bool isEmpty() { + return _isEmpty(); + } + + JIterator? iterator() { + return _iterator(); + } + + int lastIndexOf(jni$_.JObject? object) { + return _lastIndexOf(object); + } + + jni$_.JObject? listIterator() { + return _listIterator(); + } + + jni$_.JObject? listIterator$1(int i) { + return _listIterator$1(i); + } + + JList? of() { + return _of(); + } + + JList? of$1(jni$_.JObject? object) { + return _of$1(object); + } + + JList? of$2(jni$_.JObject? object, jni$_.JObject? object1) { + return _of$2(object, object1); + } + + JList? of$3( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2) { + return _of$3(object, object1, object2); + } + + JList? of$4(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3) { + return _of$4(object, object1, object2, object3); + } + + JList? of$5(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3, jni$_.JObject? object4) { + return _of$5(object, object1, object2, object3, object4); + } + + JList? of$6( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) { + return _of$6(object, object1, object2, object3, object4, object5); + } + + JList? of$7( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) { + return _of$7(object, object1, object2, object3, object4, object5, object6); + } + + JList? of$8( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) { + return _of$8( + object, object1, object2, object3, object4, object5, object6, object7); + } + + JList? of$9( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) { + return _of$9(object, object1, object2, object3, object4, object5, object6, + object7, object8); + } + + JList? of$10( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) { + return _of$10(object, object1, object2, object3, object4, object5, object6, + object7, object8, object9); + } + + JList? of$11(jni$_.JArray? objects) { + return _of$11(objects); + } + + jni$_.JObject? remove(int i) { + return _remove(i); + } + + core$_.bool remove$1(jni$_.JObject? object) { + return _remove$1(object); + } + + core$_.bool removeAll(JCollection? collection) { + return _removeAll(collection); + } + + jni$_.JObject? removeFirst() { + return _removeFirst(); + } + + jni$_.JObject? removeLast() { + return _removeLast(); + } + + void replaceAll(jni$_.JObject? unaryOperator) { + return _replaceAll(unaryOperator); + } + + core$_.bool retainAll(JCollection? collection) { + return _retainAll(collection); + } + + JList? reversed() { + return _reversed(); + } + + jni$_.JObject? set(int i, jni$_.JObject? object) { + return _set(i, object); + } + + int size() { + return _size(); + } + + void sort(jni$_.JObject? comparator) { + return _sort(comparator); + } + + jni$_.JObject? spliterator() { + return _spliterator(); + } + + JList? subList(int i, int i1) { + return _subList(i, i1); + } + + jni$_.JArray? toArray() { + return _toArray(); + } + + jni$_.JArray? toArray$1( + jni$_.JArray? objects) { + return _toArray$1(objects); + } + + jni$_.JObject? parallelStream() { + return _parallelStream(); + } + + core$_.bool removeIf(jni$_.JObject? predicate) { + return _removeIf(predicate); + } + + jni$_.JObject? stream() { + return _stream(); + } + + jni$_.JArray? toArray$2(jni$_.JObject? intFunction) { + return _toArray$2(intFunction); + } +} + +final class $JList$Type$ extends jni$_.JType { + @jni$_.internal + const $JList$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/List;'; +} + +/// from: `java.util.Map$Entry` +extension type JMap$JEntry<$K extends jni$_.JObject?, + $V extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = jni$_.JClass.forName(r'java/util/Map$Entry'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JMap$JEntry$Type$(); + static final _id_comparingByKey = _class.staticMethodId( + r'comparingByKey', + r'()Ljava/util/Comparator;', + ); + + static final _comparingByKey = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.Comparator> comparingByKey()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JObject? + comparingByKey<$K extends jni$_.JObject?, $V extends jni$_.JObject?>() { + return _comparingByKey(_class.reference.pointer, _id_comparingByKey.pointer) + .object(); + } + + static final _id_comparingByKey$1 = _class.staticMethodId( + r'comparingByKey', + r'(Ljava/util/Comparator;)Ljava/util/Comparator;', + ); + + static final _comparingByKey$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Comparator> comparingByKey(java.util.Comparator comparator)` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JObject? + comparingByKey$1<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + jni$_.JObject? comparator, + ) { + final _$comparator = comparator?.reference ?? jni$_.jNullReference; + return _comparingByKey$1(_class.reference.pointer, + _id_comparingByKey$1.pointer, _$comparator.pointer) + .object(); + } + + static final _id_comparingByValue = _class.staticMethodId( + r'comparingByValue', + r'()Ljava/util/Comparator;', + ); + + static final _comparingByValue = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.Comparator> comparingByValue()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JObject? + comparingByValue<$K extends jni$_.JObject?, $V extends jni$_.JObject?>() { + return _comparingByValue( + _class.reference.pointer, _id_comparingByValue.pointer) + .object(); + } + + static final _id_comparingByValue$1 = _class.staticMethodId( + r'comparingByValue', + r'(Ljava/util/Comparator;)Ljava/util/Comparator;', + ); + + static final _comparingByValue$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Comparator> comparingByValue(java.util.Comparator comparator)` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JObject? + comparingByValue$1<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + jni$_.JObject? comparator, + ) { + final _$comparator = comparator?.reference ?? jni$_.jNullReference; + return _comparingByValue$1(_class.reference.pointer, + _id_comparingByValue$1.pointer, _$comparator.pointer) + .object(); + } + + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Map$Entry;)Ljava/util/Map$Entry;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Map$Entry copyOf(java.util.Map$Entry entry)` + /// The returned object must be released after use, by calling the [release] method. + static JMap$JEntry<$K?, $V?>? + copyOf<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + JMap$JEntry<$K?, $V?>? entry, + ) { + final _$entry = entry?.reference ?? jni$_.jNullReference; + return _copyOf( + _class.reference.pointer, _id_copyOf.pointer, _$entry.pointer) + .object?>(); + } + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'comparingByKey()Ljava/util/Comparator;') { + final $r = _$impls[$p]!.comparingByKey(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'comparingByKey(Ljava/util/Comparator;)Ljava/util/Comparator;') { + final $r = _$impls[$p]!.comparingByKey$1( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'comparingByValue()Ljava/util/Comparator;') { + final $r = _$impls[$p]!.comparingByValue(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'comparingByValue(Ljava/util/Comparator;)Ljava/util/Comparator;') { + final $r = _$impls[$p]!.comparingByValue$1( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'copyOf(Ljava/util/Map$Entry;)Ljava/util/Map$Entry;') { + final $r = _$impls[$p]!.copyOf( + ($a![0] as JMap$JEntry?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'equals(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.equals( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'getKey()Ljava/lang/Object;') { + final $r = _$impls[$p]!.getKey(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'getValue()Ljava/lang/Object;') { + final $r = _$impls[$p]!.getValue(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'hashCode()I') { + final $r = _$impls[$p]!.hashCode$1(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'setValue(Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.setValue( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $JMap$JEntry<$K, $V> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'java.util.Map$Entry', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory JMap$JEntry.implement( + $JMap$JEntry<$K, $V> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension JMap$JEntry$$Methods<$K extends jni$_.JObject?, + $V extends jni$_.JObject?> on JMap$JEntry<$K, $V> { + static final _id_equals = JMap$JEntry._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_getKey = JMap$JEntry._class.instanceMethodId( + r'getKey', + r'()Ljava/lang/Object;', + ); + + static final _getKey = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract K getKey()` + /// The returned object must be released after use, by calling the [release] method. + $K? getKey() { + return _getKey(reference.pointer, _id_getKey.pointer).object<$K?>(); + } + + static final _id_getValue = JMap$JEntry._class.instanceMethodId( + r'getValue', + r'()Ljava/lang/Object;', + ); + + static final _getValue = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract V getValue()` + /// The returned object must be released after use, by calling the [release] method. + $V? getValue() { + return _getValue(reference.pointer, _id_getValue.pointer).object<$V?>(); + } + + static final _id_hashCode$1 = JMap$JEntry._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_setValue = JMap$JEntry._class.instanceMethodId( + r'setValue', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _setValue = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract V setValue(V object)` + /// The returned object must be released after use, by calling the [release] method. + $V? setValue( + $V? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _setValue(reference.pointer, _id_setValue.pointer, _$object.pointer) + .object<$V?>(); + } +} + +abstract base mixin class $JMap$JEntry<$K extends jni$_.JObject?, + $V extends jni$_.JObject?> { + factory $JMap$JEntry({ + required jni$_.JObject? Function() comparingByKey, + required jni$_.JObject? Function(jni$_.JObject? comparator) + comparingByKey$1, + required jni$_.JObject? Function() comparingByValue, + required jni$_.JObject? Function(jni$_.JObject? comparator) + comparingByValue$1, + required JMap$JEntry? Function( + JMap$JEntry? entry) + copyOf, + required core$_.bool Function(jni$_.JObject? object) equals, + required jni$_.JObject? Function() getKey, + required jni$_.JObject? Function() getValue, + required int Function() hashCode$1, + required jni$_.JObject? Function(jni$_.JObject? object) setValue, + }) = _$JMap$JEntry<$K, $V>; + + jni$_.JObject? comparingByKey(); + jni$_.JObject? comparingByKey$1(jni$_.JObject? comparator); + jni$_.JObject? comparingByValue(); + jni$_.JObject? comparingByValue$1(jni$_.JObject? comparator); + JMap$JEntry? copyOf( + JMap$JEntry? entry); + core$_.bool equals(jni$_.JObject? object); + jni$_.JObject? getKey(); + jni$_.JObject? getValue(); + int hashCode$1(); + jni$_.JObject? setValue(jni$_.JObject? object); +} + +final class _$JMap$JEntry<$K extends jni$_.JObject?, $V extends jni$_.JObject?> + with $JMap$JEntry<$K, $V> { + _$JMap$JEntry({ + required jni$_.JObject? Function() comparingByKey, + required jni$_.JObject? Function(jni$_.JObject? comparator) + comparingByKey$1, + required jni$_.JObject? Function() comparingByValue, + required jni$_.JObject? Function(jni$_.JObject? comparator) + comparingByValue$1, + required JMap$JEntry? Function( + JMap$JEntry? entry) + copyOf, + required core$_.bool Function(jni$_.JObject? object) equals, + required jni$_.JObject? Function() getKey, + required jni$_.JObject? Function() getValue, + required int Function() hashCode$1, + required jni$_.JObject? Function(jni$_.JObject? object) setValue, + }) : _comparingByKey = comparingByKey, + _comparingByKey$1 = comparingByKey$1, + _comparingByValue = comparingByValue, + _comparingByValue$1 = comparingByValue$1, + _copyOf = copyOf, + _equals = equals, + _getKey = getKey, + _getValue = getValue, + _hashCode$1 = hashCode$1, + _setValue = setValue; + + final jni$_.JObject? Function() _comparingByKey; + final jni$_.JObject? Function(jni$_.JObject? comparator) _comparingByKey$1; + final jni$_.JObject? Function() _comparingByValue; + final jni$_.JObject? Function(jni$_.JObject? comparator) _comparingByValue$1; + final JMap$JEntry? Function( + JMap$JEntry? entry) _copyOf; + final core$_.bool Function(jni$_.JObject? object) _equals; + final jni$_.JObject? Function() _getKey; + final jni$_.JObject? Function() _getValue; + final int Function() _hashCode$1; + final jni$_.JObject? Function(jni$_.JObject? object) _setValue; + + jni$_.JObject? comparingByKey() { + return _comparingByKey(); + } + + jni$_.JObject? comparingByKey$1(jni$_.JObject? comparator) { + return _comparingByKey$1(comparator); + } + + jni$_.JObject? comparingByValue() { + return _comparingByValue(); + } + + jni$_.JObject? comparingByValue$1(jni$_.JObject? comparator) { + return _comparingByValue$1(comparator); + } + + JMap$JEntry? copyOf( + JMap$JEntry? entry) { + return _copyOf(entry); + } + + core$_.bool equals(jni$_.JObject? object) { + return _equals(object); + } + + jni$_.JObject? getKey() { + return _getKey(); + } + + jni$_.JObject? getValue() { + return _getValue(); + } + + int hashCode$1() { + return _hashCode$1(); + } + + jni$_.JObject? setValue(jni$_.JObject? object) { + return _setValue(object); + } +} + +final class $JMap$JEntry$Type$ extends jni$_.JType { + @jni$_.internal + const $JMap$JEntry$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/Map$Entry;'; +} + +/// from: `java.util.Map` +extension type JMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { + static final _class = jni$_.JClass.forName(r'java/util/Map'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JMap$Type$(); + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Map;)Ljava/util/Map;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Map copyOf(java.util.Map map)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + copyOf<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + JMap<$K?, $V?>? map, + ) { + final _$map = map?.reference ?? jni$_.jNullReference; + return _copyOf(_class.reference.pointer, _id_copyOf.pointer, _$map.pointer) + .object?>(); + } + + static final _id_entry = _class.staticMethodId( + r'entry', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map$Entry;', + ); + + static final _entry = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map$Entry entry(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + static JMap$JEntry<$K?, $V?>? + entry<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _entry(_class.reference.pointer, _id_entry.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of = _class.staticMethodId( + r'of', + r'()Ljava/util/Map;', + ); + + static final _of = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.Map of()` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of<$K extends jni$_.JObject?, $V extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer) + .object?>(); + } + + static final _id_of$1 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$1<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of$2 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$2<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer, _$object3.pointer) + .object?>(); + } + + static final _id_of$3 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$3<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + return _of$3( + _class.reference.pointer, + _id_of$3.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer) + .object?>(); + } + + static final _id_of$4 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$4<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + return _of$4( + _class.reference.pointer, + _id_of$4.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer) + .object?>(); + } + + static final _id_of$5 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$5<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + return _of$5( + _class.reference.pointer, + _id_of$5.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer) + .object?>(); + } + + static final _id_of$6 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$6<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + return _of$6( + _class.reference.pointer, + _id_of$6.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer) + .object?>(); + } + + static final _id_of$7 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$7 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$7<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + return _of$7( + _class.reference.pointer, + _id_of$7.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer) + .object?>(); + } + + static final _id_of$8 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$8 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13, K object14, V object15)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$8<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + $K? object14, + $V? object15, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + final _$object14 = object14?.reference ?? jni$_.jNullReference; + final _$object15 = object15?.reference ?? jni$_.jNullReference; + return _of$8( + _class.reference.pointer, + _id_of$8.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer, + _$object14.pointer, + _$object15.pointer) + .object?>(); + } + + static final _id_of$9 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$9 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13, K object14, V object15, K object16, V object17)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$9<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + $K? object14, + $V? object15, + $K? object16, + $V? object17, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + final _$object14 = object14?.reference ?? jni$_.jNullReference; + final _$object15 = object15?.reference ?? jni$_.jNullReference; + final _$object16 = object16?.reference ?? jni$_.jNullReference; + final _$object17 = object17?.reference ?? jni$_.jNullReference; + return _of$9( + _class.reference.pointer, + _id_of$9.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer, + _$object14.pointer, + _$object15.pointer, + _$object16.pointer, + _$object17.pointer) + .object?>(); + } + + static final _id_of$10 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', + ); + + static final _of$10 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Map of(K object, V object1, K object2, V object3, K object4, V object5, K object6, V object7, K object8, V object9, K object10, V object11, K object12, V object13, K object14, V object15, K object16, V object17, K object18, V object19)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + of$10<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + $K? object, + $V? object1, + $K? object2, + $V? object3, + $K? object4, + $V? object5, + $K? object6, + $V? object7, + $K? object8, + $V? object9, + $K? object10, + $V? object11, + $K? object12, + $V? object13, + $K? object14, + $V? object15, + $K? object16, + $V? object17, + $K? object18, + $V? object19, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + final _$object10 = object10?.reference ?? jni$_.jNullReference; + final _$object11 = object11?.reference ?? jni$_.jNullReference; + final _$object12 = object12?.reference ?? jni$_.jNullReference; + final _$object13 = object13?.reference ?? jni$_.jNullReference; + final _$object14 = object14?.reference ?? jni$_.jNullReference; + final _$object15 = object15?.reference ?? jni$_.jNullReference; + final _$object16 = object16?.reference ?? jni$_.jNullReference; + final _$object17 = object17?.reference ?? jni$_.jNullReference; + final _$object18 = object18?.reference ?? jni$_.jNullReference; + final _$object19 = object19?.reference ?? jni$_.jNullReference; + return _of$10( + _class.reference.pointer, + _id_of$10.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer, + _$object10.pointer, + _$object11.pointer, + _$object12.pointer, + _$object13.pointer, + _$object14.pointer, + _$object15.pointer, + _$object16.pointer, + _$object17.pointer, + _$object18.pointer, + _$object19.pointer) + .object?>(); + } + + static final _id_ofEntries = _class.staticMethodId( + r'ofEntries', + r'([Ljava/util/Map$Entry;)Ljava/util/Map;', + ); + + static final _ofEntries = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Map ofEntries(java.util.Map$Entry[] entrys)` + /// The returned object must be released after use, by calling the [release] method. + static JMap<$K?, $V?>? + ofEntries<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + jni$_.JArray?>? entrys, + ) { + final _$entrys = entrys?.reference ?? jni$_.jNullReference; + return _ofEntries( + _class.reference.pointer, _id_ofEntries.pointer, _$entrys.pointer) + .object?>(); + } + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'clear()V') { + _$impls[$p]!.clear(); + return jni$_.nullptr; + } + if ($d == + r'compute(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.compute( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'computeIfAbsent(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.computeIfAbsent( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'computeIfPresent(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.computeIfPresent( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'containsKey(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.containsKey( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'containsValue(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.containsValue( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'copyOf(Ljava/util/Map;)Ljava/util/Map;') { + final $r = _$impls[$p]!.copyOf( + ($a![0] as JMap?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'entry(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map$Entry;') { + final $r = _$impls[$p]!.entry( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'entrySet()Ljava/util/Set;') { + final $r = _$impls[$p]!.entrySet(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'equals(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.equals( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'forEach(Ljava/util/function/BiConsumer;)V') { + _$impls[$p]!.forEach( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'get(Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.get( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'getOrDefault(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.getOrDefault( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'hashCode()I') { + final $r = _$impls[$p]!.hashCode$1(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'isEmpty()Z') { + final $r = _$impls[$p]!.isEmpty(); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'keySet()Ljava/util/Set;') { + final $r = _$impls[$p]!.keySet(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'merge(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.merge( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of()Ljava/util/Map;') { + final $r = _$impls[$p]!.of(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$1( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$2( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$3( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$4( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$5( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$6( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ($a![10] as jni$_.JObject?), + ($a![11] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$7( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ($a![10] as jni$_.JObject?), + ($a![11] as jni$_.JObject?), + ($a![12] as jni$_.JObject?), + ($a![13] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$8( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ($a![10] as jni$_.JObject?), + ($a![11] as jni$_.JObject?), + ($a![12] as jni$_.JObject?), + ($a![13] as jni$_.JObject?), + ($a![14] as jni$_.JObject?), + ($a![15] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$9( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ($a![10] as jni$_.JObject?), + ($a![11] as jni$_.JObject?), + ($a![12] as jni$_.JObject?), + ($a![13] as jni$_.JObject?), + ($a![14] as jni$_.JObject?), + ($a![15] as jni$_.JObject?), + ($a![16] as jni$_.JObject?), + ($a![17] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.of$10( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ($a![10] as jni$_.JObject?), + ($a![11] as jni$_.JObject?), + ($a![12] as jni$_.JObject?), + ($a![13] as jni$_.JObject?), + ($a![14] as jni$_.JObject?), + ($a![15] as jni$_.JObject?), + ($a![16] as jni$_.JObject?), + ($a![17] as jni$_.JObject?), + ($a![18] as jni$_.JObject?), + ($a![19] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'ofEntries([Ljava/util/Map$Entry;)Ljava/util/Map;') { + final $r = _$impls[$p]!.ofEntries( + ($a![0] + as jni$_.JArray?>?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.put( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'putAll(Ljava/util/Map;)V') { + _$impls[$p]!.putAll( + ($a![0] as JMap?), + ); + return jni$_.nullptr; + } + if ($d == + r'putIfAbsent(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.putIfAbsent( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove(Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.remove( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove(Ljava/lang/Object;Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.remove$1( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == + r'replace(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.replace( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'replace(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.replace$1( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'replaceAll(Ljava/util/function/BiFunction;)V') { + _$impls[$p]!.replaceAll( + ($a![0] as jni$_.JObject?), + ); + return jni$_.nullptr; + } + if ($d == r'size()I') { + final $r = _$impls[$p]!.size(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'values()Ljava/util/Collection;') { + final $r = _$impls[$p]!.values(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $JMap<$K, $V> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'java.util.Map', + $p, + _$invokePointer, + [ + if ($impl.clear$async) r'clear()V', + if ($impl.forEach$async) r'forEach(Ljava/util/function/BiConsumer;)V', + if ($impl.putAll$async) r'putAll(Ljava/util/Map;)V', + if ($impl.replaceAll$async) + r'replaceAll(Ljava/util/function/BiFunction;)V', + ], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory JMap.implement( + $JMap<$K, $V> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension JMap$$Methods<$K extends jni$_.JObject?, $V extends jni$_.JObject?> + on JMap<$K, $V> { + static final _id_clear = JMap._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_compute = JMap._class.instanceMethodId( + r'compute', + r'(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', + ); + + static final _compute = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V compute(K object, java.util.function.BiFunction biFunction)` + /// The returned object must be released after use, by calling the [release] method. + $V? compute( + $K? object, + jni$_.JObject? biFunction, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + return _compute(reference.pointer, _id_compute.pointer, _$object.pointer, + _$biFunction.pointer) + .object<$V?>(); + } + + static final _id_computeIfAbsent = JMap._class.instanceMethodId( + r'computeIfAbsent', + r'(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;', + ); + + static final _computeIfAbsent = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V computeIfAbsent(K object, java.util.function.Function function)` + /// The returned object must be released after use, by calling the [release] method. + $V? computeIfAbsent( + $K? object, + jni$_.JObject? function, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$function = function?.reference ?? jni$_.jNullReference; + return _computeIfAbsent(reference.pointer, _id_computeIfAbsent.pointer, + _$object.pointer, _$function.pointer) + .object<$V?>(); + } + + static final _id_computeIfPresent = JMap._class.instanceMethodId( + r'computeIfPresent', + r'(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', + ); + + static final _computeIfPresent = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V computeIfPresent(K object, java.util.function.BiFunction biFunction)` + /// The returned object must be released after use, by calling the [release] method. + $V? computeIfPresent( + $K? object, + jni$_.JObject? biFunction, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + return _computeIfPresent(reference.pointer, _id_computeIfPresent.pointer, + _$object.pointer, _$biFunction.pointer) + .object<$V?>(); + } + + static final _id_containsKey = JMap._class.instanceMethodId( + r'containsKey', + r'(Ljava/lang/Object;)Z', + ); + + static final _containsKey = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsKey(java.lang.Object object)` + core$_.bool containsKey( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _containsKey( + reference.pointer, _id_containsKey.pointer, _$object.pointer) + .boolean; + } + + static final _id_containsValue = JMap._class.instanceMethodId( + r'containsValue', + r'(Ljava/lang/Object;)Z', + ); + + static final _containsValue = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsValue(java.lang.Object object)` + core$_.bool containsValue( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _containsValue( + reference.pointer, _id_containsValue.pointer, _$object.pointer) + .boolean; + } + + static final _id_entrySet = JMap._class.instanceMethodId( + r'entrySet', + r'()Ljava/util/Set;', + ); + + static final _entrySet = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.Set> entrySet()` + /// The returned object must be released after use, by calling the [release] method. + JSet?>? entrySet() { + return _entrySet(reference.pointer, _id_entrySet.pointer) + .object?>?>(); + } + + static final _id_equals = JMap._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_forEach = JMap._class.instanceMethodId( + r'forEach', + r'(Ljava/util/function/BiConsumer;)V', + ); + + static final _forEach = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void forEach(java.util.function.BiConsumer biConsumer)` + void forEach( + jni$_.JObject? biConsumer, + ) { + final _$biConsumer = biConsumer?.reference ?? jni$_.jNullReference; + _forEach(reference.pointer, _id_forEach.pointer, _$biConsumer.pointer) + .check(); + } + + static final _id_get = JMap._class.instanceMethodId( + r'get', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _get = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract V get(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + $V? get( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _get(reference.pointer, _id_get.pointer, _$object.pointer) + .object<$V?>(); + } + + static final _id_getOrDefault = JMap._class.instanceMethodId( + r'getOrDefault', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _getOrDefault = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V getOrDefault(java.lang.Object object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? getOrDefault( + jni$_.JObject? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _getOrDefault(reference.pointer, _id_getOrDefault.pointer, + _$object.pointer, _$object1.pointer) + .object<$V?>(); + } + + static final _id_hashCode$1 = JMap._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_isEmpty = JMap._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_keySet = JMap._class.instanceMethodId( + r'keySet', + r'()Ljava/util/Set;', + ); + + static final _keySet = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.Set keySet()` + /// The returned object must be released after use, by calling the [release] method. + JSet<$K?>? keySet() { + return _keySet(reference.pointer, _id_keySet.pointer).object?>(); + } + + static final _id_merge = JMap._class.instanceMethodId( + r'merge', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', + ); + + static final _merge = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V merge(K object, V object1, java.util.function.BiFunction biFunction)` + /// The returned object must be released after use, by calling the [release] method. + $V? merge( + $K? object, + $V? object1, + jni$_.JObject? biFunction, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + return _merge(reference.pointer, _id_merge.pointer, _$object.pointer, + _$object1.pointer, _$biFunction.pointer) + .object<$V?>(); + } + + static final _id_put = JMap._class.instanceMethodId( + r'put', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _put = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public abstract V put(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? put( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _put(reference.pointer, _id_put.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); + } + + static final _id_putAll = JMap._class.instanceMethodId( + r'putAll', + r'(Ljava/util/Map;)V', + ); + + static final _putAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract void putAll(java.util.Map map)` + void putAll( + JMap<$K?, $V?>? map, + ) { + final _$map = map?.reference ?? jni$_.jNullReference; + _putAll(reference.pointer, _id_putAll.pointer, _$map.pointer).check(); + } + + static final _id_putIfAbsent = JMap._class.instanceMethodId( + r'putIfAbsent', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _putIfAbsent = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V putIfAbsent(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? putIfAbsent( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _putIfAbsent(reference.pointer, _id_putIfAbsent.pointer, + _$object.pointer, _$object1.pointer) + .object<$V?>(); + } + + static final _id_remove = JMap._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract V remove(java.lang.Object object)` + /// The returned object must be released after use, by calling the [release] method. + $V? remove( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove(reference.pointer, _id_remove.pointer, _$object.pointer) + .object<$V?>(); + } + + static final _id_remove$1 = JMap._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;Ljava/lang/Object;)Z', + ); + + static final _remove$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public boolean remove(java.lang.Object object, java.lang.Object object1)` + core$_.bool remove$1( + jni$_.JObject? object, + jni$_.JObject? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _remove$1(reference.pointer, _id_remove$1.pointer, _$object.pointer, + _$object1.pointer) + .boolean; + } + + static final _id_replace = JMap._class.instanceMethodId( + r'replace', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', + ); + + static final _replace = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public V replace(K object, V object1)` + /// The returned object must be released after use, by calling the [release] method. + $V? replace( + $K? object, + $V? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _replace(reference.pointer, _id_replace.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); + } + + static final _id_replace$1 = JMap._class.instanceMethodId( + r'replace', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z', + ); + + static final _replace$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `public boolean replace(K object, V object1, V object2)` + core$_.bool replace$1( + $K? object, + $V? object1, + $V? object2, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + return _replace$1(reference.pointer, _id_replace$1.pointer, + _$object.pointer, _$object1.pointer, _$object2.pointer) + .boolean; + } + + static final _id_replaceAll = JMap._class.instanceMethodId( + r'replaceAll', + r'(Ljava/util/function/BiFunction;)V', + ); + + static final _replaceAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void replaceAll(java.util.function.BiFunction biFunction)` + void replaceAll( + jni$_.JObject? biFunction, + ) { + final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; + _replaceAll(reference.pointer, _id_replaceAll.pointer, _$biFunction.pointer) + .check(); + } + + static final _id_size = JMap._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_values = JMap._class.instanceMethodId( + r'values', + r'()Ljava/util/Collection;', + ); + + static final _values = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.Collection values()` + /// The returned object must be released after use, by calling the [release] method. + JCollection<$V?>? values() { + return _values(reference.pointer, _id_values.pointer) + .object?>(); + } +} + +abstract base mixin class $JMap<$K extends jni$_.JObject?, + $V extends jni$_.JObject?> { + factory $JMap({ + required void Function() clear, + core$_.bool clear$async, + required $V? Function($K? object, jni$_.JObject? biFunction) compute, + required $V? Function($K? object, jni$_.JObject? function) computeIfAbsent, + required $V? Function($K? object, jni$_.JObject? biFunction) + computeIfPresent, + required core$_.bool Function(jni$_.JObject? object) containsKey, + required core$_.bool Function(jni$_.JObject? object) containsValue, + required JMap? Function( + JMap? map) + copyOf, + required JMap$JEntry? Function( + jni$_.JObject? object, jni$_.JObject? object1) + entry, + required JSet?>? Function() + entrySet, + required core$_.bool Function(jni$_.JObject? object) equals, + required void Function(jni$_.JObject? biConsumer) forEach, + core$_.bool forEach$async, + required jni$_.JObject? Function(jni$_.JObject? object) get, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + getOrDefault, + required int Function() hashCode$1, + required core$_.bool Function() isEmpty, + required JSet? Function() keySet, + required jni$_.JObject? Function(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? biFunction) + merge, + required JMap? Function() of, + required JMap? Function( + jni$_.JObject? object, jni$_.JObject? object1) + of$1, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) + of$2, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) + of$3, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) + of$4, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) + of$5, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11) + of$6, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13) + of$7, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15) + of$8, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17) + of$9, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17, + jni$_.JObject? object18, + jni$_.JObject? object19) + of$10, + required JMap? Function( + jni$_.JArray?>? entrys) + ofEntries, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + put, + required void Function(JMap? map) putAll, + core$_.bool putAll$async, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + putIfAbsent, + required jni$_.JObject? Function(jni$_.JObject? object) remove, + required core$_.bool Function(jni$_.JObject? object, jni$_.JObject? object1) + remove$1, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + replace, + required core$_.bool Function(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2) + replace$1, + required void Function(jni$_.JObject? biFunction) replaceAll, + core$_.bool replaceAll$async, + required int Function() size, + required JCollection? Function() values, + }) = _$JMap<$K, $V>; + + void clear(); + core$_.bool get clear$async => false; + $V? compute($K? object, jni$_.JObject? biFunction); + $V? computeIfAbsent($K? object, jni$_.JObject? function); + $V? computeIfPresent($K? object, jni$_.JObject? biFunction); + core$_.bool containsKey(jni$_.JObject? object); + core$_.bool containsValue(jni$_.JObject? object); + JMap? copyOf( + JMap? map); + JMap$JEntry? entry( + jni$_.JObject? object, jni$_.JObject? object1); + JSet?>? entrySet(); + core$_.bool equals(jni$_.JObject? object); + void forEach(jni$_.JObject? biConsumer); + core$_.bool get forEach$async => false; + jni$_.JObject? get(jni$_.JObject? object); + jni$_.JObject? getOrDefault(jni$_.JObject? object, jni$_.JObject? object1); + int hashCode$1(); + core$_.bool isEmpty(); + JSet? keySet(); + jni$_.JObject? merge( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? biFunction); + JMap? of(); + JMap? of$1( + jni$_.JObject? object, jni$_.JObject? object1); + JMap? of$2(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? object2, jni$_.JObject? object3); + JMap? of$3( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5); + JMap? of$4( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7); + JMap? of$5( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9); + JMap? of$6( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11); + JMap? of$7( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13); + JMap? of$8( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15); + JMap? of$9( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17); + JMap? of$10( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17, + jni$_.JObject? object18, + jni$_.JObject? object19); + JMap? ofEntries( + jni$_.JArray?>? entrys); + jni$_.JObject? put(jni$_.JObject? object, jni$_.JObject? object1); + void putAll(JMap? map); + core$_.bool get putAll$async => false; + jni$_.JObject? putIfAbsent(jni$_.JObject? object, jni$_.JObject? object1); + jni$_.JObject? remove(jni$_.JObject? object); + core$_.bool remove$1(jni$_.JObject? object, jni$_.JObject? object1); + jni$_.JObject? replace(jni$_.JObject? object, jni$_.JObject? object1); + core$_.bool replace$1( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2); + void replaceAll(jni$_.JObject? biFunction); + core$_.bool get replaceAll$async => false; + int size(); + JCollection? values(); +} + +final class _$JMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> + with $JMap<$K, $V> { + _$JMap({ + required void Function() clear, + this.clear$async = false, + required $V? Function($K? object, jni$_.JObject? biFunction) compute, + required $V? Function($K? object, jni$_.JObject? function) computeIfAbsent, + required $V? Function($K? object, jni$_.JObject? biFunction) + computeIfPresent, + required core$_.bool Function(jni$_.JObject? object) containsKey, + required core$_.bool Function(jni$_.JObject? object) containsValue, + required JMap? Function( + JMap? map) + copyOf, + required JMap$JEntry? Function( + jni$_.JObject? object, jni$_.JObject? object1) + entry, + required JSet?>? Function() + entrySet, + required core$_.bool Function(jni$_.JObject? object) equals, + required void Function(jni$_.JObject? biConsumer) forEach, + this.forEach$async = false, + required jni$_.JObject? Function(jni$_.JObject? object) get, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + getOrDefault, + required int Function() hashCode$1, + required core$_.bool Function() isEmpty, + required JSet? Function() keySet, + required jni$_.JObject? Function(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? biFunction) + merge, + required JMap? Function() of, + required JMap? Function( + jni$_.JObject? object, jni$_.JObject? object1) + of$1, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) + of$2, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) + of$3, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) + of$4, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) + of$5, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11) + of$6, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13) + of$7, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15) + of$8, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17) + of$9, + required JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17, + jni$_.JObject? object18, + jni$_.JObject? object19) + of$10, + required JMap? Function( + jni$_.JArray?>? entrys) + ofEntries, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + put, + required void Function(JMap? map) putAll, + this.putAll$async = false, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + putIfAbsent, + required jni$_.JObject? Function(jni$_.JObject? object) remove, + required core$_.bool Function(jni$_.JObject? object, jni$_.JObject? object1) + remove$1, + required jni$_.JObject? Function( + jni$_.JObject? object, jni$_.JObject? object1) + replace, + required core$_.bool Function(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2) + replace$1, + required void Function(jni$_.JObject? biFunction) replaceAll, + this.replaceAll$async = false, + required int Function() size, + required JCollection? Function() values, + }) : _clear = clear, + _compute = compute, + _computeIfAbsent = computeIfAbsent, + _computeIfPresent = computeIfPresent, + _containsKey = containsKey, + _containsValue = containsValue, + _copyOf = copyOf, + _entry = entry, + _entrySet = entrySet, + _equals = equals, + _forEach = forEach, + _get = get, + _getOrDefault = getOrDefault, + _hashCode$1 = hashCode$1, + _isEmpty = isEmpty, + _keySet = keySet, + _merge = merge, + _of = of, + _of$1 = of$1, + _of$2 = of$2, + _of$3 = of$3, + _of$4 = of$4, + _of$5 = of$5, + _of$6 = of$6, + _of$7 = of$7, + _of$8 = of$8, + _of$9 = of$9, + _of$10 = of$10, + _ofEntries = ofEntries, + _put = put, + _putAll = putAll, + _putIfAbsent = putIfAbsent, + _remove = remove, + _remove$1 = remove$1, + _replace = replace, + _replace$1 = replace$1, + _replaceAll = replaceAll, + _size = size, + _values = values; + + final void Function() _clear; + final core$_.bool clear$async; + final $V? Function($K? object, jni$_.JObject? biFunction) _compute; + final $V? Function($K? object, jni$_.JObject? function) _computeIfAbsent; + final $V? Function($K? object, jni$_.JObject? biFunction) _computeIfPresent; + final core$_.bool Function(jni$_.JObject? object) _containsKey; + final core$_.bool Function(jni$_.JObject? object) _containsValue; + final JMap? Function( + JMap? map) _copyOf; + final JMap$JEntry? Function( + jni$_.JObject? object, jni$_.JObject? object1) _entry; + final JSet?>? Function() + _entrySet; + final core$_.bool Function(jni$_.JObject? object) _equals; + final void Function(jni$_.JObject? biConsumer) _forEach; + final core$_.bool forEach$async; + final jni$_.JObject? Function(jni$_.JObject? object) _get; + final jni$_.JObject? Function(jni$_.JObject? object, jni$_.JObject? object1) + _getOrDefault; + final int Function() _hashCode$1; + final core$_.bool Function() _isEmpty; + final JSet? Function() _keySet; + final jni$_.JObject? Function(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? biFunction) _merge; + final JMap? Function() _of; + final JMap? Function( + jni$_.JObject? object, jni$_.JObject? object1) _of$1; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) _of$2; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) _of$3; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) _of$4; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) _of$5; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11) _of$6; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13) _of$7; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15) _of$8; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17) _of$9; + final JMap? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17, + jni$_.JObject? object18, + jni$_.JObject? object19) _of$10; + final JMap? Function( + jni$_.JArray?>? entrys) + _ofEntries; + final jni$_.JObject? Function(jni$_.JObject? object, jni$_.JObject? object1) + _put; + final void Function(JMap? map) _putAll; + final core$_.bool putAll$async; + final jni$_.JObject? Function(jni$_.JObject? object, jni$_.JObject? object1) + _putIfAbsent; + final jni$_.JObject? Function(jni$_.JObject? object) _remove; + final core$_.bool Function(jni$_.JObject? object, jni$_.JObject? object1) + _remove$1; + final jni$_.JObject? Function(jni$_.JObject? object, jni$_.JObject? object1) + _replace; + final core$_.bool Function( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2) + _replace$1; + final void Function(jni$_.JObject? biFunction) _replaceAll; + final core$_.bool replaceAll$async; + final int Function() _size; + final JCollection? Function() _values; + + void clear() { + return _clear(); + } + + $V? compute($K? object, jni$_.JObject? biFunction) { + return _compute(object, biFunction); + } + + $V? computeIfAbsent($K? object, jni$_.JObject? function) { + return _computeIfAbsent(object, function); + } + + $V? computeIfPresent($K? object, jni$_.JObject? biFunction) { + return _computeIfPresent(object, biFunction); + } + + core$_.bool containsKey(jni$_.JObject? object) { + return _containsKey(object); + } + + core$_.bool containsValue(jni$_.JObject? object) { + return _containsValue(object); + } + + JMap? copyOf( + JMap? map) { + return _copyOf(map); + } + + JMap$JEntry? entry( + jni$_.JObject? object, jni$_.JObject? object1) { + return _entry(object, object1); + } + + JSet?>? entrySet() { + return _entrySet(); + } + + core$_.bool equals(jni$_.JObject? object) { + return _equals(object); + } + + void forEach(jni$_.JObject? biConsumer) { + return _forEach(biConsumer); + } + + jni$_.JObject? get(jni$_.JObject? object) { + return _get(object); + } + + jni$_.JObject? getOrDefault(jni$_.JObject? object, jni$_.JObject? object1) { + return _getOrDefault(object, object1); + } + + int hashCode$1() { + return _hashCode$1(); + } + + core$_.bool isEmpty() { + return _isEmpty(); + } + + JSet? keySet() { + return _keySet(); + } + + jni$_.JObject? merge(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? biFunction) { + return _merge(object, object1, biFunction); + } + + JMap? of() { + return _of(); + } + + JMap? of$1( + jni$_.JObject? object, jni$_.JObject? object1) { + return _of$1(object, object1); + } + + JMap? of$2(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? object2, jni$_.JObject? object3) { + return _of$2(object, object1, object2, object3); + } + + JMap? of$3( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) { + return _of$3(object, object1, object2, object3, object4, object5); + } + + JMap? of$4( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) { + return _of$4( + object, object1, object2, object3, object4, object5, object6, object7); + } + + JMap? of$5( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) { + return _of$5(object, object1, object2, object3, object4, object5, object6, + object7, object8, object9); + } + + JMap? of$6( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11) { + return _of$6(object, object1, object2, object3, object4, object5, object6, + object7, object8, object9, object10, object11); + } + + JMap? of$7( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13) { + return _of$7(object, object1, object2, object3, object4, object5, object6, + object7, object8, object9, object10, object11, object12, object13); + } + + JMap? of$8( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15) { + return _of$8( + object, + object1, + object2, + object3, + object4, + object5, + object6, + object7, + object8, + object9, + object10, + object11, + object12, + object13, + object14, + object15); + } + + JMap? of$9( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17) { + return _of$9( + object, + object1, + object2, + object3, + object4, + object5, + object6, + object7, + object8, + object9, + object10, + object11, + object12, + object13, + object14, + object15, + object16, + object17); + } + + JMap? of$10( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9, + jni$_.JObject? object10, + jni$_.JObject? object11, + jni$_.JObject? object12, + jni$_.JObject? object13, + jni$_.JObject? object14, + jni$_.JObject? object15, + jni$_.JObject? object16, + jni$_.JObject? object17, + jni$_.JObject? object18, + jni$_.JObject? object19) { + return _of$10( + object, + object1, + object2, + object3, + object4, + object5, + object6, + object7, + object8, + object9, + object10, + object11, + object12, + object13, + object14, + object15, + object16, + object17, + object18, + object19); + } + + JMap? ofEntries( + jni$_.JArray?>? entrys) { + return _ofEntries(entrys); + } + + jni$_.JObject? put(jni$_.JObject? object, jni$_.JObject? object1) { + return _put(object, object1); + } + + void putAll(JMap? map) { + return _putAll(map); + } + + jni$_.JObject? putIfAbsent(jni$_.JObject? object, jni$_.JObject? object1) { + return _putIfAbsent(object, object1); + } + + jni$_.JObject? remove(jni$_.JObject? object) { + return _remove(object); + } + + core$_.bool remove$1(jni$_.JObject? object, jni$_.JObject? object1) { + return _remove$1(object, object1); + } + + jni$_.JObject? replace(jni$_.JObject? object, jni$_.JObject? object1) { + return _replace(object, object1); + } + + core$_.bool replace$1( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2) { + return _replace$1(object, object1, object2); + } + + void replaceAll(jni$_.JObject? biFunction) { + return _replaceAll(biFunction); + } + + int size() { + return _size(); + } + + JCollection? values() { + return _values(); + } +} + +final class $JMap$Type$ extends jni$_.JType { + @jni$_.internal + const $JMap$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/Map;'; +} + +/// from: `java.util.Set` +extension type JSet<$E extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject, JCollection<$E?> { + static final _class = jni$_.JClass.forName(r'java/util/Set'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $JSet$Type$(); + static final _id_copyOf = _class.staticMethodId( + r'copyOf', + r'(Ljava/util/Collection;)Ljava/util/Set;', + ); + + static final _copyOf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Set copyOf(java.util.Collection collection)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? copyOf<$E extends jni$_.JObject?>( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _copyOf( + _class.reference.pointer, _id_copyOf.pointer, _$collection.pointer) + .object?>(); + } + + static final _id_of = _class.staticMethodId( + r'of', + r'()Ljava/util/Set;', + ); + + static final _of = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public java.util.Set of()` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of<$E extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer).object?>(); + } + + static final _id_of$1 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$1<$E extends jni$_.JObject?>( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer) + .object?>(); + } + + static final _id_of$2 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$2<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); + } + + static final _id_of$3 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$3 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$3<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + return _of$3(_class.reference.pointer, _id_of$3.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer) + .object?>(); + } + + static final _id_of$4 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$4<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + return _of$4(_class.reference.pointer, _id_of$4.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer, _$object3.pointer) + .object?>(); + } + + static final _id_of$5 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$5 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$5<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + return _of$5( + _class.reference.pointer, + _id_of$5.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer) + .object?>(); + } + + static final _id_of$6 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$6 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$6<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + return _of$6( + _class.reference.pointer, + _id_of$6.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer) + .object?>(); + } + + static final _id_of$7 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$7 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$7<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + return _of$7( + _class.reference.pointer, + _id_of$7.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer) + .object?>(); + } + + static final _id_of$8 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$8 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$8<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + return _of$8( + _class.reference.pointer, + _id_of$8.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer) + .object?>(); + } + + static final _id_of$9 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$9 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$9<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + return _of$9( + _class.reference.pointer, + _id_of$9.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer) + .object?>(); + } + + static final _id_of$10 = _class.staticMethodId( + r'of', + r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$10 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E object, E object1, E object2, E object3, E object4, E object5, E object6, E object7, E object8, E object9)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$10<$E extends jni$_.JObject?>( + $E? object, + $E? object1, + $E? object2, + $E? object3, + $E? object4, + $E? object5, + $E? object6, + $E? object7, + $E? object8, + $E? object9, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + final _$object2 = object2?.reference ?? jni$_.jNullReference; + final _$object3 = object3?.reference ?? jni$_.jNullReference; + final _$object4 = object4?.reference ?? jni$_.jNullReference; + final _$object5 = object5?.reference ?? jni$_.jNullReference; + final _$object6 = object6?.reference ?? jni$_.jNullReference; + final _$object7 = object7?.reference ?? jni$_.jNullReference; + final _$object8 = object8?.reference ?? jni$_.jNullReference; + final _$object9 = object9?.reference ?? jni$_.jNullReference; + return _of$10( + _class.reference.pointer, + _id_of$10.pointer, + _$object.pointer, + _$object1.pointer, + _$object2.pointer, + _$object3.pointer, + _$object4.pointer, + _$object5.pointer, + _$object6.pointer, + _$object7.pointer, + _$object8.pointer, + _$object9.pointer) + .object?>(); + } + + static final _id_of$11 = _class.staticMethodId( + r'of', + r'([Ljava/lang/Object;)Ljava/util/Set;', + ); + + static final _of$11 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public java.util.Set of(E[] objects)` + /// The returned object must be released after use, by calling the [release] method. + static JSet<$E?>? of$11<$E extends jni$_.JObject?>( + jni$_.JArray<$E?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _of$11( + _class.reference.pointer, _id_of$11.pointer, _$objects.pointer) + .object?>(); + } + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'add(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.add( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'addAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.addAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'clear()V') { + _$impls[$p]!.clear(); + return jni$_.nullptr; + } + if ($d == r'contains(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.contains( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'containsAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.containsAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'copyOf(Ljava/util/Collection;)Ljava/util/Set;') { + final $r = _$impls[$p]!.copyOf( + ($a![0] as JCollection?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'equals(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.equals( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'hashCode()I') { + final $r = _$impls[$p]!.hashCode$1(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'isEmpty()Z') { + final $r = _$impls[$p]!.isEmpty(); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'iterator()Ljava/util/Iterator;') { + final $r = _$impls[$p]!.iterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of()Ljava/util/Set;') { + final $r = _$impls[$p]!.of(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of(Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$1( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$2( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$3( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$4( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$5( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$6( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$7( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$8( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$9( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$10( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ($a![2] as jni$_.JObject?), + ($a![3] as jni$_.JObject?), + ($a![4] as jni$_.JObject?), + ($a![5] as jni$_.JObject?), + ($a![6] as jni$_.JObject?), + ($a![7] as jni$_.JObject?), + ($a![8] as jni$_.JObject?), + ($a![9] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'of([Ljava/lang/Object;)Ljava/util/Set;') { + final $r = _$impls[$p]!.of$11( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'remove(Ljava/lang/Object;)Z') { + final $r = _$impls[$p]!.remove( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'removeAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.removeAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'retainAll(Ljava/util/Collection;)Z') { + final $r = _$impls[$p]!.retainAll( + ($a![0] as JCollection?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'size()I') { + final $r = _$impls[$p]!.size(); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'spliterator()Ljava/util/Spliterator;') { + final $r = _$impls[$p]!.spliterator(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'toArray()[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'toArray([Ljava/lang/Object;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray$1( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'parallelStream()Ljava/util/stream/Stream;') { + final $r = _$impls[$p]!.parallelStream(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'removeIf(Ljava/util/function/Predicate;)Z') { + final $r = _$impls[$p]!.removeIf( + ($a![0] as jni$_.JObject?), + ); + return jni$_.JBoolean($r).reference.toPointer(); + } + if ($d == r'stream()Ljava/util/stream/Stream;') { + final $r = _$impls[$p]!.stream(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'toArray(Ljava/util/function/IntFunction;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.toArray$2( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$E extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $JSet<$E> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'java.util.Set', + $p, + _$invokePointer, + [ + if ($impl.clear$async) r'clear()V', + ], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory JSet.implement( + $JSet<$E> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension JSet$$Methods<$E extends jni$_.JObject?> on JSet<$E> { + static final _id_add = JSet._class.instanceMethodId( + r'add', + r'(Ljava/lang/Object;)Z', + ); + + static final _add = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean add(E object)` + core$_.bool add( + $E? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _add(reference.pointer, _id_add.pointer, _$object.pointer).boolean; + } + + static final _id_addAll = JSet._class.instanceMethodId( + r'addAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _addAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean addAll(java.util.Collection collection)` + core$_.bool addAll( + JCollection<$E?>? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _addAll(reference.pointer, _id_addAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_clear = JSet._class.instanceMethodId( + r'clear', + r'()V', + ); + + static final _clear = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void clear()` + void clear() { + _clear(reference.pointer, _id_clear.pointer).check(); + } + + static final _id_contains = JSet._class.instanceMethodId( + r'contains', + r'(Ljava/lang/Object;)Z', + ); + + static final _contains = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean contains(java.lang.Object object)` + core$_.bool contains( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _contains(reference.pointer, _id_contains.pointer, _$object.pointer) + .boolean; + } + + static final _id_containsAll = JSet._class.instanceMethodId( + r'containsAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _containsAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean containsAll(java.util.Collection collection)` + core$_.bool containsAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _containsAll( + reference.pointer, _id_containsAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_equals = JSet._class.instanceMethodId( + r'equals', + r'(Ljava/lang/Object;)Z', + ); + + static final _equals = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean equals(java.lang.Object object)` + core$_.bool equals( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) + .boolean; + } + + static final _id_hashCode$1 = JSet._class.instanceMethodId( + r'hashCode', + r'()I', + ); + + static final _hashCode$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int hashCode()` + int hashCode$1() { + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; + } + + static final _id_isEmpty = JSet._class.instanceMethodId( + r'isEmpty', + r'()Z', + ); + + static final _isEmpty = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract boolean isEmpty()` + core$_.bool isEmpty() { + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; + } + + static final _id_iterator = JSet._class.instanceMethodId( + r'iterator', + r'()Ljava/util/Iterator;', + ); + + static final _iterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.util.Iterator iterator()` + /// The returned object must be released after use, by calling the [release] method. + JIterator<$E?>? iterator() { + return _iterator(reference.pointer, _id_iterator.pointer) + .object?>(); + } + + static final _id_remove = JSet._class.instanceMethodId( + r'remove', + r'(Ljava/lang/Object;)Z', + ); + + static final _remove = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean remove(java.lang.Object object)` + core$_.bool remove( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _remove(reference.pointer, _id_remove.pointer, _$object.pointer) + .boolean; + } + + static final _id_removeAll = JSet._class.instanceMethodId( + r'removeAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _removeAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean removeAll(java.util.Collection collection)` + core$_.bool removeAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _removeAll( + reference.pointer, _id_removeAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_retainAll = JSet._class.instanceMethodId( + r'retainAll', + r'(Ljava/util/Collection;)Z', + ); + + static final _retainAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract boolean retainAll(java.util.Collection collection)` + core$_.bool retainAll( + JCollection? collection, + ) { + final _$collection = collection?.reference ?? jni$_.jNullReference; + return _retainAll( + reference.pointer, _id_retainAll.pointer, _$collection.pointer) + .boolean; + } + + static final _id_size = JSet._class.instanceMethodId( + r'size', + r'()I', + ); + + static final _size = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract int size()` + int size() { + return _size(reference.pointer, _id_size.pointer).integer; + } + + static final _id_spliterator = JSet._class.instanceMethodId( + r'spliterator', + r'()Ljava/util/Spliterator;', + ); + + static final _spliterator = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.Spliterator spliterator()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? spliterator() { + return _spliterator(reference.pointer, _id_spliterator.pointer) + .object(); + } + + static final _id_toArray = JSet._class.instanceMethodId( + r'toArray', + r'()[Ljava/lang/Object;', + ); + + static final _toArray = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.lang.Object[] toArray()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray? toArray() { + return _toArray(reference.pointer, _id_toArray.pointer) + .object?>(); + } + + static final _id_toArray$1 = JSet._class.instanceMethodId( + r'toArray', + r'([Ljava/lang/Object;)[Ljava/lang/Object;', + ); + + static final _toArray$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract T[] toArray(T[] objects)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$1<$T extends jni$_.JObject?>( + jni$_.JArray<$T?>? objects, + ) { + final _$objects = objects?.reference ?? jni$_.jNullReference; + return _toArray$1( + reference.pointer, _id_toArray$1.pointer, _$objects.pointer) + .object?>(); + } + + static final _id_parallelStream = JSet._class.instanceMethodId( + r'parallelStream', + r'()Ljava/util/stream/Stream;', + ); + + static final _parallelStream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream parallelStream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? parallelStream() { + return _parallelStream(reference.pointer, _id_parallelStream.pointer) + .object(); + } + + static final _id_removeIf = JSet._class.instanceMethodId( + r'removeIf', + r'(Ljava/util/function/Predicate;)Z', + ); + + static final _removeIf = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public boolean removeIf(java.util.function.Predicate predicate)` + core$_.bool removeIf( + jni$_.JObject? predicate, + ) { + final _$predicate = predicate?.reference ?? jni$_.jNullReference; + return _removeIf( + reference.pointer, _id_removeIf.pointer, _$predicate.pointer) + .boolean; + } + + static final _id_stream = JSet._class.instanceMethodId( + r'stream', + r'()Ljava/util/stream/Stream;', + ); + + static final _stream = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.util.stream.Stream stream()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? stream() { + return _stream(reference.pointer, _id_stream.pointer) + .object(); + } + + static final _id_toArray$2 = JSet._class.instanceMethodId( + r'toArray', + r'(Ljava/util/function/IntFunction;)[Ljava/lang/Object;', + ); + + static final _toArray$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T[] toArray(java.util.function.IntFunction intFunction)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray<$T?>? toArray$2<$T extends jni$_.JObject?>( + jni$_.JObject? intFunction, + ) { + final _$intFunction = intFunction?.reference ?? jni$_.jNullReference; + return _toArray$2( + reference.pointer, _id_toArray$2.pointer, _$intFunction.pointer) + .object?>(); + } +} + +abstract base mixin class $JSet<$E extends jni$_.JObject?> { + factory $JSet({ + required core$_.bool Function($E? object) add, + required core$_.bool Function(JCollection? collection) + addAll, + required void Function() clear, + core$_.bool clear$async, + required core$_.bool Function(jni$_.JObject? object) contains, + required core$_.bool Function(JCollection? collection) + containsAll, + required JSet? Function( + JCollection? collection) + copyOf, + required core$_.bool Function(jni$_.JObject? object) equals, + required int Function() hashCode$1, + required core$_.bool Function() isEmpty, + required JIterator? Function() iterator, + required JSet? Function() of, + required JSet? Function(jni$_.JObject? object) of$1, + required JSet? Function( + jni$_.JObject? object, jni$_.JObject? object1) + of$2, + required JSet? Function(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? object2) + of$3, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) + of$4, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4) + of$5, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) + of$6, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) + of$7, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) + of$8, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) + of$9, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) + of$10, + required JSet? Function( + jni$_.JArray? objects) + of$11, + required core$_.bool Function(jni$_.JObject? object) remove, + required core$_.bool Function(JCollection? collection) + removeAll, + required core$_.bool Function(JCollection? collection) + retainAll, + required int Function() size, + required jni$_.JObject? Function() spliterator, + required jni$_.JArray? Function() toArray, + required jni$_.JArray? Function( + jni$_.JArray? objects) + toArray$1, + required jni$_.JObject? Function() parallelStream, + required core$_.bool Function(jni$_.JObject? predicate) removeIf, + required jni$_.JObject? Function() stream, + required jni$_.JArray? Function(jni$_.JObject? intFunction) + toArray$2, + }) = _$JSet<$E>; + + core$_.bool add($E? object); + core$_.bool addAll(JCollection? collection); + void clear(); + core$_.bool get clear$async => false; + core$_.bool contains(jni$_.JObject? object); + core$_.bool containsAll(JCollection? collection); + JSet? copyOf(JCollection? collection); + core$_.bool equals(jni$_.JObject? object); + int hashCode$1(); + core$_.bool isEmpty(); + JIterator? iterator(); + JSet? of(); + JSet? of$1(jni$_.JObject? object); + JSet? of$2(jni$_.JObject? object, jni$_.JObject? object1); + JSet? of$3( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2); + JSet? of$4(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3); + JSet? of$5(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3, jni$_.JObject? object4); + JSet? of$6( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5); + JSet? of$7( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6); + JSet? of$8( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7); + JSet? of$9( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8); + JSet? of$10( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9); + JSet? of$11(jni$_.JArray? objects); + core$_.bool remove(jni$_.JObject? object); + core$_.bool removeAll(JCollection? collection); + core$_.bool retainAll(JCollection? collection); + int size(); + jni$_.JObject? spliterator(); + jni$_.JArray? toArray(); + jni$_.JArray? toArray$1( + jni$_.JArray? objects); + jni$_.JObject? parallelStream(); + core$_.bool removeIf(jni$_.JObject? predicate); + jni$_.JObject? stream(); + jni$_.JArray? toArray$2(jni$_.JObject? intFunction); +} + +final class _$JSet<$E extends jni$_.JObject?> with $JSet<$E> { + _$JSet({ + required core$_.bool Function($E? object) add, + required core$_.bool Function(JCollection? collection) + addAll, + required void Function() clear, + this.clear$async = false, + required core$_.bool Function(jni$_.JObject? object) contains, + required core$_.bool Function(JCollection? collection) + containsAll, + required JSet? Function( + JCollection? collection) + copyOf, + required core$_.bool Function(jni$_.JObject? object) equals, + required int Function() hashCode$1, + required core$_.bool Function() isEmpty, + required JIterator? Function() iterator, + required JSet? Function() of, + required JSet? Function(jni$_.JObject? object) of$1, + required JSet? Function( + jni$_.JObject? object, jni$_.JObject? object1) + of$2, + required JSet? Function(jni$_.JObject? object, + jni$_.JObject? object1, jni$_.JObject? object2) + of$3, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) + of$4, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4) + of$5, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) + of$6, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) + of$7, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) + of$8, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) + of$9, + required JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) + of$10, + required JSet? Function( + jni$_.JArray? objects) + of$11, + required core$_.bool Function(jni$_.JObject? object) remove, + required core$_.bool Function(JCollection? collection) + removeAll, + required core$_.bool Function(JCollection? collection) + retainAll, + required int Function() size, + required jni$_.JObject? Function() spliterator, + required jni$_.JArray? Function() toArray, + required jni$_.JArray? Function( + jni$_.JArray? objects) + toArray$1, + required jni$_.JObject? Function() parallelStream, + required core$_.bool Function(jni$_.JObject? predicate) removeIf, + required jni$_.JObject? Function() stream, + required jni$_.JArray? Function(jni$_.JObject? intFunction) + toArray$2, + }) : _add = add, + _addAll = addAll, + _clear = clear, + _contains = contains, + _containsAll = containsAll, + _copyOf = copyOf, + _equals = equals, + _hashCode$1 = hashCode$1, + _isEmpty = isEmpty, + _iterator = iterator, + _of = of, + _of$1 = of$1, + _of$2 = of$2, + _of$3 = of$3, + _of$4 = of$4, + _of$5 = of$5, + _of$6 = of$6, + _of$7 = of$7, + _of$8 = of$8, + _of$9 = of$9, + _of$10 = of$10, + _of$11 = of$11, + _remove = remove, + _removeAll = removeAll, + _retainAll = retainAll, + _size = size, + _spliterator = spliterator, + _toArray = toArray, + _toArray$1 = toArray$1, + _parallelStream = parallelStream, + _removeIf = removeIf, + _stream = stream, + _toArray$2 = toArray$2; + + final core$_.bool Function($E? object) _add; + final core$_.bool Function(JCollection? collection) _addAll; + final void Function() _clear; + final core$_.bool clear$async; + final core$_.bool Function(jni$_.JObject? object) _contains; + final core$_.bool Function(JCollection? collection) + _containsAll; + final JSet? Function(JCollection? collection) + _copyOf; + final core$_.bool Function(jni$_.JObject? object) _equals; + final int Function() _hashCode$1; + final core$_.bool Function() _isEmpty; + final JIterator? Function() _iterator; + final JSet? Function() _of; + final JSet? Function(jni$_.JObject? object) _of$1; + final JSet? Function( + jni$_.JObject? object, jni$_.JObject? object1) _of$2; + final JSet? Function( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2) + _of$3; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3) _of$4; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4) _of$5; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) _of$6; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) _of$7; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) _of$8; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) _of$9; + final JSet? Function( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) _of$10; + final JSet? Function(jni$_.JArray? objects) + _of$11; + final core$_.bool Function(jni$_.JObject? object) _remove; + final core$_.bool Function(JCollection? collection) + _removeAll; + final core$_.bool Function(JCollection? collection) + _retainAll; + final int Function() _size; + final jni$_.JObject? Function() _spliterator; + final jni$_.JArray? Function() _toArray; + final jni$_.JArray? Function( + jni$_.JArray? objects) _toArray$1; + final jni$_.JObject? Function() _parallelStream; + final core$_.bool Function(jni$_.JObject? predicate) _removeIf; + final jni$_.JObject? Function() _stream; + final jni$_.JArray? Function(jni$_.JObject? intFunction) + _toArray$2; + + core$_.bool add($E? object) { + return _add(object); + } + + core$_.bool addAll(JCollection? collection) { + return _addAll(collection); + } + + void clear() { + return _clear(); + } + + core$_.bool contains(jni$_.JObject? object) { + return _contains(object); + } + + core$_.bool containsAll(JCollection? collection) { + return _containsAll(collection); + } + + JSet? copyOf(JCollection? collection) { + return _copyOf(collection); + } + + core$_.bool equals(jni$_.JObject? object) { + return _equals(object); + } + + int hashCode$1() { + return _hashCode$1(); + } + + core$_.bool isEmpty() { + return _isEmpty(); + } + + JIterator? iterator() { + return _iterator(); + } + + JSet? of() { + return _of(); + } + + JSet? of$1(jni$_.JObject? object) { + return _of$1(object); + } + + JSet? of$2(jni$_.JObject? object, jni$_.JObject? object1) { + return _of$2(object, object1); + } + + JSet? of$3( + jni$_.JObject? object, jni$_.JObject? object1, jni$_.JObject? object2) { + return _of$3(object, object1, object2); + } + + JSet? of$4(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3) { + return _of$4(object, object1, object2, object3); + } + + JSet? of$5(jni$_.JObject? object, jni$_.JObject? object1, + jni$_.JObject? object2, jni$_.JObject? object3, jni$_.JObject? object4) { + return _of$5(object, object1, object2, object3, object4); + } + + JSet? of$6( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5) { + return _of$6(object, object1, object2, object3, object4, object5); + } + + JSet? of$7( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6) { + return _of$7(object, object1, object2, object3, object4, object5, object6); + } + + JSet? of$8( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7) { + return _of$8( + object, object1, object2, object3, object4, object5, object6, object7); + } + + JSet? of$9( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8) { + return _of$9(object, object1, object2, object3, object4, object5, object6, + object7, object8); + } + + JSet? of$10( + jni$_.JObject? object, + jni$_.JObject? object1, + jni$_.JObject? object2, + jni$_.JObject? object3, + jni$_.JObject? object4, + jni$_.JObject? object5, + jni$_.JObject? object6, + jni$_.JObject? object7, + jni$_.JObject? object8, + jni$_.JObject? object9) { + return _of$10(object, object1, object2, object3, object4, object5, object6, + object7, object8, object9); + } + + JSet? of$11(jni$_.JArray? objects) { + return _of$11(objects); + } + + core$_.bool remove(jni$_.JObject? object) { + return _remove(object); + } + + core$_.bool removeAll(JCollection? collection) { + return _removeAll(collection); + } + + core$_.bool retainAll(JCollection? collection) { + return _retainAll(collection); + } + + int size() { + return _size(); + } + + jni$_.JObject? spliterator() { + return _spliterator(); + } + + jni$_.JArray? toArray() { + return _toArray(); + } + + jni$_.JArray? toArray$1( + jni$_.JArray? objects) { + return _toArray$1(objects); + } + + jni$_.JObject? parallelStream() { + return _parallelStream(); + } + + core$_.bool removeIf(jni$_.JObject? predicate) { + return _removeIf(predicate); + } + + jni$_.JObject? stream() { + return _stream(); + } + + jni$_.JArray? toArray$2(jni$_.JObject? intFunction) { + return _toArray$2(intFunction); + } +} + +final class $JSet$Type$ extends jni$_.JType { + @jni$_.internal + const $JSet$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Ljava/util/Set;'; +} diff --git a/pkgs/jni/lib/src/errors.dart b/pkgs/jni/lib/src/errors.dart index c48bb6fba4..1e77805313 100644 --- a/pkgs/jni/lib/src/errors.dart +++ b/pkgs/jni/lib/src/errors.dart @@ -106,21 +106,6 @@ final class NoJvmInstanceError extends Error { String toString() => 'No JNI instance is available'; } -// TODO(#567): Remove this class in favor of `JThrowable`. -class JniException implements Exception { - /// Error message from Java exception. - final String message; - - /// Stack trace from Java. - final String stackTrace; - - JniException(this.message, this.stackTrace); - - @override - String toString() => 'Exception in Java code called through JNI: ' - '$message\n\n$stackTrace\n'; -} - final class HelperNotFoundError extends Error { final String path; @@ -155,3 +140,11 @@ Please ensure ${Platform.isWindows ? r'that `\bin\server\jvm.dll` is in the PATH '''; } } + +final class JniNewStringException implements Exception { + final String string; + JniNewStringException(this.string); + + @override + String toString() => 'Failed to convert string to a JString: $string'; +} diff --git a/pkgs/jni/lib/src/jarray.dart b/pkgs/jni/lib/src/jarray.dart index f614d9b87a..520ea9cbbe 100644 --- a/pkgs/jni/lib/src/jarray.dart +++ b/pkgs/jni/lib/src/jarray.dart @@ -2,139 +2,53 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// ignore_for_file: unnecessary_cast, overridden_fields - +import 'dart:collection'; import 'dart:ffi'; import 'dart:typed_data'; +import 'package:collection/collection.dart'; import 'package:ffi/ffi.dart'; -import 'package:meta/meta.dart' show internal; import 'jni.dart'; import 'jobject.dart'; import 'jreference.dart'; -import 'third_party/generated_bindings.dart'; import 'types.dart'; -@internal -final class $JArray$NullableType$ - extends JType?> { - final JType elementType; - - const $JArray$NullableType$(this.elementType); - - @override - String get signature => '[${elementType.signature}'; - - @override - JArray? fromReference(JReference reference) => - reference.isNull ? null : JArray.fromReference(elementType, reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType?> get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => Object.hash($JArray$NullableType$, elementType); - - @override - bool operator ==(Object other) { - return other.runtimeType == ($JArray$NullableType$) && - other is $JArray$NullableType$ && - elementType == other.elementType; - } -} - -@internal -final class $JArray$Type$ extends JType> { - final JType elementType; - - const $JArray$Type$(this.elementType); - - @override - String get signature => '[${elementType.signature}'; - - @override - JArray fromReference(JReference reference) => - JArray.fromReference(elementType, reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType?> get nullableType => $JArray$NullableType$(elementType); - - @override - final int superCount = 1; +part 'primitive_jarrays.dart'; - @override - int get hashCode => Object.hash($JArray$Type$, elementType); +final class _$JArray$Type$ extends JType> { + _$JArray$Type$(JType elementType) + : signature = '[${elementType.signature}'; @override - bool operator ==(Object other) { - return other.runtimeType == ($JArray$Type$) && - other is $JArray$Type$ && - elementType == other.elementType; - } + final String signature; } -class JArray extends JObject with Iterable { - final JType elementType; - - @internal - @override - final JType> $type; - - /// The type which includes information such as the signature of this class. - static JType> type(JType innerType) => - $JArray$Type$(innerType); - +extension type JArray._(JObject _$this) implements JObject { /// The type which includes information such as the signature of this class. - static JType?> nullableType( - JType innerType) => - $JArray$NullableType$(innerType); - - /// Construct a new [JArray] with [reference] as its underlying reference. - JArray.fromReference(this.elementType, JReference reference) - : $type = type(elementType), - super.fromReference(reference); + static JType> type<$E extends JObject?>(JType<$E> innerType) => + _$JArray$Type$<$E>(innerType); /// Creates a [JArray] of the given length from the given [elementType]. /// /// The [length] must be a non-negative integer. - /// For objects, [elementType] must be a nullable type as this constructor - /// initializes all elements with `null`. - factory JArray(JType elementType, int length) { + static JArray<$E?> withLength<$E extends JObject?>( + JType<$E> elementType, int length) { RangeError.checkNotNegative(length); - if (!elementType.isNullable) { - throw ArgumentError.value( - elementType, - 'elementType', - 'Element type of JArray must be nullable when constructed with a ' - 'length (because the elements will be initialized to null).\n\n' - 'Try using .nullableType instead'); - } - return _newArray(elementType, length); + return _newArray<$E>(elementType.jClass, length); } - static JArray<$E> _newArray<$E extends JObject?>( - JType<$E> elementType, int length, + static JArray<$E> _newArray<$E extends JObject?>(JClass jClass, int length, [$E? fill]) { - final classRef = elementType.jClass.reference; + final classRef = jClass.reference; final fillRef = fill?.reference ?? jNullReference; - final array = JArray<$E>.fromReference( - elementType, + final array = JObject.fromReference( JGlobalReference(Jni.env.NewObjectArray( length, classRef.pointer, fillRef.pointer, )), - ); + ) as JArray<$E>; classRef.release(); return array; } @@ -143,39 +57,37 @@ class JArray extends JObject with Iterable { /// /// The [length] must be a non-negative integer. static JArray<$E> filled<$E extends JObject>(int length, $E fill, - {JType<$E>? E}) { + {JType<$E>? elementType}) { RangeError.checkNotNegative(length); - E ??= fill.$type as JType<$E>; - return _newArray<$E>(E, length, fill); + final jClass = elementType == null ? fill.jClass : elementType.jClass; + return _newArray<$E>(jClass, length, fill); } /// Creates a [JArray] from `elements`. static JArray<$E> of<$E extends JObject?>( JType<$E> elementType, Iterable<$E> elements) { - return _newArray<$E>(elementType, elements.length) - ..setRange(0, elements.length, elements); + final len = elements.length; + return _newArray<$E>(elementType.jClass, len)..setRange(0, len, elements); } /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); + int get length => Jni.env.GetArrayLength(reference.pointer); - @override - E elementAt(int index) { - RangeError.checkValidIndex(index, this); + E _elementAt(int index) { + RangeError.checkValueInInterval(index, 0, length - 1); final pointer = Jni.env.GetObjectArrayElement(reference.pointer, index); if (pointer == nullptr) { return null as E; } - return (elementType as JType).fromReference(JGlobalReference(pointer)); + return JObject.fromReference(JGlobalReference(pointer)) as E; } E operator [](int index) { - return elementAt(index); + return _elementAt(index); } void operator []=(int index, E value) { - RangeError.checkValidIndex(index, this); + RangeError.checkValueInInterval(index, 0, length - 1); final valueRef = value?.reference ?? jNullReference; Jni.env.SetObjectArrayElement(reference.pointer, index, valueRef.pointer); } @@ -188,42 +100,35 @@ class JArray extends JObject with Iterable { this[index] = element; } } - - @override - Iterator get iterator => _JArrayIterator(this); } -class _JArrayIterator implements Iterator { - final Iterable _iterable; - final int _length; - int _index; - E? _current; +final class _JArrayListView + with ListMixin, NonGrowableListMixin { + final JArray _jarray; - _JArrayIterator(Iterable iterable) - : _iterable = iterable, - _length = iterable.length, - _index = 0; + _JArrayListView(this._jarray); @override - E get current => _current as E; + int get length => _jarray.length; @override - @pragma('vm:prefer-inline') - bool moveNext() { - final length = _iterable.length; - if (_length != length) { - throw ConcurrentModificationError(_iterable); - } - if (_index >= length) { - _current = null; - return false; - } - _current = _iterable.elementAt(_index); - _index++; - return true; + E operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, E value) { + _jarray[index] = value; } } +extension JArrayToList on JArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JArrayListView(this); +} + void _allocate( int byteCount, void Function(Pointer ptr) use, @@ -243,1057 +148,3 @@ extension on Allocator { }; } } - -@internal -final class $JBooleanArray$NullableType$ extends JType { - const $JBooleanArray$NullableType$(); - - @override - String get signature => '[Z'; - - @override - JBooleanArray? fromReference(JReference reference) => - reference.isNull ? null : JBooleanArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JBooleanArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JBooleanArray$NullableType$ && - other is $JBooleanArray$NullableType$; - } -} - -@internal -final class $JBooleanArray$Type$ extends JType { - const $JBooleanArray$Type$(); - - @override - String get signature => '[Z'; - - @override - JBooleanArray fromReference(JReference reference) => - JBooleanArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => - const $JBooleanArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JBooleanArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JBooleanArray$Type$ && - other is $JBooleanArray$Type$; - } -} - -class JBooleanArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JBooleanArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = - $JBooleanArray$NullableType$(); - - /// Construct a new [JBooleanArray] with [reference] as its underlying - /// reference. - JBooleanArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JBooleanArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JBooleanArray(int length) { - RangeError.checkNotNegative(length); - return JBooleanArray.fromReference( - JGlobalReference(Jni.env.NewBooleanArray(length)), - ); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - bool elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetBooleanArrayElement(reference.pointer, index); - } - - bool operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, bool value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetBooleanArrayElement(reference.pointer, index, value); - } - - Uint8List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env - .GetBooleanArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable.map((e) => e ? 1 : 0), skipCount); - Jni.env.SetBooleanArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JByteArray$NullableType$ extends JType { - const $JByteArray$NullableType$(); - - @override - String get signature => '[B'; - - @override - JByteArray? fromReference(JReference reference) => - reference.isNull ? null : JByteArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JByteArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JByteArray$NullableType$ && - other is $JByteArray$NullableType$; - } -} - -@internal -final class $JByteArray$Type$ extends JType { - const $JByteArray$Type$(); - - @override - String get signature => '[B'; - - @override - JByteArray fromReference(JReference reference) => - JByteArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JByteArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JByteArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JByteArray$Type$ && other is $JByteArray$Type$; - } -} - -/// A fixed-length array of Java [`Byte`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Byte.html). -/// -/// Integers stored in the list are truncated to their low eight bits, -/// interpreted as a signed 8-bit two's complement integer with values in the -/// range -128 to +127. -/// -/// Java equivalent of [Int8List]. -class JByteArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JByteArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JByteArray$NullableType$(); - - /// Construct a new [JByteArray] with [reference] as its underlying - /// reference. - JByteArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JByteArray] containing all `elements`. - /// - /// The [Iterator] of elements provides the order of the elements. - /// - /// Elements outside of the range -128 to +127 are truncated to their low - /// eight bits and interpreted as signed 8-bit two's complement integers. - factory JByteArray.from(Iterable elements) { - return JByteArray(elements.length)..setRange(0, elements.length, elements); - } - - /// Creates a [JByteArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JByteArray(int length) { - RangeError.checkNotNegative(length); - return JByteArray.fromReference( - JGlobalReference(Jni.env.NewByteArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - int elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetByteArrayElement(reference.pointer, index); - } - - int operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, int value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetByteArrayElement(reference.pointer, index, value); - } - - Int8List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetByteArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetByteArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JCharArray$NullableType$ extends JType { - const $JCharArray$NullableType$(); - - @override - String get signature => '[C'; - - @override - JCharArray? fromReference(JReference reference) => - reference.isNull ? null : JCharArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JCharArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JCharArray$NullableType$ && - other is $JCharArray$NullableType$; - } -} - -@internal -final class $JCharArray$Type$ extends JType { - const $JCharArray$Type$(); - - @override - String get signature => '[C'; - - @override - JCharArray fromReference(JReference reference) => - JCharArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JCharArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JCharArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JCharArray$Type$ && other is $JCharArray$Type$; - } -} - -/// `JCharArray` is a 16-bit integer array. -/// -/// Due to variable length encoding, the number of code units is not equal to -/// the number of characters. -class JCharArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JCharArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JCharArray$NullableType$(); - - /// Construct a new [JCharArray] with [reference] as its underlying - /// reference. - JCharArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JCharArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JCharArray(int length) { - RangeError.checkNotNegative(length); - return JCharArray.fromReference( - JGlobalReference(Jni.env.NewCharArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - int elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetCharArrayElement(reference.pointer, index); - } - - int operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, int value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetCharArrayElement(reference.pointer, index, value); - } - - Uint16List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetCharArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetCharArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JShortArray$NullableType$ extends JType { - const $JShortArray$NullableType$(); - - @override - String get signature => '[S'; - - @override - JShortArray? fromReference(JReference reference) => - reference.isNull ? null : JShortArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JShortArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JShortArray$NullableType$ && - other is $JShortArray$NullableType$; - } -} - -@internal -final class $JShortArray$Type$ extends JType { - const $JShortArray$Type$(); - - @override - String get signature => '[S'; - - @override - JShortArray fromReference(JReference reference) => - JShortArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JShortArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JShortArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JShortArray$Type$ && - other is $JShortArray$Type$; - } -} - -class JShortArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JShortArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JShortArray$NullableType$(); - - /// Construct a new [JShortArray] with [reference] as its underlying - /// reference. - JShortArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JShortArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JShortArray(int length) { - RangeError.checkNotNegative(length); - return JShortArray.fromReference( - JGlobalReference(Jni.env.NewShortArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - int elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetShortArrayElement(reference.pointer, index); - } - - int operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, int value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetShortArrayElement(reference.pointer, index, value); - } - - Int16List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetShortArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetShortArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JIntArray$NullableType$ extends JType { - const $JIntArray$NullableType$(); - - @override - String get signature => '[I'; - - @override - JIntArray? fromReference(JReference reference) => - reference.isNull ? null : JIntArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JIntArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JIntArray$NullableType$ && - other is $JIntArray$NullableType$; - } -} - -@internal -final class $JIntArray$Type$ extends JType { - const $JIntArray$Type$(); - - @override - String get signature => '[I'; - - @override - JIntArray fromReference(JReference reference) => - JIntArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JIntArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JIntArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JIntArray$Type$ && other is $JIntArray$Type$; - } -} - -class JIntArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JIntArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JIntArray$NullableType$(); - - /// Construct a new [JIntArray] with [reference] as its underlying - /// reference. - JIntArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JIntArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JIntArray(int length) { - RangeError.checkNotNegative(length); - return JIntArray.fromReference( - JGlobalReference(Jni.env.NewIntArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - int elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetIntArrayElement(reference.pointer, index); - } - - int operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, int value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetIntArrayElement(reference.pointer, index, value); - } - - Int32List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetIntArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetIntArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JLongArray$NullableType$ extends JType { - const $JLongArray$NullableType$(); - - @override - String get signature => '[J'; - - @override - JLongArray? fromReference(JReference reference) => - reference.isNull ? null : JLongArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JLongArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JLongArray$NullableType$ && - other is $JLongArray$NullableType$; - } -} - -@internal -final class $JLongArray$Type$ extends JType { - const $JLongArray$Type$(); - - @override - String get signature => '[J'; - - @override - JLongArray fromReference(JReference reference) => - JLongArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JLongArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JLongArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JLongArray$Type$ && other is $JLongArray$Type$; - } -} - -class JLongArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JLongArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JLongArray$NullableType$(); - - /// Construct a new [JLongArray] with [reference] as its underlying - /// reference. - JLongArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JLongArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JLongArray(int length) { - RangeError.checkNotNegative(length); - return JLongArray.fromReference( - JGlobalReference(Jni.env.NewLongArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - int elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetLongArrayElement(reference.pointer, index); - } - - int operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, int value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetLongArrayElement(reference.pointer, index, value); - } - - Int64List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetLongArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetLongArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JFloatArray$NullableType$ extends JType { - const $JFloatArray$NullableType$(); - - @override - String get signature => '[F'; - - @override - JFloatArray? fromReference(JReference reference) => - reference.isNull ? null : JFloatArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JFloatArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JFloatArray$NullableType$ && - other is $JFloatArray$NullableType$; - } -} - -@internal -final class $JFloatArray$Type$ extends JType { - const $JFloatArray$Type$(); - - @override - String get signature => '[F'; - - @override - JFloatArray fromReference(JReference reference) => - JFloatArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JFloatArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JFloatArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JFloatArray$Type$ && - other is $JFloatArray$Type$; - } -} - -class JFloatArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JFloatArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JFloatArray$NullableType$(); - - /// Construct a new [JFloatArray] with [reference] as its underlying - /// reference. - JFloatArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JFloatArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JFloatArray(int length) { - RangeError.checkNotNegative(length); - return JFloatArray.fromReference( - JGlobalReference(Jni.env.NewFloatArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - double elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetFloatArrayElement(reference.pointer, index); - } - - double operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, double value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetFloatArrayElement(reference.pointer, index, value); - } - - Float32List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetFloatArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetFloatArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} - -@internal -final class $JDoubleArray$NullableType$ extends JType { - const $JDoubleArray$NullableType$(); - - @override - String get signature => '[D'; - - @override - JDoubleArray? fromReference(JReference reference) => - reference.isNull ? null : JDoubleArray.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JDoubleArray$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JDoubleArray$NullableType$ && - other is $JDoubleArray$NullableType$; - } -} - -@internal -final class $JDoubleArray$Type$ extends JType { - const $JDoubleArray$Type$(); - - @override - String get signature => '[D'; - - @override - JDoubleArray fromReference(JReference reference) => - JDoubleArray.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JDoubleArray$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JDoubleArray$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JDoubleArray$Type$ && - other is $JDoubleArray$Type$; - } -} - -class JDoubleArray extends JObject with Iterable { - @internal - @override - final JType $type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JDoubleArray$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = - $JDoubleArray$NullableType$(); - - /// Construct a new [JDoubleArray] with [reference] as its underlying - /// reference. - JDoubleArray.fromReference(super.reference) - : $type = type, - super.fromReference(); - - /// Creates a [JDoubleArray] of the given [length]. - /// - /// The [length] must be a non-negative integer. - factory JDoubleArray(int length) { - RangeError.checkNotNegative(length); - return JDoubleArray.fromReference( - JGlobalReference(Jni.env.NewDoubleArray(length))); - } - - /// The number of elements in this array. - @override - late final length = Jni.env.GetArrayLength(reference.pointer); - - @override - double elementAt(int index) { - RangeError.checkValidIndex(index, this); - return Jni.env.GetDoubleArrayElement(reference.pointer, index); - } - - double operator [](int index) { - return elementAt(index); - } - - void operator []=(int index, double value) { - RangeError.checkValidIndex(index, this); - Jni.env.SetDoubleArrayElement(reference.pointer, index, value); - } - - Float64List getRange(int start, int end, {Allocator allocator = malloc}) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - final buffer = allocator(rangeLength); - Jni.env.GetDoubleArrayRegion(reference.pointer, start, rangeLength, buffer); - return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); - } - - void setRange(int start, int end, Iterable iterable, - [int skipCount = 0]) { - RangeError.checkValidRange(start, end, length); - final rangeLength = end - start; - _allocate(sizeOf() * rangeLength, (ptr) { - ptr - .asTypedList(rangeLength) - .setRange(0, rangeLength, iterable, skipCount); - Jni.env.SetDoubleArrayRegion(reference.pointer, start, rangeLength, ptr); - }); - } - - @override - Iterator get iterator => _JArrayIterator(this); -} diff --git a/pkgs/jni/lib/src/jclass.dart b/pkgs/jni/lib/src/jclass.dart index 4807580e01..a29db97b8a 100644 --- a/pkgs/jni/lib/src/jclass.dart +++ b/pkgs/jni/lib/src/jclass.dart @@ -51,13 +51,19 @@ extension type JInstanceFieldId._fromPointer(JFieldIDPtr pointer) { DartT get(JObject object, JAccessible type) { final objectRef = object.reference; - return type._instanceGet(objectRef.pointer, this as JFieldIDPtr); + return type._instanceGet(objectRef.pointer, pointer); + } + + DartT? getNullable( + JObject object, JAccessible type) { + final objectRef = object.reference; + return type._instanceGetNullable(objectRef.pointer, pointer); } void set( JObject object, JAccessible type, DartT value) { final objectRef = object.reference; - type._instanceSet(objectRef.pointer, this as JFieldIDPtr, value); + type._instanceSet(objectRef.pointer, pointer, value); } } @@ -75,18 +81,26 @@ extension type JStaticFieldId._fromPointer(JFieldIDPtr pointer) { DartT get(JClass jClass, JAccessible type) { final jClassRef = jClass.reference; - return type._staticGet(jClassRef.pointer, this as JFieldIDPtr); + return type._staticGet(jClassRef.pointer, pointer); + } + + DartT? getNullable( + JClass jClass, JAccessible type) { + final jClassRef = jClass.reference; + return type._staticGetNullable(jClassRef.pointer, pointer); } void set( JObject object, JAccessible type, DartT value) { final objectRef = object.reference; - type._staticSet(objectRef.pointer, this as JFieldIDPtr, value); + type._staticSet(objectRef.pointer, pointer, value); } } /// A thin wrapper over a [JMethodIDPtr] of an instance method. -extension type JInstanceMethodId._fromPointer(JMethodIDPtr pointer) { +class JInstanceMethodId { + JMethodIDPtr pointer; + JInstanceMethodId._( JClass jClass, String name, @@ -108,8 +122,21 @@ extension type JInstanceMethodId._fromPointer(JMethodIDPtr pointer) { ) { return using((arena) { final objectRef = object.reference; - return returnType._instanceCall(objectRef.pointer, this as JMethodIDPtr, - toJValues(args, allocator: arena)); + return returnType._instanceCall( + objectRef.pointer, pointer, toJValues(args, allocator: arena)); + }); + } + + /// Calls the instance method on [object] with the given arguments. + DartT? callNullable( + JObject object, + JCallable returnType, + List args, + ) { + return using((arena) { + final objectRef = object.reference; + return returnType._instanceCallNullable( + objectRef.pointer, pointer, toJValues(args, allocator: arena)); }); } } @@ -136,8 +163,19 @@ extension type JStaticMethodId._fromPointer(JMethodIDPtr pointer) { List args, ) { final jClassRef = jClass.reference; - return using((arena) => returnType._staticCall(jClassRef.pointer, - this as JMethodIDPtr, toJValues(args, allocator: arena))); + return using((arena) => returnType._staticCall( + jClassRef.pointer, pointer, toJValues(args, allocator: arena))); + } + + /// Calls the static method on [jClass] with the given arguments. + DartT? callNullable( + JClass jClass, + JCallable returnType, + List args, + ) { + final jClassRef = jClass.reference; + return using((arena) => returnType._staticCallNullable( + jClassRef.pointer, pointer, toJValues(args, allocator: arena))); } } @@ -156,12 +194,16 @@ extension type JConstructorId._fromPointer(JMethodIDPtr pointer) { }); /// Constructs an instance of [jClass] with the given arguments. - DartT call(JClass jClass, - JConstructable returnType, List args) { + DartT call(JClass jClass, List args) { return using((arena) { final jClassRef = jClass.reference; - return returnType._newObject(jClassRef.pointer, this as JMethodIDPtr, - toJValues(args, allocator: arena)); + return JObject.fromReference( + JGlobalReference(Jni.env.NewObjectA( + jClassRef.pointer, + this as JMethodIDPtr, + toJValues(args, allocator: arena), + )), + ) as DartT; }); } } diff --git a/pkgs/jni/lib/src/jimplementer.dart b/pkgs/jni/lib/src/jimplementer.dart index 6196c566da..deeb5c4988 100644 --- a/pkgs/jni/lib/src/jimplementer.dart +++ b/pkgs/jni/lib/src/jimplementer.dart @@ -11,7 +11,6 @@ import 'package:meta/meta.dart' show internal; import 'accessors.dart'; import 'jni.dart'; import 'jobject.dart'; -import 'jreference.dart'; import 'lang/jstring.dart'; import 'third_party/generated_bindings.dart'; import 'types.dart'; @@ -42,10 +41,8 @@ class JImplementer extends JObject { factory JImplementer() { ProtectedJniExtensions.ensureInitialized(); - return JImplementer.fromReference(_new( - _class.reference.pointer, - _newId as JMethodIDPtr, - ProtectedJniExtensions.getCurrentIsolateId()) + return JImplementer.fromReference(_new(_class.reference.pointer, + _newId.pointer, ProtectedJniExtensions.getCurrentIsolateId()) .reference); } @@ -79,13 +76,11 @@ class JImplementer extends JObject { (binaryName.toJString()..releasedBy(arena)).reference; _addImplementation( reference.pointer, - _addImplementationId as JMethodIDPtr, + _addImplementationId.pointer, binaryNameRef.pointer, port.sendPort.nativePort, pointer.address, - (asyncMethods - .map((m) => m.toJString()..releasedBy(arena)) - .toJList(JString.type) + (asyncMethods.map((m) => m.toJString()..releasedBy(arena)).toJList() ..releasedBy(arena)) .reference .pointer, @@ -114,17 +109,7 @@ class JImplementer extends JObject { /// added interfaces with the given implementations. /// /// Releases this implementer. - T implement(JType type) { - return type.fromReference(implementReference()); - } - - /// Used in the JNIgen generated code. - /// - /// It is unnecessary to construct the type object when the code is generated. - @internal - JReference implementReference() { - final ref = _build(reference.pointer, _buildId as JMethodIDPtr).reference; - release(); - return ref; + T implement() { + return _build(reference.pointer, _buildId.pointer).object(); } } diff --git a/pkgs/jni/lib/src/jni.dart b/pkgs/jni/lib/src/jni.dart index 9156e17fc1..e04b947f5f 100644 --- a/pkgs/jni/lib/src/jni.dart +++ b/pkgs/jni/lib/src/jni.dart @@ -190,22 +190,25 @@ abstract final class Jni { /// Uses the correct class loader on Android. /// Prefer this over `Jni.env.FindClass`. static JClassPtr findClass(String name) { + // TODO(https://github.com/dart-lang/native/issues/3174): Remove this hack. + if (name.startsWith('L') && name.endsWith(';')) { + name = name.substring(1, name.length - 1); + } return using((arena) => _bindings.JniFindClass(name.toNativeChars(arena))) .checkedClassRef; } /// Throws an exception. - // TODO(#561): Throw an actual `JThrowable`. @internal static void throwException(JThrowablePtr exception) { final details = _bindings.GetExceptionDetails(exception); final env = Jni.env; final message = env.toDartString(details.message); final stacktrace = env.toDartString(details.stacktrace); - env.DeleteGlobalRef(exception); env.DeleteGlobalRef(details.message); env.DeleteGlobalRef(details.stacktrace); - throw JniException(message, stacktrace); + throw JThrowable.fromReference( + JGlobalReference(exception), message, stacktrace); } /// Returns the instance of [GlobalJniEnvStruct], which is an abstraction over @@ -418,8 +421,7 @@ extension AdditionalEnvMethods on GlobalJniEnv { final utf = s.toNativeUtf16(allocator: arena).cast(); final result = NewString(utf, s.length); if (utf == nullptr) { - throw JniException( - 'Fatal: cannot convert string to Java string: $s', ''); + throw JniNewStringException(s); } return result; }); diff --git a/pkgs/jni/lib/src/jobject.dart b/pkgs/jni/lib/src/jobject.dart index 1b65931177..76e2b8f8fb 100644 --- a/pkgs/jni/lib/src/jobject.dart +++ b/pkgs/jni/lib/src/jobject.dart @@ -24,69 +24,13 @@ final class CastError extends Error { } } -@internal -final class $JObject$NullableType$ extends JType { - const $JObject$NullableType$(); - - @override - String get signature => 'Ljava/lang/Object;'; - - @override - JObject? fromReference(JReference reference) => - reference.isNull ? null : JObject.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - // TODO(#70): Once interface implementation lands, other than [superType], - // we should have a list of implemented interfaces. - - @override - final int superCount = 0; - - @override - int get hashCode => ($JObject$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JObject$NullableType$ && - other is $JObject$NullableType$; - } -} - -@internal final class $JObject$Type$ extends JType { + @internal const $JObject$Type$(); + @internal @override - String get signature => 'Ljava/lang/Object;'; - - @override - JObject fromReference(JReference reference) => - JObject.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JObject$NullableType$(); - - // TODO(#70): Once interface implementation lands, other than [superType], - // we should have a list of implemented interfaces. - - @override - final int superCount = 0; - - @override - int get hashCode => ($JObject$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JObject$Type$ && other is $JObject$Type$; - } + String get signature => r'Ljava/lang/Object;'; } /// A high-level wrapper for JNI global object reference. @@ -96,15 +40,9 @@ class JObject { @internal final JReference reference; - @internal - final JType $type = type; - /// The type which includes information such as the signature of this class. static const JType type = $JObject$Type$(); - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JObject$NullableType$(); - /// Constructs a [JObject] with the underlying [reference]. JObject.fromReference(this.reference) { if (reference.isNull) { @@ -147,7 +85,7 @@ class JObject { /// ... /// } /// ``` - bool isA(JType type) { + bool isA(JType type) { final targetJClass = type.jClass; final canBeCasted = isInstanceOf(targetJClass); targetJClass.release(); @@ -164,7 +102,7 @@ class JObject { /// If [releaseOriginal] is `true`, the casted object will be released. /// /// Throws [CastError] if this object is not an instance of [type]. - T as( + T as( JType type, { bool releaseOriginal = false, }) { @@ -173,12 +111,13 @@ class JObject { } if (releaseOriginal) { - final ret = type.fromReference(JGlobalReference(reference.pointer)); + final ret = + JObject.fromReference(JGlobalReference(reference.pointer)) as T; reference.setAsReleased(); return ret; } final newRef = JGlobalReference(Jni.env.NewGlobalRef(reference.pointer)); - return type.fromReference(newRef); + return JObject.fromReference(newRef) as T; } static final _class = JClass.forName('java/lang/Object'); @@ -203,7 +142,7 @@ class JObject { _class.instanceMethodId(r'toString', r'()Ljava/lang/String;'); @override String toString() { - return _toStringId(this, const $JString$Type$(), []) + return _toStringId(this, JString.type, []) .toDartString(releaseOriginal: true); } @@ -225,6 +164,25 @@ class JObject { } } +/// A high-level wrapper for JNI global object reference of a +/// `java.lang.Throwable`. +/// +/// This is the base class for all exceptions generated by `jnigen`. +class JThrowable extends JObject implements Exception { + final String message; + final String javaStackTrace; + + @internal + JThrowable.fromReference( + super.reference, + this.message, + this.javaStackTrace, + ) : super.fromReference(); + + @override + String toString() => 'Exception in Java: $message\n$javaStackTrace'; +} + extension JObjectUseExtension on T { /// Applies [callback] on this object and then delete the underlying JNI /// reference, returning the result of [callback]. diff --git a/pkgs/jni/lib/src/jprimitives.dart b/pkgs/jni/lib/src/jprimitives.dart index 625ceea66b..fe37cf5fd4 100644 --- a/pkgs/jni/lib/src/jprimitives.dart +++ b/pkgs/jni/lib/src/jprimitives.dart @@ -49,6 +49,28 @@ final class jbyteType extends JTypeBase return Jni.env.GetStaticByteField(clazz, fieldID); } + @override + int? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + int? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + int? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + int? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, int val) { return Jni.env.SetStaticByteField(clazz, fieldID, val); @@ -94,6 +116,28 @@ final class jbooleanType extends JTypeBase return Jni.env.GetStaticBooleanField(clazz, fieldID); } + @override + bool? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + bool? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + bool? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + bool? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, bool val) { return Jni.env.SetStaticBooleanField(clazz, fieldID, val ? 1 : 0); @@ -139,6 +183,28 @@ final class jcharType extends JTypeBase return Jni.env.GetStaticCharField(clazz, fieldID); } + @override + int? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + int? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + int? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + int? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, int val) { return Jni.env.SetStaticCharField(clazz, fieldID, val); @@ -184,6 +250,28 @@ final class jshortType extends JTypeBase return Jni.env.GetStaticShortField(clazz, fieldID); } + @override + int? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + int? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + int? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + int? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, int val) { return Jni.env.SetStaticShortField(clazz, fieldID, val); @@ -229,6 +317,28 @@ final class jintType extends JTypeBase return Jni.env.GetStaticIntField(clazz, fieldID); } + @override + int? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + int? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + int? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + int? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, int val) { return Jni.env.SetStaticIntField(clazz, fieldID, val); @@ -274,6 +384,28 @@ final class jlongType extends JTypeBase return Jni.env.GetStaticLongField(clazz, fieldID); } + @override + int? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + int? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + int? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + int? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, int val) { return Jni.env.SetStaticLongField(clazz, fieldID, val); @@ -319,6 +451,28 @@ final class jfloatType extends JTypeBase return Jni.env.GetStaticFloatField(clazz, fieldID); } + @override + double? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + double? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + double? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + double? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, double val) { return Jni.env.SetStaticFloatField(clazz, fieldID, val); @@ -364,6 +518,28 @@ final class jdoubleType extends JTypeBase return Jni.env.GetStaticDoubleField(clazz, fieldID); } + @override + double? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + return _staticGet(clazz, fieldID); + } + + @override + double? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + return _instanceGet(obj, fieldID); + } + + @override + double? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + double? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, double val) { return Jni.env.SetStaticDoubleField(clazz, fieldID, val); @@ -387,6 +563,18 @@ final class jvoidType extends JTypeBase with JCallable { return Jni.env.CallStaticVoidMethodA(clazz, methodID, args); } + @override + void _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + return _staticCall(clazz, methodID, args); + } + + @override + void _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + return _instanceCall(obj, methodID, args); + } + @override void _instanceCall( JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { diff --git a/pkgs/jni/lib/src/kotlin.dart b/pkgs/jni/lib/src/kotlin.dart index 079d234ec2..4283ebfc67 100644 --- a/pkgs/jni/lib/src/kotlin.dart +++ b/pkgs/jni/lib/src/kotlin.dart @@ -39,6 +39,11 @@ final _coroutineSuspended = _coroutineIntrinsicsClass.staticMethodId( '()Ljava/lang/Object;', )(_coroutineIntrinsicsClass, const $JObject$Type$(), []); +final _unitClass = JClass.forName('kotlin/Unit'); +final _unit = _unitClass + .staticFieldId('INSTANCE', 'Lkotlin/Unit;') + .get(_unitClass, const $JObject$Type$()); + @internal class KotlinContinuation extends JObject { KotlinContinuation.fromReference(super.reference) : super.fromReference(); @@ -58,7 +63,7 @@ class KotlinContinuation extends JObject { ); void resumeWithException(Object dartException, StackTrace stackTrace) { resumeWith( - _result$FailureConstructor(result$FailureClass, JObject.type, [ + _result$FailureConstructor(result$FailureClass, [ ProtectedJniExtensions.newDartException('$dartException\n$stackTrace'), ]), ); @@ -68,4 +73,7 @@ class KotlinContinuation extends JObject { future.then(resumeWith, onError: resumeWithException); return _coroutineSuspended; } + + JObject resumeWithVoidFuture(Future future) => + resumeWithFuture(future.then((_) => _unit)); } diff --git a/pkgs/jni/lib/src/lang/jboolean.dart b/pkgs/jni/lib/src/lang/jboolean.dart index 67c907925f..380197a159 100644 --- a/pkgs/jni/lib/src/lang/jboolean.dart +++ b/pkgs/jni/lib/src/lang/jboolean.dart @@ -2,92 +2,26 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - import '../jobject.dart'; -import '../jreference.dart'; import '../types.dart'; -@internal -final class $JBoolean$NullableType$ extends JType { - const $JBoolean$NullableType$(); - - @override - String get signature => r'Ljava/lang/Boolean;'; - - @override - JBoolean? fromReference(JReference reference) => - reference.isNull ? null : JBoolean.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JBoolean$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JBoolean$NullableType$ && - other is $JBoolean$NullableType$; - } -} - -@internal -final class $JBoolean$Type$ extends JType { - const $JBoolean$Type$(); +final class _$JBoolean$Type$ extends JType { + const _$JBoolean$Type$(); @override String get signature => r'Ljava/lang/Boolean;'; - - @override - JBoolean fromReference(JReference reference) => - JBoolean.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JBoolean$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JBoolean$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JBoolean$Type$ && other is $JBoolean$Type$; - } } -class JBoolean extends JObject { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JBoolean.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JBoolean$Type$(); - +extension type JBoolean._(JObject _$this) implements JObject { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JBoolean$NullableType$(); + static const JType type = _$JBoolean$Type$(); - static final _class = JClass.forName(r'java/lang/Boolean'); + static final _class = type.jClass; static final _ctorId = _class.constructorId(r'(Z)V'); + JBoolean(bool boolean) - : super.fromReference(_ctorId(_class, referenceType, [boolean ? 1 : 0])); + : _$this = _ctorId(_class, [boolean ? 1 : 0]); static final _booleanValueId = _class.instanceMethodId(r'booleanValue', r'()Z'); diff --git a/pkgs/jni/lib/src/lang/jbyte.dart b/pkgs/jni/lib/src/lang/jbyte.dart index d8a4dd57d2..08d5a781d3 100644 --- a/pkgs/jni/lib/src/lang/jbyte.dart +++ b/pkgs/jni/lib/src/lang/jbyte.dart @@ -2,90 +2,25 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - -import '../jreference.dart'; +import '../jobject.dart'; import '../jvalues.dart'; import '../types.dart'; import 'jnumber.dart'; -@internal -final class $JByte$NullableType$ extends JType { - const $JByte$NullableType$(); - - @override - String get signature => r'Ljava/lang/Byte;'; - - @override - JByte? fromReference(JReference reference) => - reference.isNull ? null : JByte.fromReference(reference); - - @override - JType get superType => const $JNumber$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JByte$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JByte$NullableType$ && - other is $JByte$NullableType$; - } -} - -@internal -final class $JByte$Type$ extends JType { - const $JByte$Type$(); +final class _$JByte$Type$ extends JType { + const _$JByte$Type$(); @override String get signature => r'Ljava/lang/Byte;'; - - @override - JByte fromReference(JReference reference) => JByte.fromReference(reference); - - @override - JType get superType => const $JNumber$Type$(); - - @override - JType get nullableType => const $JByte$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JByte$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JByte$Type$ && other is $JByte$Type$; - } } -class JByte extends JNumber { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JByte.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JByte$Type$(); - +extension type JByte._(JObject _$this) implements JNumber { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JByte$NullableType$(); + static const JType type = _$JByte$Type$(); static final _class = JClass.forName(r'java/lang/Byte'); static final _ctorId = _class.constructorId(r'(B)V'); - JByte(int num) - : super.fromReference(_ctorId(_class, referenceType, [JValueByte(num)])); + + JByte(int num) : _$this = _ctorId(_class, [JValueByte(num)]); } diff --git a/pkgs/jni/lib/src/lang/jcharacter.dart b/pkgs/jni/lib/src/lang/jcharacter.dart index 1689d7cece..cfe742a128 100644 --- a/pkgs/jni/lib/src/lang/jcharacter.dart +++ b/pkgs/jni/lib/src/lang/jcharacter.dart @@ -2,94 +2,26 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - import '../jobject.dart'; -import '../jreference.dart'; import '../jvalues.dart'; import '../types.dart'; -@internal -final class $JCharacter$NullableType$ extends JType { - const $JCharacter$NullableType$(); +final class _$JCharacter$Type$ extends JType { + const _$JCharacter$Type$(); @override String get signature => r'Ljava/lang/Character;'; - - @override - JCharacter? fromReference(JReference reference) => - reference.isNull ? null : JCharacter.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => ($JCharacter$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JCharacter$NullableType$ && - other is $JCharacter$NullableType$; - } } -@internal -final class $JCharacter$Type$ extends JType { - const $JCharacter$Type$(); - - @override - String get signature => r'Ljava/lang/Character;'; - - @override - JCharacter fromReference(JReference reference) => - JCharacter.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JCharacter$NullableType$(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JCharacter$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JCharacter$Type$ && other is $JCharacter$Type$; - } -} - -class JCharacter extends JObject { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JCharacter.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JCharacter$Type$(); - +extension type JCharacter._(JObject _$this) implements JObject { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JCharacter$NullableType$(); + static const JType type = _$JCharacter$Type$(); static final _class = JClass.forName(r'java/lang/Character'); static final _ctorId = _class.constructorId(r'(C)V'); - JCharacter(int c) - : super.fromReference(_ctorId(_class, referenceType, [JValueChar(c)])); + JCharacter(int c) : _$this = _ctorId(_class, [JValueChar(c)]); static final _charValueId = _class.instanceMethodId(r'charValue', r'()C'); diff --git a/pkgs/jni/lib/src/lang/jdouble.dart b/pkgs/jni/lib/src/lang/jdouble.dart index 9e4c237fc7..e82581be28 100644 --- a/pkgs/jni/lib/src/lang/jdouble.dart +++ b/pkgs/jni/lib/src/lang/jdouble.dart @@ -2,90 +2,24 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - -import '../jreference.dart'; +import '../jobject.dart'; import '../types.dart'; import 'jnumber.dart'; -@internal -final class $JDouble$NullableType$ extends JType { - const $JDouble$NullableType$(); - - @override - String get signature => r'Ljava/lang/Double;'; - - @override - JDouble? fromReference(JReference reference) => - reference.isNull ? null : JDouble.fromReference(reference); - - @override - JType get superType => const $JNumber$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JDouble$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JDouble$NullableType$ && - other is $JDouble$NullableType$; - } -} - -@internal -final class $JDouble$Type$ extends JType { - const $JDouble$Type$(); +final class _$JDouble$Type$ extends JType { + const _$JDouble$Type$(); @override String get signature => r'Ljava/lang/Double;'; - - @override - JDouble fromReference(JReference reference) => - JDouble.fromReference(reference); - - @override - JType get superType => const $JNumber$Type$(); - - @override - JType get nullableType => const $JDouble$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JDouble$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JDouble$Type$ && other is $JDouble$Type$; - } } -class JDouble extends JNumber { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JDouble.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JDouble$Type$(); - +extension type JDouble._(JObject _$this) implements JNumber { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JDouble$NullableType$(); + static const JType type = _$JDouble$Type$(); static final _class = JClass.forName(r'java/lang/Double'); static final _ctorId = _class.constructorId(r'(D)V'); - JDouble(double num) - : super.fromReference(_ctorId(_class, referenceType, [num])); + + JDouble(double num) : _$this = _ctorId(_class, [num]); } diff --git a/pkgs/jni/lib/src/lang/jfloat.dart b/pkgs/jni/lib/src/lang/jfloat.dart index 1649fb7cba..cadf0bf0a0 100644 --- a/pkgs/jni/lib/src/lang/jfloat.dart +++ b/pkgs/jni/lib/src/lang/jfloat.dart @@ -2,91 +2,25 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - -import '../jreference.dart'; +import '../jobject.dart'; import '../jvalues.dart'; import '../types.dart'; import 'jnumber.dart'; -@internal -final class $JFloat$NullableType$ extends JType { - const $JFloat$NullableType$(); +final class _$JFloat$Type$ extends JType { + const _$JFloat$Type$(); @override String get signature => r'Ljava/lang/Float;'; - - @override - JFloat? fromReference(JReference reference) => - reference.isNull ? null : JFloat.fromReference(reference); - - @override - JType get superType => const $JNumber$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JFloat$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JFloat$NullableType$ && - other is $JFloat$NullableType$; - } } -@internal -final class $JFloat$Type$ extends JType { - const $JFloat$Type$(); - - @override - String get signature => r'Ljava/lang/Float;'; - - @override - JFloat fromReference(JReference reference) => JFloat.fromReference(reference); - - @override - JType get superType => const $JNumber$Type$(); - - @override - JType get nullableType => const $JFloat$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JFloat$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JFloat$Type$ && other is $JFloat$Type$; - } -} - -class JFloat extends JNumber { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JFloat.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JFloat$Type$(); - +extension type JFloat._(JObject _$this) implements JNumber { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JFloat$NullableType$(); + static const JType type = _$JFloat$Type$(); - static final _class = JClass.forName(r'java/lang/Float'); + static final _class = type.jClass; static final _ctorId = _class.constructorId(r'(F)V'); - JFloat(double num) - : super.fromReference(_ctorId(_class, referenceType, [JValueFloat(num)])); + JFloat(double num) : _$this = _ctorId(_class, [JValueFloat(num)]); } diff --git a/pkgs/jni/lib/src/lang/jinteger.dart b/pkgs/jni/lib/src/lang/jinteger.dart index b856aedff3..b9d35dd51b 100644 --- a/pkgs/jni/lib/src/lang/jinteger.dart +++ b/pkgs/jni/lib/src/lang/jinteger.dart @@ -2,91 +2,25 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - -import '../jreference.dart'; +import '../jobject.dart'; import '../jvalues.dart'; import '../types.dart'; import 'jnumber.dart'; -@internal -final class $JInteger$NullableType$ extends JType { - const $JInteger$NullableType$(); +final class _$JInteger$Type$ extends JType { + const _$JInteger$Type$(); @override String get signature => r'Ljava/lang/Integer;'; - - @override - JInteger? fromReference(JReference reference) => - reference.isNull ? null : JInteger.fromReference(reference); - - @override - JType get superType => const $JNumber$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JInteger$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JInteger$NullableType$ && - other is $JInteger$NullableType$; - } } -@internal -final class $JInteger$Type$ extends JType { - const $JInteger$Type$(); - - @override - String get signature => r'Ljava/lang/Integer;'; - - @override - JInteger fromReference(JReference reference) => - JInteger.fromReference(reference); - - @override - JType get superType => const $JNumber$Type$(); - - @override - JType get nullableType => const $JInteger$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JInteger$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JInteger$Type$ && other is $JInteger$Type$; - } -} - -class JInteger extends JNumber { - @override - // ignore: overridden_fields - final JType $type = type; - - JInteger.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JInteger$Type$(); - +extension type JInteger._(JObject _$this) implements JNumber { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JInteger$NullableType$(); + static const JType type = _$JInteger$Type$(); static final _class = JClass.forName(r'java/lang/Integer'); static final _ctorId = _class.constructorId('(I)V'); - JInteger(int num) - : super.fromReference(_ctorId(_class, referenceType, [JValueInt(num)])); + JInteger(int num) : _$this = _ctorId(_class, [JValueInt(num)]); } diff --git a/pkgs/jni/lib/src/lang/jlong.dart b/pkgs/jni/lib/src/lang/jlong.dart index 62173f3479..7ba2eb0993 100644 --- a/pkgs/jni/lib/src/lang/jlong.dart +++ b/pkgs/jni/lib/src/lang/jlong.dart @@ -2,89 +2,24 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - -import '../jreference.dart'; +import '../jobject.dart'; import '../types.dart'; import 'jnumber.dart'; -@internal -final class $JLong$NullableType$ extends JType { - const $JLong$NullableType$(); +final class _$JLong$Type$ extends JType { + const _$JLong$Type$(); @override String get signature => r'Ljava/lang/Long;'; - - @override - JLong? fromReference(JReference reference) => - reference.isNull ? null : JLong.fromReference(reference); - - @override - JType get superType => const $JNumber$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JLong$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JLong$NullableType$ && - other is $JLong$NullableType$; - } } -@internal -final class $JLong$Type$ extends JType { - const $JLong$Type$(); - - @override - String get signature => r'Ljava/lang/Long;'; - - @override - JLong fromReference(JReference reference) => JLong.fromReference(reference); - - @override - JType get superType => const $JNumber$Type$(); - - @override - JType get nullableType => const $JLong$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JLong$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JLong$Type$ && other is $JLong$Type$; - } -} - -class JLong extends JNumber { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JLong.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JLong$Type$(); - +extension type JLong._(JObject _$this) implements JNumber { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JLong$NullableType$(); + static const JType type = _$JLong$Type$(); static final _class = JClass.forName(r'java/lang/Long'); static final _ctorId = _class.constructorId(r'(J)V'); - JLong(int num) : super.fromReference(_ctorId(_class, referenceType, [num])); + JLong(int num) : _$this = _ctorId(_class, [num]); } diff --git a/pkgs/jni/lib/src/lang/jnumber.dart b/pkgs/jni/lib/src/lang/jnumber.dart index 6863c00ff4..9f68e4c6aa 100644 --- a/pkgs/jni/lib/src/lang/jnumber.dart +++ b/pkgs/jni/lib/src/lang/jnumber.dart @@ -2,10 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - import '../jobject.dart'; -import '../jreference.dart'; import '../types.dart'; import 'jboolean.dart'; import 'jbyte.dart'; @@ -16,86 +13,22 @@ import 'jinteger.dart'; import 'jlong.dart'; import 'jshort.dart'; -@internal -final class $JNumber$NullableType$ extends JType { - const $JNumber$NullableType$(); +final class _$JNumber$Type$ extends JType { + const _$JNumber$Type$(); @override String get signature => r'Ljava/lang/Number;'; - - @override - JNumber? fromReference(JReference reference) => - reference.isNull ? null : JNumber.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => ($JNumber$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JNumber$NullableType$ && - other is $JNumber$NullableType$; - } } -@internal -final class $JNumber$Type$ extends JType { - const $JNumber$Type$(); - - @override - String get signature => r'Ljava/lang/Number;'; - - @override - JNumber fromReference(JReference reference) => - JNumber.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JNumber$NullableType$(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JNumber$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JNumber$Type$ && other is $JNumber$Type$; - } -} - -class JNumber extends JObject { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JNumber.fromReference( - super.reference, - ) : super.fromReference(); - +extension type JNumber._(JObject _$this) implements JObject { static final _class = JClass.forName(r'java/lang/Number'); /// The type which includes information such as the signature of this class. - static const JType type = $JNumber$Type$(); - - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JNumber$NullableType$(); + static const JType type = _$JNumber$Type$(); static final _ctorId = _class.constructorId(r'()V'); - JNumber() : super.fromReference(_ctorId(_class, referenceType, [])); + JNumber() : _$this = _ctorId(_class, []); static final _intValueId = _class.instanceMethodId(r'intValue', r'()I'); diff --git a/pkgs/jni/lib/src/lang/jshort.dart b/pkgs/jni/lib/src/lang/jshort.dart index f15c266f33..f3e05d25f4 100644 --- a/pkgs/jni/lib/src/lang/jshort.dart +++ b/pkgs/jni/lib/src/lang/jshort.dart @@ -2,91 +2,25 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - -import '../jreference.dart'; +import '../jobject.dart'; import '../jvalues.dart'; import '../types.dart'; import 'jnumber.dart'; -@internal -final class $JShort$NullableType$ extends JType { - const $JShort$NullableType$(); +final class _$JShort$Type$ extends JType { + const _$JShort$Type$(); @override String get signature => r'Ljava/lang/Short;'; - - @override - JShort? fromReference(JReference reference) => - reference.isNull ? null : JShort.fromReference(reference); - - @override - JType get superType => const $JNumber$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JShort$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JShort$NullableType$ && - other is $JShort$NullableType$; - } } -@internal -final class $JShort$Type$ extends JType { - const $JShort$Type$(); - - @override - String get signature => r'Ljava/lang/Short;'; - - @override - JShort fromReference(JReference reference) => JShort.fromReference(reference); - - @override - JType get superType => const $JNumber$Type$(); - - @override - JType get nullableType => const $JShort$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JShort$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JShort$Type$ && other is $JShort$Type$; - } -} - -class JShort extends JNumber { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JShort.fromReference( - super.reference, - ) : super.fromReference(); - - /// The type which includes information such as the signature of this class. - static const JType type = $JShort$Type$(); - +extension type JShort._(JObject _$this) implements JNumber { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JShort$NullableType$(); + static const JType type = _$JShort$Type$(); static final _class = JClass.forName(r'java/lang/Short'); static final _ctorId = _class.constructorId(r'(S)V'); - JShort(int num) - : super.fromReference(_ctorId(_class, referenceType, [JValueShort(num)])); + JShort(int num) : _$this = _ctorId(_class, [JValueShort(num)]); } diff --git a/pkgs/jni/lib/src/lang/jstring.dart b/pkgs/jni/lib/src/lang/jstring.dart index 5d976485b2..2e58b42577 100644 --- a/pkgs/jni/lib/src/lang/jstring.dart +++ b/pkgs/jni/lib/src/lang/jstring.dart @@ -2,93 +2,29 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:meta/meta.dart' show internal; - import '../jni.dart'; import '../jobject.dart'; import '../jreference.dart'; import '../types.dart'; -@internal -final class $JString$NullableType$ extends JType { - const $JString$NullableType$(); +final class _$JString$Type$ extends JType { + const _$JString$Type$(); @override String get signature => 'Ljava/lang/String;'; - - @override - JString? fromReference(JReference reference) => - reference.isNull ? null : JString.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final int superCount = 1; - - @override - int get hashCode => ($JString$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JString$NullableType$ && - other is $JString$NullableType$; - } } -@internal -final class $JString$Type$ extends JType { - const $JString$Type$(); - - @override - String get signature => 'Ljava/lang/String;'; - - @override - JString fromReference(JReference reference) => - JString.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JString$NullableType$(); - - @override - final int superCount = 1; - - @override - int get hashCode => ($JString$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JString$Type$ && other is $JString$Type$; - } -} - -class JString extends JObject { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - /// The type which includes information such as the signature of this class. - static const JType type = $JString$Type$(); - +extension type JString._(JObject _$this) implements JObject { /// The type which includes information such as the signature of this class. - static const JType nullableType = $JString$NullableType$(); - - /// Construct a new [JString] with [reference] as its underlying reference. - JString.fromReference(super.reference) : super.fromReference(); + static const JType type = _$JString$Type$(); /// The number of Unicode characters in this Java string. int get length => Jni.env.GetStringLength(reference.pointer); /// Construct a [JString] from the contents of Dart string [s]. JString.fromString(String s) - : super.fromReference(JGlobalReference(Jni.env.toJStringPtr(s))); + : _$this = + JObject.fromReference(JGlobalReference(Jni.env.toJStringPtr(s))); /// Returns the contents as a Dart String. /// diff --git a/pkgs/jni/lib/src/lang/lang.dart b/pkgs/jni/lib/src/lang/lang.dart index 862444cb96..786488c068 100644 --- a/pkgs/jni/lib/src/lang/lang.dart +++ b/pkgs/jni/lib/src/lang/lang.dart @@ -2,13 +2,13 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'jboolean.dart' hide $JBoolean$NullableType$, $JBoolean$Type$; -export 'jbyte.dart' hide $JByte$NullableType$, $JByte$Type$; -export 'jcharacter.dart' hide $JCharacter$NullableType$, $JCharacter$Type$; -export 'jdouble.dart' hide $JDouble$NullableType$, $JDouble$Type$; -export 'jfloat.dart' hide $JFloat$NullableType$, $JFloat$Type$; -export 'jinteger.dart' hide $JInteger$NullableType$, $JInteger$Type$; -export 'jlong.dart' hide $JLong$NullableType$, $JLong$Type$; -export 'jnumber.dart' hide $JNumber$NullableType$, $JNumber$Type$; -export 'jshort.dart' hide $JShort$NullableType$, $JShort$Type$; -export 'jstring.dart' hide $JString$NullableType$, $JString$Type$; +export 'jboolean.dart'; +export 'jbyte.dart'; +export 'jcharacter.dart'; +export 'jdouble.dart'; +export 'jfloat.dart'; +export 'jinteger.dart'; +export 'jlong.dart'; +export 'jnumber.dart'; +export 'jshort.dart'; +export 'jstring.dart'; diff --git a/pkgs/jni/lib/src/method_invocation.dart b/pkgs/jni/lib/src/method_invocation.dart index 470bc8f093..197f91b8ed 100644 --- a/pkgs/jni/lib/src/method_invocation.dart +++ b/pkgs/jni/lib/src/method_invocation.dart @@ -27,14 +27,14 @@ class MethodInvocation { ) { return MethodInvocation._( Pointer.fromAddress(resultAddress), - JString.fromReference( - JGlobalReference(Pointer.fromAddress(descriptorAddress))), + JObject.fromReference( + JGlobalReference(Pointer.fromAddress(descriptorAddress))) + as JString, argsAddress == 0 ? null - : JArray.fromReference( - const $JObject$NullableType$(), + : JObject.fromReference( JGlobalReference(Pointer.fromAddress(argsAddress)), - ), + ) as JArray, ); } diff --git a/pkgs/jni/lib/src/nio/jbuffer.dart b/pkgs/jni/lib/src/nio/jbuffer.dart index f4a9d2a0c7..4103305025 100644 --- a/pkgs/jni/lib/src/nio/jbuffer.dart +++ b/pkgs/jni/lib/src/nio/jbuffer.dart @@ -5,68 +5,16 @@ import 'package:meta/meta.dart' show internal; import '../jobject.dart'; -import '../jreference.dart'; import '../jvalues.dart'; import '../types.dart'; import 'jbyte_buffer.dart'; -@internal -final class $JBuffer$NullableType$ extends JType { - const $JBuffer$NullableType$(); - - @override - String get signature => r'Ljava/nio/Buffer;'; - - @override - JBuffer? fromReference(JReference reference) => - reference.isNull ? null : JBuffer.fromReference(reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => ($JBuffer$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JBuffer$NullableType$ && - other is $JBuffer$NullableType$; - } -} - @internal final class $JBuffer$Type$ extends JType { const $JBuffer$Type$(); @override String get signature => r'Ljava/nio/Buffer;'; - - @override - JBuffer fromReference(JReference reference) => - JBuffer.fromReference(reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType get nullableType => const $JBuffer$NullableType$(); - - @override - final superCount = 1; - - @override - int get hashCode => ($JBuffer$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JBuffer$Type$ && other is $JBuffer$Type$; - } } /// A container for data of a specific primitive type. @@ -80,24 +28,12 @@ final class $JBuffer$Type$ extends JType { /// There is one subclass of this class for each non-boolean primitive type. /// We currently only have the bindings for `java.nio.ByteBuffer` in this /// package as [JByteBuffer]. -class JBuffer extends JObject { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JBuffer.fromReference( - super.reference, - ) : super.fromReference(); - +extension type JBuffer._(JObject _$this) implements JObject { static final _class = JClass.forName(r'java/nio/Buffer'); /// The type which includes information such as the signature of this class. static const JType type = $JBuffer$Type$(); - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JBuffer$NullableType$(); - static final _capacityId = _class.instanceMethodId(r'capacity', r'()I'); /// The number of elements this buffer contains. diff --git a/pkgs/jni/lib/src/nio/jbyte_buffer.dart b/pkgs/jni/lib/src/nio/jbyte_buffer.dart index 0b577625ae..907b8f2743 100644 --- a/pkgs/jni/lib/src/nio/jbyte_buffer.dart +++ b/pkgs/jni/lib/src/nio/jbyte_buffer.dart @@ -15,64 +15,12 @@ import '../jvalues.dart'; import '../types.dart'; import 'jbuffer.dart'; -@internal -final class $JByteBuffer$NullableType$ extends JType { - const $JByteBuffer$NullableType$(); - - @override - String get signature => r'Ljava/nio/ByteBuffer;'; - - @override - JByteBuffer? fromReference(JReference reference) => - reference.isNull ? null : JByteBuffer.fromReference(reference); - - @override - JType get superType => const $JByteBuffer$NullableType$(); - - @override - JType get nullableType => this; - - @override - final superCount = 2; - - @override - int get hashCode => ($JByteBuffer$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JByteBuffer$NullableType$ && - other is $JByteBuffer$NullableType$; - } -} - @internal final class $JByteBuffer$Type$ extends JType { const $JByteBuffer$Type$(); @override String get signature => r'Ljava/nio/ByteBuffer;'; - - @override - JByteBuffer fromReference(JReference reference) => - JByteBuffer.fromReference(reference); - - @override - JType get superType => const $JBuffer$Type$(); - - @override - JType get nullableType => const $JByteBuffer$NullableType$(); - - @override - final superCount = 2; - - @override - int get hashCode => ($JByteBuffer$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $JByteBuffer$Type$ && - other is $JByteBuffer$Type$; - } } /// A byte [JBuffer]. @@ -124,24 +72,12 @@ final class $JByteBuffer$Type$ extends JType { /// final data2 = directBuffer.asUint8List(releaseOriginal: true); /// // directBuffer.nextByte = 42; // throws [UseAfterReleaseException]! /// ``` -class JByteBuffer extends JBuffer { - @internal - @override - // ignore: overridden_fields - final JType $type = type; - - JByteBuffer.fromReference( - super.reference, - ) : super.fromReference(); - +extension type JByteBuffer._(JObject _$this) implements JBuffer { static final _class = JClass.forName(r'java/nio/ByteBuffer'); /// The type which includes information such as the signature of this class. static const JType type = $JByteBuffer$Type$(); - /// The type which includes information such as the signature of this class. - static const JType nullableType = $JByteBuffer$NullableType$(); - static final _allocateDirectId = _class.staticMethodId(r'allocateDirect', r'(I)Ljava/nio/ByteBuffer;'); @@ -260,7 +196,6 @@ class JByteBuffer extends JBuffer { static final _arrayId = _class.instanceMethodId(r'array', r'()[B'); - @override JByteArray get array { return _arrayId(this, JByteArray.type, [])!; } diff --git a/pkgs/jni/lib/src/nio/nio.dart b/pkgs/jni/lib/src/nio/nio.dart index 0775fec09f..d07d6e2400 100644 --- a/pkgs/jni/lib/src/nio/nio.dart +++ b/pkgs/jni/lib/src/nio/nio.dart @@ -2,5 +2,5 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'jbuffer.dart' hide $JBuffer$NullableType$, $JBuffer$Type$; -export 'jbyte_buffer.dart' hide $JByteBuffer$NullableType$, $JByteBuffer$Type$; +export 'jbuffer.dart' hide $JBuffer$Type$; +export 'jbyte_buffer.dart' hide $JByteBuffer$Type$; diff --git a/pkgs/jni/lib/src/plugin/generated_plugin.dart b/pkgs/jni/lib/src/plugin/generated_plugin.dart index b5eda2f20e..df00eb62ee 100644 --- a/pkgs/jni/lib/src/plugin/generated_plugin.dart +++ b/pkgs/jni/lib/src/plugin/generated_plugin.dart @@ -1,6 +1,6 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -42,24 +42,10 @@ import 'package:jni/_internal.dart' as jni$_; import 'package:jni/jni.dart' as jni$_; /// from: `com.github.dart_lang.jni.JniPlugin` -class JniPlugin extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JniPlugin.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JniPlugin._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jni/JniPlugin'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JniPlugin$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JniPlugin$Type$(); static final _id_new$ = _class.constructorId( @@ -81,9 +67,8 @@ class JniPlugin extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory JniPlugin() { - return JniPlugin.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_getApplicationContext = _class.staticMethodId( @@ -106,9 +91,9 @@ class JniPlugin extends jni$_.JObject { /// from: `static public android.content.Context getApplicationContext()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JObject getApplicationContext() { - return _getApplicationContext(_class.reference.pointer, - _id_getApplicationContext as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$Type$()); + return _getApplicationContext( + _class.reference.pointer, _id_getApplicationContext.pointer) + .object(); } static final _id_getActivity = _class.staticMethodId( @@ -130,12 +115,13 @@ class JniPlugin extends jni$_.JObject { static jni$_.JObject? getActivity( int j, ) { - return _getActivity( - _class.reference.pointer, _id_getActivity as jni$_.JMethodIDPtr, j) - .object(const jni$_.$JObject$NullableType$()); + return _getActivity(_class.reference.pointer, _id_getActivity.pointer, j) + .object(); } +} - static final _id_onAttachedToEngine = _class.instanceMethodId( +extension JniPlugin$$Methods on JniPlugin { + static final _id_onAttachedToEngine = JniPlugin._class.instanceMethodId( r'onAttachedToEngine', r'(Lio/flutter/embedding/engine/plugins/FlutterPlugin$FlutterPluginBinding;)V', ); @@ -156,14 +142,12 @@ class JniPlugin extends jni$_.JObject { jni$_.JObject flutterPluginBinding, ) { final _$flutterPluginBinding = flutterPluginBinding.reference; - _onAttachedToEngine( - reference.pointer, - _id_onAttachedToEngine as jni$_.JMethodIDPtr, + _onAttachedToEngine(reference.pointer, _id_onAttachedToEngine.pointer, _$flutterPluginBinding.pointer) .check(); } - static final _id_onDetachedFromEngine = _class.instanceMethodId( + static final _id_onDetachedFromEngine = JniPlugin._class.instanceMethodId( r'onDetachedFromEngine', r'(Lio/flutter/embedding/engine/plugins/FlutterPlugin$FlutterPluginBinding;)V', ); @@ -184,14 +168,12 @@ class JniPlugin extends jni$_.JObject { jni$_.JObject flutterPluginBinding, ) { final _$flutterPluginBinding = flutterPluginBinding.reference; - _onDetachedFromEngine( - reference.pointer, - _id_onDetachedFromEngine as jni$_.JMethodIDPtr, + _onDetachedFromEngine(reference.pointer, _id_onDetachedFromEngine.pointer, _$flutterPluginBinding.pointer) .check(); } - static final _id_onAttachedToActivity = _class.instanceMethodId( + static final _id_onAttachedToActivity = JniPlugin._class.instanceMethodId( r'onAttachedToActivity', r'(Lio/flutter/embedding/engine/plugins/activity/ActivityPluginBinding;)V', ); @@ -212,15 +194,13 @@ class JniPlugin extends jni$_.JObject { jni$_.JObject activityPluginBinding, ) { final _$activityPluginBinding = activityPluginBinding.reference; - _onAttachedToActivity( - reference.pointer, - _id_onAttachedToActivity as jni$_.JMethodIDPtr, + _onAttachedToActivity(reference.pointer, _id_onAttachedToActivity.pointer, _$activityPluginBinding.pointer) .check(); } static final _id_onDetachedFromActivityForConfigChanges = - _class.instanceMethodId( + JniPlugin._class.instanceMethodId( r'onDetachedFromActivityForConfigChanges', r'()V', ); @@ -241,12 +221,12 @@ class JniPlugin extends jni$_.JObject { /// from: `public void onDetachedFromActivityForConfigChanges()` void onDetachedFromActivityForConfigChanges() { _onDetachedFromActivityForConfigChanges(reference.pointer, - _id_onDetachedFromActivityForConfigChanges as jni$_.JMethodIDPtr) + _id_onDetachedFromActivityForConfigChanges.pointer) .check(); } static final _id_onReattachedToActivityForConfigChanges = - _class.instanceMethodId( + JniPlugin._class.instanceMethodId( r'onReattachedToActivityForConfigChanges', r'(Lio/flutter/embedding/engine/plugins/activity/ActivityPluginBinding;)V', ); @@ -270,12 +250,12 @@ class JniPlugin extends jni$_.JObject { final _$activityPluginBinding = activityPluginBinding.reference; _onReattachedToActivityForConfigChanges( reference.pointer, - _id_onReattachedToActivityForConfigChanges as jni$_.JMethodIDPtr, + _id_onReattachedToActivityForConfigChanges.pointer, _$activityPluginBinding.pointer) .check(); } - static final _id_onDetachedFromActivity = _class.instanceMethodId( + static final _id_onDetachedFromActivity = JniPlugin._class.instanceMethodId( r'onDetachedFromActivity', r'()V', ); @@ -295,48 +275,11 @@ class JniPlugin extends jni$_.JObject { /// from: `public void onDetachedFromActivity()` void onDetachedFromActivity() { _onDetachedFromActivity( - reference.pointer, _id_onDetachedFromActivity as jni$_.JMethodIDPtr) + reference.pointer, _id_onDetachedFromActivity.pointer) .check(); } } -final class $JniPlugin$NullableType$ extends jni$_.JType { - @jni$_.internal - const $JniPlugin$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jni/JniPlugin;'; - - @jni$_.internal - @core$_.override - JniPlugin? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : JniPlugin.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JniPlugin$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JniPlugin$NullableType$) && - other is $JniPlugin$NullableType$; - } -} - final class $JniPlugin$Type$ extends jni$_.JType { @jni$_.internal const $JniPlugin$Type$(); @@ -344,30 +287,4 @@ final class $JniPlugin$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jni/JniPlugin;'; - - @jni$_.internal - @core$_.override - JniPlugin fromReference(jni$_.JReference reference) => - JniPlugin.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $JniPlugin$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JniPlugin$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JniPlugin$Type$) && other is $JniPlugin$Type$; - } } diff --git a/pkgs/jni/lib/src/primitive_jarrays.dart b/pkgs/jni/lib/src/primitive_jarrays.dart new file mode 100644 index 0000000000..3e8490e0d0 --- /dev/null +++ b/pkgs/jni/lib/src/primitive_jarrays.dart @@ -0,0 +1,750 @@ +// AUTO GENERATED. DO NOT EDIT! +// +// To regenerate, run `dart run tool/generate_primtive_arrays.dart` + +part of 'jarray.dart'; + +final class _$JBooleanArray$Type$ extends JType { + const _$JBooleanArray$Type$(); + + @override + String get signature => '[Z'; +} + +/// A fixed-length array of Java Boolean. +/// +/// Java equivalent of [Uint8List]. +extension type JBooleanArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JBooleanArray$Type$(); + + /// Creates a [JBooleanArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JBooleanArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewBooleanArray(length)), + ) as JBooleanArray; + } + + /// Creates a [JBooleanArray] from `elements`. + static JBooleanArray of(Iterable elements) { + final len = elements.length; + return JBooleanArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + bool operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetBooleanArrayElement(reference.pointer, index); + } + + void operator []=(int index, bool value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetBooleanArrayElement(reference.pointer, index, value); + } + + Uint8List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env + .GetBooleanArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable.map((e) => e ? 1 : 0), skipCount); + Jni.env.SetBooleanArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JBooleanArrayListView + with ListMixin, NonGrowableListMixin { + final JBooleanArray _jarray; + + _JBooleanArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + bool operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, bool value) { + _jarray[index] = value; + } +} + +extension JBooleanArrayToList on JBooleanArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JBooleanArrayListView(this); +} + +final class _$JByteArray$Type$ extends JType { + const _$JByteArray$Type$(); + + @override + String get signature => '[B'; +} + +/// A fixed-length array of Java Byte. +/// +/// Integers stored in the list are truncated to their low eight bits +/// interpreted as a signed 8-bit two's complement integer with values in the +/// range -128 to +127. +/// +/// Java equivalent of [Int8List]. +extension type JByteArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JByteArray$Type$(); + + /// Creates a [JByteArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JByteArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewByteArray(length)), + ) as JByteArray; + } + + /// Creates a [JByteArray] from `elements`. + static JByteArray of(Iterable elements) { + final len = elements.length; + return JByteArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + int operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetByteArrayElement(reference.pointer, index); + } + + void operator []=(int index, int value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetByteArrayElement(reference.pointer, index, value); + } + + Int8List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetByteArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetByteArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JByteArrayListView with ListMixin, NonGrowableListMixin { + final JByteArray _jarray; + + _JByteArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + int operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, int value) { + _jarray[index] = value; + } +} + +extension JByteArrayToList on JByteArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JByteArrayListView(this); +} + +final class _$JCharArray$Type$ extends JType { + const _$JCharArray$Type$(); + + @override + String get signature => '[C'; +} + +/// A fixed-length array of Java Char. +/// +/// Integers stored in the list are truncated to their low 16 bits +/// interpreted as an unsigned 16-bit integer with values in the +/// range 0 to +65535. +/// +/// Java equivalent of [Uint16List]. +extension type JCharArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JCharArray$Type$(); + + /// Creates a [JCharArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JCharArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewCharArray(length)), + ) as JCharArray; + } + + /// Creates a [JCharArray] from `elements`. + static JCharArray of(Iterable elements) { + final len = elements.length; + return JCharArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + int operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetCharArrayElement(reference.pointer, index); + } + + void operator []=(int index, int value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetCharArrayElement(reference.pointer, index, value); + } + + Uint16List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetCharArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetCharArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JCharArrayListView with ListMixin, NonGrowableListMixin { + final JCharArray _jarray; + + _JCharArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + int operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, int value) { + _jarray[index] = value; + } +} + +extension JCharArrayToList on JCharArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JCharArrayListView(this); +} + +final class _$JShortArray$Type$ extends JType { + const _$JShortArray$Type$(); + + @override + String get signature => '[S'; +} + +/// A fixed-length array of Java Short. +/// +/// Integers stored in the list are truncated to their low 16 bits +/// interpreted as a signed 16-bit two's complement integer with values in the +/// range -32768 to +32767. +/// +/// Java equivalent of [Int16List]. +extension type JShortArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JShortArray$Type$(); + + /// Creates a [JShortArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JShortArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewShortArray(length)), + ) as JShortArray; + } + + /// Creates a [JShortArray] from `elements`. + static JShortArray of(Iterable elements) { + final len = elements.length; + return JShortArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + int operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetShortArrayElement(reference.pointer, index); + } + + void operator []=(int index, int value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetShortArrayElement(reference.pointer, index, value); + } + + Int16List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetShortArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetShortArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JShortArrayListView + with ListMixin, NonGrowableListMixin { + final JShortArray _jarray; + + _JShortArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + int operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, int value) { + _jarray[index] = value; + } +} + +extension JShortArrayToList on JShortArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JShortArrayListView(this); +} + +final class _$JIntArray$Type$ extends JType { + const _$JIntArray$Type$(); + + @override + String get signature => '[I'; +} + +/// A fixed-length array of Java Int. +/// +/// Integers stored in the list are truncated to their low 32 bits +/// interpreted as a signed 32-bit two's complement integer with values in the +/// range -2147483648 to +2147483647. +/// +/// Java equivalent of [Int32List]. +extension type JIntArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JIntArray$Type$(); + + /// Creates a [JIntArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JIntArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewIntArray(length)), + ) as JIntArray; + } + + /// Creates a [JIntArray] from `elements`. + static JIntArray of(Iterable elements) { + final len = elements.length; + return JIntArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + int operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetIntArrayElement(reference.pointer, index); + } + + void operator []=(int index, int value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetIntArrayElement(reference.pointer, index, value); + } + + Int32List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetIntArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetIntArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JIntArrayListView with ListMixin, NonGrowableListMixin { + final JIntArray _jarray; + + _JIntArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + int operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, int value) { + _jarray[index] = value; + } +} + +extension JIntArrayToList on JIntArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JIntArrayListView(this); +} + +final class _$JLongArray$Type$ extends JType { + const _$JLongArray$Type$(); + + @override + String get signature => '[J'; +} + +/// A fixed-length array of Java Long. +/// +/// Integers stored in the list are truncated to their low 64 bits +/// interpreted as a signed 64-bit two's complement integer with values in the +/// range -9223372036854775808 to +9223372036854775807. +/// +/// Java equivalent of [Int64List]. +extension type JLongArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JLongArray$Type$(); + + /// Creates a [JLongArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JLongArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewLongArray(length)), + ) as JLongArray; + } + + /// Creates a [JLongArray] from `elements`. + static JLongArray of(Iterable elements) { + final len = elements.length; + return JLongArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + int operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetLongArrayElement(reference.pointer, index); + } + + void operator []=(int index, int value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetLongArrayElement(reference.pointer, index, value); + } + + Int64List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetLongArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetLongArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JLongArrayListView with ListMixin, NonGrowableListMixin { + final JLongArray _jarray; + + _JLongArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + int operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, int value) { + _jarray[index] = value; + } +} + +extension JLongArrayToList on JLongArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JLongArrayListView(this); +} + +final class _$JFloatArray$Type$ extends JType { + const _$JFloatArray$Type$(); + + @override + String get signature => '[F'; +} + +/// A fixed-length array of Java Float. +/// +/// Java equivalent of [Float32List]. +extension type JFloatArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JFloatArray$Type$(); + + /// Creates a [JFloatArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JFloatArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewFloatArray(length)), + ) as JFloatArray; + } + + /// Creates a [JFloatArray] from `elements`. + static JFloatArray of(Iterable elements) { + final len = elements.length; + return JFloatArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + double operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetFloatArrayElement(reference.pointer, index); + } + + void operator []=(int index, double value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetFloatArrayElement(reference.pointer, index, value); + } + + Float32List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetFloatArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetFloatArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JFloatArrayListView + with ListMixin, NonGrowableListMixin { + final JFloatArray _jarray; + + _JFloatArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + double operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, double value) { + _jarray[index] = value; + } +} + +extension JFloatArrayToList on JFloatArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JFloatArrayListView(this); +} + +final class _$JDoubleArray$Type$ extends JType { + const _$JDoubleArray$Type$(); + + @override + String get signature => '[D'; +} + +/// A fixed-length array of Java Double. +/// +/// Java equivalent of [Float64List]. +extension type JDoubleArray._(JObject _$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType type = _$JDoubleArray$Type$(); + + /// Creates a [JDoubleArray] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory JDoubleArray(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.NewDoubleArray(length)), + ) as JDoubleArray; + } + + /// Creates a [JDoubleArray] from `elements`. + static JDoubleArray of(Iterable elements) { + final len = elements.length; + return JDoubleArray(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + double operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.GetDoubleArrayElement(reference.pointer, index); + } + + void operator []=(int index, double value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.SetDoubleArrayElement(reference.pointer, index, value); + } + + Float64List getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator(rangeLength); + Jni.env.GetDoubleArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate(sizeOf() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable, skipCount); + Jni.env.SetDoubleArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _JDoubleArrayListView + with ListMixin, NonGrowableListMixin { + final JDoubleArray _jarray; + + _JDoubleArrayListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + double operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, double value) { + _jarray[index] = value; + } +} + +extension JDoubleArrayToList on JDoubleArray { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List asDart() => _JDoubleArrayListView(this); +} diff --git a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart index 32fcff47e1..da5c05dc04 100644 --- a/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart +++ b/pkgs/jni/lib/src/third_party/jni_bindings_generated.dart @@ -46,7 +46,7 @@ import 'dart:ffi' as ffi; /// /// However, functions prefixed JNI_ are not usable because they are in a different shared library. /// -/// Regenerate bindings with `flutter pub run ffigen --config ffigen.yaml`. +/// Regenerate bindings with `dart run ffigen --config ffigen.yaml`. /// class JniBindings { /// Holds the symbol lookup function. @@ -63,77 +63,34 @@ class JniBindings { lookup) : _lookup = lookup; - late final ffi.Pointer _tlsKey = - _lookup('tlsKey'); - - Dart__darwin_pthread_key_t get tlsKey => _tlsKey.value; - - set tlsKey(Dart__darwin_pthread_key_t value) => _tlsKey.value = value; - - JniClassLookupResult JniFindClass( - ffi.Pointer name, - ) { - return _JniFindClass( - name, - ); - } - - late final _JniFindClassPtr = _lookup< - ffi.NativeFunction< - JniClassLookupResult Function(ffi.Pointer)>>('FindClass'); - late final _JniFindClass = _JniFindClassPtr.asFunction< - JniClassLookupResult Function(ffi.Pointer)>(); - - JniExceptionDetails GetExceptionDetails( - JThrowablePtr exception, + JniResult DartException__ctor( + JStringPtr message, + JThrowablePtr cause, ) { - return _GetExceptionDetails( - exception, + return _DartException__ctor( + message, + cause, ); } - late final _GetExceptionDetailsPtr = - _lookup>( - 'GetExceptionDetails'); - late final _GetExceptionDetails = _GetExceptionDetailsPtr.asFunction< - JniExceptionDetails Function(JThrowablePtr)>(); - - ffi.Pointer JniGetJavaVM() { - return _JniGetJavaVM(); - } - - late final _JniGetJavaVMPtr = - _lookup Function()>>('GetJavaVM'); - late final _JniGetJavaVM = - _JniGetJavaVMPtr.asFunction Function()>(); - - ffi.Pointer GetJniEnv() { - return _GetJniEnv(); - } - - late final _GetJniEnvPtr = - _lookup Function()>>('GetJniEnv'); - late final _GetJniEnv = - _GetJniEnvPtr.asFunction Function()>(); + late final _DartException__ctorPtr = _lookup< + ffi.NativeFunction>( + 'DartException__ctor'); + late final _DartException__ctor = _DartException__ctorPtr.asFunction< + JniResult Function(JStringPtr, JThrowablePtr)>(); - /// Spawn a JVM with given arguments. + /// Returns application context on Android. /// - /// Returns JNI_OK on success, and one of the documented JNI error codes on - /// failure. It returns DART_JNI_SINGLETON_EXISTS if an attempt to spawn multiple - /// JVMs is made, even if the underlying API potentially supports multiple VMs. - JniErrorCode SpawnJvm( - ffi.Pointer args, - ) { - return JniErrorCode.fromValue(_SpawnJvm( - args, - )); + /// On other platforms, NULL is returned. + JObjectPtr GetApplicationContext() { + return _GetApplicationContext(); } - late final _SpawnJvmPtr = _lookup< - ffi.NativeFunction)>>( - 'SpawnJvm'); - late final _SpawnJvm = - _SpawnJvmPtr.asFunction)>(); + late final _GetApplicationContextPtr = + _lookup>( + 'GetApplicationContext'); + late final _GetApplicationContext = + _GetApplicationContextPtr.asFunction(); /// Returns Application classLoader (on Android), /// which can be used to load application and platform classes. @@ -148,19 +105,6 @@ class JniBindings { late final _GetClassLoader = _GetClassLoaderPtr.asFunction(); - /// Returns application context on Android. - /// - /// On other platforms, NULL is returned. - JObjectPtr GetApplicationContext() { - return _GetApplicationContext(); - } - - late final _GetApplicationContextPtr = - _lookup>( - 'GetApplicationContext'); - late final _GetApplicationContext = - _GetApplicationContextPtr.asFunction(); - /// Returns current activity of the app on Android. JObjectPtr GetCurrentActivity() { return _GetCurrentActivity(); @@ -171,6 +115,48 @@ class JniBindings { late final _GetCurrentActivity = _GetCurrentActivityPtr.asFunction(); + int GetCurrentIsolateId() { + return _GetCurrentIsolateId(); + } + + late final _GetCurrentIsolateIdPtr = + _lookup>('GetCurrentIsolateId'); + late final _GetCurrentIsolateId = + _GetCurrentIsolateIdPtr.asFunction(); + + JniExceptionDetails GetExceptionDetails( + JThrowablePtr exception, + ) { + return _GetExceptionDetails( + exception, + ); + } + + late final _GetExceptionDetailsPtr = + _lookup>( + 'GetExceptionDetails'); + late final _GetExceptionDetails = _GetExceptionDetailsPtr.asFunction< + JniExceptionDetails Function(JThrowablePtr)>(); + + ffi.Pointer GetGlobalEnv() { + return _GetGlobalEnv(); + } + + late final _GetGlobalEnvPtr = + _lookup Function()>>( + 'GetGlobalEnv'); + late final _GetGlobalEnv = + _GetGlobalEnvPtr.asFunction Function()>(); + + ffi.Pointer GetJniEnv() { + return _GetJniEnv(); + } + + late final _GetJniEnvPtr = + _lookup Function()>>('GetJniEnv'); + late final _GetJniEnv = + _GetJniEnvPtr.asFunction Function()>(); + int InitDartApiDL( ffi.Pointer data, ) { @@ -185,30 +171,28 @@ class JniBindings { late final _InitDartApiDL = _InitDartApiDLPtr.asFunction)>(); - int GetCurrentIsolateId() { - return _GetCurrentIsolateId(); + JniClassLookupResult JniFindClass( + ffi.Pointer name, + ) { + return _JniFindClass( + name, + ); } - late final _GetCurrentIsolateIdPtr = - _lookup>('GetCurrentIsolateId'); - late final _GetCurrentIsolateId = - _GetCurrentIsolateIdPtr.asFunction(); + late final _JniFindClassPtr = _lookup< + ffi.NativeFunction< + JniClassLookupResult Function(ffi.Pointer)>>('FindClass'); + late final _JniFindClass = _JniFindClassPtr.asFunction< + JniClassLookupResult Function(ffi.Pointer)>(); - JniResult DartException__ctor( - JStringPtr message, - JThrowablePtr cause, - ) { - return _DartException__ctor( - message, - cause, - ); + ffi.Pointer JniGetJavaVM() { + return _JniGetJavaVM(); } - late final _DartException__ctorPtr = _lookup< - ffi.NativeFunction>( - 'DartException__ctor'); - late final _DartException__ctor = _DartException__ctorPtr.asFunction< - JniResult Function(JStringPtr, JThrowablePtr)>(); + late final _JniGetJavaVMPtr = + _lookup Function()>>('GetJavaVM'); + late final _JniGetJavaVM = + _JniGetJavaVMPtr.asFunction Function()>(); JniResult PortContinuation__ctor( int j, @@ -224,41 +208,51 @@ class JniBindings { late final _PortContinuation__ctor = _PortContinuation__ctorPtr.asFunction(); - void resultFor( - ffi.Pointer result, - JObjectPtr object, + /// Spawn a JVM with given arguments. + /// + /// Returns JNI_OK on success, and one of the documented JNI error codes on + /// failure. It returns DART_JNI_SINGLETON_EXISTS if an attempt to spawn multiple + /// JVMs is made, even if the underlying API potentially supports multiple VMs. + JniErrorCode SpawnJvm( + ffi.Pointer args, ) { - return _resultFor( - result, - object, - ); + return JniErrorCode.fromValue(_SpawnJvm( + args, + )); } - late final _resultForPtr = _lookup< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer, JObjectPtr)>>('resultFor'); - late final _resultFor = _resultForPtr - .asFunction, JObjectPtr)>(); + late final _SpawnJvmPtr = _lookup< + ffi.NativeFunction)>>( + 'SpawnJvm'); + late final _SpawnJvm = + _SpawnJvmPtr.asFunction)>(); - Dart_FinalizableHandle newJObjectFinalizableHandle( + void deleteFinalizableHandle( + Dart_FinalizableHandle finalizableHandle, Object object, - JObjectPtr reference, - JObjectRefType refType, ) { - return _newJObjectFinalizableHandle( + return _deleteFinalizableHandle( + finalizableHandle, object, - reference, - refType.value, ); } - late final _newJObjectFinalizableHandlePtr = _lookup< + late final _deleteFinalizableHandlePtr = _lookup< ffi.NativeFunction< - Dart_FinalizableHandle Function(ffi.Handle, JObjectPtr, - ffi.UnsignedInt)>>('newJObjectFinalizableHandle'); - late final _newJObjectFinalizableHandle = _newJObjectFinalizableHandlePtr - .asFunction(); + ffi.Void Function( + Dart_FinalizableHandle, ffi.Handle)>>('deleteFinalizableHandle'); + late final _deleteFinalizableHandle = _deleteFinalizableHandlePtr + .asFunction(); + + int getCaptureStackTraceOnRelease() { + return _getCaptureStackTraceOnRelease(); + } + + late final _getCaptureStackTraceOnReleasePtr = + _lookup>( + 'getCaptureStackTraceOnRelease'); + late final _getCaptureStackTraceOnRelease = + _getCaptureStackTraceOnReleasePtr.asFunction(); Dart_FinalizableHandle newBooleanFinalizableHandle( Object object, @@ -278,50 +272,28 @@ class JniBindings { _newBooleanFinalizableHandlePtr.asFunction< Dart_FinalizableHandle Function(Object, ffi.Pointer)>(); - void deleteFinalizableHandle( - Dart_FinalizableHandle finalizableHandle, + Dart_FinalizableHandle newJObjectFinalizableHandle( Object object, + JObjectPtr reference, + JObjectRefType refType, ) { - return _deleteFinalizableHandle( - finalizableHandle, + return _newJObjectFinalizableHandle( object, + reference, + refType.value, ); } - late final _deleteFinalizableHandlePtr = _lookup< + late final _newJObjectFinalizableHandlePtr = _lookup< ffi.NativeFunction< - ffi.Void Function( - Dart_FinalizableHandle, ffi.Handle)>>('deleteFinalizableHandle'); - late final _deleteFinalizableHandle = _deleteFinalizableHandlePtr - .asFunction(); + Dart_FinalizableHandle Function(ffi.Handle, JObjectPtr, + ffi.UnsignedInt)>>('newJObjectFinalizableHandle'); + late final _newJObjectFinalizableHandle = _newJObjectFinalizableHandlePtr + .asFunction(); - void setCaptureStackTraceOnRelease( - int value, - ) { - return _setCaptureStackTraceOnRelease( - value, - ); - } - - late final _setCaptureStackTraceOnReleasePtr = - _lookup>( - 'setCaptureStackTraceOnRelease'); - late final _setCaptureStackTraceOnRelease = - _setCaptureStackTraceOnReleasePtr.asFunction(); - - int getCaptureStackTraceOnRelease() { - return _getCaptureStackTraceOnRelease(); - } - - late final _getCaptureStackTraceOnReleasePtr = - _lookup>( - 'getCaptureStackTraceOnRelease'); - late final _getCaptureStackTraceOnRelease = - _getCaptureStackTraceOnReleasePtr.asFunction(); - - Dart_FinalizableHandle newStackTraceFinalizableHandle( - Object object, - ffi.Pointer reference, + Dart_FinalizableHandle newStackTraceFinalizableHandle( + Object object, + ffi.Pointer reference, ) { return _newStackTraceFinalizableHandle( object, @@ -337,2719 +309,3696 @@ class JniBindings { _newStackTraceFinalizableHandlePtr.asFunction< Dart_FinalizableHandle Function(Object, ffi.Pointer)>(); - ffi.Pointer GetGlobalEnv() { - return _GetGlobalEnv(); + void resultFor( + ffi.Pointer result, + JObjectPtr object, + ) { + return _resultFor( + result, + object, + ); } - late final _GetGlobalEnvPtr = - _lookup Function()>>( - 'GetGlobalEnv'); - late final _GetGlobalEnv = - _GetGlobalEnvPtr.asFunction Function()>(); -} + late final _resultForPtr = _lookup< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, JObjectPtr)>>('resultFor'); + late final _resultFor = _resultForPtr + .asFunction, JObjectPtr)>(); -enum JniBooleanValues { - FALSE(0), - TRUE(1); + void setCaptureStackTraceOnRelease( + int value, + ) { + return _setCaptureStackTraceOnRelease( + value, + ); + } - final int value; - const JniBooleanValues(this.value); + late final _setCaptureStackTraceOnReleasePtr = + _lookup>( + 'setCaptureStackTraceOnRelease'); + late final _setCaptureStackTraceOnRelease = + _setCaptureStackTraceOnReleasePtr.asFunction(); - static JniBooleanValues fromValue(int value) => switch (value) { - 0 => FALSE, - 1 => TRUE, - _ => throw ArgumentError('Unknown value for JniBooleanValues: $value'), - }; + late final ffi.Pointer _tlsKey = + _lookup('tlsKey'); + + Dartpthread_key_t get tlsKey => _tlsKey.value; + + set tlsKey(Dartpthread_key_t value) => _tlsKey.value = value; } -enum JniVersions { - VERSION_1_1(65537), - VERSION_1_2(65538), - VERSION_1_4(65540), - VERSION_1_6(65542); +final class CallbackResult extends ffi.Struct { + external MutexLock lock; - final int value; - const JniVersions(this.value); + external ConditionVariable cond; - static JniVersions fromValue(int value) => switch (value) { - 65537 => VERSION_1_1, - 65538 => VERSION_1_2, - 65540 => VERSION_1_4, - 65542 => VERSION_1_6, - _ => throw ArgumentError('Unknown value for JniVersions: $value'), - }; -} + @ffi.Int() + external int ready; -enum JniErrorCode { - /// no error - OK(0), + external JObjectPtr object; +} - /// generic error - ERR(-1), +typedef ConditionVariable = pthread_cond_t; +typedef Dart_FinalizableHandle = ffi.Pointer; - /// thread detached from the VM - EDETACHED(-2), +final class Dart_FinalizableHandle_ extends ffi.Opaque {} - /// JNI version error - EVERSION(-3), +final class GlobalJniEnvStruct extends ffi.Struct { + external ffi.Pointer reserved0; - /// Out of memory - ENOMEM(-4), + external ffi.Pointer reserved1; - /// VM already created - EEXIST(-5), + external ffi.Pointer reserved2; - /// Invalid argument - EINVAL(-6), - SINGLETON_EXISTS(-99); + external ffi.Pointer reserved3; - final int value; - const JniErrorCode(this.value); + external ffi.Pointer> GetVersion; - static JniErrorCode fromValue(int value) => switch (value) { - 0 => OK, - -1 => ERR, - -2 => EDETACHED, - -3 => EVERSION, - -4 => ENOMEM, - -5 => EEXIST, - -6 => EINVAL, - -99 => SINGLETON_EXISTS, - _ => throw ArgumentError('Unknown value for JniErrorCode: $value'), - }; -} + external ffi.Pointer< + ffi.NativeFunction< + JniClassLookupResult Function( + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + JSizeMarker bufLen)>> DefineClass; -enum JniBufferWriteBack { - /// copy content, do not free buffer - COMMIT(1), + external ffi.Pointer< + ffi.NativeFunction< + JniClassLookupResult Function(ffi.Pointer name)>> FindClass; - /// free buffer w/o copying back - ABORT(2); + external ffi + .Pointer> + FromReflectedMethod; - final int value; - const JniBufferWriteBack(this.value); + external ffi + .Pointer> + FromReflectedField; - static JniBufferWriteBack fromValue(int value) => switch (value) { - 1 => COMMIT, - 2 => ABORT, - _ => - throw ArgumentError('Unknown value for JniBufferWriteBack: $value'), - }; -} + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodId, + JBooleanMarker isStatic)>> ToReflectedMethod; -final class _opaque_pthread_mutex_t extends ffi.Struct { - @ffi.Long() - external int __sig; + external ffi.Pointer< + ffi.NativeFunction> + GetSuperclass; - @ffi.Array.multi([56]) - external ffi.Array __opaque; -} + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz1, JClassPtr clazz2)>> + IsAssignableFrom; -typedef __darwin_pthread_mutex_t = _opaque_pthread_mutex_t; -typedef pthread_mutex_t = __darwin_pthread_mutex_t; -typedef MutexLock = pthread_mutex_t; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JClassPtr cls, JFieldIDPtr fieldID, JBooleanMarker isStatic)>> + ToReflectedField; -final class _opaque_pthread_cond_t extends ffi.Struct { - @ffi.Long() - external int __sig; + external ffi + .Pointer> Throw; - @ffi.Array.multi([40]) - external ffi.Array __opaque; -} + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JClassPtr clazz, ffi.Pointer message)>> ThrowNew; -typedef __darwin_pthread_cond_t = _opaque_pthread_cond_t; -typedef pthread_cond_t = __darwin_pthread_cond_t; -typedef ConditionVariable = pthread_cond_t; + external ffi.Pointer> + ExceptionOccurred; -/// Reference types, in C. -typedef JObjectPtr = ffi.Pointer; + external ffi.Pointer> + ExceptionDescribe; -final class CallbackResult extends ffi.Struct { - external MutexLock lock; + external ffi.Pointer> + ExceptionClear; - external ConditionVariable cond; + external ffi.Pointer< + ffi.NativeFunction msg)>> + FatalError; - @ffi.Int() - external int ready; + external ffi + .Pointer> + PushLocalFrame; - external JObjectPtr object; -} + external ffi + .Pointer> + PopLocalFrame; -typedef __darwin_pthread_key_t = ffi.UnsignedLong; -typedef Dart__darwin_pthread_key_t = int; -typedef pthread_key_t = __darwin_pthread_key_t; + external ffi.Pointer> + NewGlobalRef; -/// Types used by JNI API to distinguish between primitive types. -enum JniCallType { - booleanType(0), - byteType(1), - shortType(2), - charType(3), - intType(4), - longType(5), - floatType(6), - doubleType(7), - objectType(8), - voidType(9); + external ffi + .Pointer> + DeleteGlobalRef; - final int value; - const JniCallType(this.value); + external ffi + .Pointer> + DeleteLocalRef; - static JniCallType fromValue(int value) => switch (value) { - 0 => booleanType, - 1 => byteType, - 2 => shortType, - 3 => charType, - 4 => intType, - 5 => longType, - 6 => floatType, - 7 => doubleType, - 8 => objectType, - 9 => voidType, - _ => throw ArgumentError('Unknown value for JniCallType: $value'), - }; -} + external ffi.Pointer< + ffi + .NativeFunction> + IsSameObject; -/// Primitive types that match up with Java equivalents. -typedef JBooleanMarker = ffi.Uint8; -typedef DartJBooleanMarker = int; -typedef JByteMarker = ffi.Int8; -typedef DartJByteMarker = int; -typedef JCharMarker = ffi.Uint16; -typedef DartJCharMarker = int; -typedef JShortMarker = ffi.Int16; -typedef DartJShortMarker = int; -typedef JIntMarker = ffi.Int32; -typedef DartJIntMarker = int; -typedef JLongMarker = ffi.Int64; -typedef DartJLongMarker = int; -typedef JFloatMarker = ffi.Float; -typedef DartJFloatMarker = double; -typedef JDoubleMarker = ffi.Double; -typedef DartJDoubleMarker = double; - -final class JValue extends ffi.Union { - @JBooleanMarker() - external int z; - - @JByteMarker() - external int b; - - @JCharMarker() - external int c; - - @JShortMarker() - external int s; - - @JIntMarker() - external int i; - - @JLongMarker() - external int j; - - @JFloatMarker() - external double f; - - @JDoubleMarker() - external double d; - - external JObjectPtr l; -} - -typedef JThrowablePtr = JObjectPtr; - -/// Result type for use by JNI. -/// -/// If [exception] is null, it means the result is valid. -/// It's assumed that the caller knows the expected type in [result]. -final class JniResult extends ffi.Struct { - external JValue value; - - external JThrowablePtr exception; -} - -typedef JClassPtr = JObjectPtr; - -/// Similar to [JniResult] but for class lookups. -final class JniClassLookupResult extends ffi.Struct { - external JClassPtr value; - - external JThrowablePtr exception; -} - -/// Similar to [JniResult] but for method/field ID lookups. -final class JniPointerResult extends ffi.Struct { - external ffi.Pointer value; - - external JThrowablePtr exception; -} - -typedef JStringPtr = JObjectPtr; - -/// JniExceptionDetails holds 2 jstring objects, one is the result of -/// calling `toString` on exception object, other is stack trace; -final class JniExceptionDetails extends ffi.Struct { - external JStringPtr message; - - external JStringPtr stacktrace; -} - -typedef JavaVM$1 = ffi.Pointer; -typedef JniEnv$1 = ffi.Pointer; - -/// "cardinal indices and sizes" -typedef JSizeMarker = JIntMarker; - -final class jmethodID_ extends ffi.Opaque {} - -typedef JMethodIDPtr = ffi.Pointer; - -final class jfieldID_ extends ffi.Opaque {} - -typedef JFieldIDPtr = ffi.Pointer; -typedef JArrayPtr = JObjectPtr; -typedef JObjectArrayPtr = JArrayPtr; -typedef JBooleanArrayPtr = JArrayPtr; -typedef JByteArrayPtr = JArrayPtr; -typedef JCharArrayPtr = JArrayPtr; -typedef JShortArrayPtr = JArrayPtr; -typedef JIntArrayPtr = JArrayPtr; -typedef JLongArrayPtr = JArrayPtr; -typedef JFloatArrayPtr = JArrayPtr; -typedef JDoubleArrayPtr = JArrayPtr; - -final class JNINativeMethod extends ffi.Struct { - external ffi.Pointer name; - - external ffi.Pointer signature; - - external ffi.Pointer fnPtr; -} - -typedef JWeakPtr = JObjectPtr; - -enum JObjectRefType { - JNIInvalidRefType(0), - JNILocalRefType(1), - JNIGlobalRefType(2), - JNIWeakGlobalRefType(3); - - final int value; - const JObjectRefType(this.value); + external ffi.Pointer> + NewLocalRef; - static JObjectRefType fromValue(int value) => switch (value) { - 0 => JNIInvalidRefType, - 1 => JNILocalRefType, - 2 => JNIGlobalRefType, - 3 => JNIWeakGlobalRefType, - _ => throw ArgumentError('Unknown value for JObjectRefType: $value'), - }; -} + external ffi + .Pointer> + EnsureLocalCapacity; -/// Table of interface function pointers. -final class JNINativeInterface extends ffi.Struct { - external ffi.Pointer reserved0; + external ffi.Pointer> + AllocObject; - external ffi.Pointer reserved1; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + NewObject; - external ffi.Pointer reserved2; + external ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> NewObjectA; - external ffi.Pointer reserved3; + external ffi.Pointer< + ffi.NativeFunction> + GetObjectClass; external ffi.Pointer< - ffi.NativeFunction env)>> - GetVersion; + ffi + .NativeFunction> + IsInstanceOf; external ffi.Pointer< ffi.NativeFunction< - JClassPtr Function( - ffi.Pointer env, - ffi.Pointer name, - JObjectPtr loader, - ffi.Pointer buf, - JSizeMarker bufLen)>> DefineClass; + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetMethodID; external ffi.Pointer< ffi.NativeFunction< - JClassPtr Function( - ffi.Pointer env, ffi.Pointer name)>> - FindClass; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallObjectMethod; external ffi.Pointer< - ffi.NativeFunction< - JMethodIDPtr Function( - ffi.Pointer env, JObjectPtr method)>> - FromReflectedMethod; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallObjectMethodA; external ffi.Pointer< - ffi.NativeFunction< - JFieldIDPtr Function( - ffi.Pointer env, JObjectPtr field)>> FromReflectedField; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallBooleanMethod; - /// spec doesn't show jboolean parameter external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer env, - JClassPtr cls, - JMethodIDPtr methodId, - JBooleanMarker isStatic)>> ToReflectedMethod; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodId, + ffi.Pointer args)>> CallBooleanMethodA; external ffi.Pointer< ffi.NativeFunction< - JClassPtr Function(ffi.Pointer env, JClassPtr clazz)>> - GetSuperclass; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallByteMethod; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz1, - JClassPtr clazz2)>> IsAssignableFrom; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallByteMethodA; - /// spec doesn't show jboolean parameter external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr cls, - JFieldIDPtr fieldID, JBooleanMarker isStatic)>> ToReflectedField; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallCharMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer env, JThrowablePtr obj)>> Throw; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallCharMethodA; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JClassPtr clazz, - ffi.Pointer message)>> ThrowNew; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallShortMethod; external ffi.Pointer< - ffi.NativeFunction env)>> - ExceptionOccurred; - - external ffi - .Pointer env)>> - ExceptionDescribe; - - external ffi - .Pointer env)>> - ExceptionClear; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallShortMethodA; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, ffi.Pointer msg)>> - FatalError; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallIntMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer env, JIntMarker capacity)>> PushLocalFrame; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallIntMethodA; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer env, JObjectPtr result)>> PopLocalFrame; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallLongMethod; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> - NewGlobalRef; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallLongMethodA; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, JObjectPtr globalRef)>> - DeleteGlobalRef; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallFloatMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, JObjectPtr localRef)>> DeleteLocalRef; - - external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer env, JObjectPtr ref1, JObjectPtr ref2)>> - IsSameObject; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallFloatMethodA; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> - NewLocalRef; + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallDoubleMethod; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer env, JIntMarker capacity)>> - EnsureLocalCapacity; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallDoubleMethodA; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz)>> - AllocObject; + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallVoidMethod; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> NewObject; + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> CallVoidMethodA; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> NewObjectV; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualObjectMethod; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID, ffi.Pointer args)>> NewObjectA; - - external ffi.Pointer< - ffi.NativeFunction< - JClassPtr Function(ffi.Pointer env, JObjectPtr obj)>> - GetObjectClass; + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualObjectMethodA; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer env, JObjectPtr obj, JClassPtr clazz)>> - IsInstanceOf; + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualBooleanMethod; external ffi.Pointer< ffi.NativeFunction< - JMethodIDPtr Function( - ffi.Pointer env, + JniResult Function( + JObjectPtr obj, JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>> GetMethodID; - - external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallObjectMethod; + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualBooleanMethodA; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallObjectMethodV; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualByteMethod; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer env, + JniResult Function( JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallObjectMethodA; - - external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallBooleanMethod; + ffi.Pointer args)>> CallNonvirtualByteMethodA; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer, JObjectPtr, - JMethodIDPtr, ffi.Pointer)>> CallBooleanMethodV; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualCharMethod; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer env, + JniResult Function( JObjectPtr obj, - JMethodIDPtr methodId, - ffi.Pointer args)>> CallBooleanMethodA; - - external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallByteMethod; + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualCharMethodA; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallByteMethodV; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualShortMethod; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer env, + JniResult Function( JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallByteMethodA; - - external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallCharMethod; + ffi.Pointer args)>> CallNonvirtualShortMethodA; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallCharMethodV; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualIntMethod; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer env, + JniResult Function( JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallCharMethodA; - - external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallShortMethod; + ffi.Pointer args)>> CallNonvirtualIntMethodA; external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallShortMethodV; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualLongMethod; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer env, + JniResult Function( JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallShortMethodA; + ffi.Pointer args)>> CallNonvirtualLongMethodA; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallIntMethod; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualFloatMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallIntMethodV; + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualFloatMethodA; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID, ffi.Pointer args)>> CallIntMethodA; + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallLongMethod; + JniResult Function( + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualDoubleMethodA; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallLongMethodV; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualVoidMethod; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer env, + JThrowablePtr Function( JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallLongMethodA; + ffi.Pointer args)>> CallNonvirtualVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallFloatMethod; + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetFieldID; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallFloatMethodV; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetObjectField; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallFloatMethodA; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallDoubleMethod; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetByteField; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer, JObjectPtr, - JMethodIDPtr, ffi.Pointer)>> CallDoubleMethodV; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetCharField; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallDoubleMethodA; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetShortField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JMethodIDPtr methodID)>> CallVoidMethod; + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetIntField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, - ffi.Pointer)>> CallVoidMethodV; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetLongField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JObjectPtr obj, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallVoidMethodA; - + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetFloatField; + external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualObjectMethod; + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer, - JObjectPtr, - JClassPtr, - JMethodIDPtr, - ffi.Pointer)>> CallNonvirtualObjectMethodV; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val)>> + SetObjectField; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualObjectMethodA; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JBooleanMarker val)>> + SetBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualBooleanMethod; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JByteMarker val)>> + SetByteField; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer, - JObjectPtr, - JClassPtr, - JMethodIDPtr, - ffi.Pointer)>> CallNonvirtualBooleanMethodV; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JCharMarker val)>> + SetCharField; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualBooleanMethodA; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JShortMarker val)>> + SetShortField; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualByteMethod; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JIntMarker val)>> + SetIntField; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualByteMethodV; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JLongMarker val)>> + SetLongField; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualByteMethodA; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JFloatMarker val)>> + SetFloatField; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualCharMethod; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JDoubleMarker val)>> + SetDoubleField; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualCharMethodV; + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetStaticMethodID; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualCharMethodA; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticObjectMethod; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualShortMethod; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticObjectMethodA; external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualShortMethodV; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticBooleanMethod; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualShortMethodA; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticBooleanMethodA; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JObjectPtr obj, - JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualIntMethod; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticByteMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualIntMethodV; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticByteMethodA; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualIntMethodA; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticCharMethod; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualLongMethod; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticCharMethodA; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualLongMethodV; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticShortMethod; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualLongMethodA; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticShortMethodA; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualFloatMethod; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticIntMethod; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualFloatMethodV; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticIntMethodA; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualFloatMethodA; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticLongMethod; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualDoubleMethod; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticLongMethodA; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer, - JObjectPtr, - JClassPtr, - JMethodIDPtr, - ffi.Pointer)>> CallNonvirtualDoubleMethodV; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticFloatMethod; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualDoubleMethodA; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticFloatMethodA; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID)>> CallNonvirtualVoidMethod; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JObjectPtr, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallNonvirtualVoidMethodV; + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticDoubleMethodA; + + external ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticVoidMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualVoidMethodA; + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JFieldIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>> GetFieldID; + JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, + ffi.Pointer sig)>> GetStaticFieldID; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetObjectField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticObjectField; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetBooleanField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetByteField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticByteField; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetCharField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticCharField; external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetShortField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticShortField; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetIntField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticIntField; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetLongField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticLongField; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetFloatField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID)>> GetDoubleField; + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticDoubleField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JObjectPtr val)>> SetObjectField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val)>> + SetStaticObjectField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JBooleanMarker val)>> SetBooleanField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JBooleanMarker val)>> + SetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JByteMarker val)>> SetByteField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JByteMarker val)>> + SetStaticByteField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JCharMarker val)>> SetCharField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JCharMarker val)>> + SetStaticCharField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JShortMarker val)>> SetShortField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JShortMarker val)>> + SetStaticShortField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JIntMarker val)>> SetIntField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JIntMarker val)>> + SetStaticIntField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JLongMarker val)>> SetLongField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JLongMarker val)>> + SetStaticLongField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JFloatMarker val)>> SetFloatField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JFloatMarker val)>> + SetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectPtr obj, - JFieldIDPtr fieldID, JDoubleMarker val)>> SetDoubleField; + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JDoubleMarker val)>> + SetStaticDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JMethodIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>> GetStaticMethodID; + ffi.NativeFunction< + JniResult Function( + ffi.Pointer unicodeChars, JSizeMarker len)>> + NewString; - external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticObjectMethod; + external ffi + .Pointer> + GetStringLength; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticObjectMethodV; + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>> + GetStringChars; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticObjectMethodA; + ffi.NativeFunction< + JThrowablePtr Function( + JStringPtr string, ffi.Pointer isCopy)>> + ReleaseStringChars; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticBooleanMethod; + ffi.NativeFunction bytes)>> + NewStringUTF; - external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer, JClassPtr, - JMethodIDPtr, ffi.Pointer)>> CallStaticBooleanMethodV; + external ffi + .Pointer> + GetStringUTFLength; external ffi.Pointer< - ffi.NativeFunction< - JBooleanMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticBooleanMethodA; + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>> + GetStringUTFChars; external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticByteMethod; + ffi.NativeFunction< + JThrowablePtr Function( + JStringPtr string, ffi.Pointer utf)>> + ReleaseStringUTFChars; - external ffi.Pointer< - ffi.NativeFunction< - JByteMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticByteMethodV; + external ffi.Pointer> + GetArrayLength; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticByteMethodA; + JniResult Function(JSizeMarker length, JClassPtr elementClass, + JObjectPtr initialElement)>> NewObjectArray; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticCharMethod; + ffi.NativeFunction< + JniResult Function(JObjectArrayPtr array, JSizeMarker index)>> + GetObjectArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticCharMethodV; + ffi.NativeFunction< + JThrowablePtr Function( + JObjectArrayPtr array, JSizeMarker index, JObjectPtr val)>> + SetObjectArrayElement; - external ffi.Pointer< - ffi.NativeFunction< - JCharMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticCharMethodA; + external ffi + .Pointer> + NewBooleanArray; - external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticShortMethod; + external ffi + .Pointer> + NewByteArray; - external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticShortMethodV; + external ffi + .Pointer> + NewCharArray; - external ffi.Pointer< - ffi.NativeFunction< - JShortMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticShortMethodA; + external ffi + .Pointer> + NewShortArray; - external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticIntMethod; + external ffi + .Pointer> + NewIntArray; - external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticIntMethodV; + external ffi + .Pointer> + NewLongArray; - external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticIntMethodA; + external ffi + .Pointer> + NewFloatArray; - external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticLongMethod; + external ffi + .Pointer> + NewDoubleArray; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticLongMethodV; + ffi.NativeFunction< + JniPointerResult Function( + JBooleanArrayPtr array, ffi.Pointer isCopy)>> + GetBooleanArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticLongMethodA; + ffi.NativeFunction< + JniPointerResult Function( + JByteArrayPtr array, ffi.Pointer isCopy)>> + GetByteArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticFloatMethod; + ffi.NativeFunction< + JniPointerResult Function( + JCharArrayPtr array, ffi.Pointer isCopy)>> + GetCharArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticFloatMethodV; + ffi.NativeFunction< + JniPointerResult Function( + JShortArrayPtr array, ffi.Pointer isCopy)>> + GetShortArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JFloatMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticFloatMethodA; + ffi.NativeFunction< + JniPointerResult Function( + JIntArrayPtr array, ffi.Pointer isCopy)>> + GetIntArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticDoubleMethod; + ffi.NativeFunction< + JniPointerResult Function( + JLongArrayPtr array, ffi.Pointer isCopy)>> + GetLongArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticDoubleMethodV; + ffi.NativeFunction< + JniPointerResult Function( + JFloatArrayPtr array, ffi.Pointer isCopy)>> + GetFloatArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JDoubleMarker Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticDoubleMethodA; + ffi.NativeFunction< + JniPointerResult Function( + JDoubleArrayPtr array, ffi.Pointer isCopy)>> + GetDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID)>> CallStaticVoidMethod; + JThrowablePtr Function( + JBooleanArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseBooleanArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, JClassPtr, JMethodIDPtr, - ffi.Pointer)>> CallStaticVoidMethodV; + JThrowablePtr Function( + JByteArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseByteArrayElements; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticVoidMethodA; + JThrowablePtr Function( + JCharArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseCharArrayElements; external ffi.Pointer< ffi.NativeFunction< - JFieldIDPtr Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer name, - ffi.Pointer sig)>> GetStaticFieldID; + JThrowablePtr Function( + JShortArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseShortArrayElements; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticObjectField; + JThrowablePtr Function( + JIntArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseIntArrayElements; external ffi.Pointer< ffi.NativeFunction< - JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticBooleanField; + JThrowablePtr Function( + JLongArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseLongArrayElements; external ffi.Pointer< ffi.NativeFunction< - JByteMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticByteField; + JThrowablePtr Function( + JFloatArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseFloatArrayElements; external ffi.Pointer< ffi.NativeFunction< - JCharMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticCharField; + JThrowablePtr Function( + JDoubleArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> ReleaseDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< - JShortMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticShortField; + JThrowablePtr Function( + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetBooleanArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticIntField; + JThrowablePtr Function( + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetByteArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JLongMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticLongField; + JThrowablePtr Function( + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetCharArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JFloatMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticFloatField; + JThrowablePtr Function( + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetShortArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JDoubleMarker Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID)>> GetStaticDoubleField; + JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> GetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JObjectPtr val)>> SetStaticObjectField; + JThrowablePtr Function( + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetLongArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JBooleanMarker val)>> SetStaticBooleanField; + JThrowablePtr Function( + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetFloatArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JByteMarker val)>> SetStaticByteField; + JThrowablePtr Function( + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetDoubleArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JCharMarker val)>> SetStaticCharField; + JThrowablePtr Function( + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetBooleanArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JShortMarker val)>> SetStaticShortField; + JThrowablePtr Function( + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetByteArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JIntMarker val)>> SetStaticIntField; + JThrowablePtr Function( + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetCharArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JLongMarker val)>> SetStaticLongField; + JThrowablePtr Function( + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetShortArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JFloatMarker val)>> SetStaticFloatField; + JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> SetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JClassPtr clazz, - JFieldIDPtr fieldID, JDoubleMarker val)>> SetStaticDoubleField; + JThrowablePtr Function( + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetLongArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JStringPtr Function( - ffi.Pointer env, - ffi.Pointer unicodeChars, - JSizeMarker len)>> NewString; + JThrowablePtr Function( + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetFloatArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JSizeMarker Function( - ffi.Pointer env, JStringPtr string)>> GetStringLength; + JThrowablePtr Function( + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetDoubleArrayRegion; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JStringPtr string, - ffi.Pointer isCopy)>> GetStringChars; + JniResult Function( + JClassPtr clazz, + ffi.Pointer methods, + JIntMarker nMethods)>> RegisterNatives; + + external ffi.Pointer> + UnregisterNatives; + + external ffi.Pointer> + MonitorEnter; + + external ffi.Pointer> + MonitorExit; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JStringPtr string, - ffi.Pointer isCopy)>> ReleaseStringChars; + JniResult Function(ffi.Pointer> vm)>> GetJavaVM; external ffi.Pointer< - ffi.NativeFunction< - JStringPtr Function( - ffi.Pointer env, ffi.Pointer bytes)>> - NewStringUTF; + ffi.NativeFunction< + JThrowablePtr Function(JStringPtr str, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> GetStringRegion; external ffi.Pointer< - ffi.NativeFunction< - JSizeMarker Function( - ffi.Pointer env, JStringPtr string)>> - GetStringUTFLength; + ffi.NativeFunction< + JThrowablePtr Function(JStringPtr str, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> GetStringUTFRegion; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JStringPtr string, - ffi.Pointer isCopy)>> GetStringUTFChars; + ffi.NativeFunction< + JniPointerResult Function( + JArrayPtr array, ffi.Pointer isCopy)>> + GetPrimitiveArrayCritical; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JStringPtr string, - ffi.Pointer utf)>> ReleaseStringUTFChars; + JThrowablePtr Function(JArrayPtr array, ffi.Pointer carray, + JIntMarker mode)>> ReleasePrimitiveArrayCritical; external ffi.Pointer< ffi.NativeFunction< - JSizeMarker Function(ffi.Pointer env, JArrayPtr array)>> - GetArrayLength; + JniPointerResult Function( + JStringPtr str, ffi.Pointer isCopy)>> + GetStringCritical; external ffi.Pointer< - ffi.NativeFunction< - JObjectArrayPtr Function( - ffi.Pointer env, - JSizeMarker length, - JClassPtr elementClass, - JObjectPtr initialElement)>> NewObjectArray; + ffi.NativeFunction< + JThrowablePtr Function( + JStringPtr str, ffi.Pointer carray)>> + ReleaseStringCritical; + + external ffi.Pointer> + NewWeakGlobalRef; + + external ffi.Pointer> + DeleteWeakGlobalRef; + + external ffi.Pointer> ExceptionCheck; external ffi.Pointer< - ffi.NativeFunction< - JObjectPtr Function(ffi.Pointer env, JObjectArrayPtr array, - JSizeMarker index)>> GetObjectArrayElement; + ffi.NativeFunction< + JniResult Function( + ffi.Pointer address, JLongMarker capacity)>> + NewDirectByteBuffer; + + external ffi + .Pointer> + GetDirectBufferAddress; + + external ffi.Pointer> + GetDirectBufferCapacity; + + external ffi.Pointer> + GetObjectRefType; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JObjectArrayPtr array, - JSizeMarker index, JObjectPtr val)>> SetObjectArrayElement; + ffi.NativeFunction< + JniResult Function(JBooleanArrayPtr array, JSizeMarker index)>> + GetBooleanArrayElement; external ffi.Pointer< ffi.NativeFunction< - JBooleanArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewBooleanArray; + JThrowablePtr Function(JBooleanArrayPtr array, JSizeMarker index, + JBooleanMarker element)>> SetBooleanArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JByteArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewByteArray; + ffi.NativeFunction< + JniResult Function(JByteArrayPtr array, JSizeMarker index)>> + GetByteArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JCharArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewCharArray; + ffi.NativeFunction< + JThrowablePtr Function( + JByteArrayPtr array, JSizeMarker index, JByteMarker element)>> + SetByteArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JShortArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewShortArray; + ffi.NativeFunction< + JniResult Function(JCharArrayPtr array, JSizeMarker index)>> + GetCharArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JIntArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewIntArray; + ffi.NativeFunction< + JThrowablePtr Function( + JCharArrayPtr array, JSizeMarker index, JCharMarker element)>> + SetCharArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JLongArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewLongArray; + ffi.NativeFunction< + JniResult Function(JShortArrayPtr array, JSizeMarker index)>> + GetShortArrayElement; external ffi.Pointer< ffi.NativeFunction< - JFloatArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewFloatArray; + JThrowablePtr Function(JShortArrayPtr array, JSizeMarker index, + JShortMarker element)>> SetShortArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JDoubleArrayPtr Function( - ffi.Pointer env, JSizeMarker length)>> NewDoubleArray; + ffi.NativeFunction< + JniResult Function(JIntArrayPtr array, JSizeMarker index)>> + GetIntArrayElement; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JBooleanArrayPtr array, - ffi.Pointer isCopy)>> GetBooleanArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JIntArrayPtr array, JSizeMarker index, JIntMarker element)>> + SetIntArrayElement; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JByteArrayPtr array, - ffi.Pointer isCopy)>> GetByteArrayElements; + ffi.NativeFunction< + JniResult Function(JLongArrayPtr array, JSizeMarker index)>> + GetLongArrayElement; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JCharArrayPtr array, - ffi.Pointer isCopy)>> GetCharArrayElements; + ffi.NativeFunction< + JThrowablePtr Function( + JLongArrayPtr array, JSizeMarker index, JLongMarker element)>> + SetLongArrayElement; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JShortArrayPtr array, - ffi.Pointer isCopy)>> GetShortArrayElements; + ffi.NativeFunction< + JniResult Function(JFloatArrayPtr array, JSizeMarker index)>> + GetFloatArrayElement; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JIntArrayPtr array, - ffi.Pointer isCopy)>> GetIntArrayElements; + JThrowablePtr Function(JFloatArrayPtr array, JSizeMarker index, + JFloatMarker element)>> SetFloatArrayElement; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JLongArrayPtr array, - ffi.Pointer isCopy)>> GetLongArrayElements; + ffi.NativeFunction< + JniResult Function(JDoubleArrayPtr array, JSizeMarker index)>> + GetDoubleArrayElement; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JFloatArrayPtr array, - ffi.Pointer isCopy)>> GetFloatArrayElements; + JThrowablePtr Function(JDoubleArrayPtr array, JSizeMarker index, + JDoubleMarker element)>> SetDoubleArrayElement; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer reserved0, + required ffi.Pointer reserved1, + required ffi.Pointer reserved2, + required ffi.Pointer reserved3, + required ffi.Pointer> GetVersion, + required ffi.Pointer< + ffi.NativeFunction< + JniClassLookupResult Function( + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + JSizeMarker bufLen)>> + DefineClass, + required ffi.Pointer< + ffi.NativeFunction< + JniClassLookupResult Function(ffi.Pointer name)>> + FindClass, + required ffi.Pointer< + ffi.NativeFunction> + FromReflectedMethod, + required ffi.Pointer< + ffi.NativeFunction> + FromReflectedField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr cls, JMethodIDPtr methodId, + JBooleanMarker isStatic)>> + ToReflectedMethod, + required ffi.Pointer< + ffi.NativeFunction> + GetSuperclass, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz1, JClassPtr clazz2)>> + IsAssignableFrom, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr cls, JFieldIDPtr fieldID, + JBooleanMarker isStatic)>> + ToReflectedField, + required ffi + .Pointer> + Throw, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JClassPtr clazz, ffi.Pointer message)>> + ThrowNew, + required ffi.Pointer> + ExceptionOccurred, + required ffi.Pointer> + ExceptionDescribe, + required ffi.Pointer> + ExceptionClear, + required ffi.Pointer< + ffi + .NativeFunction msg)>> + FatalError, + required ffi + .Pointer> + PushLocalFrame, + required ffi + .Pointer> + PopLocalFrame, + required ffi.Pointer> + NewGlobalRef, + required ffi.Pointer< + ffi.NativeFunction> + DeleteGlobalRef, + required ffi.Pointer< + ffi.NativeFunction> + DeleteLocalRef, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr ref1, JObjectPtr ref2)>> + IsSameObject, + required ffi.Pointer> + NewLocalRef, + required ffi + .Pointer> + EnsureLocalCapacity, + required ffi + .Pointer> + AllocObject, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + NewObject, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + NewObjectA, + required ffi.Pointer< + ffi.NativeFunction> + GetObjectClass, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz)>> + IsInstanceOf, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, + ffi.Pointer name, ffi.Pointer sig)>> + GetMethodID, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallObjectMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallObjectMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallBooleanMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodId, + ffi.Pointer args)>> + CallBooleanMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallByteMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallByteMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallCharMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallCharMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallShortMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallShortMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallIntMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallIntMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallLongMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallLongMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallFloatMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallFloatMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallDoubleMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallDoubleMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID)>> + CallVoidMethod, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallVoidMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualObjectMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualObjectMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualBooleanMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualBooleanMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualByteMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualByteMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualCharMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualCharMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualShortMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualShortMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualIntMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualIntMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualLongMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualLongMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualFloatMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualFloatMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualDoubleMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualDoubleMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualVoidMethod, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JObjectPtr obj, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallNonvirtualVoidMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, + ffi.Pointer name, ffi.Pointer sig)>> + GetFieldID, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetObjectField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetByteField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetCharField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetShortField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetIntField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetLongField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetFloatField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> + GetDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val)>> + SetObjectField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JBooleanMarker val)>> + SetBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JByteMarker val)>> + SetByteField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JCharMarker val)>> + SetCharField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JShortMarker val)>> + SetShortField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JIntMarker val)>> + SetIntField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JLongMarker val)>> + SetLongField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JFloatMarker val)>> + SetFloatField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectPtr obj, JFieldIDPtr fieldID, JDoubleMarker val)>> + SetDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, + ffi.Pointer name, ffi.Pointer sig)>> + GetStaticMethodID, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticObjectMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticObjectMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticBooleanMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticBooleanMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticByteMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticByteMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticCharMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticCharMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticShortMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticShortMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticIntMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticIntMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticLongMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticLongMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticFloatMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticFloatMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticDoubleMethod, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticDoubleMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticVoidMethod, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticVoidMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JClassPtr clazz, + ffi.Pointer name, ffi.Pointer sig)>> + GetStaticFieldID, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticObjectField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticByteField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticCharField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticShortField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticIntField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticLongField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticFloatField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val)>> + SetStaticObjectField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JBooleanMarker val)>> + SetStaticBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JByteMarker val)>> + SetStaticByteField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JCharMarker val)>> + SetStaticCharField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JShortMarker val)>> + SetStaticShortField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JIntMarker val)>> + SetStaticIntField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JLongMarker val)>> + SetStaticLongField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JFloatMarker val)>> + SetStaticFloatField, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JClassPtr clazz, JFieldIDPtr fieldID, JDoubleMarker val)>> + SetStaticDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + ffi.Pointer unicodeChars, JSizeMarker len)>> + NewString, + required ffi + .Pointer> + GetStringLength, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>> + GetStringChars, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JStringPtr string, ffi.Pointer isCopy)>> + ReleaseStringChars, + required ffi.Pointer< + ffi.NativeFunction bytes)>> + NewStringUTF, + required ffi + .Pointer> + GetStringUTFLength, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr string, ffi.Pointer isCopy)>> + GetStringUTFChars, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JStringPtr string, ffi.Pointer utf)>> + ReleaseStringUTFChars, + required ffi + .Pointer> + GetArrayLength, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JSizeMarker length, JClassPtr elementClass, + JObjectPtr initialElement)>> + NewObjectArray, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JObjectArrayPtr array, JSizeMarker index)>> + GetObjectArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JObjectArrayPtr array, JSizeMarker index, JObjectPtr val)>> + SetObjectArrayElement, + required ffi + .Pointer> + NewBooleanArray, + required ffi + .Pointer> + NewByteArray, + required ffi + .Pointer> + NewCharArray, + required ffi + .Pointer> + NewShortArray, + required ffi + .Pointer> + NewIntArray, + required ffi + .Pointer> + NewLongArray, + required ffi + .Pointer> + NewFloatArray, + required ffi + .Pointer> + NewDoubleArray, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function(JBooleanArrayPtr array, + ffi.Pointer isCopy)>> + GetBooleanArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JByteArrayPtr array, ffi.Pointer isCopy)>> + GetByteArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JCharArrayPtr array, ffi.Pointer isCopy)>> + GetCharArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JShortArrayPtr array, ffi.Pointer isCopy)>> + GetShortArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JIntArrayPtr array, ffi.Pointer isCopy)>> + GetIntArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JLongArrayPtr array, ffi.Pointer isCopy)>> + GetLongArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JFloatArrayPtr array, ffi.Pointer isCopy)>> + GetFloatArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JDoubleArrayPtr array, ffi.Pointer isCopy)>> + GetDoubleArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JBooleanArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseBooleanArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JByteArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseByteArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JCharArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseCharArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JShortArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseShortArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JIntArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseIntArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JLongArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseLongArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JFloatArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseFloatArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JDoubleArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseDoubleArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetBooleanArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JByteArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetByteArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JCharArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetCharArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JShortArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetShortArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetIntArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JLongArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetLongArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JFloatArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetFloatArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JDoubleArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetDoubleArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetBooleanArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JByteArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetByteArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JCharArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetCharArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JShortArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetShortArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetIntArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JLongArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetLongArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JFloatArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetFloatArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JDoubleArrayPtr array, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + SetDoubleArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JClassPtr clazz, + ffi.Pointer methods, JIntMarker nMethods)>> + RegisterNatives, + required ffi + .Pointer> + UnregisterNatives, + required ffi.Pointer> + MonitorEnter, + required ffi.Pointer> + MonitorExit, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(ffi.Pointer> vm)>> + GetJavaVM, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JStringPtr str, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetStringRegion, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JStringPtr str, JSizeMarker start, + JSizeMarker len, ffi.Pointer buf)>> + GetStringUTFRegion, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JArrayPtr array, ffi.Pointer isCopy)>> + GetPrimitiveArrayCritical, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JArrayPtr array, + ffi.Pointer carray, JIntMarker mode)>> + ReleasePrimitiveArrayCritical, + required ffi.Pointer< + ffi.NativeFunction< + JniPointerResult Function( + JStringPtr str, ffi.Pointer isCopy)>> + GetStringCritical, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JStringPtr str, ffi.Pointer carray)>> + ReleaseStringCritical, + required ffi.Pointer> + NewWeakGlobalRef, + required ffi + .Pointer> + DeleteWeakGlobalRef, + required ffi.Pointer> + ExceptionCheck, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function( + ffi.Pointer address, JLongMarker capacity)>> + NewDirectByteBuffer, + required ffi + .Pointer> + GetDirectBufferAddress, + required ffi.Pointer> + GetDirectBufferCapacity, + required ffi.Pointer> + GetObjectRefType, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JBooleanArrayPtr array, JSizeMarker index)>> + GetBooleanArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JBooleanArrayPtr array, + JSizeMarker index, JBooleanMarker element)>> + SetBooleanArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JByteArrayPtr array, JSizeMarker index)>> + GetByteArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JByteArrayPtr array, JSizeMarker index, + JByteMarker element)>> + SetByteArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JCharArrayPtr array, JSizeMarker index)>> + GetCharArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JCharArrayPtr array, JSizeMarker index, + JCharMarker element)>> + SetCharArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JShortArrayPtr array, JSizeMarker index)>> + GetShortArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JShortArrayPtr array, JSizeMarker index, + JShortMarker element)>> + SetShortArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JIntArrayPtr array, JSizeMarker index)>> + GetIntArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function( + JIntArrayPtr array, JSizeMarker index, JIntMarker element)>> + SetIntArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JLongArrayPtr array, JSizeMarker index)>> + GetLongArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JLongArrayPtr array, JSizeMarker index, + JLongMarker element)>> + SetLongArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JFloatArrayPtr array, JSizeMarker index)>> + GetFloatArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JFloatArrayPtr array, JSizeMarker index, + JFloatMarker element)>> + SetFloatArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JniResult Function(JDoubleArrayPtr array, JSizeMarker index)>> + GetDoubleArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JThrowablePtr Function(JDoubleArrayPtr array, JSizeMarker index, + JDoubleMarker element)>> + SetDoubleArrayElement, + }) => + $allocator() + ..ref.reserved0 = reserved0 + ..ref.reserved1 = reserved1 + ..ref.reserved2 = reserved2 + ..ref.reserved3 = reserved3 + ..ref.GetVersion = GetVersion + ..ref.DefineClass = DefineClass + ..ref.FindClass = FindClass + ..ref.FromReflectedMethod = FromReflectedMethod + ..ref.FromReflectedField = FromReflectedField + ..ref.ToReflectedMethod = ToReflectedMethod + ..ref.GetSuperclass = GetSuperclass + ..ref.IsAssignableFrom = IsAssignableFrom + ..ref.ToReflectedField = ToReflectedField + ..ref.Throw = Throw + ..ref.ThrowNew = ThrowNew + ..ref.ExceptionOccurred = ExceptionOccurred + ..ref.ExceptionDescribe = ExceptionDescribe + ..ref.ExceptionClear = ExceptionClear + ..ref.FatalError = FatalError + ..ref.PushLocalFrame = PushLocalFrame + ..ref.PopLocalFrame = PopLocalFrame + ..ref.NewGlobalRef = NewGlobalRef + ..ref.DeleteGlobalRef = DeleteGlobalRef + ..ref.DeleteLocalRef = DeleteLocalRef + ..ref.IsSameObject = IsSameObject + ..ref.NewLocalRef = NewLocalRef + ..ref.EnsureLocalCapacity = EnsureLocalCapacity + ..ref.AllocObject = AllocObject + ..ref.NewObject = NewObject + ..ref.NewObjectA = NewObjectA + ..ref.GetObjectClass = GetObjectClass + ..ref.IsInstanceOf = IsInstanceOf + ..ref.GetMethodID = GetMethodID + ..ref.CallObjectMethod = CallObjectMethod + ..ref.CallObjectMethodA = CallObjectMethodA + ..ref.CallBooleanMethod = CallBooleanMethod + ..ref.CallBooleanMethodA = CallBooleanMethodA + ..ref.CallByteMethod = CallByteMethod + ..ref.CallByteMethodA = CallByteMethodA + ..ref.CallCharMethod = CallCharMethod + ..ref.CallCharMethodA = CallCharMethodA + ..ref.CallShortMethod = CallShortMethod + ..ref.CallShortMethodA = CallShortMethodA + ..ref.CallIntMethod = CallIntMethod + ..ref.CallIntMethodA = CallIntMethodA + ..ref.CallLongMethod = CallLongMethod + ..ref.CallLongMethodA = CallLongMethodA + ..ref.CallFloatMethod = CallFloatMethod + ..ref.CallFloatMethodA = CallFloatMethodA + ..ref.CallDoubleMethod = CallDoubleMethod + ..ref.CallDoubleMethodA = CallDoubleMethodA + ..ref.CallVoidMethod = CallVoidMethod + ..ref.CallVoidMethodA = CallVoidMethodA + ..ref.CallNonvirtualObjectMethod = CallNonvirtualObjectMethod + ..ref.CallNonvirtualObjectMethodA = CallNonvirtualObjectMethodA + ..ref.CallNonvirtualBooleanMethod = CallNonvirtualBooleanMethod + ..ref.CallNonvirtualBooleanMethodA = CallNonvirtualBooleanMethodA + ..ref.CallNonvirtualByteMethod = CallNonvirtualByteMethod + ..ref.CallNonvirtualByteMethodA = CallNonvirtualByteMethodA + ..ref.CallNonvirtualCharMethod = CallNonvirtualCharMethod + ..ref.CallNonvirtualCharMethodA = CallNonvirtualCharMethodA + ..ref.CallNonvirtualShortMethod = CallNonvirtualShortMethod + ..ref.CallNonvirtualShortMethodA = CallNonvirtualShortMethodA + ..ref.CallNonvirtualIntMethod = CallNonvirtualIntMethod + ..ref.CallNonvirtualIntMethodA = CallNonvirtualIntMethodA + ..ref.CallNonvirtualLongMethod = CallNonvirtualLongMethod + ..ref.CallNonvirtualLongMethodA = CallNonvirtualLongMethodA + ..ref.CallNonvirtualFloatMethod = CallNonvirtualFloatMethod + ..ref.CallNonvirtualFloatMethodA = CallNonvirtualFloatMethodA + ..ref.CallNonvirtualDoubleMethod = CallNonvirtualDoubleMethod + ..ref.CallNonvirtualDoubleMethodA = CallNonvirtualDoubleMethodA + ..ref.CallNonvirtualVoidMethod = CallNonvirtualVoidMethod + ..ref.CallNonvirtualVoidMethodA = CallNonvirtualVoidMethodA + ..ref.GetFieldID = GetFieldID + ..ref.GetObjectField = GetObjectField + ..ref.GetBooleanField = GetBooleanField + ..ref.GetByteField = GetByteField + ..ref.GetCharField = GetCharField + ..ref.GetShortField = GetShortField + ..ref.GetIntField = GetIntField + ..ref.GetLongField = GetLongField + ..ref.GetFloatField = GetFloatField + ..ref.GetDoubleField = GetDoubleField + ..ref.SetObjectField = SetObjectField + ..ref.SetBooleanField = SetBooleanField + ..ref.SetByteField = SetByteField + ..ref.SetCharField = SetCharField + ..ref.SetShortField = SetShortField + ..ref.SetIntField = SetIntField + ..ref.SetLongField = SetLongField + ..ref.SetFloatField = SetFloatField + ..ref.SetDoubleField = SetDoubleField + ..ref.GetStaticMethodID = GetStaticMethodID + ..ref.CallStaticObjectMethod = CallStaticObjectMethod + ..ref.CallStaticObjectMethodA = CallStaticObjectMethodA + ..ref.CallStaticBooleanMethod = CallStaticBooleanMethod + ..ref.CallStaticBooleanMethodA = CallStaticBooleanMethodA + ..ref.CallStaticByteMethod = CallStaticByteMethod + ..ref.CallStaticByteMethodA = CallStaticByteMethodA + ..ref.CallStaticCharMethod = CallStaticCharMethod + ..ref.CallStaticCharMethodA = CallStaticCharMethodA + ..ref.CallStaticShortMethod = CallStaticShortMethod + ..ref.CallStaticShortMethodA = CallStaticShortMethodA + ..ref.CallStaticIntMethod = CallStaticIntMethod + ..ref.CallStaticIntMethodA = CallStaticIntMethodA + ..ref.CallStaticLongMethod = CallStaticLongMethod + ..ref.CallStaticLongMethodA = CallStaticLongMethodA + ..ref.CallStaticFloatMethod = CallStaticFloatMethod + ..ref.CallStaticFloatMethodA = CallStaticFloatMethodA + ..ref.CallStaticDoubleMethod = CallStaticDoubleMethod + ..ref.CallStaticDoubleMethodA = CallStaticDoubleMethodA + ..ref.CallStaticVoidMethod = CallStaticVoidMethod + ..ref.CallStaticVoidMethodA = CallStaticVoidMethodA + ..ref.GetStaticFieldID = GetStaticFieldID + ..ref.GetStaticObjectField = GetStaticObjectField + ..ref.GetStaticBooleanField = GetStaticBooleanField + ..ref.GetStaticByteField = GetStaticByteField + ..ref.GetStaticCharField = GetStaticCharField + ..ref.GetStaticShortField = GetStaticShortField + ..ref.GetStaticIntField = GetStaticIntField + ..ref.GetStaticLongField = GetStaticLongField + ..ref.GetStaticFloatField = GetStaticFloatField + ..ref.GetStaticDoubleField = GetStaticDoubleField + ..ref.SetStaticObjectField = SetStaticObjectField + ..ref.SetStaticBooleanField = SetStaticBooleanField + ..ref.SetStaticByteField = SetStaticByteField + ..ref.SetStaticCharField = SetStaticCharField + ..ref.SetStaticShortField = SetStaticShortField + ..ref.SetStaticIntField = SetStaticIntField + ..ref.SetStaticLongField = SetStaticLongField + ..ref.SetStaticFloatField = SetStaticFloatField + ..ref.SetStaticDoubleField = SetStaticDoubleField + ..ref.NewString = NewString + ..ref.GetStringLength = GetStringLength + ..ref.GetStringChars = GetStringChars + ..ref.ReleaseStringChars = ReleaseStringChars + ..ref.NewStringUTF = NewStringUTF + ..ref.GetStringUTFLength = GetStringUTFLength + ..ref.GetStringUTFChars = GetStringUTFChars + ..ref.ReleaseStringUTFChars = ReleaseStringUTFChars + ..ref.GetArrayLength = GetArrayLength + ..ref.NewObjectArray = NewObjectArray + ..ref.GetObjectArrayElement = GetObjectArrayElement + ..ref.SetObjectArrayElement = SetObjectArrayElement + ..ref.NewBooleanArray = NewBooleanArray + ..ref.NewByteArray = NewByteArray + ..ref.NewCharArray = NewCharArray + ..ref.NewShortArray = NewShortArray + ..ref.NewIntArray = NewIntArray + ..ref.NewLongArray = NewLongArray + ..ref.NewFloatArray = NewFloatArray + ..ref.NewDoubleArray = NewDoubleArray + ..ref.GetBooleanArrayElements = GetBooleanArrayElements + ..ref.GetByteArrayElements = GetByteArrayElements + ..ref.GetCharArrayElements = GetCharArrayElements + ..ref.GetShortArrayElements = GetShortArrayElements + ..ref.GetIntArrayElements = GetIntArrayElements + ..ref.GetLongArrayElements = GetLongArrayElements + ..ref.GetFloatArrayElements = GetFloatArrayElements + ..ref.GetDoubleArrayElements = GetDoubleArrayElements + ..ref.ReleaseBooleanArrayElements = ReleaseBooleanArrayElements + ..ref.ReleaseByteArrayElements = ReleaseByteArrayElements + ..ref.ReleaseCharArrayElements = ReleaseCharArrayElements + ..ref.ReleaseShortArrayElements = ReleaseShortArrayElements + ..ref.ReleaseIntArrayElements = ReleaseIntArrayElements + ..ref.ReleaseLongArrayElements = ReleaseLongArrayElements + ..ref.ReleaseFloatArrayElements = ReleaseFloatArrayElements + ..ref.ReleaseDoubleArrayElements = ReleaseDoubleArrayElements + ..ref.GetBooleanArrayRegion = GetBooleanArrayRegion + ..ref.GetByteArrayRegion = GetByteArrayRegion + ..ref.GetCharArrayRegion = GetCharArrayRegion + ..ref.GetShortArrayRegion = GetShortArrayRegion + ..ref.GetIntArrayRegion = GetIntArrayRegion + ..ref.GetLongArrayRegion = GetLongArrayRegion + ..ref.GetFloatArrayRegion = GetFloatArrayRegion + ..ref.GetDoubleArrayRegion = GetDoubleArrayRegion + ..ref.SetBooleanArrayRegion = SetBooleanArrayRegion + ..ref.SetByteArrayRegion = SetByteArrayRegion + ..ref.SetCharArrayRegion = SetCharArrayRegion + ..ref.SetShortArrayRegion = SetShortArrayRegion + ..ref.SetIntArrayRegion = SetIntArrayRegion + ..ref.SetLongArrayRegion = SetLongArrayRegion + ..ref.SetFloatArrayRegion = SetFloatArrayRegion + ..ref.SetDoubleArrayRegion = SetDoubleArrayRegion + ..ref.RegisterNatives = RegisterNatives + ..ref.UnregisterNatives = UnregisterNatives + ..ref.MonitorEnter = MonitorEnter + ..ref.MonitorExit = MonitorExit + ..ref.GetJavaVM = GetJavaVM + ..ref.GetStringRegion = GetStringRegion + ..ref.GetStringUTFRegion = GetStringUTFRegion + ..ref.GetPrimitiveArrayCritical = GetPrimitiveArrayCritical + ..ref.ReleasePrimitiveArrayCritical = ReleasePrimitiveArrayCritical + ..ref.GetStringCritical = GetStringCritical + ..ref.ReleaseStringCritical = ReleaseStringCritical + ..ref.NewWeakGlobalRef = NewWeakGlobalRef + ..ref.DeleteWeakGlobalRef = DeleteWeakGlobalRef + ..ref.ExceptionCheck = ExceptionCheck + ..ref.NewDirectByteBuffer = NewDirectByteBuffer + ..ref.GetDirectBufferAddress = GetDirectBufferAddress + ..ref.GetDirectBufferCapacity = GetDirectBufferCapacity + ..ref.GetObjectRefType = GetObjectRefType + ..ref.GetBooleanArrayElement = GetBooleanArrayElement + ..ref.SetBooleanArrayElement = SetBooleanArrayElement + ..ref.GetByteArrayElement = GetByteArrayElement + ..ref.SetByteArrayElement = SetByteArrayElement + ..ref.GetCharArrayElement = GetCharArrayElement + ..ref.SetCharArrayElement = SetCharArrayElement + ..ref.GetShortArrayElement = GetShortArrayElement + ..ref.SetShortArrayElement = SetShortArrayElement + ..ref.GetIntArrayElement = GetIntArrayElement + ..ref.SetIntArrayElement = SetIntArrayElement + ..ref.GetLongArrayElement = GetLongArrayElement + ..ref.SetLongArrayElement = SetLongArrayElement + ..ref.GetFloatArrayElement = GetFloatArrayElement + ..ref.SetFloatArrayElement = SetFloatArrayElement + ..ref.GetDoubleArrayElement = GetDoubleArrayElement + ..ref.SetDoubleArrayElement = SetDoubleArrayElement; +} + +typedef JArrayPtr = JObjectPtr; +typedef JBooleanArrayPtr = JArrayPtr; + +/// Primitive types that match up with Java equivalents. +typedef JBooleanMarker = ffi.Uint8; +typedef DartJBooleanMarker = int; +typedef JByteArrayPtr = JArrayPtr; +typedef JByteMarker = ffi.Int8; +typedef DartJByteMarker = int; +typedef JCharArrayPtr = JArrayPtr; +typedef JCharMarker = ffi.Uint16; +typedef DartJCharMarker = int; +typedef JClassPtr = JObjectPtr; +typedef JDoubleArrayPtr = JArrayPtr; +typedef JDoubleMarker = ffi.Double; +typedef DartJDoubleMarker = double; +typedef JFieldIDPtr = ffi.Pointer; +typedef JFloatArrayPtr = JArrayPtr; +typedef JFloatMarker = ffi.Float; +typedef DartJFloatMarker = double; +typedef JIntArrayPtr = JArrayPtr; +typedef JIntMarker = ffi.Int32; +typedef DartJIntMarker = int; +typedef JLongArrayPtr = JArrayPtr; +typedef JLongMarker = ffi.Int64; +typedef DartJLongMarker = int; +typedef JMethodIDPtr = ffi.Pointer; + +/// JNI invocation interface. +final class JNIInvokeInterface extends ffi.Struct { + external ffi.Pointer reserved0; + + external ffi.Pointer reserved1; + + external ffi.Pointer reserved2; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JDoubleArrayPtr array, - ffi.Pointer isCopy)>> GetDoubleArrayElements; + ffi.NativeFunction vm)>> + DestroyJavaVM; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JBooleanArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseBooleanArrayElements; + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>> AttachCurrentThread; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JByteArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseByteArrayElements; + ffi.NativeFunction vm)>> + DetachCurrentThread; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JCharArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseCharArrayElements; + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + JIntMarker version)>> GetEnv; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JShortArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseShortArrayElements; + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>> AttachCurrentThreadAsDaemon; - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JIntArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseIntArrayElements; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer reserved0, + required ffi.Pointer reserved1, + required ffi.Pointer reserved2, + required ffi.Pointer< + ffi.NativeFunction vm)>> + DestroyJavaVM, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>> + AttachCurrentThread, + required ffi.Pointer< + ffi.NativeFunction vm)>> + DetachCurrentThread, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + JIntMarker version)>> + GetEnv, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer vm, + ffi.Pointer> p_env, + ffi.Pointer thr_args)>> + AttachCurrentThreadAsDaemon, + }) => + $allocator() + ..ref.reserved0 = reserved0 + ..ref.reserved1 = reserved1 + ..ref.reserved2 = reserved2 + ..ref.DestroyJavaVM = DestroyJavaVM + ..ref.AttachCurrentThread = AttachCurrentThread + ..ref.DetachCurrentThread = DetachCurrentThread + ..ref.GetEnv = GetEnv + ..ref.AttachCurrentThreadAsDaemon = AttachCurrentThreadAsDaemon; +} - external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JLongArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseLongArrayElements; +/// Table of interface function pointers. +final class JNINativeInterface extends ffi.Struct { + external ffi.Pointer reserved0; + + external ffi.Pointer reserved1; + + external ffi.Pointer reserved2; + + external ffi.Pointer reserved3; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JFloatArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseFloatArrayElements; + ffi.NativeFunction env)>> + GetVersion; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( + JClassPtr Function( ffi.Pointer env, - JDoubleArrayPtr array, - ffi.Pointer elems, - JIntMarker mode)>> ReleaseDoubleArrayElements; + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + JSizeMarker bufLen)>> DefineClass; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JBooleanArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetBooleanArrayRegion; + ffi.NativeFunction< + JClassPtr Function( + ffi.Pointer env, ffi.Pointer name)>> + FindClass; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JByteArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetByteArrayRegion; + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, JObjectPtr method)>> + FromReflectedMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JCharArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetCharArrayRegion; + JFieldIDPtr Function( + ffi.Pointer env, JObjectPtr field)>> FromReflectedField; + /// spec doesn't show jboolean parameter external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( + JObjectPtr Function( ffi.Pointer env, - JShortArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetShortArrayRegion; + JClassPtr cls, + JMethodIDPtr methodId, + JBooleanMarker isStatic)>> ToReflectedMethod; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JIntArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetIntArrayRegion; + ffi.NativeFunction< + JClassPtr Function(ffi.Pointer env, JClassPtr clazz)>> + GetSuperclass; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JLongArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetLongArrayRegion; + JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz1, + JClassPtr clazz2)>> IsAssignableFrom; + /// spec doesn't show jboolean parameter external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JFloatArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetFloatArrayRegion; + JObjectPtr Function(ffi.Pointer env, JClassPtr cls, + JFieldIDPtr fieldID, JBooleanMarker isStatic)>> ToReflectedField; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JDoubleArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetDoubleArrayRegion; + JIntMarker Function( + ffi.Pointer env, JThrowablePtr obj)>> Throw; - /// spec shows these without const; some jni.h do, some don't external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JBooleanArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetBooleanArrayRegion; + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer message)>> ThrowNew; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JByteArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetByteArrayRegion; + ffi.NativeFunction env)>> + ExceptionOccurred; + + external ffi + .Pointer env)>> + ExceptionDescribe; + + external ffi + .Pointer env)>> + ExceptionClear; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JCharArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetCharArrayRegion; + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, ffi.Pointer msg)>> + FatalError; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JShortArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetShortArrayRegion; + JIntMarker Function( + ffi.Pointer env, JIntMarker capacity)>> PushLocalFrame; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JIntArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetIntArrayRegion; + JObjectPtr Function( + ffi.Pointer env, JObjectPtr result)>> PopLocalFrame; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JLongArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetLongArrayRegion; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewGlobalRef; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JFloatArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetFloatArrayRegion; + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, JObjectPtr globalRef)>> + DeleteGlobalRef; external ffi.Pointer< ffi.NativeFunction< ffi.Void Function( - ffi.Pointer env, - JDoubleArrayPtr array, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> SetDoubleArrayRegion; + ffi.Pointer env, JObjectPtr localRef)>> DeleteLocalRef; external ffi.Pointer< - ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer env, - JClassPtr clazz, - ffi.Pointer methods, - JIntMarker nMethods)>> RegisterNatives; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, JObjectPtr ref1, JObjectPtr ref2)>> + IsSameObject; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JClassPtr clazz)>> - UnregisterNatives; + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewLocalRef; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> - MonitorEnter; + JIntMarker Function( + ffi.Pointer env, JIntMarker capacity)>> + EnsureLocalCapacity; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> - MonitorExit; + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz)>> + AllocObject; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function(ffi.Pointer env, - ffi.Pointer> vm)>> GetJavaVM; + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> NewObject; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JStringPtr str, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetStringRegion; + JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> NewObjectV; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer env, - JStringPtr str, - JSizeMarker start, - JSizeMarker len, - ffi.Pointer buf)>> GetStringUTFRegion; + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> NewObjectA; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JArrayPtr array, - ffi.Pointer isCopy)>> GetPrimitiveArrayCritical; + ffi.NativeFunction< + JClassPtr Function(ffi.Pointer env, JObjectPtr obj)>> + GetObjectClass; + + external ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, JObjectPtr obj, JClassPtr clazz)>> + IsInstanceOf; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function( + JMethodIDPtr Function( ffi.Pointer env, - JArrayPtr array, - ffi.Pointer carray, - JIntMarker mode)>> ReleasePrimitiveArrayCritical; + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetMethodID; external ffi.Pointer< ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, - JStringPtr str, - ffi.Pointer isCopy)>> GetStringCritical; + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallObjectMethod; external ffi.Pointer< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JStringPtr str, - ffi.Pointer carray)>> ReleaseStringCritical; + JObjectPtr Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallObjectMethodV; external ffi.Pointer< - ffi.NativeFunction< - JWeakPtr Function(ffi.Pointer env, JObjectPtr obj)>> - NewWeakGlobalRef; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallObjectMethodA; external ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function(ffi.Pointer env, JWeakPtr obj)>> - DeleteWeakGlobalRef; + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallBooleanMethod; external ffi.Pointer< - ffi - .NativeFunction env)>> - ExceptionCheck; + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> CallBooleanMethodV; external ffi.Pointer< ffi.NativeFunction< - JObjectPtr Function( + JBooleanMarker Function( ffi.Pointer env, - ffi.Pointer address, - JLongMarker capacity)>> NewDirectByteBuffer; + JObjectPtr obj, + JMethodIDPtr methodId, + ffi.Pointer args)>> CallBooleanMethodA; external ffi.Pointer< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer env, JObjectPtr buf)>> - GetDirectBufferAddress; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallByteMethod; external ffi.Pointer< - ffi.NativeFunction< - JLongMarker Function(ffi.Pointer env, JObjectPtr buf)>> - GetDirectBufferCapacity; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallByteMethodV; - /// added in JNI 1.6 external ffi.Pointer< ffi.NativeFunction< - ffi.UnsignedInt Function( - ffi.Pointer env, JObjectPtr obj)>> GetObjectRefType; -} - -typedef JniEnv = ffi.Pointer; - -/// JNI invocation interface. -final class JNIInvokeInterface extends ffi.Struct { - external ffi.Pointer reserved0; - - external ffi.Pointer reserved1; - - external ffi.Pointer reserved2; + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallByteMethodA; external ffi.Pointer< - ffi.NativeFunction vm)>> - DestroyJavaVM; + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallCharMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer vm, - ffi.Pointer> p_env, - ffi.Pointer thr_args)>> AttachCurrentThread; + JCharMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallCharMethodV; external ffi.Pointer< - ffi.NativeFunction vm)>> - DetachCurrentThread; + ffi.NativeFunction< + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallCharMethodA; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer vm, - ffi.Pointer> p_env, - JIntMarker version)>> GetEnv; + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallShortMethod; external ffi.Pointer< ffi.NativeFunction< - JIntMarker Function( - ffi.Pointer vm, - ffi.Pointer> p_env, - ffi.Pointer thr_args)>> AttachCurrentThreadAsDaemon; -} - -typedef JavaVM = ffi.Pointer; - -/// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no -/// longer supported.) -final class JavaVMOption extends ffi.Struct { - external ffi.Pointer optionString; - - external ffi.Pointer extraInfo; -} - -final class JavaVMInitArgs extends ffi.Struct { - /// use JNI_VERSION_1_2 or later - @JIntMarker() - external int version; - - @JIntMarker() - external int nOptions; + JShortMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallShortMethodV; - external ffi.Pointer options; + external ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallShortMethodA; - @JBooleanMarker() - external int ignoreUnrecognized; -} + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallIntMethod; -final class Dart_FinalizableHandle_ extends ffi.Opaque {} + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallIntMethodV; -typedef Dart_FinalizableHandle = ffi.Pointer; + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> CallIntMethodA; -final class GlobalJniEnvStruct extends ffi.Struct { - external ffi.Pointer reserved0; + external ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallLongMethod; - external ffi.Pointer reserved1; + external ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallLongMethodV; - external ffi.Pointer reserved2; + external ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallLongMethodA; - external ffi.Pointer reserved3; + external ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallFloatMethod; - external ffi.Pointer> GetVersion; + external ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallFloatMethodV; external ffi.Pointer< ffi.NativeFunction< - JniClassLookupResult Function( - ffi.Pointer name, - JObjectPtr loader, - ffi.Pointer buf, - JSizeMarker bufLen)>> DefineClass; + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallFloatMethodA; external ffi.Pointer< ffi.NativeFunction< - JniClassLookupResult Function(ffi.Pointer name)>> FindClass; + JDoubleMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallDoubleMethod; - external ffi - .Pointer> - FromReflectedMethod; + external ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> CallDoubleMethodV; - external ffi - .Pointer> - FromReflectedField; + external ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallDoubleMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr cls, JMethodIDPtr methodId, - JBooleanMarker isStatic)>> ToReflectedMethod; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> CallVoidMethod; external ffi.Pointer< - ffi.NativeFunction> - GetSuperclass; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObjectPtr, JMethodIDPtr, + ffi.Pointer)>> CallVoidMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz1, JClassPtr clazz2)>> - IsAssignableFrom; + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallVoidMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JClassPtr cls, JFieldIDPtr fieldID, JBooleanMarker isStatic)>> - ToReflectedField; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualObjectMethod; - external ffi - .Pointer> Throw; + external ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer, + JObjectPtr, + JClassPtr, + JMethodIDPtr, + ffi.Pointer)>> CallNonvirtualObjectMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JClassPtr clazz, ffi.Pointer message)>> ThrowNew; - - external ffi.Pointer> - ExceptionOccurred; - - external ffi.Pointer> - ExceptionDescribe; - - external ffi.Pointer> - ExceptionClear; - - external ffi.Pointer< - ffi.NativeFunction msg)>> - FatalError; - - external ffi - .Pointer> - PushLocalFrame; - - external ffi - .Pointer> - PopLocalFrame; - - external ffi.Pointer> - NewGlobalRef; - - external ffi - .Pointer> - DeleteGlobalRef; - - external ffi - .Pointer> - DeleteLocalRef; - - external ffi.Pointer< - ffi - .NativeFunction> - IsSameObject; - - external ffi.Pointer> - NewLocalRef; - - external ffi - .Pointer> - EnsureLocalCapacity; - - external ffi.Pointer> - AllocObject; + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualObjectMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - NewObject; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualBooleanMethod; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> NewObjectA; + JBooleanMarker Function( + ffi.Pointer, + JObjectPtr, + JClassPtr, + JMethodIDPtr, + ffi.Pointer)>> CallNonvirtualBooleanMethodV; external ffi.Pointer< - ffi.NativeFunction> - GetObjectClass; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualBooleanMethodA; external ffi.Pointer< - ffi - .NativeFunction> - IsInstanceOf; + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualByteMethod; external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig)>> GetMethodID; + JByteMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualByteMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallObjectMethod; + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualByteMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallObjectMethodA; + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualCharMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallBooleanMethod; + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualCharMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodId, - ffi.Pointer args)>> CallBooleanMethodA; + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualCharMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallByteMethod; + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualShortMethod; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallByteMethodA; + JShortMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualShortMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallCharMethod; + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualShortMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallCharMethodA; + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> CallNonvirtualIntMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallShortMethod; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualIntMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallShortMethodA; + JIntMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualIntMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallIntMethod; + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualLongMethod; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallIntMethodA; + JLongMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualLongMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallLongMethod; + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualLongMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallLongMethodA; + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualFloatMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallFloatMethod; + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualFloatMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallFloatMethodA; + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualFloatMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallDoubleMethod; + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualDoubleMethod; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallDoubleMethodA; + JDoubleMarker Function( + ffi.Pointer, + JObjectPtr, + JClassPtr, + JMethodIDPtr, + ffi.Pointer)>> CallNonvirtualDoubleMethodV; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID)>> - CallVoidMethod; + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallNonvirtualDoubleMethodA; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JObjectPtr obj, JMethodIDPtr methodID, - ffi.Pointer args)>> CallVoidMethodA; + ffi.Void Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID)>> CallNonvirtualVoidMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualObjectMethod; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallNonvirtualVoidMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( + ffi.Void Function( + ffi.Pointer env, JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualObjectMethodA; - - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualBooleanMethod; + ffi.Pointer args)>> CallNonvirtualVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, + JFieldIDPtr Function( + ffi.Pointer env, JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualBooleanMethodA; + ffi.Pointer name, + ffi.Pointer sig)>> GetFieldID; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualByteMethod; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetObjectField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualByteMethodA; + JBooleanMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualCharMethod; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetByteField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualCharMethodA; + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetCharField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualShortMethod; + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetShortField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualShortMethodA; + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetIntField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualIntMethod; + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetLongField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualIntMethodA; + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetFloatField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualLongMethod; + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> GetDoubleField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualLongMethodA; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JObjectPtr val)>> SetObjectField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualFloatMethod; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JBooleanMarker val)>> SetBooleanField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualFloatMethodA; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JByteMarker val)>> SetByteField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualDoubleMethod; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JCharMarker val)>> SetCharField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualDoubleMethodA; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JShortMarker val)>> SetShortField; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> - CallNonvirtualVoidMethod; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JIntMarker val)>> SetIntField; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, - JClassPtr clazz, - JMethodIDPtr methodID, - ffi.Pointer args)>> CallNonvirtualVoidMethodA; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JLongMarker val)>> SetLongField; external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig)>> GetFieldID; + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JFloatMarker val)>> SetFloatField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetObjectField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JDoubleMarker val)>> SetDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetBooleanField; + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetStaticMethodID; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetByteField; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticObjectMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetCharField; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticObjectMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetShortField; + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticObjectMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> GetIntField; + JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticBooleanMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetLongField; + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> CallStaticBooleanMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetFloatField; + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticBooleanMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectPtr obj, JFieldIDPtr fieldID)>> - GetDoubleField; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticByteMethod; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JObjectPtr val)>> - SetObjectField; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticByteMethodV; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JBooleanMarker val)>> - SetBooleanField; + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticByteMethodA; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JByteMarker val)>> - SetByteField; + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticCharMethod; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JCharMarker val)>> - SetCharField; + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticCharMethodV; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JShortMarker val)>> - SetShortField; + ffi.NativeFunction< + JCharMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticCharMethodA; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JIntMarker val)>> - SetIntField; + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticShortMethod; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JLongMarker val)>> - SetLongField; + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticShortMethodV; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JFloatMarker val)>> - SetFloatField; + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticShortMethodA; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectPtr obj, JFieldIDPtr fieldID, JDoubleMarker val)>> - SetDoubleField; + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticIntMethod; external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig)>> GetStaticMethodID; + JIntMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticIntMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticObjectMethod; + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticIntMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticObjectMethodA; + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticLongMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticBooleanMethod; + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticLongMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticBooleanMethodA; + JLongMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticLongMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticByteMethod; + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticFloatMethod; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticByteMethodA; + JFloatMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticFloatMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticCharMethod; + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticFloatMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticCharMethodA; + JDoubleMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticDoubleMethod; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticShortMethod; + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticDoubleMethodV; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticShortMethodA; + JDoubleMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticDoubleMethodA; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticIntMethod; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> CallStaticVoidMethod; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticIntMethodA; + ffi.Void Function(ffi.Pointer, JClassPtr, JMethodIDPtr, + ffi.Pointer)>> CallStaticVoidMethodV; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticLongMethod; + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> CallStaticVoidMethodA; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticLongMethodA; + JFieldIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> GetStaticFieldID; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticFloatMethod; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticObjectField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticFloatMethodA; + JBooleanMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticDoubleMethod; + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticByteField; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticDoubleMethodA; + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticCharField; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID)>> - CallStaticVoidMethod; + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticShortField; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JClassPtr clazz, JMethodIDPtr methodID, - ffi.Pointer args)>> CallStaticVoidMethodA; + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticIntField; external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function(JClassPtr clazz, ffi.Pointer name, - ffi.Pointer sig)>> GetStaticFieldID; + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticLongField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticObjectField; + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticBooleanField; + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> GetStaticDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticByteField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JObjectPtr val)>> SetStaticObjectField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticCharField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JBooleanMarker val)>> SetStaticBooleanField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticShortField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JByteMarker val)>> SetStaticByteField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticIntField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JCharMarker val)>> SetStaticCharField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticLongField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JShortMarker val)>> SetStaticShortField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticFloatField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JIntMarker val)>> SetStaticIntField; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JClassPtr clazz, JFieldIDPtr fieldID)>> - GetStaticDoubleField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JLongMarker val)>> SetStaticLongField; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JObjectPtr val)>> - SetStaticObjectField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JFloatMarker val)>> SetStaticFloatField; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JBooleanMarker val)>> - SetStaticBooleanField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JDoubleMarker val)>> SetStaticDoubleField; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JByteMarker val)>> - SetStaticByteField; + ffi.NativeFunction< + JStringPtr Function( + ffi.Pointer env, + ffi.Pointer unicodeChars, + JSizeMarker len)>> NewString; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JCharMarker val)>> - SetStaticCharField; + ffi.NativeFunction< + JSizeMarker Function( + ffi.Pointer env, JStringPtr string)>> GetStringLength; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JShortMarker val)>> - SetStaticShortField; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr string, + ffi.Pointer isCopy)>> GetStringChars; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JIntMarker val)>> - SetStaticIntField; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer isCopy)>> ReleaseStringChars; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JLongMarker val)>> - SetStaticLongField; + JStringPtr Function( + ffi.Pointer env, ffi.Pointer bytes)>> + NewStringUTF; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JFloatMarker val)>> - SetStaticFloatField; + JSizeMarker Function( + ffi.Pointer env, JStringPtr string)>> + GetStringUTFLength; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JClassPtr clazz, JFieldIDPtr fieldID, JDoubleMarker val)>> - SetStaticDoubleField; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr string, + ffi.Pointer isCopy)>> GetStringUTFChars; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function( - ffi.Pointer unicodeChars, JSizeMarker len)>> - NewString; - - external ffi - .Pointer> - GetStringLength; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer utf)>> ReleaseStringUTFChars; external ffi.Pointer< ffi.NativeFunction< - JniPointerResult Function( - JStringPtr string, ffi.Pointer isCopy)>> - GetStringChars; + JSizeMarker Function(ffi.Pointer env, JArrayPtr array)>> + GetArrayLength; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JStringPtr string, ffi.Pointer isCopy)>> - ReleaseStringChars; + ffi.NativeFunction< + JObjectArrayPtr Function( + ffi.Pointer env, + JSizeMarker length, + JClassPtr elementClass, + JObjectPtr initialElement)>> NewObjectArray; external ffi.Pointer< - ffi.NativeFunction bytes)>> - NewStringUTF; - - external ffi - .Pointer> - GetStringUTFLength; + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectArrayPtr array, + JSizeMarker index)>> GetObjectArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JStringPtr string, ffi.Pointer isCopy)>> - GetStringUTFChars; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectArrayPtr array, + JSizeMarker index, JObjectPtr val)>> SetObjectArrayElement; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JStringPtr string, ffi.Pointer utf)>> - ReleaseStringUTFChars; - - external ffi.Pointer> - GetArrayLength; + ffi.NativeFunction< + JBooleanArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewBooleanArray; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JSizeMarker length, JClassPtr elementClass, - JObjectPtr initialElement)>> NewObjectArray; + JByteArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewByteArray; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JObjectArrayPtr array, JSizeMarker index)>> - GetObjectArrayElement; + ffi.NativeFunction< + JCharArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewCharArray; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JObjectArrayPtr array, JSizeMarker index, JObjectPtr val)>> - SetObjectArrayElement; - - external ffi - .Pointer> - NewBooleanArray; - - external ffi - .Pointer> - NewByteArray; - - external ffi - .Pointer> - NewCharArray; - - external ffi - .Pointer> - NewShortArray; + ffi.NativeFunction< + JShortArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewShortArray; - external ffi - .Pointer> - NewIntArray; + external ffi.Pointer< + ffi.NativeFunction< + JIntArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewIntArray; - external ffi - .Pointer> - NewLongArray; + external ffi.Pointer< + ffi.NativeFunction< + JLongArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewLongArray; - external ffi - .Pointer> - NewFloatArray; + external ffi.Pointer< + ffi.NativeFunction< + JFloatArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewFloatArray; - external ffi - .Pointer> - NewDoubleArray; + external ffi.Pointer< + ffi.NativeFunction< + JDoubleArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> NewDoubleArray; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JBooleanArrayPtr array, ffi.Pointer isCopy)>> - GetBooleanArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer isCopy)>> GetBooleanArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JByteArrayPtr array, ffi.Pointer isCopy)>> - GetByteArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JByteArrayPtr array, + ffi.Pointer isCopy)>> GetByteArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JCharArrayPtr array, ffi.Pointer isCopy)>> - GetCharArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JCharArrayPtr array, + ffi.Pointer isCopy)>> GetCharArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JShortArrayPtr array, ffi.Pointer isCopy)>> - GetShortArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JShortArrayPtr array, + ffi.Pointer isCopy)>> GetShortArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JIntArrayPtr array, ffi.Pointer isCopy)>> - GetIntArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JIntArrayPtr array, + ffi.Pointer isCopy)>> GetIntArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JLongArrayPtr array, ffi.Pointer isCopy)>> - GetLongArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JLongArrayPtr array, + ffi.Pointer isCopy)>> GetLongArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JFloatArrayPtr array, ffi.Pointer isCopy)>> - GetFloatArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JFloatArrayPtr array, + ffi.Pointer isCopy)>> GetFloatArrayElements; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JDoubleArrayPtr array, ffi.Pointer isCopy)>> - GetDoubleArrayElements; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JDoubleArrayPtr array, + ffi.Pointer isCopy)>> GetDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JBooleanArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseBooleanArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JByteArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseByteArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JCharArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseCharArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JShortArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseShortArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JIntArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseIntArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JLongArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseLongArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JFloatArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseFloatArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JDoubleArrayPtr array, ffi.Pointer elems, JIntMarker mode)>> ReleaseDoubleArrayElements; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JBooleanArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3057,7 +4006,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JByteArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3065,7 +4015,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JCharArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3073,7 +4024,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JShortArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3081,12 +4033,17 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, - JSizeMarker len, ffi.Pointer buf)>> GetIntArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JLongArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3094,7 +4051,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JFloatArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3102,15 +4060,18 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JDoubleArrayPtr array, JSizeMarker start, JSizeMarker len, ffi.Pointer buf)>> GetDoubleArrayRegion; + /// spec shows these without const; some jni.h do, some don't external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JBooleanArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3118,7 +4079,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JByteArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3126,7 +4088,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JCharArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3134,7 +4097,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JShortArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3142,12 +4106,17 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JIntArrayPtr array, JSizeMarker start, - JSizeMarker len, ffi.Pointer buf)>> SetIntArrayRegion; + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> SetIntArrayRegion; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JLongArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3155,7 +4124,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JFloatArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3163,7 +4133,8 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( + ffi.Void Function( + ffi.Pointer env, JDoubleArrayPtr array, JSizeMarker start, JSizeMarker len, @@ -3171,162 +4142,2069 @@ final class GlobalJniEnvStruct extends ffi.Struct { external ffi.Pointer< ffi.NativeFunction< - JniResult Function( + JIntMarker Function( + ffi.Pointer env, JClassPtr clazz, ffi.Pointer methods, JIntMarker nMethods)>> RegisterNatives; - external ffi.Pointer> + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz)>> UnregisterNatives; - external ffi.Pointer> + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> MonitorEnter; - external ffi.Pointer> + external ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> MonitorExit; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(ffi.Pointer> vm)>> GetJavaVM; + JIntMarker Function(ffi.Pointer env, + ffi.Pointer> vm)>> GetJavaVM; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JStringPtr str, JSizeMarker start, - JSizeMarker len, ffi.Pointer buf)>> GetStringRegion; + ffi.Void Function( + ffi.Pointer env, + JStringPtr str, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetStringRegion; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JStringPtr str, JSizeMarker start, - JSizeMarker len, ffi.Pointer buf)>> GetStringUTFRegion; + ffi.Void Function( + ffi.Pointer env, + JStringPtr str, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> GetStringUTFRegion; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JArrayPtr array, ffi.Pointer isCopy)>> - GetPrimitiveArrayCritical; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JArrayPtr array, + ffi.Pointer isCopy)>> GetPrimitiveArrayCritical; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JArrayPtr array, ffi.Pointer carray, + ffi.Void Function( + ffi.Pointer env, + JArrayPtr array, + ffi.Pointer carray, JIntMarker mode)>> ReleasePrimitiveArrayCritical; external ffi.Pointer< - ffi.NativeFunction< - JniPointerResult Function( - JStringPtr str, ffi.Pointer isCopy)>> - GetStringCritical; + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JStringPtr str, + ffi.Pointer isCopy)>> GetStringCritical; external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JStringPtr str, ffi.Pointer carray)>> - ReleaseStringCritical; + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr str, + ffi.Pointer carray)>> ReleaseStringCritical; - external ffi.Pointer> + external ffi.Pointer< + ffi.NativeFunction< + JWeakPtr Function(ffi.Pointer env, JObjectPtr obj)>> NewWeakGlobalRef; - external ffi.Pointer> - DeleteWeakGlobalRef; - - external ffi.Pointer> ExceptionCheck; - external ffi.Pointer< ffi.NativeFunction< - JniResult Function( - ffi.Pointer address, JLongMarker capacity)>> - NewDirectByteBuffer; - - external ffi - .Pointer> - GetDirectBufferAddress; - - external ffi.Pointer> - GetDirectBufferCapacity; - - external ffi.Pointer> - GetObjectRefType; + ffi.Void Function(ffi.Pointer env, JWeakPtr obj)>> + DeleteWeakGlobalRef; external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JBooleanArrayPtr array, JSizeMarker index)>> - GetBooleanArrayElement; + ffi + .NativeFunction env)>> + ExceptionCheck; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function(JBooleanArrayPtr array, JSizeMarker index, - JBooleanMarker element)>> SetBooleanArrayElement; + JObjectPtr Function( + ffi.Pointer env, + ffi.Pointer address, + JLongMarker capacity)>> NewDirectByteBuffer; external ffi.Pointer< ffi.NativeFunction< - JniResult Function(JByteArrayPtr array, JSizeMarker index)>> - GetByteArrayElement; + ffi.Pointer Function( + ffi.Pointer env, JObjectPtr buf)>> + GetDirectBufferAddress; external ffi.Pointer< ffi.NativeFunction< - JThrowablePtr Function( - JByteArrayPtr array, JSizeMarker index, JByteMarker element)>> - SetByteArrayElement; + JLongMarker Function(ffi.Pointer env, JObjectPtr buf)>> + GetDirectBufferCapacity; + /// added in JNI 1.6 external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JCharArrayPtr array, JSizeMarker index)>> - GetCharArrayElement; + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer env, JObjectPtr obj)>> GetObjectRefType; - external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JCharArrayPtr array, JSizeMarker index, JCharMarker element)>> - SetCharArrayElement; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer reserved0, + required ffi.Pointer reserved1, + required ffi.Pointer reserved2, + required ffi.Pointer reserved3, + required ffi.Pointer< + ffi.NativeFunction env)>> + GetVersion, + required ffi.Pointer< + ffi.NativeFunction< + JClassPtr Function( + ffi.Pointer env, + ffi.Pointer name, + JObjectPtr loader, + ffi.Pointer buf, + JSizeMarker bufLen)>> + DefineClass, + required ffi.Pointer< + ffi.NativeFunction< + JClassPtr Function( + ffi.Pointer env, ffi.Pointer name)>> + FindClass, + required ffi.Pointer< + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, JObjectPtr method)>> + FromReflectedMethod, + required ffi.Pointer< + ffi.NativeFunction< + JFieldIDPtr Function( + ffi.Pointer env, JObjectPtr field)>> + FromReflectedField, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr cls, + JMethodIDPtr methodId, JBooleanMarker isStatic)>> + ToReflectedMethod, + required ffi.Pointer< + ffi.NativeFunction< + JClassPtr Function(ffi.Pointer env, JClassPtr clazz)>> + GetSuperclass, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JClassPtr clazz1, JClassPtr clazz2)>> + IsAssignableFrom, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr cls, + JFieldIDPtr fieldID, JBooleanMarker isStatic)>> + ToReflectedField, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, JThrowablePtr obj)>> + Throw, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer message)>> + ThrowNew, + required ffi.Pointer< + ffi + .NativeFunction env)>> + ExceptionOccurred, + required ffi.Pointer< + ffi.NativeFunction env)>> + ExceptionDescribe, + required ffi.Pointer< + ffi.NativeFunction env)>> + ExceptionClear, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, ffi.Pointer msg)>> + FatalError, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, JIntMarker capacity)>> + PushLocalFrame, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, JObjectPtr result)>> + PopLocalFrame, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewGlobalRef, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, JObjectPtr globalRef)>> + DeleteGlobalRef, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, JObjectPtr localRef)>> + DeleteLocalRef, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JObjectPtr ref1, JObjectPtr ref2)>> + IsSameObject, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewLocalRef, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, JIntMarker capacity)>> + EnsureLocalCapacity, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, JClassPtr clazz)>> + AllocObject, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + NewObject, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + NewObjectV, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + NewObjectA, + required ffi.Pointer< + ffi.NativeFunction< + JClassPtr Function(ffi.Pointer env, JObjectPtr obj)>> + GetObjectClass, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JObjectPtr obj, JClassPtr clazz)>> + IsInstanceOf, + required ffi.Pointer< + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> + GetMethodID, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallObjectMethod, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallObjectMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallObjectMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JObjectPtr obj, JMethodIDPtr methodID)>> + CallBooleanMethod, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallBooleanMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodId, + ffi.Pointer args)>> + CallBooleanMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallByteMethod, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallByteMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallByteMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallCharMethod, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallCharMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallCharMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallShortMethod, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallShortMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallShortMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallIntMethod, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallIntMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallIntMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallLongMethod, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallLongMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallLongMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallFloatMethod, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallFloatMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallFloatMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, + JObjectPtr obj, JMethodIDPtr methodID)>> + CallDoubleMethod, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallDoubleMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallDoubleMethodA, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID)>> + CallVoidMethod, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObjectPtr, + JMethodIDPtr, ffi.Pointer)>> + CallVoidMethodV, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallVoidMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualObjectMethod, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualObjectMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualObjectMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualBooleanMethod, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualBooleanMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualBooleanMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualByteMethod, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualByteMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualByteMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualCharMethod, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualCharMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualCharMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualShortMethod, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualShortMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualShortMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualIntMethod, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualIntMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualIntMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualLongMethod, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualLongMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualLongMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualFloatMethod, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualFloatMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualFloatMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, + JObjectPtr obj, JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualDoubleMethod, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer, JObjectPtr, + JClassPtr, JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualDoubleMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualDoubleMethodA, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallNonvirtualVoidMethod, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JObjectPtr, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallNonvirtualVoidMethodV, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JObjectPtr obj, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallNonvirtualVoidMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JFieldIDPtr Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer name, ffi.Pointer sig)>> + GetFieldID, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetObjectField, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JObjectPtr obj, JFieldIDPtr fieldID)>> + GetBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetByteField, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetCharField, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetShortField, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetIntField, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetLongField, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID)>> + GetFloatField, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, + JObjectPtr obj, JFieldIDPtr fieldID)>> + GetDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JObjectPtr val)>> + SetObjectField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JBooleanMarker val)>> + SetBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JByteMarker val)>> + SetByteField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JCharMarker val)>> + SetCharField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JShortMarker val)>> + SetShortField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JIntMarker val)>> + SetIntField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JLongMarker val)>> + SetLongField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JFloatMarker val)>> + SetFloatField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JObjectPtr obj, + JFieldIDPtr fieldID, JDoubleMarker val)>> + SetDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + JMethodIDPtr Function( + ffi.Pointer env, + JClassPtr clazz, + ffi.Pointer name, + ffi.Pointer sig)>> + GetStaticMethodID, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + CallStaticObjectMethod, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticObjectMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallStaticObjectMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticBooleanMethod, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticBooleanMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticBooleanMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + CallStaticByteMethod, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticByteMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallStaticByteMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + CallStaticCharMethod, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticCharMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallStaticCharMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticShortMethod, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticShortMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticShortMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + CallStaticIntMethod, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticIntMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallStaticIntMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + CallStaticLongMethod, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticLongMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallStaticLongMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticFloatMethod, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticFloatMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticFloatMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, + JClassPtr clazz, JMethodIDPtr methodID)>> + CallStaticDoubleMethod, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticDoubleMethodV, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function( + ffi.Pointer env, + JClassPtr clazz, + JMethodIDPtr methodID, + ffi.Pointer args)>> + CallStaticDoubleMethodA, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID)>> + CallStaticVoidMethod, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, JClassPtr, + JMethodIDPtr, ffi.Pointer)>> + CallStaticVoidMethodV, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JMethodIDPtr methodID, ffi.Pointer args)>> + CallStaticVoidMethodA, + required ffi.Pointer< + ffi.NativeFunction< + JFieldIDPtr Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer name, ffi.Pointer sig)>> + GetStaticFieldID, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> + GetStaticObjectField, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanMarker Function(ffi.Pointer env, + JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + JByteMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> + GetStaticByteField, + required ffi.Pointer< + ffi.NativeFunction< + JCharMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> + GetStaticCharField, + required ffi.Pointer< + ffi.NativeFunction< + JShortMarker Function(ffi.Pointer env, + JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticShortField, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> + GetStaticIntField, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID)>> + GetStaticLongField, + required ffi.Pointer< + ffi.NativeFunction< + JFloatMarker Function(ffi.Pointer env, + JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticFloatField, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleMarker Function(ffi.Pointer env, + JClassPtr clazz, JFieldIDPtr fieldID)>> + GetStaticDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JObjectPtr val)>> + SetStaticObjectField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JBooleanMarker val)>> + SetStaticBooleanField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JByteMarker val)>> + SetStaticByteField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JCharMarker val)>> + SetStaticCharField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JShortMarker val)>> + SetStaticShortField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JIntMarker val)>> + SetStaticIntField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JLongMarker val)>> + SetStaticLongField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JFloatMarker val)>> + SetStaticFloatField, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JClassPtr clazz, + JFieldIDPtr fieldID, JDoubleMarker val)>> + SetStaticDoubleField, + required ffi.Pointer< + ffi.NativeFunction< + JStringPtr Function(ffi.Pointer env, + ffi.Pointer unicodeChars, JSizeMarker len)>> + NewString, + required ffi.Pointer< + ffi.NativeFunction< + JSizeMarker Function( + ffi.Pointer env, JStringPtr string)>> + GetStringLength, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JStringPtr string, ffi.Pointer isCopy)>> + GetStringChars, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer isCopy)>> + ReleaseStringChars, + required ffi.Pointer< + ffi.NativeFunction< + JStringPtr Function( + ffi.Pointer env, ffi.Pointer bytes)>> + NewStringUTF, + required ffi.Pointer< + ffi.NativeFunction< + JSizeMarker Function( + ffi.Pointer env, JStringPtr string)>> + GetStringUTFLength, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JStringPtr string, ffi.Pointer isCopy)>> + GetStringUTFChars, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr string, + ffi.Pointer utf)>> + ReleaseStringUTFChars, + required ffi.Pointer< + ffi.NativeFunction< + JSizeMarker Function( + ffi.Pointer env, JArrayPtr array)>> + GetArrayLength, + required ffi.Pointer< + ffi.NativeFunction< + JObjectArrayPtr Function( + ffi.Pointer env, + JSizeMarker length, + JClassPtr elementClass, + JObjectPtr initialElement)>> + NewObjectArray, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, + JObjectArrayPtr array, JSizeMarker index)>> + GetObjectArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, + JObjectArrayPtr array, JSizeMarker index, JObjectPtr val)>> + SetObjectArrayElement, + required ffi.Pointer< + ffi.NativeFunction< + JBooleanArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewBooleanArray, + required ffi.Pointer< + ffi.NativeFunction< + JByteArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewByteArray, + required ffi.Pointer< + ffi.NativeFunction< + JCharArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewCharArray, + required ffi.Pointer< + ffi.NativeFunction< + JShortArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewShortArray, + required ffi.Pointer< + ffi.NativeFunction< + JIntArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewIntArray, + required ffi.Pointer< + ffi.NativeFunction< + JLongArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewLongArray, + required ffi.Pointer< + ffi.NativeFunction< + JFloatArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewFloatArray, + required ffi.Pointer< + ffi.NativeFunction< + JDoubleArrayPtr Function( + ffi.Pointer env, JSizeMarker length)>> + NewDoubleArray, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer isCopy)>> + GetBooleanArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JByteArrayPtr array, ffi.Pointer isCopy)>> + GetByteArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JCharArrayPtr array, ffi.Pointer isCopy)>> + GetCharArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JShortArrayPtr array, ffi.Pointer isCopy)>> + GetShortArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JIntArrayPtr array, ffi.Pointer isCopy)>> + GetIntArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JLongArrayPtr array, ffi.Pointer isCopy)>> + GetLongArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JFloatArrayPtr array, ffi.Pointer isCopy)>> + GetFloatArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JDoubleArrayPtr array, ffi.Pointer isCopy)>> + GetDoubleArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseBooleanArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JByteArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseByteArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JCharArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseCharArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JShortArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseShortArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JIntArrayPtr array, + ffi.Pointer elems, JIntMarker mode)>> + ReleaseIntArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JLongArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseLongArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JFloatArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseFloatArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + ffi.Pointer elems, + JIntMarker mode)>> + ReleaseDoubleArrayElements, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetBooleanArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetByteArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetCharArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetShortArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetIntArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetLongArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetFloatArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetDoubleArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JBooleanArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetBooleanArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JByteArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetByteArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JCharArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetCharArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JShortArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetShortArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JIntArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetIntArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JLongArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetLongArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JFloatArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetFloatArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JDoubleArrayPtr array, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + SetDoubleArrayRegion, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JClassPtr clazz, + ffi.Pointer methods, JIntMarker nMethods)>> + RegisterNatives, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function( + ffi.Pointer env, JClassPtr clazz)>> + UnregisterNatives, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> + MonitorEnter, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, JObjectPtr obj)>> + MonitorExit, + required ffi.Pointer< + ffi.NativeFunction< + JIntMarker Function(ffi.Pointer env, + ffi.Pointer> vm)>> + GetJavaVM, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JStringPtr str, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetStringRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer env, + JStringPtr str, + JSizeMarker start, + JSizeMarker len, + ffi.Pointer buf)>> + GetStringUTFRegion, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JArrayPtr array, ffi.Pointer isCopy)>> + GetPrimitiveArrayCritical, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JArrayPtr array, + ffi.Pointer carray, JIntMarker mode)>> + ReleasePrimitiveArrayCritical, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function(ffi.Pointer env, + JStringPtr str, ffi.Pointer isCopy)>> + GetStringCritical, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JStringPtr str, + ffi.Pointer carray)>> + ReleaseStringCritical, + required ffi.Pointer< + ffi.NativeFunction< + JWeakPtr Function(ffi.Pointer env, JObjectPtr obj)>> + NewWeakGlobalRef, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer env, JWeakPtr obj)>> + DeleteWeakGlobalRef, + required ffi.Pointer< + ffi + .NativeFunction env)>> + ExceptionCheck, + required ffi.Pointer< + ffi.NativeFunction< + JObjectPtr Function(ffi.Pointer env, + ffi.Pointer address, JLongMarker capacity)>> + NewDirectByteBuffer, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer env, JObjectPtr buf)>> + GetDirectBufferAddress, + required ffi.Pointer< + ffi.NativeFunction< + JLongMarker Function( + ffi.Pointer env, JObjectPtr buf)>> + GetDirectBufferCapacity, + required ffi.Pointer< + ffi.NativeFunction< + ffi.UnsignedInt Function( + ffi.Pointer env, JObjectPtr obj)>> + GetObjectRefType, + }) => + $allocator() + ..ref.reserved0 = reserved0 + ..ref.reserved1 = reserved1 + ..ref.reserved2 = reserved2 + ..ref.reserved3 = reserved3 + ..ref.GetVersion = GetVersion + ..ref.DefineClass = DefineClass + ..ref.FindClass = FindClass + ..ref.FromReflectedMethod = FromReflectedMethod + ..ref.FromReflectedField = FromReflectedField + ..ref.ToReflectedMethod = ToReflectedMethod + ..ref.GetSuperclass = GetSuperclass + ..ref.IsAssignableFrom = IsAssignableFrom + ..ref.ToReflectedField = ToReflectedField + ..ref.Throw = Throw + ..ref.ThrowNew = ThrowNew + ..ref.ExceptionOccurred = ExceptionOccurred + ..ref.ExceptionDescribe = ExceptionDescribe + ..ref.ExceptionClear = ExceptionClear + ..ref.FatalError = FatalError + ..ref.PushLocalFrame = PushLocalFrame + ..ref.PopLocalFrame = PopLocalFrame + ..ref.NewGlobalRef = NewGlobalRef + ..ref.DeleteGlobalRef = DeleteGlobalRef + ..ref.DeleteLocalRef = DeleteLocalRef + ..ref.IsSameObject = IsSameObject + ..ref.NewLocalRef = NewLocalRef + ..ref.EnsureLocalCapacity = EnsureLocalCapacity + ..ref.AllocObject = AllocObject + ..ref.NewObject = NewObject + ..ref.NewObjectV = NewObjectV + ..ref.NewObjectA = NewObjectA + ..ref.GetObjectClass = GetObjectClass + ..ref.IsInstanceOf = IsInstanceOf + ..ref.GetMethodID = GetMethodID + ..ref.CallObjectMethod = CallObjectMethod + ..ref.CallObjectMethodV = CallObjectMethodV + ..ref.CallObjectMethodA = CallObjectMethodA + ..ref.CallBooleanMethod = CallBooleanMethod + ..ref.CallBooleanMethodV = CallBooleanMethodV + ..ref.CallBooleanMethodA = CallBooleanMethodA + ..ref.CallByteMethod = CallByteMethod + ..ref.CallByteMethodV = CallByteMethodV + ..ref.CallByteMethodA = CallByteMethodA + ..ref.CallCharMethod = CallCharMethod + ..ref.CallCharMethodV = CallCharMethodV + ..ref.CallCharMethodA = CallCharMethodA + ..ref.CallShortMethod = CallShortMethod + ..ref.CallShortMethodV = CallShortMethodV + ..ref.CallShortMethodA = CallShortMethodA + ..ref.CallIntMethod = CallIntMethod + ..ref.CallIntMethodV = CallIntMethodV + ..ref.CallIntMethodA = CallIntMethodA + ..ref.CallLongMethod = CallLongMethod + ..ref.CallLongMethodV = CallLongMethodV + ..ref.CallLongMethodA = CallLongMethodA + ..ref.CallFloatMethod = CallFloatMethod + ..ref.CallFloatMethodV = CallFloatMethodV + ..ref.CallFloatMethodA = CallFloatMethodA + ..ref.CallDoubleMethod = CallDoubleMethod + ..ref.CallDoubleMethodV = CallDoubleMethodV + ..ref.CallDoubleMethodA = CallDoubleMethodA + ..ref.CallVoidMethod = CallVoidMethod + ..ref.CallVoidMethodV = CallVoidMethodV + ..ref.CallVoidMethodA = CallVoidMethodA + ..ref.CallNonvirtualObjectMethod = CallNonvirtualObjectMethod + ..ref.CallNonvirtualObjectMethodV = CallNonvirtualObjectMethodV + ..ref.CallNonvirtualObjectMethodA = CallNonvirtualObjectMethodA + ..ref.CallNonvirtualBooleanMethod = CallNonvirtualBooleanMethod + ..ref.CallNonvirtualBooleanMethodV = CallNonvirtualBooleanMethodV + ..ref.CallNonvirtualBooleanMethodA = CallNonvirtualBooleanMethodA + ..ref.CallNonvirtualByteMethod = CallNonvirtualByteMethod + ..ref.CallNonvirtualByteMethodV = CallNonvirtualByteMethodV + ..ref.CallNonvirtualByteMethodA = CallNonvirtualByteMethodA + ..ref.CallNonvirtualCharMethod = CallNonvirtualCharMethod + ..ref.CallNonvirtualCharMethodV = CallNonvirtualCharMethodV + ..ref.CallNonvirtualCharMethodA = CallNonvirtualCharMethodA + ..ref.CallNonvirtualShortMethod = CallNonvirtualShortMethod + ..ref.CallNonvirtualShortMethodV = CallNonvirtualShortMethodV + ..ref.CallNonvirtualShortMethodA = CallNonvirtualShortMethodA + ..ref.CallNonvirtualIntMethod = CallNonvirtualIntMethod + ..ref.CallNonvirtualIntMethodV = CallNonvirtualIntMethodV + ..ref.CallNonvirtualIntMethodA = CallNonvirtualIntMethodA + ..ref.CallNonvirtualLongMethod = CallNonvirtualLongMethod + ..ref.CallNonvirtualLongMethodV = CallNonvirtualLongMethodV + ..ref.CallNonvirtualLongMethodA = CallNonvirtualLongMethodA + ..ref.CallNonvirtualFloatMethod = CallNonvirtualFloatMethod + ..ref.CallNonvirtualFloatMethodV = CallNonvirtualFloatMethodV + ..ref.CallNonvirtualFloatMethodA = CallNonvirtualFloatMethodA + ..ref.CallNonvirtualDoubleMethod = CallNonvirtualDoubleMethod + ..ref.CallNonvirtualDoubleMethodV = CallNonvirtualDoubleMethodV + ..ref.CallNonvirtualDoubleMethodA = CallNonvirtualDoubleMethodA + ..ref.CallNonvirtualVoidMethod = CallNonvirtualVoidMethod + ..ref.CallNonvirtualVoidMethodV = CallNonvirtualVoidMethodV + ..ref.CallNonvirtualVoidMethodA = CallNonvirtualVoidMethodA + ..ref.GetFieldID = GetFieldID + ..ref.GetObjectField = GetObjectField + ..ref.GetBooleanField = GetBooleanField + ..ref.GetByteField = GetByteField + ..ref.GetCharField = GetCharField + ..ref.GetShortField = GetShortField + ..ref.GetIntField = GetIntField + ..ref.GetLongField = GetLongField + ..ref.GetFloatField = GetFloatField + ..ref.GetDoubleField = GetDoubleField + ..ref.SetObjectField = SetObjectField + ..ref.SetBooleanField = SetBooleanField + ..ref.SetByteField = SetByteField + ..ref.SetCharField = SetCharField + ..ref.SetShortField = SetShortField + ..ref.SetIntField = SetIntField + ..ref.SetLongField = SetLongField + ..ref.SetFloatField = SetFloatField + ..ref.SetDoubleField = SetDoubleField + ..ref.GetStaticMethodID = GetStaticMethodID + ..ref.CallStaticObjectMethod = CallStaticObjectMethod + ..ref.CallStaticObjectMethodV = CallStaticObjectMethodV + ..ref.CallStaticObjectMethodA = CallStaticObjectMethodA + ..ref.CallStaticBooleanMethod = CallStaticBooleanMethod + ..ref.CallStaticBooleanMethodV = CallStaticBooleanMethodV + ..ref.CallStaticBooleanMethodA = CallStaticBooleanMethodA + ..ref.CallStaticByteMethod = CallStaticByteMethod + ..ref.CallStaticByteMethodV = CallStaticByteMethodV + ..ref.CallStaticByteMethodA = CallStaticByteMethodA + ..ref.CallStaticCharMethod = CallStaticCharMethod + ..ref.CallStaticCharMethodV = CallStaticCharMethodV + ..ref.CallStaticCharMethodA = CallStaticCharMethodA + ..ref.CallStaticShortMethod = CallStaticShortMethod + ..ref.CallStaticShortMethodV = CallStaticShortMethodV + ..ref.CallStaticShortMethodA = CallStaticShortMethodA + ..ref.CallStaticIntMethod = CallStaticIntMethod + ..ref.CallStaticIntMethodV = CallStaticIntMethodV + ..ref.CallStaticIntMethodA = CallStaticIntMethodA + ..ref.CallStaticLongMethod = CallStaticLongMethod + ..ref.CallStaticLongMethodV = CallStaticLongMethodV + ..ref.CallStaticLongMethodA = CallStaticLongMethodA + ..ref.CallStaticFloatMethod = CallStaticFloatMethod + ..ref.CallStaticFloatMethodV = CallStaticFloatMethodV + ..ref.CallStaticFloatMethodA = CallStaticFloatMethodA + ..ref.CallStaticDoubleMethod = CallStaticDoubleMethod + ..ref.CallStaticDoubleMethodV = CallStaticDoubleMethodV + ..ref.CallStaticDoubleMethodA = CallStaticDoubleMethodA + ..ref.CallStaticVoidMethod = CallStaticVoidMethod + ..ref.CallStaticVoidMethodV = CallStaticVoidMethodV + ..ref.CallStaticVoidMethodA = CallStaticVoidMethodA + ..ref.GetStaticFieldID = GetStaticFieldID + ..ref.GetStaticObjectField = GetStaticObjectField + ..ref.GetStaticBooleanField = GetStaticBooleanField + ..ref.GetStaticByteField = GetStaticByteField + ..ref.GetStaticCharField = GetStaticCharField + ..ref.GetStaticShortField = GetStaticShortField + ..ref.GetStaticIntField = GetStaticIntField + ..ref.GetStaticLongField = GetStaticLongField + ..ref.GetStaticFloatField = GetStaticFloatField + ..ref.GetStaticDoubleField = GetStaticDoubleField + ..ref.SetStaticObjectField = SetStaticObjectField + ..ref.SetStaticBooleanField = SetStaticBooleanField + ..ref.SetStaticByteField = SetStaticByteField + ..ref.SetStaticCharField = SetStaticCharField + ..ref.SetStaticShortField = SetStaticShortField + ..ref.SetStaticIntField = SetStaticIntField + ..ref.SetStaticLongField = SetStaticLongField + ..ref.SetStaticFloatField = SetStaticFloatField + ..ref.SetStaticDoubleField = SetStaticDoubleField + ..ref.NewString = NewString + ..ref.GetStringLength = GetStringLength + ..ref.GetStringChars = GetStringChars + ..ref.ReleaseStringChars = ReleaseStringChars + ..ref.NewStringUTF = NewStringUTF + ..ref.GetStringUTFLength = GetStringUTFLength + ..ref.GetStringUTFChars = GetStringUTFChars + ..ref.ReleaseStringUTFChars = ReleaseStringUTFChars + ..ref.GetArrayLength = GetArrayLength + ..ref.NewObjectArray = NewObjectArray + ..ref.GetObjectArrayElement = GetObjectArrayElement + ..ref.SetObjectArrayElement = SetObjectArrayElement + ..ref.NewBooleanArray = NewBooleanArray + ..ref.NewByteArray = NewByteArray + ..ref.NewCharArray = NewCharArray + ..ref.NewShortArray = NewShortArray + ..ref.NewIntArray = NewIntArray + ..ref.NewLongArray = NewLongArray + ..ref.NewFloatArray = NewFloatArray + ..ref.NewDoubleArray = NewDoubleArray + ..ref.GetBooleanArrayElements = GetBooleanArrayElements + ..ref.GetByteArrayElements = GetByteArrayElements + ..ref.GetCharArrayElements = GetCharArrayElements + ..ref.GetShortArrayElements = GetShortArrayElements + ..ref.GetIntArrayElements = GetIntArrayElements + ..ref.GetLongArrayElements = GetLongArrayElements + ..ref.GetFloatArrayElements = GetFloatArrayElements + ..ref.GetDoubleArrayElements = GetDoubleArrayElements + ..ref.ReleaseBooleanArrayElements = ReleaseBooleanArrayElements + ..ref.ReleaseByteArrayElements = ReleaseByteArrayElements + ..ref.ReleaseCharArrayElements = ReleaseCharArrayElements + ..ref.ReleaseShortArrayElements = ReleaseShortArrayElements + ..ref.ReleaseIntArrayElements = ReleaseIntArrayElements + ..ref.ReleaseLongArrayElements = ReleaseLongArrayElements + ..ref.ReleaseFloatArrayElements = ReleaseFloatArrayElements + ..ref.ReleaseDoubleArrayElements = ReleaseDoubleArrayElements + ..ref.GetBooleanArrayRegion = GetBooleanArrayRegion + ..ref.GetByteArrayRegion = GetByteArrayRegion + ..ref.GetCharArrayRegion = GetCharArrayRegion + ..ref.GetShortArrayRegion = GetShortArrayRegion + ..ref.GetIntArrayRegion = GetIntArrayRegion + ..ref.GetLongArrayRegion = GetLongArrayRegion + ..ref.GetFloatArrayRegion = GetFloatArrayRegion + ..ref.GetDoubleArrayRegion = GetDoubleArrayRegion + ..ref.SetBooleanArrayRegion = SetBooleanArrayRegion + ..ref.SetByteArrayRegion = SetByteArrayRegion + ..ref.SetCharArrayRegion = SetCharArrayRegion + ..ref.SetShortArrayRegion = SetShortArrayRegion + ..ref.SetIntArrayRegion = SetIntArrayRegion + ..ref.SetLongArrayRegion = SetLongArrayRegion + ..ref.SetFloatArrayRegion = SetFloatArrayRegion + ..ref.SetDoubleArrayRegion = SetDoubleArrayRegion + ..ref.RegisterNatives = RegisterNatives + ..ref.UnregisterNatives = UnregisterNatives + ..ref.MonitorEnter = MonitorEnter + ..ref.MonitorExit = MonitorExit + ..ref.GetJavaVM = GetJavaVM + ..ref.GetStringRegion = GetStringRegion + ..ref.GetStringUTFRegion = GetStringUTFRegion + ..ref.GetPrimitiveArrayCritical = GetPrimitiveArrayCritical + ..ref.ReleasePrimitiveArrayCritical = ReleasePrimitiveArrayCritical + ..ref.GetStringCritical = GetStringCritical + ..ref.ReleaseStringCritical = ReleaseStringCritical + ..ref.NewWeakGlobalRef = NewWeakGlobalRef + ..ref.DeleteWeakGlobalRef = DeleteWeakGlobalRef + ..ref.ExceptionCheck = ExceptionCheck + ..ref.NewDirectByteBuffer = NewDirectByteBuffer + ..ref.GetDirectBufferAddress = GetDirectBufferAddress + ..ref.GetDirectBufferCapacity = GetDirectBufferCapacity + ..ref.GetObjectRefType = GetObjectRefType; +} - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JShortArrayPtr array, JSizeMarker index)>> - GetShortArrayElement; +final class JNINativeMethod extends ffi.Struct { + external ffi.Pointer name; - external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function(JShortArrayPtr array, JSizeMarker index, - JShortMarker element)>> SetShortArrayElement; + external ffi.Pointer signature; - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JIntArrayPtr array, JSizeMarker index)>> - GetIntArrayElement; + external ffi.Pointer fnPtr; - external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JIntArrayPtr array, JSizeMarker index, JIntMarker element)>> - SetIntArrayElement; + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer name, + required ffi.Pointer signature, + required ffi.Pointer fnPtr, + }) => + $allocator() + ..ref.name = name + ..ref.signature = signature + ..ref.fnPtr = fnPtr; +} - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JLongArrayPtr array, JSizeMarker index)>> - GetLongArrayElement; +typedef JObjectArrayPtr = JArrayPtr; - external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function( - JLongArrayPtr array, JSizeMarker index, JLongMarker element)>> - SetLongArrayElement; +/// Reference types, in C. +typedef JObjectPtr = ffi.Pointer; - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JFloatArrayPtr array, JSizeMarker index)>> - GetFloatArrayElement; +enum JObjectRefType { + JNIInvalidRefType(0), + JNILocalRefType(1), + JNIGlobalRefType(2), + JNIWeakGlobalRefType(3); - external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function(JFloatArrayPtr array, JSizeMarker index, - JFloatMarker element)>> SetFloatArrayElement; + final int value; + const JObjectRefType(this.value); - external ffi.Pointer< - ffi.NativeFunction< - JniResult Function(JDoubleArrayPtr array, JSizeMarker index)>> - GetDoubleArrayElement; + static JObjectRefType fromValue(int value) => switch (value) { + 0 => JNIInvalidRefType, + 1 => JNILocalRefType, + 2 => JNIGlobalRefType, + 3 => JNIWeakGlobalRefType, + _ => throw ArgumentError('Unknown value for JObjectRefType: $value'), + }; +} - external ffi.Pointer< - ffi.NativeFunction< - JThrowablePtr Function(JDoubleArrayPtr array, JSizeMarker index, - JDoubleMarker element)>> SetDoubleArrayElement; +typedef JShortArrayPtr = JArrayPtr; +typedef JShortMarker = ffi.Int16; +typedef DartJShortMarker = int; + +/// "cardinal indices and sizes" +typedef JSizeMarker = JIntMarker; +typedef JStringPtr = JObjectPtr; +typedef JThrowablePtr = JObjectPtr; + +final class JValue extends ffi.Union { + @JBooleanMarker() + external int z; + + @JByteMarker() + external int b; + + @JCharMarker() + external int c; + + @JShortMarker() + external int s; + + @JIntMarker() + external int i; + + @JLongMarker() + external int j; + + @JFloatMarker() + external double f; + + @JDoubleMarker() + external double d; + + external JObjectPtr l; +} + +typedef JWeakPtr = JObjectPtr; +typedef JavaVM = ffi.Pointer; +typedef JavaVM$1 = ffi.Pointer; + +final class JavaVMInitArgs extends ffi.Struct { + /// use JNI_VERSION_1_2 or later + @JIntMarker() + external int version; + + @JIntMarker() + external int nOptions; + + external ffi.Pointer options; + + @JBooleanMarker() + external int ignoreUnrecognized; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int version, + required int nOptions, + required ffi.Pointer options, + required int ignoreUnrecognized, + }) => + $allocator() + ..ref.version = version + ..ref.nOptions = nOptions + ..ref.options = options + ..ref.ignoreUnrecognized = ignoreUnrecognized; +} + +/// JNI 1.2+ initialization. (As of 1.6, the pre-1.2 structures are no +/// longer supported.) +final class JavaVMOption extends ffi.Struct { + external ffi.Pointer optionString; + + external ffi.Pointer extraInfo; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer optionString, + required ffi.Pointer extraInfo, + }) => + $allocator() + ..ref.optionString = optionString + ..ref.extraInfo = extraInfo; +} + +enum JniBooleanValues { + FALSE(0), + TRUE(1); + + final int value; + const JniBooleanValues(this.value); + + static JniBooleanValues fromValue(int value) => switch (value) { + 0 => FALSE, + 1 => TRUE, + _ => throw ArgumentError('Unknown value for JniBooleanValues: $value'), + }; +} + +enum JniBufferWriteBack { + /// copy content, do not free buffer + COMMIT(1), + + /// free buffer w/o copying back + ABORT(2); + + final int value; + const JniBufferWriteBack(this.value); + + static JniBufferWriteBack fromValue(int value) => switch (value) { + 1 => COMMIT, + 2 => ABORT, + _ => + throw ArgumentError('Unknown value for JniBufferWriteBack: $value'), + }; +} + +/// Types used by JNI API to distinguish between primitive types. +enum JniCallType { + booleanType(0), + byteType(1), + shortType(2), + charType(3), + intType(4), + longType(5), + floatType(6), + doubleType(7), + objectType(8), + voidType(9); + + final int value; + const JniCallType(this.value); + + static JniCallType fromValue(int value) => switch (value) { + 0 => booleanType, + 1 => byteType, + 2 => shortType, + 3 => charType, + 4 => intType, + 5 => longType, + 6 => floatType, + 7 => doubleType, + 8 => objectType, + 9 => voidType, + _ => throw ArgumentError('Unknown value for JniCallType: $value'), + }; +} + +/// Similar to [JniResult] but for class lookups. +final class JniClassLookupResult extends ffi.Struct { + external JClassPtr value; + + external JThrowablePtr exception; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required JClassPtr value, + required JThrowablePtr exception, + }) => + $allocator() + ..ref.value = value + ..ref.exception = exception; +} + +typedef JniEnv = ffi.Pointer; +typedef JniEnv$1 = ffi.Pointer; + +enum JniErrorCode { + /// no error + OK(0), + + /// generic error + ERR(-1), + + /// thread detached from the VM + EDETACHED(-2), + + /// JNI version error + EVERSION(-3), + + /// Out of memory + ENOMEM(-4), + + /// VM already created + EEXIST(-5), + + /// Invalid argument + EINVAL(-6), + SINGLETON_EXISTS(-99); + + final int value; + const JniErrorCode(this.value); + + static JniErrorCode fromValue(int value) => switch (value) { + 0 => OK, + -1 => ERR, + -2 => EDETACHED, + -3 => EVERSION, + -4 => ENOMEM, + -5 => EEXIST, + -6 => EINVAL, + -99 => SINGLETON_EXISTS, + _ => throw ArgumentError('Unknown value for JniErrorCode: $value'), + }; +} + +/// JniExceptionDetails holds 2 jstring objects, one is the result of +/// calling `toString` on exception object, other is stack trace; +final class JniExceptionDetails extends ffi.Struct { + external JStringPtr message; + + external JStringPtr stacktrace; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required JStringPtr message, + required JStringPtr stacktrace, + }) => + $allocator() + ..ref.message = message + ..ref.stacktrace = stacktrace; +} + +/// Similar to [JniResult] but for method/field ID lookups. +final class JniPointerResult extends ffi.Struct { + external ffi.Pointer value; + + external JThrowablePtr exception; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer value, + required JThrowablePtr exception, + }) => + $allocator() + ..ref.value = value + ..ref.exception = exception; +} + +/// Result type for use by JNI. +/// +/// If [exception] is null, it means the result is valid. +/// It's assumed that the caller knows the expected type in [result]. +final class JniResult extends ffi.Struct { + external JValue value; + + external JThrowablePtr exception; +} + +enum JniVersions { + VERSION_1_1(65537), + VERSION_1_2(65538), + VERSION_1_4(65540), + VERSION_1_6(65542); + + final int value; + const JniVersions(this.value); + + static JniVersions fromValue(int value) => switch (value) { + 65537 => VERSION_1_1, + 65538 => VERSION_1_2, + 65540 => VERSION_1_4, + 65542 => VERSION_1_6, + _ => throw ArgumentError('Unknown value for JniVersions: $value'), + }; +} + +typedef MutexLock = pthread_mutex_t; + +final class UnnamedStruct extends ffi.Struct { + @ffi.UnsignedInt() + external int __low; + + @ffi.UnsignedInt() + external int __high; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int $low, + required int $high, + }) => + $allocator() + ..ref.__low = $low + ..ref.__high = $high; +} + +final class __atomic_wide_counter extends ffi.Union { + @ffi.UnsignedLongLong() + external int __value64; + + external UnnamedStruct __value32; +} + +final class __pthread_cond_s extends ffi.Struct { + external __atomic_wide_counter __wseq; + + external __atomic_wide_counter __g1_start; + + @ffi.Array.multi([2]) + external ffi.Array __g_size; + + @ffi.UnsignedInt() + external int __g1_orig_size; + + @ffi.UnsignedInt() + external int __wrefs; + + @ffi.Array.multi([2]) + external ffi.Array __g_signals; + + @ffi.UnsignedInt() + external int __unused_initialized_1; + + @ffi.UnsignedInt() + external int __unused_initialized_2; +} + +final class __pthread_internal_list extends ffi.Struct { + external ffi.Pointer<__pthread_internal_list> __prev; + + external ffi.Pointer<__pthread_internal_list> __next; +} + +typedef __pthread_list_t = __pthread_internal_list; + +final class __pthread_mutex_s extends ffi.Struct { + @ffi.Int() + external int __lock; + + @ffi.UnsignedInt() + external int __count; + + @ffi.Int() + external int __owner; + + @ffi.UnsignedInt() + external int __nusers; + + @ffi.Int() + external int __kind; + + @ffi.Short() + external int __spins; + + @ffi.Short() + external int __elision; + + external __pthread_list_t __list; +} + +final class jfieldID_ extends ffi.Opaque {} + +final class jmethodID_ extends ffi.Opaque {} + +final class pthread_cond_t extends ffi.Union { + external __pthread_cond_s __data; + + @ffi.Array.multi([48]) + external ffi.Array __size; + + @ffi.LongLong() + external int __align; +} + +typedef pthread_key_t = ffi.UnsignedInt; +typedef Dartpthread_key_t = int; + +final class pthread_mutex_t extends ffi.Union { + external __pthread_mutex_s __data; + + @ffi.Array.multi([40]) + external ffi.Array __size; + + @ffi.Long() + external int __align; } diff --git a/pkgs/jni/lib/src/types.dart b/pkgs/jni/lib/src/types.dart index 58920c4431..7d7931fcb8 100644 --- a/pkgs/jni/lib/src/types.dart +++ b/pkgs/jni/lib/src/types.dart @@ -27,98 +27,73 @@ sealed class JTypeBase { mixin JCallable on JTypeBase { DartT _staticCall( JClassPtr clazz, JMethodIDPtr methodID, Pointer args); + DartT? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args); DartT _instanceCall( JObjectPtr obj, JMethodIDPtr methodID, Pointer args); -} - -/// Able to be constructed. -mixin JConstructable on JTypeBase { - DartT _newObject( - JClassPtr clazz, JMethodIDPtr methodID, Pointer args); + DartT? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args); } /// Able to be the type of a field that can be get and set. mixin JAccessible on JTypeBase { DartT _staticGet(JClassPtr clazz, JFieldIDPtr fieldID); + DartT? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID); DartT _instanceGet(JObjectPtr obj, JFieldIDPtr fieldID); + DartT? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID); void _staticSet(JClassPtr clazz, JFieldIDPtr fieldID, DartT val); void _instanceSet(JObjectPtr obj, JFieldIDPtr fieldID, DartT val); } -/// Only used for JNIgen. -/// -/// Makes constructing objects easier inside the generated bindings by allowing -/// a [JReference] to be created. This allows [JObject]s to use constructors -/// that call `super.fromReference` instead of factories. -@internal -const referenceType = _ReferenceType(); - -final class _ReferenceType extends JTypeBase - with JConstructable { - const _ReferenceType(); - - @override - JReference _newObject( - JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { - return JGlobalReference(Jni.env.NewObjectA(clazz, methodID, args)); - } - - @internal - @override - String get signature => 'Ljava/lang/Object;'; -} - abstract class JType extends JTypeBase - with JCallable, JConstructable, JAccessible { - /// Number of super types. Distance to the root type. - @internal - int get superCount; - - @internal - JType get superType; - - @internal - JType get nullableType; - - @internal - bool get isNullable => this == nullableType; - + with JCallable, JAccessible { @internal const JType(); - /// Creates an object from this type using the reference. - @internal - T fromReference(JReference reference); - JClass get jClass { - if (signature.startsWith('L') && signature.endsWith(';')) { - return JClass.forName(signature.substring(1, signature.length - 1)); - } return JClass.forName(signature); } @override T _staticCall(JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { final result = Jni.env.CallStaticObjectMethodA(clazz, methodID, args); - return fromReference(JGlobalReference(result)); + return JObject.fromReference(JGlobalReference(result)) as T; + } + + @override + T? _staticCallNullable( + JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { + final result = Jni.env.CallStaticObjectMethodA(clazz, methodID, args); + return result == nullptr + ? null + : JObject.fromReference(JGlobalReference(result)) as T?; } @override T _instanceCall(JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { - return fromReference( - JGlobalReference(Jni.env.CallObjectMethodA(obj, methodID, args))); + final result = Jni.env.CallObjectMethodA(obj, methodID, args); + return JObject.fromReference(JGlobalReference(result)) as T; } @override - T _newObject(JClassPtr clazz, JMethodIDPtr methodID, Pointer args) { - return fromReference( - JGlobalReference(Jni.env.NewObjectA(clazz, methodID, args))); + T? _instanceCallNullable( + JObjectPtr obj, JMethodIDPtr methodID, Pointer args) { + final result = Jni.env.CallObjectMethodA(obj, methodID, args); + return result == nullptr + ? null + : JObject.fromReference(JGlobalReference(result)) as T?; } @override T _instanceGet(JObjectPtr obj, JFieldIDPtr fieldID) { - return fromReference( - JGlobalReference(Jni.env.GetObjectField(obj, fieldID))); + final ref = JGlobalReference(Jni.env.GetObjectField(obj, fieldID)); + return JObject.fromReference(ref) as T; + } + + @override + T? _instanceGetNullable(JObjectPtr obj, JFieldIDPtr fieldID) { + final ref = JGlobalReference(Jni.env.GetObjectField(obj, fieldID)); + return (ref.isNull ? null : JObject.fromReference(ref)) as T?; } @override @@ -129,8 +104,14 @@ abstract class JType extends JTypeBase @override T _staticGet(JClassPtr clazz, JFieldIDPtr fieldID) { - return fromReference( - JGlobalReference(Jni.env.GetStaticObjectField(clazz, fieldID))); + final ref = JGlobalReference(Jni.env.GetStaticObjectField(clazz, fieldID)); + return JObject.fromReference(ref) as T; + } + + @override + T? _staticGetNullable(JClassPtr clazz, JFieldIDPtr fieldID) { + final ref = JGlobalReference(Jni.env.GetStaticObjectField(clazz, fieldID)); + return (ref.isNull ? null : JObject.fromReference(ref)) as T?; } @override @@ -139,29 +120,3 @@ abstract class JType extends JTypeBase Jni.env.SetStaticObjectField(clazz, fieldID, valRef.pointer); } } - -/// Lowest common ancestor of two types in the inheritance tree. -JType _lowestCommonAncestor(JType a, JType b) { - if (a is! JType || b is! JType) { - // If one of the types are nullable, the common super type should also be - // nullable. - a = a.nullableType; - b = b.nullableType; - } - while (a.superCount > b.superCount) { - a = a.superType; - } - while (b.superCount > a.superCount) { - b = b.superType; - } - while (a != b) { - a = a.superType; - b = b.superType; - } - return a; -} - -@internal -JType lowestCommonSuperType(List> types) { - return types.reduce(_lowestCommonAncestor); -} diff --git a/pkgs/jni/lib/src/util/jiterator.dart b/pkgs/jni/lib/src/util/jiterator.dart index 573747dbc2..4e93a43e7d 100644 --- a/pkgs/jni/lib/src/util/jiterator.dart +++ b/pkgs/jni/lib/src/util/jiterator.dart @@ -4,134 +4,31 @@ import 'package:meta/meta.dart' show internal; +import '../core_bindings.dart'; import '../jobject.dart'; -import '../jreference.dart'; -import '../types.dart'; -@internal -final class $JIterator$NullableType$<$E extends JObject?> - extends JType?> { - final JType<$E> E; - - const $JIterator$NullableType$( - this.E, - ); - - @override - String get signature => r'Ljava/util/Iterator;'; - - @override - JIterator<$E>? fromReference(JReference reference) => - reference.isNull ? null : JIterator<$E>.fromReference(E, reference); - - @override - JType get superType => const $JObject$NullableType$(); - - @override - JType?> get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => Object.hash($JIterator$NullableType$, E); - - @override - bool operator ==(Object other) { - return other.runtimeType == ($JIterator$NullableType$<$E>) && - other is $JIterator$NullableType$<$E> && - E == other.E; - } +extension JIteratorToAdapter on JIterator { + /// Wraps this [JIterator] in an adapter that implements an [Iterator]. + Iterator asDart() => JIteratorAdapter(this); } @internal -final class $JIterator$Type$<$E extends JObject?> extends JType> { - final JType<$E> E; - - const $JIterator$Type$( - this.E, - ); +final class JIteratorAdapter implements Iterator { + final JIterator _itr; + E? _current; - @override - String get signature => r'Ljava/util/Iterator;'; - - @override - JIterator<$E> fromReference(JReference reference) => - JIterator<$E>.fromReference(E, reference); + JIteratorAdapter(this._itr); @override - JType get superType => const $JObject$Type$(); - - @override - JType?> get nullableType => $JIterator$NullableType$<$E>(E); - - @override - final superCount = 1; - - @override - int get hashCode => Object.hash($JIterator$Type$, E); - - @override - bool operator ==(Object other) { - return other.runtimeType == ($JIterator$Type$<$E>) && - other is $JIterator$Type$<$E> && - E == other.E; - } -} - -class JIterator<$E extends JObject?> extends JObject implements Iterator<$E> { - @internal - @override - // ignore: overridden_fields - final JType> $type; - - @internal - final JType<$E> E; - - JIterator.fromReference( - this.E, - JReference reference, - ) : $type = type<$E>(E), - super.fromReference(reference); - - static final _class = JClass.forName(r'java/util/Iterator'); - - /// The type which includes information such as the signature of this class. - static JType> type<$E extends JObject?>( - JType<$E> E, - ) { - return $JIterator$Type$<$E>(E); - } - - /// The type which includes information such as the signature of this class. - static JType?> nullableType<$E extends JObject?>( - JType<$E> E, - ) { - return $JIterator$NullableType$<$E>(E); - } - - $E? _current; - - @override - $E get current => _current as $E; - - static final _hasNextId = _class.instanceMethodId(r'hasNext', r'()Z'); - bool _hasNext() { - return _hasNextId(this, const jbooleanType(), [])!; - } - - static final _nextId = - _class.instanceMethodId(r'next', r'()Ljava/lang/Object;'); - $E _next() { - return _nextId(this, E, [])!; - } + E get current => _current as E; @override + @pragma('vm:prefer-inline') bool moveNext() { - if (!_hasNext()) { + if (!_itr.hasNext()) { return false; } - _current = _next(); + _current = _itr.next() as E; return true; } } diff --git a/pkgs/jni/lib/src/util/jlist.dart b/pkgs/jni/lib/src/util/jlist.dart index 40ddd7629a..e3788e12ff 100644 --- a/pkgs/jni/lib/src/util/jlist.dart +++ b/pkgs/jni/lib/src/util/jlist.dart @@ -4,308 +4,68 @@ import 'dart:collection'; -import 'package:meta/meta.dart' show internal; - -import '../jni.dart'; +import '../../_internal.dart'; +import '../core_bindings.dart'; import '../jobject.dart'; -import '../jreference.dart'; -import '../jvalues.dart'; -import '../types.dart'; -import 'jiterator.dart'; -import 'jset.dart'; - -@internal -final class $JList$NullableType$<$E extends JObject?> - extends JType?> { - final JType<$E> E; - - const $JList$NullableType$( - this.E, - ); - - @override - String get signature => r'Ljava/util/List;'; - - @override - JList<$E>? fromReference(JReference reference) => - reference.isNull ? null : JList<$E>.fromReference(E, reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType?> get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => Object.hash($JList$NullableType$, E); - - @override - bool operator ==(Object other) { - return other.runtimeType == ($JList$NullableType$<$E>) && - other is $JList$NullableType$<$E> && - E == other.E; - } -} - -@internal -final class $JList$Type$<$E extends JObject?> extends JType> { - final JType<$E> E; - - const $JList$Type$( - this.E, - ); - - @override - String get signature => r'Ljava/util/List;'; - - @override - JList<$E> fromReference(JReference reference) => - JList<$E>.fromReference(E, reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType?> get nullableType => $JList$NullableType$<$E>(E); - - @override - final superCount = 1; - - @override - int get hashCode => Object.hash($JList$Type$, E); - @override - bool operator ==(Object other) { - return other.runtimeType == ($JList$Type$<$E>) && - other is $JList$Type$<$E> && - E == other.E; - } +extension JListToAdapter on JList { + /// Wraps this [JList] in an adapter that implements a [List]. + /// + /// This is not a conversion, doesn't create a new list, or change the + /// elements. + List asDart() => _JListAdapter(this); } -class JList<$E extends JObject?> extends JObject with ListMixin<$E> { - @internal - @override - // ignore: overridden_fields - final JType> $type; - - @internal - final JType<$E> E; - - JList.fromReference( - this.E, - JReference reference, - ) : $type = type<$E>(E), - super.fromReference(reference); +final class _JListAdapter with ListBase { + final JList _jlist; - static final _class = JClass.forName(r'java/util/List'); + _JListAdapter(this._jlist); - /// The type which includes information such as the signature of this class. - static JType> type<$E extends JObject?>( - JType<$E> E, - ) { - return $JList$Type$<$E>(E); - } - - /// The type which includes information such as the signature of this class. - static JType?> nullableType<$E extends JObject?>(JType<$E> E) { - return $JList$NullableType$<$E>(E); - } - - static final _arrayListClassRef = JClass.forName(r'java/util/ArrayList'); - static final _ctorId = _arrayListClassRef.constructorId(r'()V'); - JList.array(this.E) - : $type = type<$E>(E), - super.fromReference(_ctorId(_arrayListClassRef, referenceType, [])); - - static final _sizeId = _class.instanceMethodId(r'size', r'()I'); @override - int get length => _sizeId(this, const jintType(), [])!; + int get length => _jlist.size(); @override set length(int newLength) { RangeError.checkNotNegative(newLength); while (length < newLength) { - add(null as $E); + add(null as E); } while (newLength < length) { removeAt(length - 1); } } - static final _getId = - _class.instanceMethodId(r'get', r'(I)Ljava/lang/Object;'); - @override - $E operator [](int index) { - RangeError.checkValidIndex(index, this); - return _getId(this, E, [JValueInt(index)]); - } - - static final _setId = _class.instanceMethodId( - r'set', r'(ILjava/lang/Object;)Ljava/lang/Object;'); @override - void operator []=(int index, $E value) { + E removeAt(int index) { RangeError.checkValidIndex(index, this); - _setId(this, E, [JValueInt(index), value]); - } - - static final _addId = - _class.instanceMethodId(r'add', r'(Ljava/lang/Object;)Z'); - @override - void add($E element) { - _addId(this, const jbooleanType(), [element]); - } - - static final _collectionClass = JClass.forName('java/util/Collection'); - static final _addAllId = - _class.instanceMethodId(r'addAll', r'(Ljava/util/Collection;)Z'); - @override - void addAll(Iterable<$E> iterable) { - if (iterable is JObject) { - final iterableRef = (iterable as JObject).reference; - if (Jni.env.IsInstanceOf( - iterableRef.pointer, _collectionClass.reference.pointer)) { - _addAllId(this, const jbooleanType(), [iterableRef.pointer]); - return; - } - } - return super.addAll(iterable); - } - - static final _clearId = _class.instanceMethodId(r'clear', r'()V'); - @override - void clear() { - _clearId(this, const jvoidType(), []); - } - - static final _containsId = - _class.instanceMethodId(r'contains', r'(Ljava/lang/Object;)Z'); - @override - bool contains(Object? element) { - if (element is! JObject?) return false; - final elementRef = element?.reference ?? jNullReference; - return _containsId(this, const jbooleanType(), [elementRef.pointer])!; - } - - static final _getRangeId = - _class.instanceMethodId(r'subList', r'(II)Ljava/util/List;'); - @override - JList<$E> getRange(int start, int end) { - RangeError.checkValidRange(start, end, length); - return _getRangeId( - this, $JList$Type$<$E>(E), [JValueInt(start), JValueInt(end)])!; - } - - static final _indexOfId = - _class.instanceMethodId(r'indexOf', r'(Ljava/lang/Object;)I'); - @override - int indexOf(Object? element, [int start = 0]) { - if (element is! JObject?) return -1; - if (start < 0) start = 0; - final elementRef = element?.reference ?? jNullReference; - if (start == 0) { - return _indexOfId(this, const jintType(), [elementRef.pointer])!; - } - return _indexOfId( - getRange(start, length), - const jintType(), - [elementRef.pointer], - )!; - } - - static final _insertId = - _class.instanceMethodId(r'add', r'(ILjava/lang/Object;)V'); - @override - void insert(int index, $E element) { - _insertId(this, const jvoidType(), [JValueInt(index), element]); - } - - static final _insertAllId = - _class.instanceMethodId(r'addAll', r'(ILjava/util/Collection;)Z'); - @override - void insertAll(int index, Iterable<$E> iterable) { - if (iterable is JObject) { - final iterableRef = (iterable as JObject).reference; - if (Jni.env.IsInstanceOf( - iterableRef.pointer, _collectionClass.reference.pointer)) { - _insertAllId( - this, - const jbooleanType(), - [JValueInt(index), iterableRef.pointer], - ); - return; - } - } - super.insertAll(index, iterable); - } - - static final _isEmptyId = _class.instanceMethodId(r'isEmpty', r'()Z'); - @override - bool get isEmpty => _isEmptyId(this, const jbooleanType(), [])!; - - @override - bool get isNotEmpty => !isEmpty; - - static final _iteratorId = - _class.instanceMethodId(r'iterator', r'()Ljava/util/Iterator;'); - @override - JIterator<$E> get iterator => _iteratorId(this, $JIterator$Type$<$E>(E), [])!; - - static final _lastIndexOfId = - _class.instanceMethodId(r'lastIndexOf', r'(Ljava/lang/Object;)I'); - @override - int lastIndexOf(Object? element, [int? start]) { - if (element is! JObject?) return -1; - if (start == null || start >= length) start = length - 1; - final elementRef = element?.reference ?? jNullReference; - if (start == length - 1) { - return _lastIndexOfId(this, const jintType(), [elementRef.pointer]); - } - final range = getRange(0, start); - final res = _lastIndexOfId( - range, - const jintType(), - [elementRef.pointer], - ); - range.release(); - return res; + return _jlist.remove(index) as E; } - static final _removeId = - _class.instanceMethodId(r'remove', r'(Ljava/lang/Object;)Z'); @override - bool remove(Object? element) { - if (element is! JObject?) return false; - final elementRef = element?.reference ?? jNullReference; - return _removeId(this, const jbooleanType(), [elementRef.pointer]); - } + Iterator get iterator => JIteratorAdapter(_jlist.iterator()!); - static final _removeAtId = - _class.instanceMethodId(r'remove', r'(I)Ljava/lang/Object;'); @override - $E removeAt(int index) { - return _removeAtId(this, E, [JValueInt(index)])!; + E operator [](int index) { + RangeError.checkValidIndex(index, this); + return _jlist.get(index) as E; } @override - void removeRange(int start, int end) { - final range = getRange(start, end); - range.clear(); - range.release(); + void operator []=(int index, E value) { + RangeError.checkValidIndex(index, this); + _jlist.set(index, value); } @override - JSet<$E> toSet() { - return toJSet(E); - } + void add(E value) => _jlist.add(value); } extension ToJavaList on Iterable { - JList toJList(JType type) { - final list = JList.array(type); - list.addAll(this); + JList toJList() { + // TODO(https://github.com/dart-lang/native/issues/2012): Remove this as + // hack. + final list = (JArrayList() as JObject) as JList; + list.asDart().addAll(this); return list; } } diff --git a/pkgs/jni/lib/src/util/jmap.dart b/pkgs/jni/lib/src/util/jmap.dart index a8abfc49d4..fd17c9df50 100644 --- a/pkgs/jni/lib/src/util/jmap.dart +++ b/pkgs/jni/lib/src/util/jmap.dart @@ -4,232 +4,85 @@ import 'dart:collection'; -import 'package:meta/meta.dart' show internal; - +import '../core_bindings.dart'; import '../jobject.dart'; -import '../jreference.dart'; -import '../types.dart'; -import 'jset.dart'; - -@internal -final class $JMap$NullableType$<$K extends JObject?, $V extends JObject?> - extends JType?> { - final JType<$K> K; - - final JType<$V> V; - - const $JMap$NullableType$( - this.K, - this.V, - ); - - @override - String get signature => r'Ljava/util/Map;'; - - @override - JMap<$K, $V>? fromReference(JReference reference) => - reference.isNull ? null : JMap<$K, $V>.fromReference(K, V, reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType?> get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => Object.hash($JMap$NullableType$, K, V); - - @override - bool operator ==(Object other) { - return other.runtimeType == ($JMap$NullableType$<$K, $V>) && - other is $JMap$NullableType$<$K, $V> && - K == other.K && - V == other.V; - } +import 'jiterator.dart'; + +extension JMapToAdapter on JMap { + /// Wraps this [JMap] in an adapter that implements an immutable [Map]. + /// + /// This is not a conversion, doesn't create a new map, or change the + /// elements. + Map asDart() => _JMapAdapter(this); } -@internal -final class $JMap$Type$<$K extends JObject?, $V extends JObject?> - extends JType> { - final JType<$K> K; - - final JType<$V> V; +final class _JMapAdapter + with MapBase { + final JMap _jmap; - const $JMap$Type$( - this.K, - this.V, - ); + _JMapAdapter(this._jmap); @override - String get signature => r'Ljava/util/Map;'; + int get length => _jmap.size(); @override - JMap<$K, $V> fromReference(JReference reference) => - JMap<$K, $V>.fromReference(K, V, reference); + V? operator [](Object? key) => key is K ? _jmap.get(key) : null; @override - JType get superType => const $JObject$Type$(); + void operator []=(K key, V value) => _jmap.put(key, value); @override - JType?> get nullableType => $JMap$NullableType$<$K, $V>(K, V); + Iterable get keys => _JMapKeySetAdapter(_jmap.keySet()!); @override - final superCount = 1; + Iterable get values => _JMapValueCollectionsAdapter(_jmap.values()!); @override - int get hashCode => Object.hash($JMap$Type$, K, V); + bool containsKey(Object? key) => key is K ? _jmap.containsKey(key) : false; @override - bool operator ==(Object other) { - return other.runtimeType == ($JMap$Type$<$K, $V>) && - other is $JMap$Type$<$K, $V> && - K == other.K && - V == other.V; - } -} + bool containsValue(Object? key) => + key is K ? _jmap.containsValue(key) : false; -class JMap<$K extends JObject?, $V extends JObject?> extends JObject - with MapMixin<$K, $V> { - @internal @override - // ignore: overridden_fields - final JType> $type; - - @internal - final JType<$K> K; - - @internal - final JType<$V> V; - - JMap.fromReference( - this.K, - this.V, - JReference reference, - ) : $type = type<$K, $V>(K, V), - super.fromReference(reference); - - static final _class = JClass.forName(r'java/util/Map'); - - /// The type which includes information such as the signature of this class. - static JType> type<$K extends JObject?, $V extends JObject?>( - JType<$K> K, - JType<$V> V, - ) { - return $JMap$Type$<$K, $V>(K, V); - } - - /// The type which includes information such as the signature of this class. - static JType?> - nullableType<$K extends JObject?, $V extends JObject?>( - JType<$K> K, - JType<$V> V, - ) { - return $JMap$NullableType$<$K, $V>(K, V); - } + void clear() => _jmap.clear(); - static final _hashMapClass = JClass.forName(r'java/util/HashMap'); - static final _ctorId = _hashMapClass.constructorId(r'()V'); - JMap.hash(this.K, this.V) - : $type = type<$K, $V>(K, V), - super.fromReference(_ctorId(_hashMapClass, referenceType, [])); - - static final _getId = _class.instanceMethodId( - r'get', r'(Ljava/lang/Object;)Ljava/lang/Object;'); @override - $V? operator [](Object? key) { - if (key is! JObject?) { - return null; - } - final keyRef = key?.reference ?? jNullReference; - final value = _getId(this, V.nullableType, [keyRef.pointer]); - return value; - } - - static final _putId = _class.instanceMethodId( - r'put', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;'); - @override - void operator []=($K key, $V value) { - final keyRef = key?.reference ?? jNullReference; - final valueRef = value?.reference ?? jNullReference; - _putId(this, V.nullableType, [keyRef.pointer, valueRef.pointer]); - } - - static final _addAllId = - _class.instanceMethodId(r'putAll', r'(Ljava/util/Map;)V'); - @override - void addAll(Map<$K, $V> other) { - if (other is JMap<$K, $V>) { - final otherRef = other.reference; - _addAllId(this, const jvoidType(), [otherRef.pointer]); - return; - } - super.addAll(other); - } + V? remove(Object? key) => key is K ? _jmap.remove(key) : null; +} - static final _clearId = _class.instanceMethodId(r'clear', r'()V'); - @override - void clear() { - _clearId(this, const jvoidType(), []); - } +// Note: We could just use _JSetAdapter, except that Java's Map.keySet method +// returns JSet instead of JSet. +final class _JMapKeySetAdapter with Iterable { + final JSet _keys; - static final _containsKeyId = - _class.instanceMethodId(r'containsKey', r'(Ljava/lang/Object;)Z'); - @override - bool containsKey(Object? key) { - if (key is! JObject?) { - return false; - } - final keyRef = key?.reference ?? jNullReference; - return _containsKeyId(this, const jbooleanType(), [keyRef.pointer]); - } + _JMapKeySetAdapter(this._keys); - static final _containsValueId = - _class.instanceMethodId(r'containsValue', r'(Ljava/lang/Object;)Z'); @override - bool containsValue(Object? value) { - if (value is! JObject?) { - return false; - } - final valueRef = value?.reference ?? jNullReference; - return _containsValueId(this, const jbooleanType(), [valueRef.pointer]); - } + int get length => _keys.size(); - static final isEmptyId = _class.instanceMethodId(r'isEmpty', r'()Z'); @override - bool get isEmpty => isEmptyId(this, const jbooleanType(), []); + Iterator get iterator => JIteratorAdapter(_keys.iterator()!); @override - bool get isNotEmpty => !isEmpty; + bool contains(Object? key) => key is K ? _keys.contains(key) : false; +} - static final _keysId = - _class.instanceMethodId(r'keySet', r'()Ljava/util/Set;'); - @override - JSet<$K> get keys => _keysId(this, $JSet$Type$<$K>(K), [])!; +final class _JMapValueCollectionsAdapter with Iterable { + final JCollection _values; - static final _sizeId = _class.instanceMethodId(r'size', r'()I'); - @override - int get length => _sizeId(this, const jintType(), []); + _JMapValueCollectionsAdapter(this._values); - static final _removeId = _class.instanceMethodId( - r'remove', r'(Ljava/lang/Object;)Ljava/lang/Object;'); @override - $V? remove(Object? key) { - if (key is! JObject?) { - return null; - } - final keyRef = key?.reference ?? jNullReference; - final value = _removeId(this, V.nullableType, [keyRef.pointer]); - return value; - } + Iterator get iterator => JIteratorAdapter(_values.iterator()!); } extension ToJavaMap on Map { - JMap toJMap(JType keyType, JType valueType) { - final map = JMap.hash(keyType, valueType); - map.addAll(this); + JMap toJMap() { + // TODO(https://github.com/dart-lang/native/issues/2012): Remove this as + // hack. + final map = (JHashMap() as JObject) as JMap; + map.asDart().addAll(this); return map; } } diff --git a/pkgs/jni/lib/src/util/jset.dart b/pkgs/jni/lib/src/util/jset.dart index 6992ac244a..1b9b22c50b 100644 --- a/pkgs/jni/lib/src/util/jset.dart +++ b/pkgs/jni/lib/src/util/jset.dart @@ -4,255 +4,56 @@ import 'dart:collection'; -import 'package:meta/meta.dart' show internal; - -import '../jni.dart'; +import '../core_bindings.dart'; import '../jobject.dart'; -import '../jreference.dart'; -import '../types.dart'; import 'jiterator.dart'; -@internal -final class $JSet$NullableType$<$E extends JObject?> extends JType?> { - final JType<$E> E; - - const $JSet$NullableType$( - this.E, - ); - - @override - String get signature => r'Ljava/util/Set;'; - - @override - JSet<$E>? fromReference(JReference reference) => - reference.isNull ? null : JSet<$E>.fromReference(E, reference); - - @override - JType get superType => const $JObject$Type$(); - - @override - JType?> get nullableType => this; - - @override - final superCount = 1; - - @override - int get hashCode => Object.hash($JSet$NullableType$, E); - - @override - bool operator ==(Object other) { - return other.runtimeType == ($JSet$NullableType$<$E>) && - other is $JSet$NullableType$<$E> && - E == other.E; - } +extension JSetToAdapter on JSet { + /// Wraps this [JSet] in an adapter that implements a [Set]. + /// + /// This is not a conversion, doesn't create a new list, or change the + /// elements. + Set asDart() => _JSetAdapter(this); } -@internal -final class $JSet$Type$<$E extends JObject?> extends JType> { - final JType<$E> E; +final class _JSetAdapter with SetBase { + final JSet _jset; - const $JSet$Type$( - this.E, - ); + _JSetAdapter(this._jset); @override - String get signature => r'Ljava/util/Set;'; + int get length => _jset.size(); @override - JSet<$E> fromReference(JReference reference) => - JSet<$E>.fromReference(E, reference); + bool contains(Object? element) => + element is JObject? ? _jset.contains(element) : false; @override - JType get superType => const $JObject$Type$(); + E? lookup(Object? element) => throw UnsupportedError( + "Java's Set class has no equivalent of Dart's Set.lookup method."); @override - JType?> get nullableType => $JSet$NullableType$<$E>(E); + Iterator get iterator => JIteratorAdapter(_jset.iterator()!); @override - final superCount = 1; + Set toSet() => {...this}; @override - int get hashCode => Object.hash($JSet$Type$, E); + bool add(E value) => _jset.add(value); @override - bool operator ==(Object other) { - return other.runtimeType == ($JSet$Type$<$E>) && - other is $JSet$Type$<$E> && - E == other.E; - } -} + bool remove(Object? value) => value is JObject? ? _jset.remove(value) : false; -class JSet<$E extends JObject?> extends JObject with SetMixin<$E> { - @internal @override - // ignore: overridden_fields - final JType> $type; - - @internal - final JType<$E> E; - - JSet.fromReference( - this.E, - JReference reference, - ) : $type = type<$E>(E), - super.fromReference(reference); - - static final _class = JClass.forName(r'java/util/Set'); - - /// The type which includes information such as the signature of this class. - static JType> type<$E extends JObject?>( - JType<$E> E, - ) { - return $JSet$Type$<$E>(E); - } - - /// The type which includes information such as the signature of this class. - static JType?> nullableType<$E extends JObject?>( - JType<$E> E, - ) { - return $JSet$NullableType$<$E>(E); - } - - static final _hashSetClass = JClass.forName(r'java/util/HashSet'); - static final _ctorId = _hashSetClass.constructorId(r'()V'); - JSet.hash(this.E) - : $type = type<$E>(E), - super.fromReference(_ctorId(_hashSetClass, referenceType, [])); - - static final _addId = - _class.instanceMethodId(r'add', r'(Ljava/lang/Object;)Z'); - @override - bool add($E value) { - final valueRef = value?.reference ?? jNullReference; - return _addId(this, const jbooleanType(), [valueRef.pointer]); - } - - static final _addAllId = - _class.instanceMethodId(r'addAll', r'(Ljava/util/Collection;)Z'); - @override - void addAll(Iterable<$E> elements) { - if (elements is JObject) { - final elementsRef = (elements as JObject).reference; - if (Jni.env.IsInstanceOf( - elementsRef.pointer, _collectionClass.reference.pointer)) { - _addAllId( - this, - const jbooleanType(), - [elementsRef.pointer], - ); - return; - } - } - - return super.addAll(elements); - } - - static final _clearId = _class.instanceMethodId(r'clear', r'()V'); - @override - void clear() { - _clearId(this, const jvoidType(), []); - } - - static final _containsId = - _class.instanceMethodId(r'contains', r'(Ljava/lang/Object;)Z'); - - @override - bool contains(Object? element) { - if (element is! JObject?) { - return false; - } - final elementRef = element?.reference ?? jNullReference; - return _containsId(this, const jbooleanType(), [elementRef.pointer]); - } - - static final _containsAllId = - _class.instanceMethodId(r'containsAll', r'(Ljava/util/Collection;)Z'); - static final _collectionClass = JClass.forName('java/util/Collection'); - @override - bool containsAll(Iterable other) { - if (other is JObject) { - final otherRef = (other as JObject).reference; - if (Jni.env - .IsInstanceOf(otherRef.pointer, _collectionClass.reference.pointer)) { - return _containsAllId(this, const jbooleanType(), [otherRef.pointer]); - } - } - return super.containsAll(other); - } - - static final _isEmptyId = _class.instanceMethodId(r'isEmpty', r'()Z'); - @override - bool get isEmpty => _isEmptyId(this, const jbooleanType(), []); - - @override - bool get isNotEmpty => !isEmpty; - - static final _iteratorId = - _class.instanceMethodId(r'iterator', r'()Ljava/util/Iterator;'); - @override - JIterator<$E> get iterator => _iteratorId(this, $JIterator$Type$<$E>(E), [])!; - - static final _sizeId = _class.instanceMethodId(r'size', r'()I'); - @override - int get length => _sizeId(this, const jintType(), []); - - static final _removeId = - _class.instanceMethodId(r'remove', r'(Ljava/lang/Object;)Z'); - @override - bool remove(Object? value) { - if (value is! JObject?) { - return false; - } - final valueRef = value?.reference ?? jNullReference; - return _removeId(this, const jbooleanType(), [valueRef.pointer]); - } - - static final _removeAllId = - _class.instanceMethodId(r'removeAll', r'(Ljava/util/Collection;)Z'); - @override - void removeAll(Iterable elements) { - if (elements is JObject) { - final elementsRef = (elements as JObject).reference; - if (Jni.env.IsInstanceOf( - elementsRef.pointer, _collectionClass.reference.pointer)) { - _removeAllId(this, const jbooleanType(), [elementsRef.pointer]); - return; - } - } - return super.removeAll(elements); - } - - static final _retainAllId = - _class.instanceMethodId(r'retainAll', r'(Ljava/util/Collection;)Z'); - @override - void retainAll(Iterable elements) { - if (elements is JObject) { - final elementsRef = (elements as JObject).reference; - if (Jni.env.IsInstanceOf( - elementsRef.pointer, _collectionClass.reference.pointer)) { - _retainAllId(this, const jbooleanType(), [elementsRef.pointer]); - return; - } - } - return super.retainAll(elements); - } - - @override - $E? lookup(Object? element) { - if (contains(element)) return element as $E; - return null; - } - - @override - JSet<$E> toSet() { - return toJSet(E); - } + void clear() => _jset.clear(); } extension ToJavaSet on Iterable { - JSet toJSet(JType type) { - final set = JSet.hash(type); - set.addAll(this); + JSet toJSet() { + // TODO(https://github.com/dart-lang/native/issues/2012): Remove this as + // hack. + final set = (JHashSet() as JObject) as JSet; + set.asDart().addAll(this); return set; } } diff --git a/pkgs/jni/lib/src/util/util.dart b/pkgs/jni/lib/src/util/util.dart index 2509b63c4f..d0a0dc5032 100644 --- a/pkgs/jni/lib/src/util/util.dart +++ b/pkgs/jni/lib/src/util/util.dart @@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'jiterator.dart' hide $JIterator$NullableType$, $JIterator$Type$; -export 'jlist.dart' hide $JList$NullableType$, $JList$Type$; -export 'jmap.dart' hide $JMap$NullableType$, $JMap$Type$; -export 'jset.dart' hide $JSet$NullableType$, $JSet$Type$; +export 'jiterator.dart'; +export 'jlist.dart'; +export 'jmap.dart'; +export 'jset.dart'; diff --git a/pkgs/jni/pubspec.yaml b/pkgs/jni/pubspec.yaml index 9999f48cc2..85fb168dcb 100644 --- a/pkgs/jni/pubspec.yaml +++ b/pkgs/jni/pubspec.yaml @@ -4,7 +4,7 @@ name: jni description: A library to access JNI from Dart and Flutter that acts as a support library for package:jnigen. -version: 0.15.3-wip +version: 0.16.0-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/jni issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ajni @@ -21,6 +21,7 @@ environment: dependencies: args: ^2.5.0 + collection: ^1.19.1 ffi: ^2.1.3 meta: ^1.15.0 package_config: ^2.1.0 @@ -29,6 +30,7 @@ dependencies: dev_dependencies: dart_flutter_team_lints: ^3.5.2 + dart_style: ^3.1.2 ffigen: path: ../ffigen jnigen: diff --git a/pkgs/jni/test/boxed_test.dart b/pkgs/jni/test/boxed_test.dart index d61938df6a..d1f30dd662 100644 --- a/pkgs/jni/test/boxed_test.dart +++ b/pkgs/jni/test/boxed_test.dart @@ -79,68 +79,4 @@ void run({required TestRunnerCallback testRunner}) { expect(JBoolean(true).booleanValue(releaseOriginal: true), true); }); }); - testRunner('JByte.\$type hashCode and ==', () { - using((arena) { - final a = JByte(1)..releasedBy(arena); - final b = JByte(2)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JCharacter.\$type hashCode and ==', () { - using((arena) { - final a = JCharacter(1)..releasedBy(arena); - final b = JCharacter(2)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JShort.\$type hashCode and ==', () { - using((arena) { - final a = JShort(1)..releasedBy(arena); - final b = JShort(2)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JInteger.\$type hashCode and ==', () { - using((arena) { - final a = JInteger(1)..releasedBy(arena); - final b = JInteger(2)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JLong.\$type hashCode and ==', () { - using((arena) { - final a = JLong(1)..releasedBy(arena); - final b = JLong(2)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JFloat.\$type hashCode and ==', () { - using((arena) { - final a = JFloat(1.0)..releasedBy(arena); - final b = JFloat(2.0)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JDouble.\$type hashCode and ==', () { - using((arena) { - final a = JDouble(1.0)..releasedBy(arena); - final b = JDouble(2.0)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); - testRunner('JBoolean.\$type hashCode and ==', () { - using((arena) { - final a = JBoolean(true)..releasedBy(arena); - final b = JBoolean(false)..releasedBy(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - }); - }); } diff --git a/pkgs/jni/test/exception_test.dart b/pkgs/jni/test/exception_test.dart index ba3123f28e..0b04606de6 100644 --- a/pkgs/jni/test/exception_test.dart +++ b/pkgs/jni/test/exception_test.dart @@ -38,7 +38,7 @@ void main() { void run({required TestRunnerCallback testRunner}) { JObject newRandom(JClass randomClass) { - return randomClass.constructorId('()V').call(randomClass, JObject.type, []); + return randomClass.constructorId('()V').call(randomClass, []); } testRunner('double free throws exception', () { @@ -59,13 +59,13 @@ void run({required TestRunnerCallback testRunner}) { throwsA(isA())); }); - testRunner('An exception in JNI throws JniException in Dart', () { + testRunner('An exception in JNI throws JThrowable in Dart', () { final rc = JClass.forName('java/util/Random'); final r = newRandom(rc); expect( () => rc .instanceMethodId('nextInt', '(I)I') .call(r, jint.type, [JValueInt(-1)]), - throwsA(isA())); + throwsA(isA())); }); } diff --git a/pkgs/jni/test/global_env_test.dart b/pkgs/jni/test/global_env_test.dart index 8498ca516d..88c2339074 100644 --- a/pkgs/jni/test/global_env_test.dart +++ b/pkgs/jni/test/global_env_test.dart @@ -115,7 +115,7 @@ void run({required TestRunnerCallback testRunner}) { expect( () => env.CallStaticIntMethodA( integerClass, parseIntMethod, args), - throwsA(isA())); + throwsA(isA())); })); testRunner( diff --git a/pkgs/jni/test/jarray_test.dart b/pkgs/jni/test/jarray_test.dart index a3ffa47084..e09620b3d4 100644 --- a/pkgs/jni/test/jarray_test.dart +++ b/pkgs/jni/test/jarray_test.dart @@ -25,7 +25,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JBooleanArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -67,7 +67,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JCharArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -107,16 +107,16 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('Java byte array', () { using((arena) { - expect(JByteArray.from([]), isEmpty); - expect(JByteArray.from([1]), containsAllInOrder([1])); - expect(JByteArray.from([1, 2]), containsAllInOrder([1, 2])); - expect(JByteArray.from([-1, -2]), containsAllInOrder([-1, -2])); - expect(JByteArray.from([127, 128, 129]), + expect(JByteArray.of([]).asDart(), isEmpty); + expect(JByteArray.of([1]).asDart(), containsAllInOrder([1])); + expect(JByteArray.of([1, 2]).asDart(), containsAllInOrder([1, 2])); + expect(JByteArray.of([-1, -2]).asDart(), containsAllInOrder([-1, -2])); + expect(JByteArray.of([127, 128, 129]).asDart(), containsAllInOrder([127, -128, -127])); final array = JByteArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -158,7 +158,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JShortArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -200,7 +200,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JIntArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -242,7 +242,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JLongArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -285,7 +285,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JFloatArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -327,7 +327,7 @@ void run({required TestRunnerCallback testRunner}) { using((arena) { final array = JDoubleArray(3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -367,9 +367,9 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('Java string array', () { using((arena) { - final array = JArray(JString.nullableType, 3)..releasedBy(arena); + final array = JArray.withLength(JString.type, 3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -408,9 +408,9 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('Java object array', () { using((arena) { - final array = JArray(JObject.nullableType, 3)..releasedBy(arena); + final array = JArray.withLength(JObject.type, 3)..releasedBy(arena); var counter = 0; - for (final element in array) { + for (final element in array.asDart()) { expect(element, array[counter]); ++counter; } @@ -419,8 +419,6 @@ void run({required TestRunnerCallback testRunner}) { expect(array[0], isNull); expect(array[1], isNull); expect(array[2], isNull); - - expect(() => JArray(JObject.type, 3), throwsArgumentError); }); }); testRunner('Java 2d array', () { @@ -429,7 +427,8 @@ void run({required TestRunnerCallback testRunner}) { array[0] = 1; array[1] = 2; array[2] = 3; - final twoDimArray = JArray(JIntArray.nullableType, 3)..releasedBy(arena); + final twoDimArray = JArray.withLength(JIntArray.type, 3) + ..releasedBy(arena); expect(twoDimArray.length, 3); twoDimArray[0] = array; twoDimArray[1] = array; @@ -468,7 +467,7 @@ void run({required TestRunnerCallback testRunner}) { expect(array1[0].toDartString(releaseOriginal: true), 'apple'); expect(array1[1].toDartString(releaseOriginal: true), 'banana'); - final array2 = JArray.of(JString.nullableType, [ + final array2 = JArray.of(JString.type, [ 'apple'.toJString()..releasedBy(arena), null, 'banana'.toJString()..releasedBy(arena) @@ -481,82 +480,79 @@ void run({required TestRunnerCallback testRunner}) { final array3 = JArray.of(JString.type, []); expect(array3.length, 0); - final array4 = JArray.of(JString.nullableType, []); + final array4 = JArray.of(JString.type, []); expect(array4.length, 0); }); }); testRunner('JArray of JByte', () { using((arena) { - final arr = JArray(JByte.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JByte.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JShort', () { using((arena) { - final arr = JArray(JShort.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JShort.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JInteger', () { using((arena) { - final arr = JArray(JInteger.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JInteger.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JCharacter', () { using((arena) { - final arr = JArray(JCharacter.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JCharacter.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JLong', () { using((arena) { - final arr = JArray(JLong.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JLong.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JFloat', () { using((arena) { - final arr = JArray(JFloat.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JFloat.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JDouble', () { using((arena) { - final arr = JArray(JDouble.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JDouble.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JBoolean', () { using((arena) { - final arr = JArray(JBoolean.nullableType, 1)..releasedBy(arena); + final arr = JArray.withLength(JBoolean.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JSet', () { using((arena) { - final arr = JArray(JSet.nullableType(JString.type), 1)..releasedBy(arena); + final arr = JArray.withLength(JSet.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JList', () { using((arena) { - final arr = JArray(JList.nullableType(JString.type), 1) - ..releasedBy(arena); + final arr = JArray.withLength(JList.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JMap', () { using((arena) { - final arr = JArray(JMap.nullableType(JString.type, JString.type), 1) - ..releasedBy(arena); + final arr = JArray.withLength(JMap.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); testRunner('JArray of JIterator', () { using((arena) { - final arr = JArray(JIterator.nullableType(JString.type), 1) - ..releasedBy(arena); + final arr = JArray.withLength(JIterator.type, 1)..releasedBy(arena); expect(arr[0], isNull); }); }); diff --git a/pkgs/jni/test/jbyte_buffer_test.dart b/pkgs/jni/test/jbyte_buffer_test.dart index 666479dcbe..b66db26c8d 100644 --- a/pkgs/jni/test/jbyte_buffer_test.dart +++ b/pkgs/jni/test/jbyte_buffer_test.dart @@ -20,7 +20,7 @@ void main() { } void run({required TestRunnerCallback testRunner}) { - final throwsAJniException = throwsA(isA()); + final throwsAJThrowable = throwsA(isA()); JByteBuffer testDataBuffer(Arena arena) { final buffer = JByteBuffer.allocate(3)..releasedBy(arena); buffer.nextByte = 1; @@ -49,7 +49,7 @@ void run({required TestRunnerCallback testRunner}) { array[2] = 3; final buffer = JByteBuffer.wrap(array, 1, 1)..releasedBy(arena); expect(buffer.nextByte, 2); - expect(() => buffer.nextByte, throwsAJniException); + expect(() => buffer.nextByte, throwsAJThrowable); }); }); @@ -117,7 +117,7 @@ void run({required TestRunnerCallback testRunner}) { buffer.position = 2; buffer.rewind(); expect(buffer.position, 0); - expect(buffer.reset, throwsAJniException); + expect(buffer.reset, throwsAJThrowable); }); }); @@ -195,22 +195,6 @@ void run({required TestRunnerCallback testRunner}) { }); }); - testRunner('type hashCode, ==', () { - using((arena) { - final a = testDataBuffer(arena); - final b = testDataBuffer(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - final c = JBuffer.fromReference(a.reference); - final d = JBuffer.fromReference(b.reference); - expect(c.$type, d.$type); - expect(c.$type.hashCode, d.$type.hashCode); - - expect(a.$type, isNot(c.$type)); - expect(a.$type.hashCode, isNot(c.$type.hashCode)); - }); - }); - testRunner('asUint8List releasing original', () { using((arena) { // Used as an example in [JByteBuffer]. diff --git a/pkgs/jni/test/jlist_test.dart b/pkgs/jni/test/jlist_test.dart index d8362f77e0..b9d8ddadc8 100644 --- a/pkgs/jni/test/jlist_test.dart +++ b/pkgs/jni/test/jlist_test.dart @@ -24,7 +24,7 @@ void run({required TestRunnerCallback testRunner}) { '1'.toJString()..releasedBy(arena), '2'.toJString()..releasedBy(arena), '3'.toJString()..releasedBy(arena), - ].toJList(JString.type) + ].toJList() ..releasedBy(arena); } @@ -33,24 +33,25 @@ void run({required TestRunnerCallback testRunner}) { '1'.toJString()..releasedBy(arena), '2'.toJString()..releasedBy(arena), null, - ].toJList(JString.nullableType) + ].toJList() ..releasedBy(arena); } testRunner('length get', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); expect(list.length, 3); }); }); testRunner('length set', () { using((arena) { - final list = [ + final list = ([ '1'.toJString()..releasedBy(arena), '2'.toJString()..releasedBy(arena), '3'.toJString()..releasedBy(arena), - ].toJList(JString.nullableType) - ..releasedBy(arena); + ].toJList() + ..releasedBy(arena)) + .asDart(); list.length = 2; expect(list.length, 2); list.length = 3; @@ -60,7 +61,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('[]', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); expect(list[0].toDartString(releaseOriginal: true), '1'); expect(list[1].toDartString(releaseOriginal: true), '2'); expect(list[2].toDartString(releaseOriginal: true), '3'); @@ -68,7 +69,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable []', () { using((arena) { - final list = testNullableDataList(arena); + final list = testNullableDataList(arena).asDart(); expect(list[0]!.toDartString(releaseOriginal: true), '1'); expect(list[1]!.toDartString(releaseOriginal: true), '2'); expect(list[2], isNull); @@ -76,7 +77,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('[]=', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); expect(list[0].toDartString(releaseOriginal: true), '1'); list[0] = '2'.toJString()..releasedBy(arena); expect(list[0].toDartString(releaseOriginal: true), '2'); @@ -84,7 +85,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable []=', () { using((arena) { - final list = testNullableDataList(arena); + final list = testNullableDataList(arena).asDart(); expect(list[0]!.toDartString(releaseOriginal: true), '1'); list[0] = '2'.toJString()..releasedBy(arena); expect(list[0]!.toDartString(releaseOriginal: true), '2'); @@ -94,7 +95,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('add', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); list.add('4'.toJString()..releasedBy(arena)); expect(list.length, 4); expect(list[3].toDartString(releaseOriginal: true), '4'); @@ -102,7 +103,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable add', () { using((arena) { - final list = testNullableDataList(arena); + final list = testNullableDataList(arena).asDart(); list.add('4'.toJString()..releasedBy(arena)); expect(list.length, 4); expect(list[3]!.toDartString(releaseOriginal: true), '4'); @@ -112,8 +113,8 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('addAll', () { using((arena) { - final list = testDataList(arena); - final toAppend = testDataList(arena); + final list = testDataList(arena).asDart(); + final toAppend = testDataList(arena).asDart(); list.addAll(toAppend); expect(list.length, 6); list.addAll(['4'.toJString()..releasedBy(arena)]); @@ -122,7 +123,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('clear, isEmpty, isNotEmpty', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); expect(list.isNotEmpty, true); expect(list.isEmpty, false); list.clear(); @@ -132,18 +133,16 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('contains', () { using((arena) { - final list = testDataList(arena); - // ignore: collection_methods_unrelated_type - expect(list.contains('1'), false); + final list = testDataList(arena).asDart(); + expect((list as List).contains('1'), false); expect(list.contains('1'.toJString()..releasedBy(arena)), true); expect(list.contains('4'.toJString()..releasedBy(arena)), false); }); }); testRunner('nullable contains', () { using((arena) { - final list = testNullableDataList(arena); - // ignore: collection_methods_unrelated_type - expect(list.contains('1'), false); + final list = testNullableDataList(arena).asDart(); + expect((list as List).contains('1'), false); expect(list.contains('1'.toJString()..releasedBy(arena)), true); expect(list.contains('4'.toJString()..releasedBy(arena)), false); expect(list.contains(null), true); @@ -151,17 +150,16 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('getRange', () { using((arena) { - final list = testDataList(arena); - // ignore: iterable_contains_unrelated_type - final range = list.getRange(1, 2)..releasedBy(arena); + final list = testDataList(arena).asDart(); + final range = list.getRange(1, 2); expect(range.length, 1); expect(range.first.toDartString(releaseOriginal: true), '2'); }); }); testRunner('indexOf', () { using((arena) { - final list = testDataList(arena); - expect(list.indexOf(1), -1); + final list = testDataList(arena).asDart(); + expect((list as List).indexOf(1), -1); expect(list.indexOf('1'.toJString()..toDartString()), 0); expect(list.indexOf('2'.toJString()..toDartString()), 1); expect(list.indexOf('1'.toJString()..toDartString(), 1), -1); @@ -170,8 +168,8 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable indexOf', () { using((arena) { - final list = testNullableDataList(arena); - expect(list.indexOf(1), -1); + final list = testNullableDataList(arena).asDart(); + expect((list as List).indexOf(1), -1); expect(list.indexOf('1'.toJString()..toDartString()), 0); expect(list.indexOf('2'.toJString()..toDartString()), 1); expect(list.indexOf(null), 2); @@ -181,8 +179,8 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('lastIndexOf', () { using((arena) { - final list = testDataList(arena); - expect(list.lastIndexOf(1), -1); + final list = testDataList(arena).asDart(); + expect((list as List).lastIndexOf(1), -1); expect(list.lastIndexOf('1'.toJString()..toDartString()), 0); expect(list.lastIndexOf('2'.toJString()..toDartString()), 1); expect(list.lastIndexOf('3'.toJString()..toDartString()), 2); @@ -191,8 +189,8 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable lastIndexOf', () { using((arena) { - final list = testNullableDataList(arena); - expect(list.lastIndexOf(1), -1); + final list = testNullableDataList(arena).asDart(); + expect((list as List).lastIndexOf(1), -1); expect(list.lastIndexOf('1'.toJString()..toDartString()), 0); expect(list.lastIndexOf('2'.toJString()..toDartString()), 1); expect(list.lastIndexOf(null), 2); @@ -201,7 +199,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('insert', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); list.insert(1, '0'.toJString()..releasedBy(arena)); expect(list.length, 4); expect(list[1].toDartString(releaseOriginal: true), '0'); @@ -209,8 +207,8 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('insertAll', () { using((arena) { - final list = testDataList(arena); - final toInsert = testDataList(arena); + final list = testDataList(arena).asDart(); + final toInsert = testDataList(arena).asDart(); list.insertAll(1, toInsert); expect(list[1].toDartString(releaseOriginal: true), '1'); expect(list.length, 6); @@ -221,7 +219,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('iterator', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); final it = list.iterator; expect(it.moveNext(), true); expect(it.current.toDartString(releaseOriginal: true), '1'); @@ -234,7 +232,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('remove', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); expect(list.remove('3'.toJString()..releasedBy(arena)), true); expect(list.length, 2); expect(list.remove('4'.toJString()..releasedBy(arena)), false); @@ -244,7 +242,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable remove', () { using((arena) { - final list = testNullableDataList(arena); + final list = testNullableDataList(arena).asDart(); expect(list.remove('3'.toJString()..releasedBy(arena)), false); expect(list.length, 3); expect(list.remove(null), true); @@ -255,56 +253,32 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('removeAt', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); expect(list.removeAt(0).toDartString(releaseOriginal: true), '1'); expect(list.removeAt(1).toDartString(releaseOriginal: true), '3'); }); }); testRunner('removeRange', () { using((arena) { - final list = testDataList(arena); + final list = testDataList(arena).asDart(); list.removeRange(0, 2); expect(list.single.toDartString(releaseOriginal: true), '3'); }); }); testRunner('==, hashCode', () { using((arena) { - final a = testDataList(arena); - final b = testDataList(arena); - expect(a.hashCode, b.hashCode); - expect(a, b); - b.add('4'.toJString()..releasedBy(arena)); + final a = testDataList(arena).asDart(); + final b = testDataList(arena).asDart(); expect(a.hashCode, isNot(b.hashCode)); - expect(a, isNot(b)); + expect(a, b); + expect(a == b, isFalse); }); }); testRunner('toSet', () { using((arena) { - final list = testDataList(arena); - final set = list.toSet()..releasedBy(arena); + final list = testDataList(arena).asDart(); + final set = list.toSet(); expect(set.length, 3); }); }); - testRunner('type hashCode, ==', () { - using((arena) { - final a = testDataList(arena); - final b = testDataList(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - final c = JList.array(JObject.type)..releasedBy(arena); - expect(a.$type, isNot(c.$type)); - expect(a.$type.hashCode, isNot(c.$type.hashCode)); - }); - }); - testRunner('JIterator type hashCode, ==', () { - using((arena) { - final a = testDataList(arena); - final b = testDataList(arena); - expect(a.iterator.$type, b.iterator.$type); - expect(a.iterator.$type.hashCode, b.iterator.$type.hashCode); - final c = JList.array(JObject.type)..releasedBy(arena); - expect(a.iterator.$type, isNot(c.iterator.$type)); - expect(a.iterator.$type.hashCode, isNot(c.iterator.$type.hashCode)); - }); - }); } diff --git a/pkgs/jni/test/jmap_test.dart b/pkgs/jni/test/jmap_test.dart index f8d624a601..6eb675c48a 100644 --- a/pkgs/jni/test/jmap_test.dart +++ b/pkgs/jni/test/jmap_test.dart @@ -24,7 +24,7 @@ void run({required TestRunnerCallback testRunner}) { '2'.toJString()..releasedBy(arena): 'Two'.toJString()..releasedBy(arena), '3'.toJString()..releasedBy(arena): 'Three'.toJString() ..releasedBy(arena), - }.toJMap(JString.type, JString.type) + }.toJMap() ..releasedBy(arena); } @@ -34,19 +34,19 @@ void run({required TestRunnerCallback testRunner}) { '2'.toJString()..releasedBy(arena): 'Two'.toJString()..releasedBy(arena), '3'.toJString()..releasedBy(arena): null, null: null, - }.toJMap(JString.nullableType, JString.nullableType) + }.toJMap() ..releasedBy(arena); } testRunner('length', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); expect(map.length, 3); }); }); testRunner('[]', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map[1], null); expect( @@ -62,7 +62,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable []', () { using((arena) { - final map = testNullableDataMap(arena); + final map = testNullableDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map[1], null); expect( @@ -86,7 +86,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('[]=', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); map['0'.toJString()..releasedBy(arena)] = 'Zero'.toJString() ..releasedBy(arena); expect( @@ -107,7 +107,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable []=', () { using((arena) { - final map = testNullableDataMap(arena); + final map = testNullableDataMap(arena).asDart(); map['0'.toJString()..releasedBy(arena)] = 'Zero'.toJString() ..releasedBy(arena); expect( @@ -136,13 +136,13 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('addAll', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); final toAdd = { '0'.toJString()..releasedBy(arena): 'Zero'.toJString() ..releasedBy(arena), '1'.toJString()..releasedBy(arena): 'one!'.toJString() ..releasedBy(arena), - }.toJMap(JString.type, JString.type); + }; map.addAll(toAdd); expect(map.length, 4); expect( @@ -164,7 +164,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('clear, isEmpty, isNotEmpty', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); expect(map.isEmpty, false); expect(map.isNotEmpty, true); map.clear(); @@ -174,7 +174,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('containsKey', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map.containsKey(1), false); expect(map.containsKey('1'.toJString()..releasedBy(arena)), true); @@ -183,7 +183,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable containsKey', () { using((arena) { - final map = testNullableDataMap(arena); + final map = testNullableDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map.containsKey(1), false); expect(map.containsKey('1'.toJString()..releasedBy(arena)), true); @@ -193,7 +193,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('containsValue', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map.containsValue(1), false); expect(map.containsValue('One'.toJString()..releasedBy(arena)), true); @@ -202,7 +202,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable containsValue', () { using((arena) { - final map = testNullableDataMap(arena); + final map = testNullableDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map.containsValue(1), false); expect(map.containsValue('One'.toJString()..releasedBy(arena)), true); @@ -212,7 +212,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('keys', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); final keys = map.keys; expect( keys @@ -224,7 +224,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('remove', () { using((arena) { - final map = testDataMap(arena); + final map = testDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map.remove(1), null); expect(map.remove('4'.toJString()..releasedBy(arena)), null); @@ -240,7 +240,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable remove', () { using((arena) { - final map = testNullableDataMap(arena); + final map = testNullableDataMap(arena).asDart(); // ignore: collection_methods_unrelated_type expect(map.remove(1), null); expect(map.remove('4'.toJString()..releasedBy(arena)), null); @@ -259,16 +259,4 @@ void run({required TestRunnerCallback testRunner}) { expect(map.length, 2); }); }); - testRunner('type hashCode, ==', () { - using((arena) { - final a = testDataMap(arena); - final b = testDataMap(arena); - expect(a.$type, b.$type); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - final c = JMap.hash(JObject.type, JObject.type)..releasedBy(arena); - expect(a.$type, isNot(c.$type)); - expect(a.$type.hashCode, isNot(c.$type.hashCode)); - }); - }); } diff --git a/pkgs/jni/test/jobject_test.dart b/pkgs/jni/test/jobject_test.dart index 35108bc9f2..77d4c5ae4f 100644 --- a/pkgs/jni/test/jobject_test.dart +++ b/pkgs/jni/test/jobject_test.dart @@ -42,7 +42,7 @@ void run({required TestRunnerCallback testRunner}) { // Allowed argument types are primitive types, JObject and its subclasses, // and raw JNI references (JObject). Strings will be automatically converted // to JNI strings. - final long = longCtor(longClass, JObject.type, [176]); + final long = longCtor(longClass, [176]); final intValueMethod = longClass.instanceMethodId('intValue', '()I'); final intValue = intValueMethod( long, @@ -98,8 +98,7 @@ void run({required TestRunnerCallback testRunner}) { final bitCountMethod = longClass.staticMethodId('bitCount', '(J)I'); final randomClass = JClass.forName('java/util/Random'); - final random = - randomClass.constructorId('()V').call(randomClass, JObject.type, []); + final random = randomClass.constructorId('()V').call(randomClass, []); final nextIntMethod = randomClass.instanceMethodId('nextInt', '(I)I'); @@ -168,7 +167,7 @@ void run({required TestRunnerCallback testRunner}) { final randomInt = JClass.forName('java/util/Random').use((randomClass) { return randomClass .constructorId('()V') - .call(randomClass, JObject.type, []).use((random) { + .call(randomClass, []).use((random) { return randomClass .instanceMethodId('nextInt', '(I)I') .call(random, jint.type, [JValueInt(15)]); @@ -187,8 +186,7 @@ void run({required TestRunnerCallback testRunner}) { final randomClass = JClass.forName('java/util/Random')..releasedBy(arena); final constructor = randomClass.constructorId('()V'); for (var i = 0; i < 10; i++) { - objects - .add(constructor(randomClass, JObject.type, [])..releasedBy(arena)); + objects.add(constructor(randomClass, [])..releasedBy(arena)); } }); for (var object in objects) { @@ -228,8 +226,7 @@ void run({required TestRunnerCallback testRunner}) { final receivePort = ReceivePort(); await Isolate.spawn((sendPort) { final randomClass = JClass.forName('java/util/Random'); - final random = - randomClass.constructorId('()V').call(randomClass, JObject.type, []); + final random = randomClass.constructorId('()V').call(randomClass, []); final result = randomClass .instanceMethodId('nextInt', '(I)I') .call(random, jint.type, [256]); @@ -247,7 +244,7 @@ void run({required TestRunnerCallback testRunner}) { expect(random, lessThan(256)); }); - testRunner('Methods rethrow exceptions in Java as JniException', () { + testRunner('Methods rethrow exceptions in Java as JThrowable', () { expect( () { final integerClass = JInteger.type.jClass; @@ -255,7 +252,7 @@ void run({required TestRunnerCallback testRunner}) { .staticMethodId('parseInt', '(Ljava/lang/String;)I') .call(integerClass, jint.type, ['X'.toJString()]); }, - throwsA(isA()), + throwsA(isA()), ); }); @@ -282,19 +279,14 @@ void run({required TestRunnerCallback testRunner}) { testRunner('isA returns true', () { final long = JLong(1); expect(long.isA(JLong.type), isTrue); - expect(long.isA(JLong.nullableType), isTrue); expect(long.isA(JNumber.type), isTrue); - expect(long.isA(JNumber.nullableType), isTrue); expect(long.isA(JObject.type), isTrue); - expect(long.isA(JObject.nullableType), isTrue); }); testRunner('isA returns false', () { final long = JLong(1); expect(long.isA(JInteger.type), isFalse); - expect(long.isA(JInteger.nullableType), isFalse); expect(long.isA(JString.type), isFalse); - expect(long.isA(JString.nullableType), isFalse); }); testRunner('Casting correctly succeeds', () { diff --git a/pkgs/jni/test/jset_test.dart b/pkgs/jni/test/jset_test.dart index ca7065f342..c2d94d9748 100644 --- a/pkgs/jni/test/jset_test.dart +++ b/pkgs/jni/test/jset_test.dart @@ -24,7 +24,7 @@ void run({required TestRunnerCallback testRunner}) { '1'.toJString()..releasedBy(arena), '2'.toJString()..releasedBy(arena), '3'.toJString()..releasedBy(arena), - }.toJSet(JString.type) + }.toJSet() ..releasedBy(arena); } @@ -33,19 +33,19 @@ void run({required TestRunnerCallback testRunner}) { '1'.toJString()..releasedBy(arena), '2'.toJString()..releasedBy(arena), null, - }.toJSet(JString.nullableType) + }.toJSet() ..releasedBy(arena); } testRunner('length', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); expect(set.length, 3); }); }); testRunner('add', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); set.add('1'.toJString()..releasedBy(arena)); expect(set.length, 3); set.add('4'.toJString()..releasedBy(arena)); @@ -54,7 +54,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable add', () { using((arena) { - final set = testNullableDataSet(arena); + final set = testNullableDataSet(arena).asDart(); set.add('1'.toJString()..releasedBy(arena)); expect(set.length, 3); set.add('4'.toJString()..releasedBy(arena)); @@ -65,8 +65,8 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('addAll', () { using((arena) { - final set = testDataSet(arena); - final toAdd = testDataSet(arena); + final set = testDataSet(arena).asDart(); + final toAdd = testDataSet(arena).asDart(); toAdd.add('4'.toJString()..releasedBy(arena)); set.addAll(toAdd); expect(set.length, 4); @@ -79,7 +79,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('clear, isEmpty, isNotEmpty', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); set.clear(); expect(set.isEmpty, true); expect(set.isNotEmpty, false); @@ -87,7 +87,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('contains', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); // ignore: collection_methods_unrelated_type expect(set.contains(1), false); expect(set.contains('1'.toJString()..releasedBy(arena)), true); @@ -96,7 +96,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable contains', () { using((arena) { - final set = testNullableDataSet(arena); + final set = testNullableDataSet(arena).asDart(); // ignore: collection_methods_unrelated_type expect(set.contains(1), false); expect(set.contains('1'.toJString()..releasedBy(arena)), true); @@ -106,7 +106,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('containsAll', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); expect(set.containsAll(set), true); expect( set.containsAll([ @@ -115,7 +115,7 @@ void run({required TestRunnerCallback testRunner}) { ]), true, ); - final testSet = testDataSet(arena); + final testSet = testDataSet(arena).asDart(); testSet.add('4'.toJString()..releasedBy(arena)); expect(set.containsAll(testSet), false); expect(set.containsAll(['4'.toJString()..releasedBy(arena)]), false); @@ -123,7 +123,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('iterator', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); final it = set.iterator; // There are no order guarantees in a hashset. final dartSet = {}; @@ -140,7 +140,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('remove', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); // ignore: collection_methods_unrelated_type expect(set.remove(1), false); expect(set.remove('4'.toJString()..releasedBy(arena)), false); @@ -151,7 +151,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('nullable remove', () { using((arena) { - final set = testNullableDataSet(arena); + final set = testNullableDataSet(arena).asDart(); // ignore: collection_methods_unrelated_type expect(set.remove(1), false); expect(set.remove('4'.toJString()..releasedBy(arena)), false); @@ -162,18 +162,17 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('removeAll', () { using((arena) { - final set = testDataSet(arena); - final toRemoveExclusive = {'4'.toJString()..releasedBy(arena)} - .toJSet(JString.type) + final set = testDataSet(arena).asDart(); + final toRemoveExclusive = {'4'.toJString()..releasedBy(arena)}.toJSet() ..releasedBy(arena); - set.removeAll(toRemoveExclusive); + set.removeAll(toRemoveExclusive.asDart()); expect(set.length, 3); final toRemoveInclusive = { '1'.toJString()..releasedBy(arena), '4'.toJString()..releasedBy(arena), - }.toJSet(JString.type) + }.toJSet() ..releasedBy(arena); - set.removeAll(toRemoveInclusive); + set.removeAll(toRemoveInclusive.asDart()); expect(set.length, 2); set.removeAll(['2'.toJString()..releasedBy(arena)]); expect(set.length, 1); @@ -181,7 +180,7 @@ void run({required TestRunnerCallback testRunner}) { }); testRunner('retainAll', () { using((arena) { - final set = testDataSet(arena); + final set = testDataSet(arena).asDart(); final toRetain = { '1'.toJString()..releasedBy(arena), '3'.toJString()..releasedBy(arena), @@ -191,53 +190,34 @@ void run({required TestRunnerCallback testRunner}) { expect(set.length, 3); set.retainAll(toRetain); expect(set.length, 2); - final toRetainJSet = toRetain.toJSet(JString.type)..releasedBy(arena); - set.retainAll(toRetainJSet); + final toRetainJSet = toRetain.toJSet()..releasedBy(arena); + set.retainAll(toRetainJSet.asDart()); expect(set.length, 2); }); }); testRunner('==, hashCode', () { using((arena) { - final a = testDataSet(arena); - final b = testDataSet(arena); - expect(a.hashCode, b.hashCode); - expect(a, b); - b.add('4'.toJString()..releasedBy(arena)); + final a = testDataSet(arena).asDart(); + final b = testDataSet(arena).asDart(); expect(a.hashCode, isNot(b.hashCode)); - expect(a, isNot(b)); + expect(a, b); + expect(a == b, isFalse); }); }); testRunner('lookup', () { using((arena) { - final set = testDataSet(arena); - // ignore: collection_methods_unrelated_type - expect(set.lookup(1), null); - expect( - set.lookup('1'.toJString())?.toDartString(releaseOriginal: true), - '1', - ); - expect(set.lookup('4'.toJString()..releasedBy(arena)), null); + final set = testDataSet(arena).asDart(); + expect(() => set.lookup('1'.toJString()), throwsUnsupportedError); }); }); testRunner('toSet', () { using((arena) { // Test if the set gets copied. - final set = testDataSet(arena); - final setCopy = set.toSet()..releasedBy(arena); + final set = testDataSet(arena).asDart(); + final setCopy = set.toSet(); expect(set, setCopy); set.add('4'.toJString()..releasedBy(arena)); expect(set, isNot(setCopy)); }); }); - testRunner('type hashCode, ==', () { - using((arena) { - final a = testDataSet(arena); - final b = testDataSet(arena); - expect(a.$type, b.$type); - expect(a.$type.hashCode, b.$type.hashCode); - final c = JSet.hash(JObject.type)..releasedBy(arena); - expect(a.$type, isNot(c.$type)); - expect(a.$type.hashCode, isNot(c.$type.hashCode)); - }); - }); } diff --git a/pkgs/jni/test/load_test.dart b/pkgs/jni/test/load_test.dart index e67fb9b8b7..78d81f6ef4 100644 --- a/pkgs/jni/test/load_test.dart +++ b/pkgs/jni/test/load_test.dart @@ -46,7 +46,7 @@ final random = Random.secure(); final randomClass = JClass.forName('java/util/Random'); JObject newRandom() => randomClass .constructorId('(J)V') - .call(randomClass, JObject.type, [random.nextInt(secureRandomSeedBound)]); + .call(randomClass, [random.nextInt(secureRandomSeedBound)]); void run({required TestRunnerCallback testRunner}) { testRunner('Test 4K refs can be created in a row', () { diff --git a/pkgs/jni/test/type_test.dart b/pkgs/jni/test/type_test.dart deleted file mode 100644 index 537b33bd13..0000000000 --- a/pkgs/jni/test/type_test.dart +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:jni/_internal.dart'; -import 'package:jni/jni.dart'; -import 'package:test/test.dart'; - -import 'test_util/test_util.dart'; - -// Mocking this type tree: -// JObject -// | \ -// A B -// / \ \ -// C D E -// / -// F - -class A extends JObject { - A.fromReference(super.reference) : super.fromReference(); - @override - JType get $type => $A$Type$(); -} - -final class $A$NullableType$ extends JType { - @internal - @override - A? fromReference(JReference reference) { - return reference.isNull ? null : A.fromReference(reference); - } - - @internal - @override - String get signature => 'A'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => JObject.nullableType; - - @internal - @override - JType get nullableType => this; - - @override - int get hashCode => ($A$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $A$NullableType$ && other is $A$NullableType$; - } -} - -final class $A$Type$ extends JType { - @internal - @override - A fromReference(JReference reference) { - return A.fromReference(reference); - } - - @internal - @override - String get signature => 'A'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => JObject.type; - - @internal - @override - JType get nullableType => $A$NullableType$(); - - @override - int get hashCode => ($A$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $A$Type$ && other is $A$Type$; - } -} - -class B extends JObject { - B.fromReference(super.reference) : super.fromReference(); - @override - JType get $type => $B$Type$(); -} - -final class $B$NullableType$ extends JType { - @internal - @override - B? fromReference(JReference reference) { - return reference.isNull ? null : B.fromReference(reference); - } - - @internal - @override - String get signature => 'B'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => JObject.nullableType; - - @internal - @override - JType get nullableType => this; - - @override - int get hashCode => ($B$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $B$NullableType$ && other is $B$NullableType$; - } -} - -final class $B$Type$ extends JType { - @internal - @override - B fromReference(JReference reference) { - return B.fromReference(reference); - } - - @internal - @override - String get signature => 'B'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => JObject.type; - - @internal - @override - JType get nullableType => $B$NullableType$(); - - @override - int get hashCode => ($B$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $B$Type$ && other is $B$Type$; - } -} - -class C extends A { - C.fromReference(super.reference) : super.fromReference(); - - @override - JType get $type => $C$Type$(); -} - -final class $C$NullableType$ extends JType { - @internal - @override - C? fromReference(JReference reference) { - return reference.isNull ? null : C.fromReference(reference); - } - - @internal - @override - String get signature => 'C'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $A$NullableType$(); - - @internal - @override - JType get nullableType => this; - - @override - int get hashCode => ($C$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $C$NullableType$ && other is $C$NullableType$; - } -} - -final class $C$Type$ extends JType { - @internal - @override - C fromReference(JReference reference) { - return C.fromReference(reference); - } - - @internal - @override - String get signature => 'C'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $A$Type$(); - - @internal - @override - JType get nullableType => $C$NullableType$(); - - @override - int get hashCode => ($C$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $C$Type$ && other is $C$Type$; - } -} - -class D extends A { - D.fromReference(super.reference) : super.fromReference(); - - @override - JType get $type => $D$Type$(); -} - -final class $D$NullableType$ extends JType { - @internal - @override - D? fromReference(JReference reference) { - return reference.isNull ? null : D.fromReference(reference); - } - - @internal - @override - String get signature => 'D'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $A$NullableType$(); - - @internal - @override - JType get nullableType => this; - - @override - int get hashCode => ($D$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $D$NullableType$ && other is $D$NullableType$; - } -} - -final class $D$Type$ extends JType { - @internal - @override - D fromReference(JReference reference) { - return D.fromReference(reference); - } - - @internal - @override - String get signature => 'D'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $A$Type$(); - - @internal - @override - JType get nullableType => $D$NullableType$(); - - @override - int get hashCode => ($D$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $D$Type$ && other is $D$Type$; - } -} - -class E extends B { - E.fromReference(super.reference) : super.fromReference(); - - @override - JType get $type => $E$Type$(); -} - -final class $E$NullableType$ extends JType { - @internal - @override - E? fromReference(JReference reference) { - return reference.isNull ? null : E.fromReference(reference); - } - - @internal - @override - String get signature => 'E'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $B$NullableType$(); - - @internal - @override - JType get nullableType => this; - - @override - int get hashCode => ($E$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $E$NullableType$ && other is $E$NullableType$; - } -} - -final class $E$Type$ extends JType { - @internal - @override - E fromReference(JReference reference) { - return E.fromReference(reference); - } - - @internal - @override - String get signature => 'E'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $B$Type$(); - - @internal - @override - JType get nullableType => $E$NullableType$(); - - @override - int get hashCode => ($E$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $E$Type$ && other is $E$Type$; - } -} - -class F extends C { - F.fromReference(super.reference) : super.fromReference(); - - @override - JType get $type => $F$Type$(); -} - -final class $F$NullableType$ extends JType { - @internal - @override - F? fromReference(JReference reference) { - return reference.isNull ? null : F.fromReference(reference); - } - - @internal - @override - String get signature => 'F'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $C$NullableType$(); - - @internal - @override - JType get nullableType => this; - - @override - int get hashCode => ($F$NullableType$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $F$NullableType$ && other is $F$NullableType$; - } -} - -final class $F$Type$ extends JType { - @internal - @override - F fromReference(JReference reference) { - return F.fromReference(reference); - } - - @internal - @override - String get signature => 'F'; - - @internal - @override - int get superCount => superType.superCount + 1; - - @internal - @override - JType get superType => $C$Type$(); - - @internal - @override - JType get nullableType => $F$NullableType$(); - - @override - int get hashCode => ($F$Type$).hashCode; - - @override - bool operator ==(Object other) { - return other.runtimeType == $F$Type$ && other is $F$Type$; - } -} - -void main() { - run(testRunner: test); -} - -void run({required TestRunnerCallback testRunner}) { - testRunner('lowestCommonSuperType', () { - expect(lowestCommonSuperType([JObject.type]), JObject.type); - expect(lowestCommonSuperType([JString.type]), JString.type); - expect(lowestCommonSuperType([JObject.type, JObject.type]), JObject.type); - expect(lowestCommonSuperType([JString.type, JString.type]), JString.type); - expect(lowestCommonSuperType([JString.type, JArray.type(JString.type)]), - JObject.type); - }); - - testRunner('Boxed types', () { - expect( - lowestCommonSuperType([ - JByte.type, - JInteger.type, - JLong.type, - JShort.type, - JDouble.type, - JFloat.type, - ]), - JNumber.type, - ); - expect(lowestCommonSuperType([JByte.type, JBoolean.type]), JObject.type); - }); - - testRunner('Nullable boxed types', () { - expect( - lowestCommonSuperType([ - JByte.type, - JInteger.type, - JLong.type, - JShort.nullableType, // A single nullable type, - JDouble.type, - JFloat.type, - ]), - JNumber.nullableType, // Makes the common super class nullable. - ); - expect(lowestCommonSuperType([JByte.type, JBoolean.type]), JObject.type); - }); - - testRunner('array types', () { - using((arena) { - expect( - lowestCommonSuperType([ - JIntArray.type, - JIntArray.type, - ]), - JIntArray.type, - ); - expect( - lowestCommonSuperType([ - JArray.type(JObject.type), - JArray.type(JObject.type), - ]), - JArray.type(JObject.type), - ); - expect( - lowestCommonSuperType([ - JArray.type(JObject.type), - JIntArray.type, - ]), - JObject.type, - ); - }); - }); - - testRunner('util types', () { - using((arena) { - expect( - lowestCommonSuperType([ - JList.type(JObject.type), - JList.type(JObject.type), - ]), - JList.type(JObject.type), - ); - expect( - lowestCommonSuperType([ - JList.type(JObject.type), - JList.type(JString.type), - ]), - JObject.type, - ); - expect( - lowestCommonSuperType([ - JList.type(JObject.type), - JMap.type(JObject.type, JObject.type), - ]), - JObject.type, - ); - expect( - lowestCommonSuperType([ - JSet.type(JObject.type), - JIterator.type(JObject.type), - ]), - JObject.type, - ); - expect( - lowestCommonSuperType([ - JByteBuffer.type, - JBuffer.type, - ]), - JBuffer.type, - ); - }); - }); - - testRunner('Mocked type tree', () { - // As a reminder, this is how the type tree looks like: - // JObject - // | \ - // A B - // / \ \ - // C D E - // / - // F - expect(lowestCommonSuperType([$A$Type$(), $B$Type$()]), JObject.type); - expect(lowestCommonSuperType([$C$Type$(), $B$Type$()]), JObject.type); - expect(lowestCommonSuperType([$F$Type$(), $B$Type$()]), JObject.type); - expect(lowestCommonSuperType([$E$Type$(), $C$Type$(), $F$Type$()]), - JObject.type); - - expect(lowestCommonSuperType([$C$Type$(), $D$Type$()]), $A$Type$()); - expect(lowestCommonSuperType([$F$Type$(), $D$Type$()]), $A$Type$()); - expect(lowestCommonSuperType([$F$Type$(), $C$Type$(), $D$Type$()]), - $A$Type$()); - - expect(lowestCommonSuperType([$E$Type$(), $B$Type$()]), $B$Type$()); - expect(lowestCommonSuperType([$B$Type$(), $B$Type$()]), $B$Type$()); - }); - - testRunner('Mocked nullable type tree', () { - // As a reminder, this is how the type tree looks like: - // JObject - // | \ - // A B - // / \ \ - // C D E - // / - // F - expect(lowestCommonSuperType([$A$Type$(), $B$NullableType$()]), - JObject.nullableType); - expect(lowestCommonSuperType([$C$NullableType$(), $B$Type$()]), - JObject.nullableType); - expect(lowestCommonSuperType([$F$NullableType$(), $B$NullableType$()]), - JObject.nullableType); - expect(lowestCommonSuperType([$E$NullableType$(), $C$Type$(), $F$Type$()]), - JObject.nullableType); - - expect(lowestCommonSuperType([$C$Type$(), $D$NullableType$()]), - $A$NullableType$()); - expect(lowestCommonSuperType([$F$NullableType$(), $D$Type$()]), - $A$NullableType$()); - expect(lowestCommonSuperType([$F$Type$(), $C$NullableType$(), $D$Type$()]), - $A$NullableType$()); - - expect(lowestCommonSuperType([$E$NullableType$(), $B$Type$()]), - $B$NullableType$()); - expect(lowestCommonSuperType([$B$NullableType$(), $B$Type$()]), - $B$NullableType$()); - expect(lowestCommonSuperType([$B$NullableType$(), $B$NullableType$()]), - $B$NullableType$()); - }); -} diff --git a/pkgs/jni/tool/generate_jni_bindings.dart b/pkgs/jni/tool/generate_jni_bindings.dart index bd334d92a4..2514a41ade 100644 --- a/pkgs/jni/tool/generate_jni_bindings.dart +++ b/pkgs/jni/tool/generate_jni_bindings.dart @@ -5,28 +5,66 @@ import 'dart:io'; import 'package:jnigen/jnigen.dart'; +import 'package:jnigen/src/elements/j_elements.dart' as j; -void main() { - generateJniBindings( +class Renamer extends j.Visitor { + @override + void visitClass(j.ClassDecl c) { + c.name = 'J${c.originalName}'; + } +} + +Future main() async { + final classes = [ + 'java.util.ArrayList', + 'java.util.Collection', + 'java.util.HashMap', + 'java.util.HashSet', + 'java.util.Iterator', + 'java.util.List', + 'java.util.Map', + 'java.util.Set', + ]; + const preamble = ''' +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: prefer_relative_imports'''; + + final packageRoot = Platform.script.resolve('..'); + await generateJniBindings( Config( androidSdkConfig: AndroidSdkConfig( addGradleDeps: true, - androidExample: 'example/', + androidExample: packageRoot.resolve('example/').toFilePath(), ), outputConfig: OutputConfig( dartConfig: DartCodeOutputConfig( - path: Platform.script - .resolve('../lib/src/plugin/generated_plugin.dart'), + path: packageRoot.resolve('lib/src/core_bindings.dart'), + structure: OutputStructure.singleFile, + ), + ), + classes: classes, + hide: classes, + preamble: preamble, + visitors: [Renamer()], + ), + ); + await generateJniBindings( + Config( + androidSdkConfig: AndroidSdkConfig( + addGradleDeps: true, + androidExample: packageRoot.resolve('example/').toFilePath(), + ), + outputConfig: OutputConfig( + dartConfig: DartCodeOutputConfig( + path: packageRoot.resolve('lib/src/plugin/generated_plugin.dart'), structure: OutputStructure.singleFile, ), ), classes: ['com.github.dart_lang.jni.JniPlugin'], - preamble: ''' -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -// ignore_for_file: prefer_relative_imports''', + preamble: preamble, ), ); } diff --git a/pkgs/jni/tool/generate_primitive_arrays.dart b/pkgs/jni/tool/generate_primitive_arrays.dart new file mode 100644 index 0000000000..693e9e183f --- /dev/null +++ b/pkgs/jni/tool/generate_primitive_arrays.dart @@ -0,0 +1,200 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Generates lib/src/primitive_jarrays.dart. + +import 'dart:io'; + +import 'package:dart_style/dart_style.dart'; + +class PrimitiveType { + final String name; + final String signature; + final String dartType; + final int size; + final bool isUnsigned; + + const PrimitiveType( + this.name, + this.signature, { + required this.dartType, + required this.size, + this.isUnsigned = false, + }); + + String get nativeDartListType { + if (dartType == 'double') { + return 'Float${size}List'; + } + return '${isUnsigned ? 'Uint' : 'Int'}${size}List'; + } + + String get nativeDartType { + if (dartType == 'double') { + return size == 32 ? 'Float' : 'Double'; + } + return '${isUnsigned ? 'Uint' : 'Int'}$size'; + } + + String get sizeInDoc => size == 8 ? 'eight' : '$size'; + + int get lowestInRange { + if (isUnsigned) { + return 0; + } + return -(1 << (size - 1)); + } + + int get highestInRange { + if (isUnsigned) { + return (1 << size) - 1; + } + return (1 << (size - 1)) - 1; + } +} + +void main() { + final outputUri = + Platform.script.resolve('../lib/src/primitive_jarrays.dart'); + final outputFile = File.fromUri(outputUri); + final s = StringBuffer(); + s.writeln(''' +// AUTO GENERATED. DO NOT EDIT! +// +// To regenerate, run `dart run tool/generate_primtive_arrays.dart` + +part of 'jarray.dart'; +'''); + const primitiveTypes = [ + PrimitiveType('Boolean', 'Z', dartType: 'bool', size: 8, isUnsigned: true), + PrimitiveType('Byte', 'B', dartType: 'int', size: 8), + PrimitiveType('Char', 'C', dartType: 'int', size: 16, isUnsigned: true), + PrimitiveType('Short', 'S', dartType: 'int', size: 16), + PrimitiveType('Int', 'I', dartType: 'int', size: 32), + PrimitiveType('Long', 'J', dartType: 'int', size: 64), + PrimitiveType('Float', 'F', dartType: 'double', size: 32), + PrimitiveType('Double', 'D', dartType: 'double', size: 64), + ]; + for (final type in primitiveTypes) { + final typeName = type.name; + final arrayName = 'J${typeName}Array'; + s.write(''' +final class _\$$arrayName\$Type\$ extends JType<$arrayName> { + const _\$$arrayName\$Type\$(); + + @override + String get signature => '[${type.signature}'; +} + +/// A fixed-length array of Java $typeName. +/// +'''); + if (type.dartType == 'int') { + s.write(''' +/// Integers stored in the list are truncated to their low ${type.sizeInDoc} bits +'''); + if (type.isUnsigned) { + s.write(''' +/// interpreted as an unsigned ${type.size}-bit integer with values in the +/// range ${type.lowestInRange} to +${type.highestInRange}. +/// +'''); + } else { + s.write(''' +/// interpreted as a signed ${type.size}-bit two's complement integer with values in the +/// range ${type.lowestInRange} to +${type.highestInRange}. +/// +'''); + } + } + s.write(''' +/// Java equivalent of [${type.nativeDartListType}]. +extension type $arrayName._(JObject _\$this) implements JObject { + /// The type which includes information such as the signature of this class. + static const JType<$arrayName> type = _\$$arrayName\$Type\$(); + + /// Creates a [$arrayName] of the given [length]. + /// + /// The [length] must be a non-negative integer. + factory $arrayName(int length) { + RangeError.checkNotNegative(length); + return JObject.fromReference( + JGlobalReference(Jni.env.New${typeName}Array(length)), + ) as $arrayName; + } + + /// Creates a [$arrayName] from `elements`. + static $arrayName of(Iterable<${type.dartType}> elements) { + final len = elements.length; + return $arrayName(len)..setRange(0, len, elements); + } + + /// The number of elements in this array. + int get length => Jni.env.GetArrayLength(reference.pointer); + + ${type.dartType} operator [](int index) { + RangeError.checkValueInInterval(index, 0, length - 1); + return Jni.env.Get${typeName}ArrayElement(reference.pointer, index); + } + + void operator []=(int index, ${type.dartType} value) { + RangeError.checkValueInInterval(index, 0, length - 1); + Jni.env.Set${typeName}ArrayElement(reference.pointer, index, value); + } + + ${type.nativeDartListType} getRange(int start, int end, {Allocator allocator = malloc}) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + final buffer = allocator<${type.nativeDartType}>(rangeLength); + Jni.env + .Get${typeName}ArrayRegion(reference.pointer, start, rangeLength, buffer); + return buffer.asTypedList(rangeLength, finalizer: allocator._nativeFree); + } + + void setRange(int start, int end, Iterable<${type.dartType}> iterable, + [int skipCount = 0]) { + RangeError.checkValidRange(start, end, length); + final rangeLength = end - start; + _allocate<${type.nativeDartType}>(sizeOf<${type.nativeDartType}>() * rangeLength, (ptr) { + ptr + .asTypedList(rangeLength) + .setRange(0, rangeLength, iterable${typeName == 'Boolean' ? '.map((e) => e ? 1 : 0)' : ''}, skipCount); + Jni.env.Set${typeName}ArrayRegion(reference.pointer, start, rangeLength, ptr); + }); + } +} + +final class _${arrayName}ListView + with ListMixin<${type.dartType}>, NonGrowableListMixin<${type.dartType}> { + final $arrayName _jarray; + + _${arrayName}ListView(this._jarray); + + @override + int get length => _jarray.length; + + @override + ${type.dartType} operator [](int index) { + return _jarray[index]; + } + + @override + void operator []=(int index, ${type.dartType} value) { + _jarray[index] = value; + } +} + +extension ${arrayName}ToList on $arrayName { + /// Returns a [List] view into this array. + /// + /// Any changes to this list will reflect in the original array as well. + List<${type.dartType}> asDart() => _${arrayName}ListView(this); +} + +'''); + final formatter = DartFormatter( + languageVersion: DartFormatter.latestShortStyleLanguageVersion); + outputFile.writeAsStringSync(formatter.format(s.toString())); + } +} diff --git a/pkgs/jnigen/CHANGELOG.md b/pkgs/jnigen/CHANGELOG.md index f95a43a23e..b7e376f0aa 100644 --- a/pkgs/jnigen/CHANGELOG.md +++ b/pkgs/jnigen/CHANGELOG.md @@ -1,10 +1,23 @@ -## 0.15.1-wip - +## 0.16.0 + +- **Breaking Change**: All Java wrapper classes have been migrated to extension + types. The main effects are: + - No more nullable `JType` classes, only `JType` classes, and the `JType` + class is simplified. + - It is no longer necessary to pass around the `JType` in many cases where it + used to be required. - Add docs about debugging. - Add support for Kotlin interfaces with suspend functions. These can now be implemented using Dart functions that return a `Future`. - Namespace primitive types to avoid collisions with generated API names, eg `bool`. +- Kotlin suspend functions with no result (a return type of `Unit`) now return + `Future` in Dart instead of `Future`. +- Improve error message for unsupported Java class file versions in summary + generation. +- Generated extension types now implement their Java interfaces. +- Instance members of generated extension types have been moved to extension + methods. ## 0.15.0 diff --git a/pkgs/jnigen/example/in_app_java/lib/android_utils.g.dart b/pkgs/jnigen/example/in_app_java/lib/android_utils.g.dart index 0975619023..f3310abe55 100644 --- a/pkgs/jnigen/example/in_app_java/lib/android_utils.g.dart +++ b/pkgs/jnigen/example/in_app_java/lib/android_utils.g.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // ignore_for_file: annotate_overrides // ignore_for_file: argument_type_not_assignable @@ -37,24 +37,10 @@ import 'package:jni/_internal.dart' as jni$_; import 'package:jni/jni.dart' as jni$_; /// from: `com.example.in_app_java.R$drawable` -class R$drawable extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - R$drawable.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type R$drawable._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/example/in_app_java/R$drawable'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $R$drawable$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $R$drawable$Type$(); static final _id_launch_background = _class.staticFieldId( @@ -64,48 +50,11 @@ class R$drawable extends jni$_.JObject { /// from: `static public int launch_background` static int get launch_background => - _id_launch_background.get(_class, const jni$_.jintType()); + _id_launch_background.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int launch_background` static set launch_background(int value) => - _id_launch_background.set(_class, const jni$_.jintType(), value); -} - -final class $R$drawable$NullableType$ extends jni$_.JType { - @jni$_.internal - const $R$drawable$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/example/in_app_java/R$drawable;'; - - @jni$_.internal - @core$_.override - R$drawable? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R$drawable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$drawable$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$drawable$NullableType$) && - other is $R$drawable$NullableType$; - } + _id_launch_background.set(_class, jni$_.jint.type, value); } final class $R$drawable$Type$ extends jni$_.JType { @@ -115,54 +64,13 @@ final class $R$drawable$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/example/in_app_java/R$drawable;'; - - @jni$_.internal - @core$_.override - R$drawable fromReference(jni$_.JReference reference) => - R$drawable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $R$drawable$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$drawable$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$drawable$Type$) && - other is $R$drawable$Type$; - } } /// from: `com.example.in_app_java.R$mipmap` -class R$mipmap extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - R$mipmap.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type R$mipmap._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/example/in_app_java/R$mipmap'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $R$mipmap$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $R$mipmap$Type$(); static final _id_ic_launcher = _class.staticFieldId( @@ -172,48 +80,11 @@ class R$mipmap extends jni$_.JObject { /// from: `static public int ic_launcher` static int get ic_launcher => - _id_ic_launcher.get(_class, const jni$_.jintType()); + _id_ic_launcher.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int ic_launcher` static set ic_launcher(int value) => - _id_ic_launcher.set(_class, const jni$_.jintType(), value); -} - -final class $R$mipmap$NullableType$ extends jni$_.JType { - @jni$_.internal - const $R$mipmap$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/example/in_app_java/R$mipmap;'; - - @jni$_.internal - @core$_.override - R$mipmap? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R$mipmap.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$mipmap$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$mipmap$NullableType$) && - other is $R$mipmap$NullableType$; - } + _id_ic_launcher.set(_class, jni$_.jint.type, value); } final class $R$mipmap$Type$ extends jni$_.JType { @@ -223,51 +94,13 @@ final class $R$mipmap$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/example/in_app_java/R$mipmap;'; - - @jni$_.internal - @core$_.override - R$mipmap fromReference(jni$_.JReference reference) => R$mipmap.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $R$mipmap$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$mipmap$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$mipmap$Type$) && other is $R$mipmap$Type$; - } } /// from: `com.example.in_app_java.R$style` -class R$style extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - R$style.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type R$style._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/example/in_app_java/R$style'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $R$style$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $R$style$Type$(); static final _id_LaunchTheme = _class.staticFieldId( @@ -277,11 +110,11 @@ class R$style extends jni$_.JObject { /// from: `static public int LaunchTheme` static int get LaunchTheme => - _id_LaunchTheme.get(_class, const jni$_.jintType()); + _id_LaunchTheme.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int LaunchTheme` static set LaunchTheme(int value) => - _id_LaunchTheme.set(_class, const jni$_.jintType(), value); + _id_LaunchTheme.set(_class, jni$_.jint.type, value); static final _id_NormalTheme = _class.staticFieldId( r'NormalTheme', @@ -290,48 +123,11 @@ class R$style extends jni$_.JObject { /// from: `static public int NormalTheme` static int get NormalTheme => - _id_NormalTheme.get(_class, const jni$_.jintType()); + _id_NormalTheme.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int NormalTheme` static set NormalTheme(int value) => - _id_NormalTheme.set(_class, const jni$_.jintType(), value); -} - -final class $R$style$NullableType$ extends jni$_.JType { - @jni$_.internal - const $R$style$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/example/in_app_java/R$style;'; - - @jni$_.internal - @core$_.override - R$style? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R$style.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$style$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$style$NullableType$) && - other is $R$style$NullableType$; - } + _id_NormalTheme.set(_class, jni$_.jint.type, value); } final class $R$style$Type$ extends jni$_.JType { @@ -341,90 +137,16 @@ final class $R$style$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/example/in_app_java/R$style;'; - - @jni$_.internal - @core$_.override - R$style fromReference(jni$_.JReference reference) => R$style.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $R$style$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$style$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$style$Type$) && other is $R$style$Type$; - } } /// from: `com.example.in_app_java.R` -class R extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - R.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type R._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/example/in_app_java/R'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $R$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $R$Type$(); } -final class $R$NullableType$ extends jni$_.JType { - @jni$_.internal - const $R$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/example/in_app_java/R;'; - - @jni$_.internal - @core$_.override - R? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$NullableType$) && other is $R$NullableType$; - } -} - final class $R$Type$ extends jni$_.JType { @jni$_.internal const $R$Type$(); @@ -432,52 +154,14 @@ final class $R$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/example/in_app_java/R;'; - - @jni$_.internal - @core$_.override - R fromReference(jni$_.JReference reference) => R.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $R$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R$Type$) && other is $R$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$CodepointSequenceMatchResult` -class EmojiCompat$CodepointSequenceMatchResult extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$CodepointSequenceMatchResult.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$CodepointSequenceMatchResult._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/EmojiCompat$CodepointSequenceMatchResult'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType - nullableType = $EmojiCompat$CodepointSequenceMatchResult$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$CodepointSequenceMatchResult$Type$(); @@ -549,9 +233,7 @@ class EmojiCompat$CodepointSequenceMatchResult extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return EmojiCompat$CodepointSequenceMatchResult.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } @@ -565,50 +247,6 @@ final class _$EmojiCompat$CodepointSequenceMatchResult _$EmojiCompat$CodepointSequenceMatchResult(); } -final class $EmojiCompat$CodepointSequenceMatchResult$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$CodepointSequenceMatchResult$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/EmojiCompat$CodepointSequenceMatchResult;'; - - @jni$_.internal - @core$_.override - EmojiCompat$CodepointSequenceMatchResult? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$CodepointSequenceMatchResult.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($EmojiCompat$CodepointSequenceMatchResult$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($EmojiCompat$CodepointSequenceMatchResult$NullableType$) && - other is $EmojiCompat$CodepointSequenceMatchResult$NullableType$; - } -} - final class $EmojiCompat$CodepointSequenceMatchResult$Type$ extends jni$_.JType { @jni$_.internal @@ -618,62 +256,22 @@ final class $EmojiCompat$CodepointSequenceMatchResult$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$CodepointSequenceMatchResult;'; - - @jni$_.internal - @core$_.override - EmojiCompat$CodepointSequenceMatchResult fromReference( - jni$_.JReference reference) => - EmojiCompat$CodepointSequenceMatchResult.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$CodepointSequenceMatchResult$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($EmojiCompat$CodepointSequenceMatchResult$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($EmojiCompat$CodepointSequenceMatchResult$Type$) && - other is $EmojiCompat$CodepointSequenceMatchResult$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$Config` -class EmojiCompat$Config extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$Config.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$Config._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat$Config'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$Config$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$Config$Type$(); - static final _id_registerInitCallback = _class.instanceMethodId( +} + +extension EmojiCompat$Config$$Methods on EmojiCompat$Config { + static final _id_registerInitCallback = + EmojiCompat$Config._class.instanceMethodId( r'registerInitCallback', r'(Landroidx/emoji2/text/EmojiCompat$InitCallback;)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -695,14 +293,13 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$InitCallback initCallback, ) { final _$initCallback = initCallback.reference; - return _registerInitCallback( - reference.pointer, - _id_registerInitCallback as jni$_.JMethodIDPtr, - _$initCallback.pointer) - .object(const $EmojiCompat$Config$Type$()); + return _registerInitCallback(reference.pointer, + _id_registerInitCallback.pointer, _$initCallback.pointer) + .object(); } - static final _id_unregisterInitCallback = _class.instanceMethodId( + static final _id_unregisterInitCallback = + EmojiCompat$Config._class.instanceMethodId( r'unregisterInitCallback', r'(Landroidx/emoji2/text/EmojiCompat$InitCallback;)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -724,14 +321,12 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$InitCallback initCallback, ) { final _$initCallback = initCallback.reference; - return _unregisterInitCallback( - reference.pointer, - _id_unregisterInitCallback as jni$_.JMethodIDPtr, - _$initCallback.pointer) - .object(const $EmojiCompat$Config$Type$()); + return _unregisterInitCallback(reference.pointer, + _id_unregisterInitCallback.pointer, _$initCallback.pointer) + .object(); } - static final _id_setReplaceAll = _class.instanceMethodId( + static final _id_setReplaceAll = EmojiCompat$Config._class.instanceMethodId( r'setReplaceAll', r'(Z)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -751,12 +346,13 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$Config setReplaceAll( core$_.bool z, ) { - return _setReplaceAll(reference.pointer, - _id_setReplaceAll as jni$_.JMethodIDPtr, z ? 1 : 0) - .object(const $EmojiCompat$Config$Type$()); + return _setReplaceAll( + reference.pointer, _id_setReplaceAll.pointer, z ? 1 : 0) + .object(); } - static final _id_setUseEmojiAsDefaultStyle = _class.instanceMethodId( + static final _id_setUseEmojiAsDefaultStyle = + EmojiCompat$Config._class.instanceMethodId( r'setUseEmojiAsDefaultStyle', r'(Z)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -776,12 +372,13 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$Config setUseEmojiAsDefaultStyle( core$_.bool z, ) { - return _setUseEmojiAsDefaultStyle(reference.pointer, - _id_setUseEmojiAsDefaultStyle as jni$_.JMethodIDPtr, z ? 1 : 0) - .object(const $EmojiCompat$Config$Type$()); + return _setUseEmojiAsDefaultStyle( + reference.pointer, _id_setUseEmojiAsDefaultStyle.pointer, z ? 1 : 0) + .object(); } - static final _id_setUseEmojiAsDefaultStyle$1 = _class.instanceMethodId( + static final _id_setUseEmojiAsDefaultStyle$1 = + EmojiCompat$Config._class.instanceMethodId( r'setUseEmojiAsDefaultStyle', r'(ZLjava/util/List;)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -808,15 +405,13 @@ class EmojiCompat$Config extends jni$_.JObject { jni$_.JList? list, ) { final _$list = list?.reference ?? jni$_.jNullReference; - return _setUseEmojiAsDefaultStyle$1( - reference.pointer, - _id_setUseEmojiAsDefaultStyle$1 as jni$_.JMethodIDPtr, - z ? 1 : 0, - _$list.pointer) - .object(const $EmojiCompat$Config$Type$()); + return _setUseEmojiAsDefaultStyle$1(reference.pointer, + _id_setUseEmojiAsDefaultStyle$1.pointer, z ? 1 : 0, _$list.pointer) + .object(); } - static final _id_setEmojiSpanIndicatorEnabled = _class.instanceMethodId( + static final _id_setEmojiSpanIndicatorEnabled = + EmojiCompat$Config._class.instanceMethodId( r'setEmojiSpanIndicatorEnabled', r'(Z)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -837,11 +432,12 @@ class EmojiCompat$Config extends jni$_.JObject { core$_.bool z, ) { return _setEmojiSpanIndicatorEnabled(reference.pointer, - _id_setEmojiSpanIndicatorEnabled as jni$_.JMethodIDPtr, z ? 1 : 0) - .object(const $EmojiCompat$Config$Type$()); + _id_setEmojiSpanIndicatorEnabled.pointer, z ? 1 : 0) + .object(); } - static final _id_setEmojiSpanIndicatorColor = _class.instanceMethodId( + static final _id_setEmojiSpanIndicatorColor = + EmojiCompat$Config._class.instanceMethodId( r'setEmojiSpanIndicatorColor', r'(I)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -861,12 +457,13 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$Config setEmojiSpanIndicatorColor( int i, ) { - return _setEmojiSpanIndicatorColor(reference.pointer, - _id_setEmojiSpanIndicatorColor as jni$_.JMethodIDPtr, i) - .object(const $EmojiCompat$Config$Type$()); + return _setEmojiSpanIndicatorColor( + reference.pointer, _id_setEmojiSpanIndicatorColor.pointer, i) + .object(); } - static final _id_setMetadataLoadStrategy = _class.instanceMethodId( + static final _id_setMetadataLoadStrategy = + EmojiCompat$Config._class.instanceMethodId( r'setMetadataLoadStrategy', r'(I)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -886,12 +483,12 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$Config setMetadataLoadStrategy( int i, ) { - return _setMetadataLoadStrategy(reference.pointer, - _id_setMetadataLoadStrategy as jni$_.JMethodIDPtr, i) - .object(const $EmojiCompat$Config$Type$()); + return _setMetadataLoadStrategy( + reference.pointer, _id_setMetadataLoadStrategy.pointer, i) + .object(); } - static final _id_setSpanFactory = _class.instanceMethodId( + static final _id_setSpanFactory = EmojiCompat$Config._class.instanceMethodId( r'setSpanFactory', r'(Landroidx/emoji2/text/EmojiCompat$SpanFactory;)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -913,12 +510,12 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$SpanFactory spanFactory, ) { final _$spanFactory = spanFactory.reference; - return _setSpanFactory(reference.pointer, - _id_setSpanFactory as jni$_.JMethodIDPtr, _$spanFactory.pointer) - .object(const $EmojiCompat$Config$Type$()); + return _setSpanFactory(reference.pointer, _id_setSpanFactory.pointer, + _$spanFactory.pointer) + .object(); } - static final _id_setGlyphChecker = _class.instanceMethodId( + static final _id_setGlyphChecker = EmojiCompat$Config._class.instanceMethodId( r'setGlyphChecker', r'(Landroidx/emoji2/text/EmojiCompat$GlyphChecker;)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -940,107 +537,27 @@ class EmojiCompat$Config extends jni$_.JObject { EmojiCompat$GlyphChecker glyphChecker, ) { final _$glyphChecker = glyphChecker.reference; - return _setGlyphChecker(reference.pointer, - _id_setGlyphChecker as jni$_.JMethodIDPtr, _$glyphChecker.pointer) - .object(const $EmojiCompat$Config$Type$()); + return _setGlyphChecker(reference.pointer, _id_setGlyphChecker.pointer, + _$glyphChecker.pointer) + .object(); } } -final class $EmojiCompat$Config$NullableType$ - extends jni$_.JType { +final class $EmojiCompat$Config$Type$ extends jni$_.JType { @jni$_.internal - const $EmojiCompat$Config$NullableType$(); + const $EmojiCompat$Config$Type$(); @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$Config;'; - - @jni$_.internal - @core$_.override - EmojiCompat$Config? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$Config.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$Config$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$Config$NullableType$) && - other is $EmojiCompat$Config$NullableType$; - } -} - -final class $EmojiCompat$Config$Type$ extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$Config$Type$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat$Config;'; - - @jni$_.internal - @core$_.override - EmojiCompat$Config fromReference(jni$_.JReference reference) => - EmojiCompat$Config.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$Config$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$Config$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$Config$Type$) && - other is $EmojiCompat$Config$Type$; - } -} +} /// from: `androidx.emoji2.text.EmojiCompat$DefaultSpanFactory` -class EmojiCompat$DefaultSpanFactory extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$DefaultSpanFactory.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$DefaultSpanFactory._(jni$_.JObject _$this) + implements jni$_.JObject, EmojiCompat$SpanFactory { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/EmojiCompat$DefaultSpanFactory'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$DefaultSpanFactory$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$DefaultSpanFactory$Type$(); @@ -1063,12 +580,15 @@ class EmojiCompat$DefaultSpanFactory extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory EmojiCompat$DefaultSpanFactory() { - return EmojiCompat$DefaultSpanFactory.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } +} - static final _id_createSpan = _class.instanceMethodId( +extension EmojiCompat$DefaultSpanFactory$$Methods + on EmojiCompat$DefaultSpanFactory { + static final _id_createSpan = + EmojiCompat$DefaultSpanFactory._class.instanceMethodId( r'createSpan', r'(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/emoji2/text/EmojiSpan;', ); @@ -1090,50 +610,9 @@ class EmojiCompat$DefaultSpanFactory extends jni$_.JObject { jni$_.JObject typefaceEmojiRasterizer, ) { final _$typefaceEmojiRasterizer = typefaceEmojiRasterizer.reference; - return _createSpan(reference.pointer, _id_createSpan as jni$_.JMethodIDPtr, + return _createSpan(reference.pointer, _id_createSpan.pointer, _$typefaceEmojiRasterizer.pointer) - .object(const jni$_.$JObject$Type$()); - } -} - -final class $EmojiCompat$DefaultSpanFactory$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$DefaultSpanFactory$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/EmojiCompat$DefaultSpanFactory;'; - - @jni$_.internal - @core$_.override - EmojiCompat$DefaultSpanFactory? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$DefaultSpanFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$DefaultSpanFactory$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($EmojiCompat$DefaultSpanFactory$NullableType$) && - other is $EmojiCompat$DefaultSpanFactory$NullableType$; + .object(); } } @@ -1146,91 +625,17 @@ final class $EmojiCompat$DefaultSpanFactory$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$DefaultSpanFactory;'; - - @jni$_.internal - @core$_.override - EmojiCompat$DefaultSpanFactory fromReference(jni$_.JReference reference) => - EmojiCompat$DefaultSpanFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$DefaultSpanFactory$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$DefaultSpanFactory$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$DefaultSpanFactory$Type$) && - other is $EmojiCompat$DefaultSpanFactory$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$GlyphChecker` -class EmojiCompat$GlyphChecker extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$GlyphChecker.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$GlyphChecker._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat$GlyphChecker'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$GlyphChecker$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$GlyphChecker$Type$(); - static final _id_hasGlyph = _class.instanceMethodId( - r'hasGlyph', - r'(Ljava/lang/CharSequence;III)Z', - ); - - static final _hasGlyph = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32 - )>)>>('globalEnv_CallBooleanMethod') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer, int, int, int)>(); - - /// from: `public abstract boolean hasGlyph(java.lang.CharSequence charSequence, int i, int i1, int i2)` - core$_.bool hasGlyph( - jni$_.JObject charSequence, - int i, - int i1, - int i2, - ) { - final _$charSequence = charSequence.reference; - return _hasGlyph(reference.pointer, _id_hasGlyph as jni$_.JMethodIDPtr, - _$charSequence.pointer, i, i1, i2) - .boolean; - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -1264,16 +669,10 @@ class EmojiCompat$GlyphChecker extends jni$_.JObject { final $a = $i.args; if ($d == r'hasGlyph(Ljava/lang/CharSequence;III)Z') { final $r = _$impls[$p]!.hasGlyph( - $a![0]!.as(const jni$_.$JObject$Type$(), releaseOriginal: true), - $a![1]! - .as(const jni$_.$JInteger$Type$(), releaseOriginal: true) - .intValue(releaseOriginal: true), - $a![2]! - .as(const jni$_.$JInteger$Type$(), releaseOriginal: true) - .intValue(releaseOriginal: true), - $a![3]! - .as(const jni$_.$JInteger$Type$(), releaseOriginal: true) - .intValue(releaseOriginal: true), + ($a![0] as jni$_.JObject), + ($a![1] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![2] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![3] as jni$_.JInteger).intValue(releaseOriginal: true), ); return jni$_.JBoolean($r).reference.toPointer(); } @@ -1313,9 +712,43 @@ class EmojiCompat$GlyphChecker extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return EmojiCompat$GlyphChecker.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension EmojiCompat$GlyphChecker$$Methods on EmojiCompat$GlyphChecker { + static final _id_hasGlyph = EmojiCompat$GlyphChecker._class.instanceMethodId( + r'hasGlyph', + r'(Ljava/lang/CharSequence;III)Z', + ); + + static final _hasGlyph = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32 + )>)>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer, int, int, int)>(); + + /// from: `public abstract boolean hasGlyph(java.lang.CharSequence charSequence, int i, int i1, int i2)` + core$_.bool hasGlyph( + jni$_.JObject charSequence, + int i, + int i1, + int i2, + ) { + final _$charSequence = charSequence.reference; + return _hasGlyph(reference.pointer, _id_hasGlyph.pointer, + _$charSequence.pointer, i, i1, i2) + .boolean; } } @@ -1344,45 +777,6 @@ final class _$EmojiCompat$GlyphChecker with $EmojiCompat$GlyphChecker { } } -final class $EmojiCompat$GlyphChecker$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$GlyphChecker$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat$GlyphChecker;'; - - @jni$_.internal - @core$_.override - EmojiCompat$GlyphChecker? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$GlyphChecker.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$GlyphChecker$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$GlyphChecker$NullableType$) && - other is $EmojiCompat$GlyphChecker$NullableType$; - } -} - final class $EmojiCompat$GlyphChecker$Type$ extends jni$_.JType { @jni$_.internal @@ -1391,59 +785,22 @@ final class $EmojiCompat$GlyphChecker$Type$ @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$GlyphChecker;'; - - @jni$_.internal - @core$_.override - EmojiCompat$GlyphChecker fromReference(jni$_.JReference reference) => - EmojiCompat$GlyphChecker.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$GlyphChecker$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$GlyphChecker$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$GlyphChecker$Type$) && - other is $EmojiCompat$GlyphChecker$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$InitCallback` -class EmojiCompat$InitCallback extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$InitCallback.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$InitCallback._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat$InitCallback'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$InitCallback$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$InitCallback$Type$(); - static final _id_onInitialized = _class.instanceMethodId( +} + +extension EmojiCompat$InitCallback$$Methods on EmojiCompat$InitCallback { + static final _id_onInitialized = + EmojiCompat$InitCallback._class.instanceMethodId( r'onInitialized', r'()V', ); @@ -1462,11 +819,10 @@ class EmojiCompat$InitCallback extends jni$_.JObject { /// from: `public void onInitialized()` void onInitialized() { - _onInitialized(reference.pointer, _id_onInitialized as jni$_.JMethodIDPtr) - .check(); + _onInitialized(reference.pointer, _id_onInitialized.pointer).check(); } - static final _id_onFailed = _class.instanceMethodId( + static final _id_onFailed = EmojiCompat$InitCallback._class.instanceMethodId( r'onFailed', r'(Ljava/lang/Throwable;)V', ); @@ -1487,51 +843,11 @@ class EmojiCompat$InitCallback extends jni$_.JObject { jni$_.JObject? throwable, ) { final _$throwable = throwable?.reference ?? jni$_.jNullReference; - _onFailed(reference.pointer, _id_onFailed as jni$_.JMethodIDPtr, - _$throwable.pointer) + _onFailed(reference.pointer, _id_onFailed.pointer, _$throwable.pointer) .check(); } } -final class $EmojiCompat$InitCallback$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$InitCallback$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat$InitCallback;'; - - @jni$_.internal - @core$_.override - EmojiCompat$InitCallback? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$InitCallback.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$InitCallback$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$InitCallback$NullableType$) && - other is $EmojiCompat$InitCallback$NullableType$; - } -} - final class $EmojiCompat$InitCallback$Type$ extends jni$_.JType { @jni$_.internal @@ -1540,55 +856,14 @@ final class $EmojiCompat$InitCallback$Type$ @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$InitCallback;'; - - @jni$_.internal - @core$_.override - EmojiCompat$InitCallback fromReference(jni$_.JReference reference) => - EmojiCompat$InitCallback.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$InitCallback$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$InitCallback$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$InitCallback$Type$) && - other is $EmojiCompat$InitCallback$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$LoadStrategy` -class EmojiCompat$LoadStrategy extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$LoadStrategy.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$LoadStrategy._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat$LoadStrategy'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$LoadStrategy$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$LoadStrategy$Type$(); @@ -1659,9 +934,7 @@ class EmojiCompat$LoadStrategy extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return EmojiCompat$LoadStrategy.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } @@ -1669,47 +942,8 @@ abstract base mixin class $EmojiCompat$LoadStrategy { factory $EmojiCompat$LoadStrategy() = _$EmojiCompat$LoadStrategy; } -final class _$EmojiCompat$LoadStrategy with $EmojiCompat$LoadStrategy { - _$EmojiCompat$LoadStrategy(); -} - -final class $EmojiCompat$LoadStrategy$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$LoadStrategy$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat$LoadStrategy;'; - - @jni$_.internal - @core$_.override - EmojiCompat$LoadStrategy? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$LoadStrategy.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$LoadStrategy$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$LoadStrategy$NullableType$) && - other is $EmojiCompat$LoadStrategy$NullableType$; - } +final class _$EmojiCompat$LoadStrategy with $EmojiCompat$LoadStrategy { + _$EmojiCompat$LoadStrategy(); } final class $EmojiCompat$LoadStrategy$Type$ @@ -1720,83 +954,17 @@ final class $EmojiCompat$LoadStrategy$Type$ @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$LoadStrategy;'; - - @jni$_.internal - @core$_.override - EmojiCompat$LoadStrategy fromReference(jni$_.JReference reference) => - EmojiCompat$LoadStrategy.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$LoadStrategy$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$LoadStrategy$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$LoadStrategy$Type$) && - other is $EmojiCompat$LoadStrategy$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$MetadataRepoLoader` -class EmojiCompat$MetadataRepoLoader extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$MetadataRepoLoader.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$MetadataRepoLoader._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/EmojiCompat$MetadataRepoLoader'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$MetadataRepoLoader$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$MetadataRepoLoader$Type$(); - static final _id_load = _class.instanceMethodId( - r'load', - r'(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;)V', - ); - - static final _load = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public abstract void load(androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback metadataRepoLoaderCallback)` - void load( - EmojiCompat$MetadataRepoLoaderCallback metadataRepoLoaderCallback, - ) { - final _$metadataRepoLoaderCallback = metadataRepoLoaderCallback.reference; - _load(reference.pointer, _id_load as jni$_.JMethodIDPtr, - _$metadataRepoLoaderCallback.pointer) - .check(); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -1831,8 +999,7 @@ class EmojiCompat$MetadataRepoLoader extends jni$_.JObject { if ($d == r'load(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;)V') { _$impls[$p]!.load( - $a![0]!.as(const $EmojiCompat$MetadataRepoLoaderCallback$Type$(), - releaseOriginal: true), + ($a![0] as EmojiCompat$MetadataRepoLoaderCallback), ); return jni$_.nullptr; } @@ -1875,9 +1042,37 @@ class EmojiCompat$MetadataRepoLoader extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return EmojiCompat$MetadataRepoLoader.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension EmojiCompat$MetadataRepoLoader$$Methods + on EmojiCompat$MetadataRepoLoader { + static final _id_load = + EmojiCompat$MetadataRepoLoader._class.instanceMethodId( + r'load', + r'(Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;)V', + ); + + static final _load = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract void load(androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback metadataRepoLoaderCallback)` + void load( + EmojiCompat$MetadataRepoLoaderCallback metadataRepoLoaderCallback, + ) { + final _$metadataRepoLoaderCallback = metadataRepoLoaderCallback.reference; + _load(reference.pointer, _id_load.pointer, + _$metadataRepoLoaderCallback.pointer) + .check(); } } @@ -1911,47 +1106,6 @@ final class _$EmojiCompat$MetadataRepoLoader } } -final class $EmojiCompat$MetadataRepoLoader$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$MetadataRepoLoader$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;'; - - @jni$_.internal - @core$_.override - EmojiCompat$MetadataRepoLoader? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$MetadataRepoLoader.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$MetadataRepoLoader$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($EmojiCompat$MetadataRepoLoader$NullableType$) && - other is $EmojiCompat$MetadataRepoLoader$NullableType$; - } -} - final class $EmojiCompat$MetadataRepoLoader$Type$ extends jni$_.JType { @jni$_.internal @@ -1961,59 +1115,23 @@ final class $EmojiCompat$MetadataRepoLoader$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoader;'; - - @jni$_.internal - @core$_.override - EmojiCompat$MetadataRepoLoader fromReference(jni$_.JReference reference) => - EmojiCompat$MetadataRepoLoader.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$MetadataRepoLoader$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$MetadataRepoLoader$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$MetadataRepoLoader$Type$) && - other is $EmojiCompat$MetadataRepoLoader$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$MetadataRepoLoaderCallback` -class EmojiCompat$MetadataRepoLoaderCallback extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$MetadataRepoLoaderCallback.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$MetadataRepoLoaderCallback._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType - nullableType = $EmojiCompat$MetadataRepoLoaderCallback$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$MetadataRepoLoaderCallback$Type$(); - static final _id_onLoaded = _class.instanceMethodId( +} + +extension EmojiCompat$MetadataRepoLoaderCallback$$Methods + on EmojiCompat$MetadataRepoLoaderCallback { + static final _id_onLoaded = + EmojiCompat$MetadataRepoLoaderCallback._class.instanceMethodId( r'onLoaded', r'(Landroidx/emoji2/text/MetadataRepo;)V', ); @@ -2034,12 +1152,12 @@ class EmojiCompat$MetadataRepoLoaderCallback extends jni$_.JObject { jni$_.JObject metadataRepo, ) { final _$metadataRepo = metadataRepo.reference; - _onLoaded(reference.pointer, _id_onLoaded as jni$_.JMethodIDPtr, - _$metadataRepo.pointer) + _onLoaded(reference.pointer, _id_onLoaded.pointer, _$metadataRepo.pointer) .check(); } - static final _id_onFailed = _class.instanceMethodId( + static final _id_onFailed = + EmojiCompat$MetadataRepoLoaderCallback._class.instanceMethodId( r'onFailed', r'(Ljava/lang/Throwable;)V', ); @@ -2060,55 +1178,11 @@ class EmojiCompat$MetadataRepoLoaderCallback extends jni$_.JObject { jni$_.JObject? throwable, ) { final _$throwable = throwable?.reference ?? jni$_.jNullReference; - _onFailed(reference.pointer, _id_onFailed as jni$_.JMethodIDPtr, - _$throwable.pointer) + _onFailed(reference.pointer, _id_onFailed.pointer, _$throwable.pointer) .check(); } } -final class $EmojiCompat$MetadataRepoLoaderCallback$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$MetadataRepoLoaderCallback$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;'; - - @jni$_.internal - @core$_.override - EmojiCompat$MetadataRepoLoaderCallback? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$MetadataRepoLoaderCallback.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($EmojiCompat$MetadataRepoLoaderCallback$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($EmojiCompat$MetadataRepoLoaderCallback$NullableType$) && - other is $EmojiCompat$MetadataRepoLoaderCallback$NullableType$; - } -} - final class $EmojiCompat$MetadataRepoLoaderCallback$Type$ extends jni$_.JType { @jni$_.internal @@ -2118,57 +1192,14 @@ final class $EmojiCompat$MetadataRepoLoaderCallback$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$MetadataRepoLoaderCallback;'; - - @jni$_.internal - @core$_.override - EmojiCompat$MetadataRepoLoaderCallback fromReference( - jni$_.JReference reference) => - EmojiCompat$MetadataRepoLoaderCallback.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$MetadataRepoLoaderCallback$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$MetadataRepoLoaderCallback$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($EmojiCompat$MetadataRepoLoaderCallback$Type$) && - other is $EmojiCompat$MetadataRepoLoaderCallback$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$ReplaceStrategy` -class EmojiCompat$ReplaceStrategy extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$ReplaceStrategy.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$ReplaceStrategy._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat$ReplaceStrategy'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$ReplaceStrategy$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$ReplaceStrategy$Type$(); @@ -2239,9 +1270,7 @@ class EmojiCompat$ReplaceStrategy extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return EmojiCompat$ReplaceStrategy.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } @@ -2253,45 +1282,6 @@ final class _$EmojiCompat$ReplaceStrategy with $EmojiCompat$ReplaceStrategy { _$EmojiCompat$ReplaceStrategy(); } -final class $EmojiCompat$ReplaceStrategy$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$ReplaceStrategy$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat$ReplaceStrategy;'; - - @jni$_.internal - @core$_.override - EmojiCompat$ReplaceStrategy? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$ReplaceStrategy.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$ReplaceStrategy$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$ReplaceStrategy$NullableType$) && - other is $EmojiCompat$ReplaceStrategy$NullableType$; - } -} - final class $EmojiCompat$ReplaceStrategy$Type$ extends jni$_.JType { @jni$_.internal @@ -2300,84 +1290,17 @@ final class $EmojiCompat$ReplaceStrategy$Type$ @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$ReplaceStrategy;'; - - @jni$_.internal - @core$_.override - EmojiCompat$ReplaceStrategy fromReference(jni$_.JReference reference) => - EmojiCompat$ReplaceStrategy.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$ReplaceStrategy$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$ReplaceStrategy$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$ReplaceStrategy$Type$) && - other is $EmojiCompat$ReplaceStrategy$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat$SpanFactory` -class EmojiCompat$SpanFactory extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat$SpanFactory.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat$SpanFactory._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat$SpanFactory'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$SpanFactory$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$SpanFactory$Type$(); - static final _id_createSpan = _class.instanceMethodId( - r'createSpan', - r'(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/emoji2/text/EmojiSpan;', - ); - - static final _createSpan = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public abstract androidx.emoji2.text.EmojiSpan createSpan(androidx.emoji2.text.TypefaceEmojiRasterizer typefaceEmojiRasterizer)` - /// The returned object must be released after use, by calling the [release] method. - jni$_.JObject createSpan( - jni$_.JObject typefaceEmojiRasterizer, - ) { - final _$typefaceEmojiRasterizer = typefaceEmojiRasterizer.reference; - return _createSpan(reference.pointer, _id_createSpan as jni$_.JMethodIDPtr, - _$typefaceEmojiRasterizer.pointer) - .object(const jni$_.$JObject$Type$()); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -2412,7 +1335,7 @@ class EmojiCompat$SpanFactory extends jni$_.JObject { if ($d == r'createSpan(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/emoji2/text/EmojiSpan;') { final $r = _$impls[$p]!.createSpan( - $a![0]!.as(const jni$_.$JObject$Type$(), releaseOriginal: true), + ($a![0] as jni$_.JObject), ); return ($r as jni$_.JObject?) ?.as(const jni$_.$JObject$Type$()) @@ -2451,14 +1374,41 @@ class EmojiCompat$SpanFactory extends jni$_.JObject { _$impls[$a] = $impl; } - factory EmojiCompat$SpanFactory.implement( - $EmojiCompat$SpanFactory $impl, + factory EmojiCompat$SpanFactory.implement( + $EmojiCompat$SpanFactory $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement(); + } +} + +extension EmojiCompat$SpanFactory$$Methods on EmojiCompat$SpanFactory { + static final _id_createSpan = EmojiCompat$SpanFactory._class.instanceMethodId( + r'createSpan', + r'(Landroidx/emoji2/text/TypefaceEmojiRasterizer;)Landroidx/emoji2/text/EmojiSpan;', + ); + + static final _createSpan = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract androidx.emoji2.text.EmojiSpan createSpan(androidx.emoji2.text.TypefaceEmojiRasterizer typefaceEmojiRasterizer)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject createSpan( + jni$_.JObject typefaceEmojiRasterizer, ) { - final $i = jni$_.JImplementer(); - implementIn($i, $impl); - return EmojiCompat$SpanFactory.fromReference( - $i.implementReference(), - ); + final _$typefaceEmojiRasterizer = typefaceEmojiRasterizer.reference; + return _createSpan(reference.pointer, _id_createSpan.pointer, + _$typefaceEmojiRasterizer.pointer) + .object(); } } @@ -2485,45 +1435,6 @@ final class _$EmojiCompat$SpanFactory with $EmojiCompat$SpanFactory { } } -final class $EmojiCompat$SpanFactory$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$SpanFactory$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat$SpanFactory;'; - - @jni$_.internal - @core$_.override - EmojiCompat$SpanFactory? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : EmojiCompat$SpanFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$SpanFactory$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$SpanFactory$NullableType$) && - other is $EmojiCompat$SpanFactory$NullableType$; - } -} - final class $EmojiCompat$SpanFactory$Type$ extends jni$_.JType { @jni$_.internal @@ -2532,55 +1443,13 @@ final class $EmojiCompat$SpanFactory$Type$ @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat$SpanFactory;'; - - @jni$_.internal - @core$_.override - EmojiCompat$SpanFactory fromReference(jni$_.JReference reference) => - EmojiCompat$SpanFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$SpanFactory$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$SpanFactory$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$SpanFactory$Type$) && - other is $EmojiCompat$SpanFactory$Type$; - } } /// from: `androidx.emoji2.text.EmojiCompat` -class EmojiCompat extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - EmojiCompat.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type EmojiCompat._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/EmojiCompat'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $EmojiCompat$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $EmojiCompat$Type$(); static final _id_EDITOR_INFO_METAVERSION_KEY = _class.staticFieldId( @@ -2591,8 +1460,8 @@ class EmojiCompat extends jni$_.JObject { /// from: `static public final java.lang.String EDITOR_INFO_METAVERSION_KEY` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get EDITOR_INFO_METAVERSION_KEY => - _id_EDITOR_INFO_METAVERSION_KEY.get( - _class, const jni$_.$JString$NullableType$()); + _id_EDITOR_INFO_METAVERSION_KEY.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_EDITOR_INFO_REPLACE_ALL_KEY = _class.staticFieldId( r'EDITOR_INFO_REPLACE_ALL_KEY', @@ -2602,8 +1471,8 @@ class EmojiCompat extends jni$_.JObject { /// from: `static public final java.lang.String EDITOR_INFO_REPLACE_ALL_KEY` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get EDITOR_INFO_REPLACE_ALL_KEY => - _id_EDITOR_INFO_REPLACE_ALL_KEY.get( - _class, const jni$_.$JString$NullableType$()); + _id_EDITOR_INFO_REPLACE_ALL_KEY.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; /// from: `static public final int LOAD_STATE_DEFAULT` static const LOAD_STATE_DEFAULT = 3; @@ -2662,9 +1531,8 @@ class EmojiCompat extends jni$_.JObject { jni$_.JObject context, ) { final _$context = context.reference; - return _init(_class.reference.pointer, _id_init as jni$_.JMethodIDPtr, - _$context.pointer) - .object(const $EmojiCompat$NullableType$()); + return _init(_class.reference.pointer, _id_init.pointer, _$context.pointer) + .object(); } static final _id_init$1 = _class.staticMethodId( @@ -2699,9 +1567,9 @@ class EmojiCompat extends jni$_.JObject { final _$context = context.reference; final _$defaultEmojiCompatConfigFactory = defaultEmojiCompatConfigFactory?.reference ?? jni$_.jNullReference; - return _init$1(_class.reference.pointer, _id_init$1 as jni$_.JMethodIDPtr, + return _init$1(_class.reference.pointer, _id_init$1.pointer, _$context.pointer, _$defaultEmojiCompatConfigFactory.pointer) - .object(const $EmojiCompat$NullableType$()); + .object(); } static final _id_init$2 = _class.staticMethodId( @@ -2726,9 +1594,9 @@ class EmojiCompat extends jni$_.JObject { EmojiCompat$Config config, ) { final _$config = config.reference; - return _init$2(_class.reference.pointer, _id_init$2 as jni$_.JMethodIDPtr, - _$config.pointer) - .object(const $EmojiCompat$Type$()); + return _init$2( + _class.reference.pointer, _id_init$2.pointer, _$config.pointer) + .object(); } static final _id_isConfigured = _class.staticMethodId( @@ -2750,8 +1618,7 @@ class EmojiCompat extends jni$_.JObject { /// from: `static public boolean isConfigured()` static core$_.bool isConfigured() { - return _isConfigured( - _class.reference.pointer, _id_isConfigured as jni$_.JMethodIDPtr) + return _isConfigured(_class.reference.pointer, _id_isConfigured.pointer) .boolean; } @@ -2777,9 +1644,8 @@ class EmojiCompat extends jni$_.JObject { EmojiCompat$Config config, ) { final _$config = config.reference; - return _reset(_class.reference.pointer, _id_reset as jni$_.JMethodIDPtr, - _$config.pointer) - .object(const $EmojiCompat$Type$()); + return _reset(_class.reference.pointer, _id_reset.pointer, _$config.pointer) + .object(); } static final _id_reset$1 = _class.staticMethodId( @@ -2804,9 +1670,9 @@ class EmojiCompat extends jni$_.JObject { EmojiCompat? emojiCompat, ) { final _$emojiCompat = emojiCompat?.reference ?? jni$_.jNullReference; - return _reset$1(_class.reference.pointer, _id_reset$1 as jni$_.JMethodIDPtr, + return _reset$1(_class.reference.pointer, _id_reset$1.pointer, _$emojiCompat.pointer) - .object(const $EmojiCompat$NullableType$()); + .object(); } static final _id_skipDefaultConfigurationLookup = _class.staticMethodId( @@ -2829,7 +1695,7 @@ class EmojiCompat extends jni$_.JObject { core$_.bool z, ) { _skipDefaultConfigurationLookup(_class.reference.pointer, - _id_skipDefaultConfigurationLookup as jni$_.JMethodIDPtr, z ? 1 : 0) + _id_skipDefaultConfigurationLookup.pointer, z ? 1 : 0) .check(); } @@ -2853,11 +1719,104 @@ class EmojiCompat extends jni$_.JObject { /// from: `static public androidx.emoji2.text.EmojiCompat get()` /// The returned object must be released after use, by calling the [release] method. static EmojiCompat get() { - return _get(_class.reference.pointer, _id_get as jni$_.JMethodIDPtr) - .object(const $EmojiCompat$Type$()); + return _get(_class.reference.pointer, _id_get.pointer) + .object(); + } + + static final _id_handleOnKeyDown = _class.staticMethodId( + r'handleOnKeyDown', + r'(Landroid/text/Editable;ILandroid/view/KeyEvent;)Z', + ); + + static final _handleOnKeyDown = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Int32, + jni$_.Pointer + )>)>>('globalEnv_CallStaticBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + int, + jni$_.Pointer)>(); + + /// from: `static public boolean handleOnKeyDown(android.text.Editable editable, int i, android.view.KeyEvent keyEvent)` + static core$_.bool handleOnKeyDown( + jni$_.JObject editable, + int i, + jni$_.JObject keyEvent, + ) { + final _$editable = editable.reference; + final _$keyEvent = keyEvent.reference; + return _handleOnKeyDown( + _class.reference.pointer, + _id_handleOnKeyDown.pointer, + _$editable.pointer, + i, + _$keyEvent.pointer) + .boolean; + } + + static final _id_handleDeleteSurroundingText = _class.staticMethodId( + r'handleDeleteSurroundingText', + r'(Landroid/view/inputmethod/InputConnection;Landroid/text/Editable;IIZ)Z', + ); + + static final _handleDeleteSurroundingText = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32 + )>)>>('globalEnv_CallStaticBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + int, + int, + int)>(); + + /// from: `static public boolean handleDeleteSurroundingText(android.view.inputmethod.InputConnection inputConnection, android.text.Editable editable, int i, int i1, boolean z)` + static core$_.bool handleDeleteSurroundingText( + jni$_.JObject inputConnection, + jni$_.JObject editable, + int i, + int i1, + core$_.bool z, + ) { + final _$inputConnection = inputConnection.reference; + final _$editable = editable.reference; + return _handleDeleteSurroundingText( + _class.reference.pointer, + _id_handleDeleteSurroundingText.pointer, + _$inputConnection.pointer, + _$editable.pointer, + i, + i1, + z ? 1 : 0) + .boolean; } +} - static final _id_load = _class.instanceMethodId( +extension EmojiCompat$$Methods on EmojiCompat { + static final _id_load = EmojiCompat._class.instanceMethodId( r'load', r'()V', ); @@ -2876,10 +1835,10 @@ class EmojiCompat extends jni$_.JObject { /// from: `public void load()` void load() { - _load(reference.pointer, _id_load as jni$_.JMethodIDPtr).check(); + _load(reference.pointer, _id_load.pointer).check(); } - static final _id_registerInitCallback = _class.instanceMethodId( + static final _id_registerInitCallback = EmojiCompat._class.instanceMethodId( r'registerInitCallback', r'(Landroidx/emoji2/text/EmojiCompat$InitCallback;)V', ); @@ -2900,14 +1859,12 @@ class EmojiCompat extends jni$_.JObject { EmojiCompat$InitCallback initCallback, ) { final _$initCallback = initCallback.reference; - _registerInitCallback( - reference.pointer, - _id_registerInitCallback as jni$_.JMethodIDPtr, + _registerInitCallback(reference.pointer, _id_registerInitCallback.pointer, _$initCallback.pointer) .check(); } - static final _id_unregisterInitCallback = _class.instanceMethodId( + static final _id_unregisterInitCallback = EmojiCompat._class.instanceMethodId( r'unregisterInitCallback', r'(Landroidx/emoji2/text/EmojiCompat$InitCallback;)V', ); @@ -2928,14 +1885,12 @@ class EmojiCompat extends jni$_.JObject { EmojiCompat$InitCallback initCallback, ) { final _$initCallback = initCallback.reference; - _unregisterInitCallback( - reference.pointer, - _id_unregisterInitCallback as jni$_.JMethodIDPtr, - _$initCallback.pointer) + _unregisterInitCallback(reference.pointer, + _id_unregisterInitCallback.pointer, _$initCallback.pointer) .check(); } - static final _id_getLoadState = _class.instanceMethodId( + static final _id_getLoadState = EmojiCompat._class.instanceMethodId( r'getLoadState', r'()I', ); @@ -2954,12 +1909,11 @@ class EmojiCompat extends jni$_.JObject { /// from: `public int getLoadState()` int getLoadState() { - return _getLoadState( - reference.pointer, _id_getLoadState as jni$_.JMethodIDPtr) - .integer; + return _getLoadState(reference.pointer, _id_getLoadState.pointer).integer; } - static final _id_isEmojiSpanIndicatorEnabled = _class.instanceMethodId( + static final _id_isEmojiSpanIndicatorEnabled = + EmojiCompat._class.instanceMethodId( r'isEmojiSpanIndicatorEnabled', r'()Z', ); @@ -2979,12 +1933,13 @@ class EmojiCompat extends jni$_.JObject { /// from: `public boolean isEmojiSpanIndicatorEnabled()` core$_.bool isEmojiSpanIndicatorEnabled() { - return _isEmojiSpanIndicatorEnabled(reference.pointer, - _id_isEmojiSpanIndicatorEnabled as jni$_.JMethodIDPtr) + return _isEmojiSpanIndicatorEnabled( + reference.pointer, _id_isEmojiSpanIndicatorEnabled.pointer) .boolean; } - static final _id_getEmojiSpanIndicatorColor = _class.instanceMethodId( + static final _id_getEmojiSpanIndicatorColor = + EmojiCompat._class.instanceMethodId( r'getEmojiSpanIndicatorColor', r'()I', ); @@ -3004,12 +1959,12 @@ class EmojiCompat extends jni$_.JObject { /// from: `public int getEmojiSpanIndicatorColor()` int getEmojiSpanIndicatorColor() { - return _getEmojiSpanIndicatorColor(reference.pointer, - _id_getEmojiSpanIndicatorColor as jni$_.JMethodIDPtr) + return _getEmojiSpanIndicatorColor( + reference.pointer, _id_getEmojiSpanIndicatorColor.pointer) .integer; } - static final _id_getEmojiStart = _class.instanceMethodId( + static final _id_getEmojiStart = EmojiCompat._class.instanceMethodId( r'getEmojiStart', r'(Ljava/lang/CharSequence;I)I', ); @@ -3032,12 +1987,12 @@ class EmojiCompat extends jni$_.JObject { int i, ) { final _$charSequence = charSequence.reference; - return _getEmojiStart(reference.pointer, - _id_getEmojiStart as jni$_.JMethodIDPtr, _$charSequence.pointer, i) + return _getEmojiStart(reference.pointer, _id_getEmojiStart.pointer, + _$charSequence.pointer, i) .integer; } - static final _id_getEmojiEnd = _class.instanceMethodId( + static final _id_getEmojiEnd = EmojiCompat._class.instanceMethodId( r'getEmojiEnd', r'(Ljava/lang/CharSequence;I)I', ); @@ -3052,111 +2007,20 @@ class EmojiCompat extends jni$_.JObject { 'globalEnv_CallIntMethod') .asFunction< jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer, int)>(); - - /// from: `public int getEmojiEnd(java.lang.CharSequence charSequence, int i)` - int getEmojiEnd( - jni$_.JObject charSequence, - int i, - ) { - final _$charSequence = charSequence.reference; - return _getEmojiEnd(reference.pointer, - _id_getEmojiEnd as jni$_.JMethodIDPtr, _$charSequence.pointer, i) - .integer; - } - - static final _id_handleOnKeyDown = _class.staticMethodId( - r'handleOnKeyDown', - r'(Landroid/text/Editable;ILandroid/view/KeyEvent;)Z', - ); - - static final _handleOnKeyDown = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Int32, - jni$_.Pointer - )>)>>('globalEnv_CallStaticBooleanMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - int, - jni$_.Pointer)>(); - - /// from: `static public boolean handleOnKeyDown(android.text.Editable editable, int i, android.view.KeyEvent keyEvent)` - static core$_.bool handleOnKeyDown( - jni$_.JObject editable, - int i, - jni$_.JObject keyEvent, - ) { - final _$editable = editable.reference; - final _$keyEvent = keyEvent.reference; - return _handleOnKeyDown( - _class.reference.pointer, - _id_handleOnKeyDown as jni$_.JMethodIDPtr, - _$editable.pointer, - i, - _$keyEvent.pointer) - .boolean; - } - - static final _id_handleDeleteSurroundingText = _class.staticMethodId( - r'handleDeleteSurroundingText', - r'(Landroid/view/inputmethod/InputConnection;Landroid/text/Editable;IIZ)Z', - ); - - static final _handleDeleteSurroundingText = - jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32 - )>)>>('globalEnv_CallStaticBooleanMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - int, - int, - int)>(); - - /// from: `static public boolean handleDeleteSurroundingText(android.view.inputmethod.InputConnection inputConnection, android.text.Editable editable, int i, int i1, boolean z)` - static core$_.bool handleDeleteSurroundingText( - jni$_.JObject inputConnection, - jni$_.JObject editable, - int i, - int i1, - core$_.bool z, - ) { - final _$inputConnection = inputConnection.reference; - final _$editable = editable.reference; - return _handleDeleteSurroundingText( - _class.reference.pointer, - _id_handleDeleteSurroundingText as jni$_.JMethodIDPtr, - _$inputConnection.pointer, - _$editable.pointer, - i, - i1, - z ? 1 : 0) - .boolean; + jni$_.JMethodIDPtr, jni$_.Pointer, int)>(); + + /// from: `public int getEmojiEnd(java.lang.CharSequence charSequence, int i)` + int getEmojiEnd( + jni$_.JObject charSequence, + int i, + ) { + final _$charSequence = charSequence.reference; + return _getEmojiEnd(reference.pointer, _id_getEmojiEnd.pointer, + _$charSequence.pointer, i) + .integer; } - static final _id_hasEmojiGlyph = _class.instanceMethodId( + static final _id_hasEmojiGlyph = EmojiCompat._class.instanceMethodId( r'hasEmojiGlyph', r'(Ljava/lang/CharSequence;)Z', ); @@ -3177,12 +2041,12 @@ class EmojiCompat extends jni$_.JObject { jni$_.JObject charSequence, ) { final _$charSequence = charSequence.reference; - return _hasEmojiGlyph(reference.pointer, - _id_hasEmojiGlyph as jni$_.JMethodIDPtr, _$charSequence.pointer) + return _hasEmojiGlyph(reference.pointer, _id_hasEmojiGlyph.pointer, + _$charSequence.pointer) .boolean; } - static final _id_hasEmojiGlyph$1 = _class.instanceMethodId( + static final _id_hasEmojiGlyph$1 = EmojiCompat._class.instanceMethodId( r'hasEmojiGlyph', r'(Ljava/lang/CharSequence;I)Z', ); @@ -3205,15 +2069,12 @@ class EmojiCompat extends jni$_.JObject { int i, ) { final _$charSequence = charSequence.reference; - return _hasEmojiGlyph$1( - reference.pointer, - _id_hasEmojiGlyph$1 as jni$_.JMethodIDPtr, - _$charSequence.pointer, - i) + return _hasEmojiGlyph$1(reference.pointer, _id_hasEmojiGlyph$1.pointer, + _$charSequence.pointer, i) .boolean; } - static final _id_getEmojiMatch = _class.instanceMethodId( + static final _id_getEmojiMatch = EmojiCompat._class.instanceMethodId( r'getEmojiMatch', r'(Ljava/lang/CharSequence;I)I', ); @@ -3236,12 +2097,12 @@ class EmojiCompat extends jni$_.JObject { int i, ) { final _$charSequence = charSequence.reference; - return _getEmojiMatch(reference.pointer, - _id_getEmojiMatch as jni$_.JMethodIDPtr, _$charSequence.pointer, i) + return _getEmojiMatch(reference.pointer, _id_getEmojiMatch.pointer, + _$charSequence.pointer, i) .integer; } - static final _id_process = _class.instanceMethodId( + static final _id_process = EmojiCompat._class.instanceMethodId( r'process', r'(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;', ); @@ -3263,12 +2124,12 @@ class EmojiCompat extends jni$_.JObject { jni$_.JObject? charSequence, ) { final _$charSequence = charSequence?.reference ?? jni$_.jNullReference; - return _process(reference.pointer, _id_process as jni$_.JMethodIDPtr, - _$charSequence.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _process( + reference.pointer, _id_process.pointer, _$charSequence.pointer) + .object(); } - static final _id_process$1 = _class.instanceMethodId( + static final _id_process$1 = EmojiCompat._class.instanceMethodId( r'process', r'(Ljava/lang/CharSequence;II)Ljava/lang/CharSequence;', ); @@ -3296,12 +2157,12 @@ class EmojiCompat extends jni$_.JObject { int i1, ) { final _$charSequence = charSequence?.reference ?? jni$_.jNullReference; - return _process$1(reference.pointer, _id_process$1 as jni$_.JMethodIDPtr, + return _process$1(reference.pointer, _id_process$1.pointer, _$charSequence.pointer, i, i1) - .object(const jni$_.$JObject$NullableType$()); + .object(); } - static final _id_process$2 = _class.instanceMethodId( + static final _id_process$2 = EmojiCompat._class.instanceMethodId( r'process', r'(Ljava/lang/CharSequence;III)Ljava/lang/CharSequence;', ); @@ -3331,12 +2192,12 @@ class EmojiCompat extends jni$_.JObject { int i2, ) { final _$charSequence = charSequence?.reference ?? jni$_.jNullReference; - return _process$2(reference.pointer, _id_process$2 as jni$_.JMethodIDPtr, + return _process$2(reference.pointer, _id_process$2.pointer, _$charSequence.pointer, i, i1, i2) - .object(const jni$_.$JObject$NullableType$()); + .object(); } - static final _id_process$3 = _class.instanceMethodId( + static final _id_process$3 = EmojiCompat._class.instanceMethodId( r'process', r'(Ljava/lang/CharSequence;IIII)Ljava/lang/CharSequence;', ); @@ -3374,12 +2235,12 @@ class EmojiCompat extends jni$_.JObject { int i3, ) { final _$charSequence = charSequence?.reference ?? jni$_.jNullReference; - return _process$3(reference.pointer, _id_process$3 as jni$_.JMethodIDPtr, + return _process$3(reference.pointer, _id_process$3.pointer, _$charSequence.pointer, i, i1, i2, i3) - .object(const jni$_.$JObject$NullableType$()); + .object(); } - static final _id_getAssetSignature = _class.instanceMethodId( + static final _id_getAssetSignature = EmojiCompat._class.instanceMethodId( r'getAssetSignature', r'()Ljava/lang/String;', ); @@ -3399,12 +2260,11 @@ class EmojiCompat extends jni$_.JObject { /// from: `public java.lang.String getAssetSignature()` /// The returned object must be released after use, by calling the [release] method. jni$_.JString getAssetSignature() { - return _getAssetSignature( - reference.pointer, _id_getAssetSignature as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); + return _getAssetSignature(reference.pointer, _id_getAssetSignature.pointer) + .object(); } - static final _id_updateEditorInfo = _class.instanceMethodId( + static final _id_updateEditorInfo = EmojiCompat._class.instanceMethodId( r'updateEditorInfo', r'(Landroid/view/inputmethod/EditorInfo;)V', ); @@ -3425,49 +2285,12 @@ class EmojiCompat extends jni$_.JObject { jni$_.JObject editorInfo, ) { final _$editorInfo = editorInfo.reference; - _updateEditorInfo(reference.pointer, - _id_updateEditorInfo as jni$_.JMethodIDPtr, _$editorInfo.pointer) + _updateEditorInfo(reference.pointer, _id_updateEditorInfo.pointer, + _$editorInfo.pointer) .check(); } } -final class $EmojiCompat$NullableType$ extends jni$_.JType { - @jni$_.internal - const $EmojiCompat$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/EmojiCompat;'; - - @jni$_.internal - @core$_.override - EmojiCompat? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : EmojiCompat.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$NullableType$) && - other is $EmojiCompat$NullableType$; - } -} - final class $EmojiCompat$Type$ extends jni$_.JType { @jni$_.internal const $EmojiCompat$Type$(); @@ -3475,59 +2298,14 @@ final class $EmojiCompat$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/EmojiCompat;'; - - @jni$_.internal - @core$_.override - EmojiCompat fromReference(jni$_.JReference reference) => - EmojiCompat.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $EmojiCompat$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($EmojiCompat$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($EmojiCompat$Type$) && - other is $EmojiCompat$Type$; - } } /// from: `androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory` -class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType - $type; - - @jni$_.internal - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory._( + jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory'); - /// The type which includes information such as the signature of this class. - static const jni$_ - .JType - nullableType = - $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_ .JType type = @@ -3555,15 +2333,17 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory ) { final _$defaultEmojiCompatConfigHelper = defaultEmojiCompatConfigHelper?.reference ?? jni$_.jNullReference; - return DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory - .fromReference(_new$( - _class.reference.pointer, - _id_new$ as jni$_.JMethodIDPtr, - _$defaultEmojiCompatConfigHelper.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, + _$defaultEmojiCompatConfigHelper.pointer) + .object(); } +} - static final _id_create = _class.instanceMethodId( +extension DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$$Methods + on DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory { + static final _id_create = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory._class + .instanceMethodId( r'create', r'(Landroid/content/Context;)Landroidx/emoji2/text/EmojiCompat$Config;', ); @@ -3585,57 +2365,8 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory jni$_.JObject context, ) { final _$context = context.reference; - return _create(reference.pointer, _id_create as jni$_.JMethodIDPtr, - _$context.pointer) - .object(const $EmojiCompat$Config$NullableType$()); - } -} - -final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$ - extends jni$_ - .JType { - @jni$_.internal - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory - .fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$) - .hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$; + return _create(reference.pointer, _id_create.pointer, _$context.pointer) + .object(); } } @@ -3649,65 +2380,14 @@ final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory fromReference( - jni$_.JReference reference) => - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$Type$) - .hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$Type$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigFactory$Type$; - } } /// from: `androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper` -class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType - $type; - - @jni$_.internal - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper._( + jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper'); - /// The type which includes information such as the signature of this class. - static const jni$_ - .JType - nullableType = - $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_ .JType type = @@ -3731,13 +2411,16 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper() { - return DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper - .fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } +} - static final _id_getSigningSignatures = _class.instanceMethodId( +extension DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$$Methods + on DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper { + static final _id_getSigningSignatures = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper._class + .instanceMethodId( r'getSigningSignatures', r'(Landroid/content/pm/PackageManager;Ljava/lang/String;)[Landroid/content/pm/Signature;', ); @@ -3769,15 +2452,15 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper final _$string = string.reference; return _getSigningSignatures( reference.pointer, - _id_getSigningSignatures as jni$_.JMethodIDPtr, + _id_getSigningSignatures.pointer, _$packageManager.pointer, _$string.pointer) - .object>( - const jni$_.$JArray$Type$( - jni$_.$JObject$NullableType$())); + .object>(); } - static final _id_queryIntentContentProviders = _class.instanceMethodId( + static final _id_queryIntentContentProviders = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper._class + .instanceMethodId( r'queryIntentContentProviders', r'(Landroid/content/pm/PackageManager;Landroid/content/Intent;I)Ljava/util/List;', ); @@ -3813,16 +2496,16 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper final _$intent = intent.reference; return _queryIntentContentProviders( reference.pointer, - _id_queryIntentContentProviders as jni$_.JMethodIDPtr, + _id_queryIntentContentProviders.pointer, _$packageManager.pointer, _$intent.pointer, i) - .object>( - const jni$_.$JList$Type$( - jni$_.$JObject$NullableType$())); + .object>(); } - static final _id_getProviderInfo = _class.instanceMethodId( + static final _id_getProviderInfo = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper._class + .instanceMethodId( r'getProviderInfo', r'(Landroid/content/pm/ResolveInfo;)Landroid/content/pm/ProviderInfo;', ); @@ -3844,57 +2527,9 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper jni$_.JObject resolveInfo, ) { final _$resolveInfo = resolveInfo.reference; - return _getProviderInfo(reference.pointer, - _id_getProviderInfo as jni$_.JMethodIDPtr, _$resolveInfo.pointer) - .object(const jni$_.$JObject$NullableType$()); - } -} - -final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$ - extends jni$_ - .JType { - @jni$_.internal - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper - .fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$) - .hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$; + return _getProviderInfo(reference.pointer, _id_getProviderInfo.pointer, + _$resolveInfo.pointer) + .object(); } } @@ -3908,64 +2543,15 @@ final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper fromReference( - jni$_.JReference reference) => - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$Type$) && - other is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$Type$; - } } /// from: `androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19` -class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 - extends DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper { - @jni$_.internal - @core$_.override - final jni$_ - .JType - $type; - - @jni$_.internal - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19._( + jni$_.JObject _$this) + implements DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19'); - /// The type which includes information such as the signature of this class. - static const jni$_ - .JType - nullableType = - $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_ .JType @@ -3990,13 +2576,16 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19() { - return DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 - .fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer).object< + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19>(); } +} - static final _id_queryIntentContentProviders = _class.instanceMethodId( +extension DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$$Methods + on DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 { + static final _id_queryIntentContentProviders = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19._class + .instanceMethodId( r'queryIntentContentProviders', r'(Landroid/content/pm/PackageManager;Landroid/content/Intent;I)Ljava/util/List;', ); @@ -4032,16 +2621,16 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 final _$intent = intent.reference; return _queryIntentContentProviders( reference.pointer, - _id_queryIntentContentProviders as jni$_.JMethodIDPtr, + _id_queryIntentContentProviders.pointer, _$packageManager.pointer, _$intent.pointer, i) - .object>( - const jni$_.$JList$Type$( - jni$_.$JObject$NullableType$())); + .object>(); } - static final _id_getProviderInfo = _class.instanceMethodId( + static final _id_getProviderInfo = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19._class + .instanceMethodId( r'getProviderInfo', r'(Landroid/content/pm/ResolveInfo;)Landroid/content/pm/ProviderInfo;', ); @@ -4063,58 +2652,9 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 jni$_.JObject resolveInfo, ) { final _$resolveInfo = resolveInfo.reference; - return _getProviderInfo(reference.pointer, - _id_getProviderInfo as jni$_.JMethodIDPtr, _$resolveInfo.pointer) - .object(const jni$_.$JObject$NullableType$()); - } -} - -final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$ - extends jni$_ - .JType { - @jni$_.internal - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 - .fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$) - .hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$; + return _getProviderInfo(reference.pointer, _id_getProviderInfo.pointer, + _$resolveInfo.pointer) + .object(); } } @@ -4128,68 +2668,15 @@ final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 fromReference( - jni$_.JReference reference) => - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 - .fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$Type$) - .hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$Type$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$Type$; - } } /// from: `androidx.emoji2.text.DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28` -class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 - extends DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 { - @jni$_.internal - @core$_.override - final jni$_ - .JType - $type; - - @jni$_.internal - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28._( + jni$_.JObject _$this) + implements DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19 { static final _class = jni$_.JClass.forName( r'androidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28'); - /// The type which includes information such as the signature of this class. - static const jni$_ - .JType - nullableType = - $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_ .JType @@ -4214,13 +2701,16 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28() { - return DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 - .fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer).object< + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28>(); } +} - static final _id_getSigningSignatures$1 = _class.instanceMethodId( +extension DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$$Methods + on DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 { + static final _id_getSigningSignatures$1 = + DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28._class + .instanceMethodId( r'getSigningSignatures', r'(Landroid/content/pm/PackageManager;Ljava/lang/String;)[Landroid/content/pm/Signature;', ); @@ -4235,78 +2725,27 @@ class DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 jni$_.Pointer, jni$_.Pointer )>)>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer)>(); - - /// from: `public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String string)` - /// The returned object must be released after use, by calling the [release] method. - jni$_.JArray getSigningSignatures$1( - jni$_.JObject packageManager, - jni$_.JString string, - ) { - final _$packageManager = packageManager.reference; - final _$string = string.reference; - return _getSigningSignatures$1( - reference.pointer, - _id_getSigningSignatures$1 as jni$_.JMethodIDPtr, - _$packageManager.pointer, - _$string.pointer) - .object>( - const jni$_.$JArray$Type$( - jni$_.$JObject$NullableType$())); - } -} - -final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$ - extends jni$_ - .JType { - @jni$_.internal - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 - .fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 3; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$) - .hashCode; + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$; + /// from: `public android.content.pm.Signature[] getSigningSignatures(android.content.pm.PackageManager packageManager, java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JArray getSigningSignatures$1( + jni$_.JObject packageManager, + jni$_.JString string, + ) { + final _$packageManager = packageManager.reference; + final _$string = string.reference; + return _getSigningSignatures$1( + reference.pointer, + _id_getSigningSignatures$1.pointer, + _$packageManager.pointer, + _$string.pointer) + .object>(); } } @@ -4320,63 +2759,14 @@ final class $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$Type$ @core$_.override String get signature => r'Landroidx/emoji2/text/DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 fromReference( - jni$_.JReference reference) => - DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28 - .fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API19$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType - get nullableType => - const $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 3; - - @core$_.override - int get hashCode => - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$Type$) - .hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$Type$) && - other - is $DefaultEmojiCompatConfig$DefaultEmojiCompatConfigHelper_API28$Type$; - } } /// from: `androidx.emoji2.text.DefaultEmojiCompatConfig` -class DefaultEmojiCompatConfig extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - DefaultEmojiCompatConfig.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type DefaultEmojiCompatConfig._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'androidx/emoji2/text/DefaultEmojiCompatConfig'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $DefaultEmojiCompatConfig$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $DefaultEmojiCompatConfig$Type$(); @@ -4402,48 +2792,9 @@ class DefaultEmojiCompatConfig extends jni$_.JObject { jni$_.JObject context, ) { final _$context = context.reference; - return _create(_class.reference.pointer, _id_create as jni$_.JMethodIDPtr, - _$context.pointer) - .object(const jni$_.$JObject$NullableType$()); - } -} - -final class $DefaultEmojiCompatConfig$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $DefaultEmojiCompatConfig$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroidx/emoji2/text/DefaultEmojiCompatConfig;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : DefaultEmojiCompatConfig.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($DefaultEmojiCompatConfig$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($DefaultEmojiCompatConfig$NullableType$) && - other is $DefaultEmojiCompatConfig$NullableType$; + return _create( + _class.reference.pointer, _id_create.pointer, _$context.pointer) + .object(); } } @@ -4455,54 +2806,13 @@ final class $DefaultEmojiCompatConfig$Type$ @jni$_.internal @core$_.override String get signature => r'Landroidx/emoji2/text/DefaultEmojiCompatConfig;'; - - @jni$_.internal - @core$_.override - DefaultEmojiCompatConfig fromReference(jni$_.JReference reference) => - DefaultEmojiCompatConfig.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $DefaultEmojiCompatConfig$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($DefaultEmojiCompatConfig$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($DefaultEmojiCompatConfig$Type$) && - other is $DefaultEmojiCompatConfig$Type$; - } } /// from: `android.os.Build$Partition` -class Build$Partition extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Build$Partition.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Build$Partition._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'android/os/Build$Partition'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Build$Partition$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Build$Partition$Type$(); static final _id_PARTITION_NAME_SYSTEM = _class.staticFieldId( @@ -4512,10 +2822,13 @@ class Build$Partition extends jni$_.JObject { /// from: `static public final java.lang.String PARTITION_NAME_SYSTEM` /// The returned object must be released after use, by calling the [release] method. - static jni$_.JString? get PARTITION_NAME_SYSTEM => _id_PARTITION_NAME_SYSTEM - .get(_class, const jni$_.$JString$NullableType$()); + static jni$_.JString? get PARTITION_NAME_SYSTEM => + _id_PARTITION_NAME_SYSTEM.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; +} - static final _id_equals = _class.instanceMethodId( +extension Build$Partition$$Methods on Build$Partition { + static final _id_equals = Build$Partition._class.instanceMethodId( r'equals', r'(Ljava/lang/Object;)Z', ); @@ -4536,12 +2849,11 @@ class Build$Partition extends jni$_.JObject { jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _equals(reference.pointer, _id_equals as jni$_.JMethodIDPtr, - _$object.pointer) + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) .boolean; } - static final _id_getBuildTimeMillis = _class.instanceMethodId( + static final _id_getBuildTimeMillis = Build$Partition._class.instanceMethodId( r'getBuildTimeMillis', r'()J', ); @@ -4561,11 +2873,11 @@ class Build$Partition extends jni$_.JObject { /// from: `public long getBuildTimeMillis()` int getBuildTimeMillis() { return _getBuildTimeMillis( - reference.pointer, _id_getBuildTimeMillis as jni$_.JMethodIDPtr) + reference.pointer, _id_getBuildTimeMillis.pointer) .long; } - static final _id_getFingerprint = _class.instanceMethodId( + static final _id_getFingerprint = Build$Partition._class.instanceMethodId( r'getFingerprint', r'()Ljava/lang/String;', ); @@ -4585,12 +2897,11 @@ class Build$Partition extends jni$_.JObject { /// from: `public java.lang.String getFingerprint()` /// The returned object must be released after use, by calling the [release] method. jni$_.JString? getFingerprint() { - return _getFingerprint( - reference.pointer, _id_getFingerprint as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getFingerprint(reference.pointer, _id_getFingerprint.pointer) + .object(); } - static final _id_getName = _class.instanceMethodId( + static final _id_getName = Build$Partition._class.instanceMethodId( r'getName', r'()Ljava/lang/String;', ); @@ -4610,11 +2921,11 @@ class Build$Partition extends jni$_.JObject { /// from: `public java.lang.String getName()` /// The returned object must be released after use, by calling the [release] method. jni$_.JString? getName() { - return _getName(reference.pointer, _id_getName as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getName(reference.pointer, _id_getName.pointer) + .object(); } - static final _id_hashCode$1 = _class.instanceMethodId( + static final _id_hashCode$1 = Build$Partition._class.instanceMethodId( r'hashCode', r'()I', ); @@ -4633,46 +2944,7 @@ class Build$Partition extends jni$_.JObject { /// from: `public int hashCode()` int hashCode$1() { - return _hashCode$1(reference.pointer, _id_hashCode$1 as jni$_.JMethodIDPtr) - .integer; - } -} - -final class $Build$Partition$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $Build$Partition$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroid/os/Build$Partition;'; - - @jni$_.internal - @core$_.override - Build$Partition? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Build$Partition.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$Partition$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$Partition$NullableType$) && - other is $Build$Partition$NullableType$; + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; } } @@ -4683,54 +2955,12 @@ final class $Build$Partition$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Landroid/os/Build$Partition;'; - - @jni$_.internal - @core$_.override - Build$Partition fromReference(jni$_.JReference reference) => - Build$Partition.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Build$Partition$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$Partition$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$Partition$Type$) && - other is $Build$Partition$Type$; - } } /// from: `android.os.Build$VERSION` -class Build$VERSION extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Build$VERSION.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Build$VERSION._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'android/os/Build$VERSION'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Build$VERSION$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Build$VERSION$Type$(); static final _id_BASE_OS = _class.staticFieldId( @@ -4741,7 +2971,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String BASE_OS` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get BASE_OS => - _id_BASE_OS.get(_class, const jni$_.$JString$NullableType$()); + _id_BASE_OS.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_CODENAME = _class.staticFieldId( r'CODENAME', @@ -4751,7 +2981,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String CODENAME` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get CODENAME => - _id_CODENAME.get(_class, const jni$_.$JString$NullableType$()); + _id_CODENAME.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_INCREMENTAL = _class.staticFieldId( r'INCREMENTAL', @@ -4761,7 +2991,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String INCREMENTAL` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get INCREMENTAL => - _id_INCREMENTAL.get(_class, const jni$_.$JString$NullableType$()); + _id_INCREMENTAL.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_MEDIA_PERFORMANCE_CLASS = _class.staticFieldId( r'MEDIA_PERFORMANCE_CLASS', @@ -4770,7 +3000,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final int MEDIA_PERFORMANCE_CLASS` static int get MEDIA_PERFORMANCE_CLASS => - _id_MEDIA_PERFORMANCE_CLASS.get(_class, const jni$_.jintType()); + _id_MEDIA_PERFORMANCE_CLASS.getNullable(_class, jni$_.jint.type) as int; static final _id_PREVIEW_SDK_INT = _class.staticFieldId( r'PREVIEW_SDK_INT', @@ -4779,7 +3009,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final int PREVIEW_SDK_INT` static int get PREVIEW_SDK_INT => - _id_PREVIEW_SDK_INT.get(_class, const jni$_.jintType()); + _id_PREVIEW_SDK_INT.getNullable(_class, jni$_.jint.type) as int; static final _id_RELEASE = _class.staticFieldId( r'RELEASE', @@ -4789,7 +3019,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String RELEASE` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get RELEASE => - _id_RELEASE.get(_class, const jni$_.$JString$NullableType$()); + _id_RELEASE.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_RELEASE_OR_CODENAME = _class.staticFieldId( r'RELEASE_OR_CODENAME', @@ -4799,7 +3029,8 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String RELEASE_OR_CODENAME` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get RELEASE_OR_CODENAME => - _id_RELEASE_OR_CODENAME.get(_class, const jni$_.$JString$NullableType$()); + _id_RELEASE_OR_CODENAME.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_RELEASE_OR_PREVIEW_DISPLAY = _class.staticFieldId( r'RELEASE_OR_PREVIEW_DISPLAY', @@ -4809,8 +3040,8 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String RELEASE_OR_PREVIEW_DISPLAY` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get RELEASE_OR_PREVIEW_DISPLAY => - _id_RELEASE_OR_PREVIEW_DISPLAY.get( - _class, const jni$_.$JString$NullableType$()); + _id_RELEASE_OR_PREVIEW_DISPLAY.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_SDK = _class.staticFieldId( r'SDK', @@ -4820,7 +3051,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String SDK` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SDK => - _id_SDK.get(_class, const jni$_.$JString$NullableType$()); + _id_SDK.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_SDK_INT = _class.staticFieldId( r'SDK_INT', @@ -4828,7 +3059,8 @@ class Build$VERSION extends jni$_.JObject { ); /// from: `static public final int SDK_INT` - static int get SDK_INT => _id_SDK_INT.get(_class, const jni$_.jintType()); + static int get SDK_INT => + _id_SDK_INT.getNullable(_class, jni$_.jint.type) as int; static final _id_SDK_INT_FULL = _class.staticFieldId( r'SDK_INT_FULL', @@ -4837,7 +3069,7 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final int SDK_INT_FULL` static int get SDK_INT_FULL => - _id_SDK_INT_FULL.get(_class, const jni$_.jintType()); + _id_SDK_INT_FULL.getNullable(_class, jni$_.jint.type) as int; static final _id_SECURITY_PATCH = _class.staticFieldId( r'SECURITY_PATCH', @@ -4847,7 +3079,8 @@ class Build$VERSION extends jni$_.JObject { /// from: `static public final java.lang.String SECURITY_PATCH` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SECURITY_PATCH => - _id_SECURITY_PATCH.get(_class, const jni$_.$JString$NullableType$()); + _id_SECURITY_PATCH.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_new$ = _class.constructorId( r'()V', @@ -4868,46 +3101,8 @@ class Build$VERSION extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Build$VERSION() { - return Build$VERSION.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $Build$VERSION$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Build$VERSION$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroid/os/Build$VERSION;'; - - @jni$_.internal - @core$_.override - Build$VERSION? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Build$VERSION.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$VERSION$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$VERSION$NullableType$) && - other is $Build$VERSION$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -4918,54 +3113,13 @@ final class $Build$VERSION$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Landroid/os/Build$VERSION;'; - - @jni$_.internal - @core$_.override - Build$VERSION fromReference(jni$_.JReference reference) => - Build$VERSION.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Build$VERSION$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$VERSION$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$VERSION$Type$) && - other is $Build$VERSION$Type$; - } } /// from: `android.os.Build$VERSION_CODES` -class Build$VERSION_CODES extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Build$VERSION_CODES.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Build$VERSION_CODES._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'android/os/Build$VERSION_CODES'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Build$VERSION_CODES$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Build$VERSION_CODES$Type$(); @@ -5099,48 +3253,8 @@ class Build$VERSION_CODES extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Build$VERSION_CODES() { - return Build$VERSION_CODES.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $Build$VERSION_CODES$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $Build$VERSION_CODES$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroid/os/Build$VERSION_CODES;'; - - @jni$_.internal - @core$_.override - Build$VERSION_CODES? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Build$VERSION_CODES.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$VERSION_CODES$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$VERSION_CODES$NullableType$) && - other is $Build$VERSION_CODES$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -5152,55 +3266,14 @@ final class $Build$VERSION_CODES$Type$ @jni$_.internal @core$_.override String get signature => r'Landroid/os/Build$VERSION_CODES;'; - - @jni$_.internal - @core$_.override - Build$VERSION_CODES fromReference(jni$_.JReference reference) => - Build$VERSION_CODES.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Build$VERSION_CODES$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$VERSION_CODES$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$VERSION_CODES$Type$) && - other is $Build$VERSION_CODES$Type$; - } } /// from: `android.os.Build$VERSION_CODES_FULL` -class Build$VERSION_CODES_FULL extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Build$VERSION_CODES_FULL.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Build$VERSION_CODES_FULL._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'android/os/Build$VERSION_CODES_FULL'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Build$VERSION_CODES_FULL$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Build$VERSION_CODES_FULL$Type$(); @@ -5304,53 +3377,14 @@ class Build$VERSION_CODES_FULL extends jni$_.JObject { /// from: `static public final int S_V2` static const S_V2 = 3200000; - /// from: `static public final int TIRAMISU` - static const TIRAMISU = 3300000; - - /// from: `static public final int UPSIDE_DOWN_CAKE` - static const UPSIDE_DOWN_CAKE = 3400000; - - /// from: `static public final int VANILLA_ICE_CREAM` - static const VANILLA_ICE_CREAM = 3500000; -} - -final class $Build$VERSION_CODES_FULL$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $Build$VERSION_CODES_FULL$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroid/os/Build$VERSION_CODES_FULL;'; - - @jni$_.internal - @core$_.override - Build$VERSION_CODES_FULL? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Build$VERSION_CODES_FULL.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; + /// from: `static public final int TIRAMISU` + static const TIRAMISU = 3300000; - @core$_.override - int get hashCode => ($Build$VERSION_CODES_FULL$NullableType$).hashCode; + /// from: `static public final int UPSIDE_DOWN_CAKE` + static const UPSIDE_DOWN_CAKE = 3400000; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$VERSION_CODES_FULL$NullableType$) && - other is $Build$VERSION_CODES_FULL$NullableType$; - } + /// from: `static public final int VANILLA_ICE_CREAM` + static const VANILLA_ICE_CREAM = 3500000; } final class $Build$VERSION_CODES_FULL$Type$ @@ -5361,53 +3395,12 @@ final class $Build$VERSION_CODES_FULL$Type$ @jni$_.internal @core$_.override String get signature => r'Landroid/os/Build$VERSION_CODES_FULL;'; - - @jni$_.internal - @core$_.override - Build$VERSION_CODES_FULL fromReference(jni$_.JReference reference) => - Build$VERSION_CODES_FULL.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Build$VERSION_CODES_FULL$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$VERSION_CODES_FULL$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$VERSION_CODES_FULL$Type$) && - other is $Build$VERSION_CODES_FULL$Type$; - } } /// from: `android.os.Build` -class Build extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Build.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Build._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'android/os/Build'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Build$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Build$Type$(); static final _id_BOARD = _class.staticFieldId( @@ -5418,7 +3411,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String BOARD` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get BOARD => - _id_BOARD.get(_class, const jni$_.$JString$NullableType$()); + _id_BOARD.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_BOOTLOADER = _class.staticFieldId( r'BOOTLOADER', @@ -5428,7 +3421,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String BOOTLOADER` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get BOOTLOADER => - _id_BOOTLOADER.get(_class, const jni$_.$JString$NullableType$()); + _id_BOOTLOADER.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_BRAND = _class.staticFieldId( r'BRAND', @@ -5438,7 +3431,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String BRAND` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get BRAND => - _id_BRAND.get(_class, const jni$_.$JString$NullableType$()); + _id_BRAND.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_CPU_ABI = _class.staticFieldId( r'CPU_ABI', @@ -5448,7 +3441,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String CPU_ABI` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get CPU_ABI => - _id_CPU_ABI.get(_class, const jni$_.$JString$NullableType$()); + _id_CPU_ABI.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_CPU_ABI2 = _class.staticFieldId( r'CPU_ABI2', @@ -5458,7 +3451,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String CPU_ABI2` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get CPU_ABI2 => - _id_CPU_ABI2.get(_class, const jni$_.$JString$NullableType$()); + _id_CPU_ABI2.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_DEVICE = _class.staticFieldId( r'DEVICE', @@ -5468,7 +3461,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String DEVICE` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get DEVICE => - _id_DEVICE.get(_class, const jni$_.$JString$NullableType$()); + _id_DEVICE.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_DISPLAY = _class.staticFieldId( r'DISPLAY', @@ -5478,7 +3471,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String DISPLAY` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get DISPLAY => - _id_DISPLAY.get(_class, const jni$_.$JString$NullableType$()); + _id_DISPLAY.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_FINGERPRINT = _class.staticFieldId( r'FINGERPRINT', @@ -5488,7 +3481,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String FINGERPRINT` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get FINGERPRINT => - _id_FINGERPRINT.get(_class, const jni$_.$JString$NullableType$()); + _id_FINGERPRINT.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_HARDWARE = _class.staticFieldId( r'HARDWARE', @@ -5498,7 +3491,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String HARDWARE` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get HARDWARE => - _id_HARDWARE.get(_class, const jni$_.$JString$NullableType$()); + _id_HARDWARE.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_HOST = _class.staticFieldId( r'HOST', @@ -5508,7 +3501,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String HOST` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get HOST => - _id_HOST.get(_class, const jni$_.$JString$NullableType$()); + _id_HOST.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_ID = _class.staticFieldId( r'ID', @@ -5518,7 +3511,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String ID` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get ID => - _id_ID.get(_class, const jni$_.$JString$NullableType$()); + _id_ID.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_MANUFACTURER = _class.staticFieldId( r'MANUFACTURER', @@ -5528,7 +3521,8 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String MANUFACTURER` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get MANUFACTURER => - _id_MANUFACTURER.get(_class, const jni$_.$JString$NullableType$()); + _id_MANUFACTURER.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_MODEL = _class.staticFieldId( r'MODEL', @@ -5538,7 +3532,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String MODEL` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get MODEL => - _id_MODEL.get(_class, const jni$_.$JString$NullableType$()); + _id_MODEL.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_ODM_SKU = _class.staticFieldId( r'ODM_SKU', @@ -5548,7 +3542,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String ODM_SKU` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get ODM_SKU => - _id_ODM_SKU.get(_class, const jni$_.$JString$NullableType$()); + _id_ODM_SKU.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_PRODUCT = _class.staticFieldId( r'PRODUCT', @@ -5558,7 +3552,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String PRODUCT` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get PRODUCT => - _id_PRODUCT.get(_class, const jni$_.$JString$NullableType$()); + _id_PRODUCT.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_RADIO = _class.staticFieldId( r'RADIO', @@ -5568,7 +3562,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String RADIO` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get RADIO => - _id_RADIO.get(_class, const jni$_.$JString$NullableType$()); + _id_RADIO.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_SERIAL = _class.staticFieldId( r'SERIAL', @@ -5578,7 +3572,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String SERIAL` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SERIAL => - _id_SERIAL.get(_class, const jni$_.$JString$NullableType$()); + _id_SERIAL.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_SKU = _class.staticFieldId( r'SKU', @@ -5588,7 +3582,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String SKU` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SKU => - _id_SKU.get(_class, const jni$_.$JString$NullableType$()); + _id_SKU.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_SOC_MANUFACTURER = _class.staticFieldId( r'SOC_MANUFACTURER', @@ -5598,7 +3592,8 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String SOC_MANUFACTURER` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SOC_MANUFACTURER => - _id_SOC_MANUFACTURER.get(_class, const jni$_.$JString$NullableType$()); + _id_SOC_MANUFACTURER.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_SOC_MODEL = _class.staticFieldId( r'SOC_MODEL', @@ -5608,7 +3603,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String SOC_MODEL` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SOC_MODEL => - _id_SOC_MODEL.get(_class, const jni$_.$JString$NullableType$()); + _id_SOC_MODEL.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_SUPPORTED_32_BIT_ABIS = _class.staticFieldId( r'SUPPORTED_32_BIT_ABIS', @@ -5618,10 +3613,9 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String[] SUPPORTED_32_BIT_ABIS` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? get SUPPORTED_32_BIT_ABIS => - _id_SUPPORTED_32_BIT_ABIS.get( - _class, - const jni$_.$JArray$NullableType$( - jni$_.$JString$NullableType$())); + _id_SUPPORTED_32_BIT_ABIS.getNullable( + _class, jni$_.JArray.type(jni$_.JString.type)) + as jni$_.JArray?; static final _id_SUPPORTED_64_BIT_ABIS = _class.staticFieldId( r'SUPPORTED_64_BIT_ABIS', @@ -5631,10 +3625,9 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String[] SUPPORTED_64_BIT_ABIS` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? get SUPPORTED_64_BIT_ABIS => - _id_SUPPORTED_64_BIT_ABIS.get( - _class, - const jni$_.$JArray$NullableType$( - jni$_.$JString$NullableType$())); + _id_SUPPORTED_64_BIT_ABIS.getNullable( + _class, jni$_.JArray.type(jni$_.JString.type)) + as jni$_.JArray?; static final _id_SUPPORTED_ABIS = _class.staticFieldId( r'SUPPORTED_ABIS', @@ -5643,11 +3636,10 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String[] SUPPORTED_ABIS` /// The returned object must be released after use, by calling the [release] method. - static jni$_.JArray? get SUPPORTED_ABIS => _id_SUPPORTED_ABIS - .get( - _class, - const jni$_.$JArray$NullableType$( - jni$_.$JString$NullableType$())); + static jni$_.JArray? get SUPPORTED_ABIS => + _id_SUPPORTED_ABIS.getNullable( + _class, jni$_.JArray.type(jni$_.JString.type)) + as jni$_.JArray?; static final _id_TAGS = _class.staticFieldId( r'TAGS', @@ -5657,7 +3649,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String TAGS` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get TAGS => - _id_TAGS.get(_class, const jni$_.$JString$NullableType$()); + _id_TAGS.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_TIME = _class.staticFieldId( r'TIME', @@ -5665,7 +3657,7 @@ class Build extends jni$_.JObject { ); /// from: `static public final long TIME` - static int get TIME => _id_TIME.get(_class, const jni$_.jlongType()); + static int get TIME => _id_TIME.getNullable(_class, jni$_.jlong.type) as int; static final _id_TYPE = _class.staticFieldId( r'TYPE', @@ -5675,7 +3667,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String TYPE` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get TYPE => - _id_TYPE.get(_class, const jni$_.$JString$NullableType$()); + _id_TYPE.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_UNKNOWN = _class.staticFieldId( r'UNKNOWN', @@ -5685,7 +3677,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String UNKNOWN` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get UNKNOWN => - _id_UNKNOWN.get(_class, const jni$_.$JString$NullableType$()); + _id_UNKNOWN.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_USER = _class.staticFieldId( r'USER', @@ -5695,7 +3687,7 @@ class Build extends jni$_.JObject { /// from: `static public final java.lang.String USER` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get USER => - _id_USER.get(_class, const jni$_.$JString$NullableType$()); + _id_USER.getNullable(_class, jni$_.JString.type) as jni$_.JString?; static final _id_new$ = _class.constructorId( r'()V', @@ -5716,9 +3708,7 @@ class Build extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Build() { - return Build.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer).object(); } static final _id_getFingerprintedPartitions = _class.staticMethodId( @@ -5742,11 +3732,9 @@ class Build extends jni$_.JObject { /// from: `static public java.util.List getFingerprintedPartitions()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JList? getFingerprintedPartitions() { - return _getFingerprintedPartitions(_class.reference.pointer, - _id_getFingerprintedPartitions as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JList$NullableType$( - $Build$Partition$NullableType$())); + return _getFingerprintedPartitions( + _class.reference.pointer, _id_getFingerprintedPartitions.pointer) + .object?>(); } static final _id_getMajorSdkVersion = _class.staticMethodId( @@ -5767,8 +3755,8 @@ class Build extends jni$_.JObject { static int getMajorSdkVersion( int i, ) { - return _getMajorSdkVersion(_class.reference.pointer, - _id_getMajorSdkVersion as jni$_.JMethodIDPtr, i) + return _getMajorSdkVersion( + _class.reference.pointer, _id_getMajorSdkVersion.pointer, i) .integer; } @@ -5790,8 +3778,8 @@ class Build extends jni$_.JObject { static int getMinorSdkVersion( int i, ) { - return _getMinorSdkVersion(_class.reference.pointer, - _id_getMinorSdkVersion as jni$_.JMethodIDPtr, i) + return _getMinorSdkVersion( + _class.reference.pointer, _id_getMinorSdkVersion.pointer, i) .integer; } @@ -5816,8 +3804,8 @@ class Build extends jni$_.JObject { /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? getRadioVersion() { return _getRadioVersion( - _class.reference.pointer, _id_getRadioVersion as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + _class.reference.pointer, _id_getRadioVersion.pointer) + .object(); } static final _id_getSerial = _class.staticMethodId( @@ -5840,46 +3828,8 @@ class Build extends jni$_.JObject { /// from: `static public java.lang.String getSerial()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? getSerial() { - return _getSerial( - _class.reference.pointer, _id_getSerial as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); - } -} - -final class $Build$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Build$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Landroid/os/Build;'; - - @jni$_.internal - @core$_.override - Build? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Build.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$NullableType$) && - other is $Build$NullableType$; + return _getSerial(_class.reference.pointer, _id_getSerial.pointer) + .object(); } } @@ -5890,80 +3840,15 @@ final class $Build$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Landroid/os/Build;'; - - @jni$_.internal - @core$_.override - Build fromReference(jni$_.JReference reference) => Build.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Build$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Build$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Build$Type$) && other is $Build$Type$; - } } /// from: `java.util.HashMap` -class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - HashMap.fromReference( - this.K, - this.V, - jni$_.JReference reference, - ) : $type = type<$K, $V>(K, V), - super.fromReference(reference); - +extension type HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject, jni$_.JMap<$K?, $V?> { static final _class = jni$_.JClass.forName(r'java/util/HashMap'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - jni$_.JType<$K> K, - jni$_.JType<$V> V, - ) { - return $HashMap$NullableType$<$K, $V>( - K, - V, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - jni$_.JType<$K> K, - jni$_.JType<$V> V, - ) { - return $HashMap$Type$<$K, $V>( - K, - V, - ); - } - + static const jni$_.JType type = $HashMap$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -5982,15 +3867,9 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory HashMap({ - required jni$_.JType<$K> K, - required jni$_.JType<$V> V, - }) { - return HashMap<$K, $V>.fromReference( - K, - V, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + factory HashMap() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } static final _id_new$1 = _class.constructorId( @@ -6010,15 +3889,10 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public void (int i)` /// The returned object must be released after use, by calling the [release] method. factory HashMap.new$1( - int i, { - required jni$_.JType<$K> K, - required jni$_.JType<$V> V, - }) { - return HashMap<$K, $V>.fromReference( - K, - V, - _new$1(_class.reference.pointer, _id_new$1 as jni$_.JMethodIDPtr, i) - .reference); + int i, + ) { + return _new$1(_class.reference.pointer, _id_new$1.pointer, i) + .object>(); } static final _id_new$2 = _class.constructorId( @@ -6040,15 +3914,10 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// The returned object must be released after use, by calling the [release] method. factory HashMap.new$2( int i, - double f, { - required jni$_.JType<$K> K, - required jni$_.JType<$V> V, - }) { - return HashMap<$K, $V>.fromReference( - K, - V, - _new$2(_class.reference.pointer, _id_new$2 as jni$_.JMethodIDPtr, i, f) - .reference); + double f, + ) { + return _new$2(_class.reference.pointer, _id_new$2.pointer, i, f) + .object>(); } static final _id_new$3 = _class.constructorId( @@ -6069,20 +3938,41 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public void (java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. factory HashMap.new$3( - jni$_.JMap<$K?, $V?>? map, { - required jni$_.JType<$K> K, - required jni$_.JType<$V> V, - }) { + jni$_.JMap<$K?, $V?>? map, + ) { final _$map = map?.reference ?? jni$_.jNullReference; - return HashMap<$K, $V>.fromReference( - K, - V, - _new$3(_class.reference.pointer, _id_new$3 as jni$_.JMethodIDPtr, - _$map.pointer) - .reference); + return _new$3(_class.reference.pointer, _id_new$3.pointer, _$map.pointer) + .object>(); + } + + static final _id_newHashMap = _class.staticMethodId( + r'newHashMap', + r'(I)Ljava/util/HashMap;', + ); + + static final _newHashMap = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Int32,)>)>>( + 'globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `static public java.util.HashMap newHashMap(int i)` + /// The returned object must be released after use, by calling the [release] method. + static HashMap<$K?, $V?>? + newHashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( + int i, + ) { + return _newHashMap(_class.reference.pointer, _id_newHashMap.pointer, i) + .object?>(); } +} - static final _id_clear = _class.instanceMethodId( +extension HashMap$$Methods<$K extends jni$_.JObject?, $V extends jni$_.JObject?> + on HashMap<$K, $V> { + static final _id_clear = HashMap._class.instanceMethodId( r'clear', r'()V', ); @@ -6101,10 +3991,10 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public void clear()` void clear() { - _clear(reference.pointer, _id_clear as jni$_.JMethodIDPtr).check(); + _clear(reference.pointer, _id_clear.pointer).check(); } - static final _id_clone = _class.instanceMethodId( + static final _id_clone = HashMap._class.instanceMethodId( r'clone', r'()Ljava/lang/Object;', ); @@ -6124,11 +4014,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public java.lang.Object clone()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? clone() { - return _clone(reference.pointer, _id_clone as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _clone(reference.pointer, _id_clone.pointer) + .object(); } - static final _id_compute = _class.instanceMethodId( + static final _id_compute = HashMap._class.instanceMethodId( r'compute', r'(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', ); @@ -6158,12 +4048,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; - return _compute(reference.pointer, _id_compute as jni$_.JMethodIDPtr, - _$object.pointer, _$biFunction.pointer) - .object<$V?>(V.nullableType); + return _compute(reference.pointer, _id_compute.pointer, _$object.pointer, + _$biFunction.pointer) + .object<$V?>(); } - static final _id_computeIfAbsent = _class.instanceMethodId( + static final _id_computeIfAbsent = HashMap._class.instanceMethodId( r'computeIfAbsent', r'(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;', ); @@ -6193,15 +4083,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$function = function?.reference ?? jni$_.jNullReference; - return _computeIfAbsent( - reference.pointer, - _id_computeIfAbsent as jni$_.JMethodIDPtr, - _$object.pointer, - _$function.pointer) - .object<$V?>(V.nullableType); + return _computeIfAbsent(reference.pointer, _id_computeIfAbsent.pointer, + _$object.pointer, _$function.pointer) + .object<$V?>(); } - static final _id_computeIfPresent = _class.instanceMethodId( + static final _id_computeIfPresent = HashMap._class.instanceMethodId( r'computeIfPresent', r'(Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', ); @@ -6231,15 +4118,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; - return _computeIfPresent( - reference.pointer, - _id_computeIfPresent as jni$_.JMethodIDPtr, - _$object.pointer, - _$biFunction.pointer) - .object<$V?>(V.nullableType); + return _computeIfPresent(reference.pointer, _id_computeIfPresent.pointer, + _$object.pointer, _$biFunction.pointer) + .object<$V?>(); } - static final _id_containsKey = _class.instanceMethodId( + static final _id_containsKey = HashMap._class.instanceMethodId( r'containsKey', r'(Ljava/lang/Object;)Z', ); @@ -6260,12 +4144,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _containsKey(reference.pointer, - _id_containsKey as jni$_.JMethodIDPtr, _$object.pointer) + return _containsKey( + reference.pointer, _id_containsKey.pointer, _$object.pointer) .boolean; } - static final _id_containsValue = _class.instanceMethodId( + static final _id_containsValue = HashMap._class.instanceMethodId( r'containsValue', r'(Ljava/lang/Object;)Z', ); @@ -6286,12 +4170,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _containsValue(reference.pointer, - _id_containsValue as jni$_.JMethodIDPtr, _$object.pointer) + return _containsValue( + reference.pointer, _id_containsValue.pointer, _$object.pointer) .boolean; } - static final _id_entrySet = _class.instanceMethodId( + static final _id_entrySet = HashMap._class.instanceMethodId( r'entrySet', r'()Ljava/util/Set;', ); @@ -6311,13 +4195,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public java.util.Set> entrySet()` /// The returned object must be released after use, by calling the [release] method. jni$_.JSet? entrySet() { - return _entrySet(reference.pointer, _id_entrySet as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JSet$NullableType$( - jni$_.$JObject$NullableType$())); + return _entrySet(reference.pointer, _id_entrySet.pointer) + .object?>(); } - static final _id_forEach = _class.instanceMethodId( + static final _id_forEach = HashMap._class.instanceMethodId( r'forEach', r'(Ljava/util/function/BiConsumer;)V', ); @@ -6338,12 +4220,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JObject? biConsumer, ) { final _$biConsumer = biConsumer?.reference ?? jni$_.jNullReference; - _forEach(reference.pointer, _id_forEach as jni$_.JMethodIDPtr, - _$biConsumer.pointer) + _forEach(reference.pointer, _id_forEach.pointer, _$biConsumer.pointer) .check(); } - static final _id_get = _class.instanceMethodId( + static final _id_get = HashMap._class.instanceMethodId( r'get', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6365,12 +4246,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _get( - reference.pointer, _id_get as jni$_.JMethodIDPtr, _$object.pointer) - .object<$V?>(V.nullableType); + return _get(reference.pointer, _id_get.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_getOrDefault = _class.instanceMethodId( + static final _id_getOrDefault = HashMap._class.instanceMethodId( r'getOrDefault', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6400,15 +4280,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _getOrDefault( - reference.pointer, - _id_getOrDefault as jni$_.JMethodIDPtr, - _$object.pointer, - _$object1.pointer) - .object<$V?>(V.nullableType); + return _getOrDefault(reference.pointer, _id_getOrDefault.pointer, + _$object.pointer, _$object1.pointer) + .object<$V?>(); } - static final _id_isEmpty = _class.instanceMethodId( + static final _id_isEmpty = HashMap._class.instanceMethodId( r'isEmpty', r'()Z', ); @@ -6427,11 +4304,10 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public boolean isEmpty()` core$_.bool isEmpty() { - return _isEmpty(reference.pointer, _id_isEmpty as jni$_.JMethodIDPtr) - .boolean; + return _isEmpty(reference.pointer, _id_isEmpty.pointer).boolean; } - static final _id_keySet = _class.instanceMethodId( + static final _id_keySet = HashMap._class.instanceMethodId( r'keySet', r'()Ljava/util/Set;', ); @@ -6451,12 +4327,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public java.util.Set keySet()` /// The returned object must be released after use, by calling the [release] method. jni$_.JSet<$K?>? keySet() { - return _keySet(reference.pointer, _id_keySet as jni$_.JMethodIDPtr) - .object?>( - jni$_.$JSet$NullableType$<$K?>(K.nullableType)); + return _keySet(reference.pointer, _id_keySet.pointer) + .object?>(); } - static final _id_merge = _class.instanceMethodId( + static final _id_merge = HashMap._class.instanceMethodId( r'merge', r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;', ); @@ -6490,40 +4365,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; - return _merge(reference.pointer, _id_merge as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer, _$biFunction.pointer) - .object<$V?>(V.nullableType); + return _merge(reference.pointer, _id_merge.pointer, _$object.pointer, + _$object1.pointer, _$biFunction.pointer) + .object<$V?>(); } - static final _id_newHashMap = _class.staticMethodId( - r'newHashMap', - r'(I)Ljava/util/HashMap;', - ); - - static final _newHashMap = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Int32,)>)>>( - 'globalEnv_CallStaticObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - - /// from: `static public java.util.HashMap newHashMap(int i)` - /// The returned object must be released after use, by calling the [release] method. - static HashMap<$K?, $V?>? - newHashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - int i, { - required jni$_.JType<$K> K, - required jni$_.JType<$V> V, - }) { - return _newHashMap( - _class.reference.pointer, _id_newHashMap as jni$_.JMethodIDPtr, i) - .object?>( - $HashMap$NullableType$<$K?, $V?>(K.nullableType, V.nullableType)); - } - - static final _id_put = _class.instanceMethodId( + static final _id_put = HashMap._class.instanceMethodId( r'put', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6553,12 +4400,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _put(reference.pointer, _id_put as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer) - .object<$V?>(V.nullableType); + return _put(reference.pointer, _id_put.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); } - static final _id_putAll = _class.instanceMethodId( + static final _id_putAll = HashMap._class.instanceMethodId( r'putAll', r'(Ljava/util/Map;)V', ); @@ -6579,11 +4426,10 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JMap<$K?, $V?>? map, ) { final _$map = map?.reference ?? jni$_.jNullReference; - _putAll(reference.pointer, _id_putAll as jni$_.JMethodIDPtr, _$map.pointer) - .check(); + _putAll(reference.pointer, _id_putAll.pointer, _$map.pointer).check(); } - static final _id_putIfAbsent = _class.instanceMethodId( + static final _id_putIfAbsent = HashMap._class.instanceMethodId( r'putIfAbsent', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6613,15 +4459,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _putIfAbsent( - reference.pointer, - _id_putIfAbsent as jni$_.JMethodIDPtr, - _$object.pointer, - _$object1.pointer) - .object<$V?>(V.nullableType); + return _putIfAbsent(reference.pointer, _id_putIfAbsent.pointer, + _$object.pointer, _$object1.pointer) + .object<$V?>(); } - static final _id_remove = _class.instanceMethodId( + static final _id_remove = HashMap._class.instanceMethodId( r'remove', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6643,12 +4486,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _remove(reference.pointer, _id_remove as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$V?>(V.nullableType); + return _remove(reference.pointer, _id_remove.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_remove$1 = _class.instanceMethodId( + static final _id_remove$1 = HashMap._class.instanceMethodId( r'remove', r'(Ljava/lang/Object;Ljava/lang/Object;)Z', ); @@ -6677,12 +4519,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _remove$1(reference.pointer, _id_remove$1 as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer) + return _remove$1(reference.pointer, _id_remove$1.pointer, _$object.pointer, + _$object1.pointer) .boolean; } - static final _id_replace = _class.instanceMethodId( + static final _id_replace = HashMap._class.instanceMethodId( r'replace', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6712,12 +4554,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _replace(reference.pointer, _id_replace as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer) - .object<$V?>(V.nullableType); + return _replace(reference.pointer, _id_replace.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); } - static final _id_replace$1 = _class.instanceMethodId( + static final _id_replace$1 = HashMap._class.instanceMethodId( r'replace', r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Z', ); @@ -6750,12 +4592,12 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; final _$object2 = object2?.reference ?? jni$_.jNullReference; - return _replace$1(reference.pointer, _id_replace$1 as jni$_.JMethodIDPtr, + return _replace$1(reference.pointer, _id_replace$1.pointer, _$object.pointer, _$object1.pointer, _$object2.pointer) .boolean; } - static final _id_replaceAll = _class.instanceMethodId( + static final _id_replaceAll = HashMap._class.instanceMethodId( r'replaceAll', r'(Ljava/util/function/BiFunction;)V', ); @@ -6776,12 +4618,11 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> jni$_.JObject? biFunction, ) { final _$biFunction = biFunction?.reference ?? jni$_.jNullReference; - _replaceAll(reference.pointer, _id_replaceAll as jni$_.JMethodIDPtr, - _$biFunction.pointer) + _replaceAll(reference.pointer, _id_replaceAll.pointer, _$biFunction.pointer) .check(); } - static final _id_size = _class.instanceMethodId( + static final _id_size = HashMap._class.instanceMethodId( r'size', r'()I', ); @@ -6800,10 +4641,10 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public int size()` int size() { - return _size(reference.pointer, _id_size as jni$_.JMethodIDPtr).integer; + return _size(reference.pointer, _id_size.pointer).integer; } - static final _id_values = _class.instanceMethodId( + static final _id_values = HashMap._class.instanceMethodId( r'values', r'()Ljava/util/Collection;', ); @@ -6823,132 +4664,25 @@ class HashMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public java.util.Collection values()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? values() { - return _values(reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); - } -} - -final class $HashMap$NullableType$<$K extends jni$_.JObject?, - $V extends jni$_.JObject?> extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $HashMap$NullableType$( - this.K, - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Ljava/util/HashMap;'; - - @jni$_.internal - @core$_.override - HashMap<$K, $V>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : HashMap<$K, $V>.fromReference( - K, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($HashMap$NullableType$, K, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($HashMap$NullableType$<$K, $V>) && - other is $HashMap$NullableType$<$K, $V> && - K == other.K && - V == other.V; + return _values(reference.pointer, _id_values.pointer) + .object(); } } -final class $HashMap$Type$<$K extends jni$_.JObject?, $V extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - +final class $HashMap$Type$ extends jni$_.JType { @jni$_.internal - const $HashMap$Type$( - this.K, - this.V, - ); + const $HashMap$Type$(); @jni$_.internal @core$_.override String get signature => r'Ljava/util/HashMap;'; - - @jni$_.internal - @core$_.override - HashMap<$K, $V> fromReference(jni$_.JReference reference) => - HashMap<$K, $V>.fromReference( - K, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $HashMap$NullableType$<$K, $V>(K, V); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($HashMap$Type$, K, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($HashMap$Type$<$K, $V>) && - other is $HashMap$Type$<$K, $V> && - K == other.K && - V == other.V; - } } /// from: `com.example.in_app_java.AndroidUtils` -class AndroidUtils extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - AndroidUtils.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type AndroidUtils._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/example/in_app_java/AndroidUtils'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $AndroidUtils$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $AndroidUtils$Type$(); static final _id_showToast = _class.staticMethodId( @@ -6983,49 +4717,12 @@ class AndroidUtils extends jni$_.JObject { ) { final _$mainActivity = mainActivity?.reference ?? jni$_.jNullReference; final _$text = text?.reference ?? jni$_.jNullReference; - _showToast(_class.reference.pointer, _id_showToast as jni$_.JMethodIDPtr, + _showToast(_class.reference.pointer, _id_showToast.pointer, _$mainActivity.pointer, _$text.pointer, duration) .check(); } } -final class $AndroidUtils$NullableType$ extends jni$_.JType { - @jni$_.internal - const $AndroidUtils$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/example/in_app_java/AndroidUtils;'; - - @jni$_.internal - @core$_.override - AndroidUtils? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : AndroidUtils.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($AndroidUtils$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($AndroidUtils$NullableType$) && - other is $AndroidUtils$NullableType$; - } -} - final class $AndroidUtils$Type$ extends jni$_.JType { @jni$_.internal const $AndroidUtils$Type$(); @@ -7033,32 +4730,4 @@ final class $AndroidUtils$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/example/in_app_java/AndroidUtils;'; - - @jni$_.internal - @core$_.override - AndroidUtils fromReference(jni$_.JReference reference) => - AndroidUtils.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $AndroidUtils$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($AndroidUtils$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($AndroidUtils$Type$) && - other is $AndroidUtils$Type$; - } } diff --git a/pkgs/jnigen/example/in_app_java/lib/main.dart b/pkgs/jnigen/example/in_app_java/lib/main.dart index 37cd135821..3147019339 100644 --- a/pkgs/jnigen/example/in_app_java/lib/main.dart +++ b/pkgs/jnigen/example/in_app_java/lib/main.dart @@ -12,7 +12,7 @@ import 'android_utils.g.dart'; JObject context = Jni.androidApplicationContext; -final hashmap = HashMap(K: JString.type, V: JString.type); +final hashmap = HashMap(); final emojiCompat = EmojiCompat.get(); diff --git a/pkgs/jnigen/example/in_app_java/tool/jnigen.dart b/pkgs/jnigen/example/in_app_java/tool/jnigen.dart index 8c74220813..c9a351944f 100644 --- a/pkgs/jnigen/example/in_app_java/tool/jnigen.dart +++ b/pkgs/jnigen/example/in_app_java/tool/jnigen.dart @@ -12,7 +12,10 @@ void main(List args) { structure: OutputStructure.singleFile, ), ), - androidSdkConfig: AndroidSdkConfig(addGradleDeps: true), + androidSdkConfig: AndroidSdkConfig( + addGradleDeps: true, + androidExample: packageRoot.toFilePath(), + ), sourcePath: [packageRoot.resolve('android/app/src/main/java')], classes: [ 'com.example.in_app_java', // Generate the entire package diff --git a/pkgs/jnigen/example/kotlin_plugin/README.md b/pkgs/jnigen/example/kotlin_plugin/README.md index b27a94d632..67f9ba45f8 100644 --- a/pkgs/jnigen/example/kotlin_plugin/README.md +++ b/pkgs/jnigen/example/kotlin_plugin/README.md @@ -4,7 +4,7 @@ This example generates bindings for a Kotlin-based library. It showcases the con The command to regenerate JNI bindings is: ``` -flutter pub run jnigen --config jnigen.yaml # run from kotlin_plugin project root +dart run jnigen --config jnigen.yaml # run from kotlin_plugin project root ``` The `example/` app must be built at least once in _release_ mode (eg `flutter build apk`) before running JNIgen. This is the equivalent of Gradle Sync in Android Studio, and enables JNIgen to run a Gradle stub and determine release build's classpath, which contains the paths to relevant dependencies. Therefore a build must have been run after cleaning build directories, or updating Java dependencies. This is a known complexity of the Gradle build system, and if you know a solution, please contribute to issue discussion at #33. diff --git a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart index 1edb81e09c..3c85d306fd 100644 --- a/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart +++ b/pkgs/jnigen/example/kotlin_plugin/lib/kotlin_bindings.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // ignore_for_file: annotate_overrides // ignore_for_file: argument_type_not_assignable @@ -37,22 +37,9 @@ import 'package:jni/_internal.dart' as jni$_; import 'package:jni/jni.dart' as jni$_; /// from: `Example` -class Example extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Example.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Example._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'Example'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Example$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Example$Type$(); static final _id_new$ = _class.constructorId( @@ -74,12 +61,12 @@ class Example extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Example() { - return Example.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer).object(); } +} - static final _id_thinkBeforeAnswering = _class.instanceMethodId( +extension Example$$Methods on Example { + static final _id_thinkBeforeAnswering = Example._class.instanceMethodId( r'thinkBeforeAnswering', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -101,11 +88,9 @@ class Example extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _thinkBeforeAnswering( - reference.pointer, - _id_thinkBeforeAnswering as jni$_.JMethodIDPtr, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = _thinkBeforeAnswering(reference.pointer, + _id_thinkBeforeAnswering.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -125,49 +110,12 @@ class Example extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } } -final class $Example$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Example$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'LExample;'; - - @jni$_.internal - @core$_.override - Example? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Example.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$NullableType$) && - other is $Example$NullableType$; - } -} - final class $Example$Type$ extends jni$_.JType { @jni$_.internal const $Example$Type$(); @@ -175,29 +123,4 @@ final class $Example$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'LExample;'; - - @jni$_.internal - @core$_.override - Example fromReference(jni$_.JReference reference) => Example.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Example$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$Type$) && other is $Example$Type$; - } } diff --git a/pkgs/jnigen/example/notification_plugin/README.md b/pkgs/jnigen/example/notification_plugin/README.md index 87e0f4984a..02fd563c99 100644 --- a/pkgs/jnigen/example/notification_plugin/README.md +++ b/pkgs/jnigen/example/notification_plugin/README.md @@ -6,7 +6,7 @@ This plugin project contains [custom code](android/src/main/java/com/example/not The command to regenerate JNI bindings is: ``` -flutter pub run jnigen --config jnigen.yaml # run from notification_plugin project root +dart run jnigen --config jnigen.yaml # run from notification_plugin project root ``` The `example/` app must be built at least once in _release_ mode (eg `flutter build apk`) before running JNIgen. This is the equivalent of Gradle Sync in Android Studio, and enables JNIgen to run a Gradle stub and determine release build's classpath, which contains the paths to relevant dependencies. Therefore a build must have been run after cleaning build directories, or updating Java dependencies. This is a known complexity of the Gradle build system, and if you know a solution, please contribute to issue discussion at #33. diff --git a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart index f763a48197..3b0985e3c3 100644 --- a/pkgs/jnigen/example/notification_plugin/lib/notifications.dart +++ b/pkgs/jnigen/example/notification_plugin/lib/notifications.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a @@ -41,24 +41,10 @@ import 'package:jni/_internal.dart' as jni$_; import 'package:jni/jni.dart' as jni$_; /// from: `com.example.notification_plugin.Notifications` -class Notifications extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Notifications.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Notifications._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/example/notification_plugin/Notifications'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Notifications$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Notifications$Type$(); static final _id_new$ = _class.constructorId( @@ -80,9 +66,8 @@ class Notifications extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Notifications() { - return Notifications.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_showNotification = _class.staticMethodId( @@ -121,54 +106,12 @@ class Notifications extends jni$_.JObject { final _$context = context?.reference ?? jni$_.jNullReference; final _$title = title?.reference ?? jni$_.jNullReference; final _$text = text?.reference ?? jni$_.jNullReference; - _showNotification( - _class.reference.pointer, - _id_showNotification as jni$_.JMethodIDPtr, - _$context.pointer, - notificationID, - _$title.pointer, - _$text.pointer) + _showNotification(_class.reference.pointer, _id_showNotification.pointer, + _$context.pointer, notificationID, _$title.pointer, _$text.pointer) .check(); } } -final class $Notifications$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Notifications$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/example/notification_plugin/Notifications;'; - - @jni$_.internal - @core$_.override - Notifications? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Notifications.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Notifications$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Notifications$NullableType$) && - other is $Notifications$NullableType$; - } -} - final class $Notifications$Type$ extends jni$_.JType { @jni$_.internal const $Notifications$Type$(); @@ -176,32 +119,4 @@ final class $Notifications$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/example/notification_plugin/Notifications;'; - - @jni$_.internal - @core$_.override - Notifications fromReference(jni$_.JReference reference) => - Notifications.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Notifications$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Notifications$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Notifications$Type$) && - other is $Notifications$Type$; - } } diff --git a/pkgs/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart b/pkgs/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart index 7b7cd3e10c..21501a0d0b 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/dart_example/bin/pdf_info.dart @@ -12,7 +12,7 @@ void writeInfo(String file) { final fileInputStreamClass = JClass.forName("java/io/FileInputStream"); final inputFile = fileInputStreamClass .constructorId("(Ljava/lang/String;)V") - .call(fileInputStreamClass, JObject.type, [file.toJString()]); + .call(fileInputStreamClass, [file.toJString()]); final pdDoc = PDDocument.load$6(inputFile)!; int pages = pdDoc.getNumberOfPages(); final info = pdDoc.getDocumentInformation()!; diff --git a/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart b/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart index 60b8aa21f0..08a5c299b8 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/example/lib/main.dart @@ -159,8 +159,8 @@ class PDFFileInfo { // create a java.io.File object. final fileClass = JClass.forName("java/io/File"); final fileConstructor = fileClass.constructorId("(Ljava/lang/String;)V"); - final inputFile = fileConstructor( - fileClass, JObject.type, [JString.fromString(filename)]); + final inputFile = + fileConstructor(fileClass, [JString.fromString(filename)]); // Static method call PDDocument.load -> PDDocument final pdf = PDDocument.load(inputFile)!; // Instance method call getNumberOfPages() -> int diff --git a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocument.dart b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocument.dart index d10b3730d2..3d53474fbb 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocument.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocument.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Generated from Apache PDFBox library which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. @@ -61,24 +61,10 @@ import 'PDDocumentInformation.dart' as pddocumentinformation$_; /// This is the in-memory representation of the PDF document. /// The \#close() method must be called once the document is no longer needed. ///@author Ben Litchfield -class PDDocument extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - PDDocument.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type PDDocument._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'org/apache/pdfbox/pdmodel/PDDocument'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $PDDocument$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $PDDocument$Type$(); static final _id_new$ = _class.constructorId( @@ -103,9 +89,8 @@ class PDDocument extends jni$_.JObject { /// Creates an empty PDF document. /// You need to add at least one page for the document to be valid. factory PDDocument() { - return PDDocument.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_new$1 = _class.constructorId( @@ -134,9 +119,9 @@ class PDDocument extends jni$_.JObject { ) { final _$memUsageSetting = memUsageSetting?.reference ?? jni$_.jNullReference; - return PDDocument.fromReference(_new$1(_class.reference.pointer, - _id_new$1 as jni$_.JMethodIDPtr, _$memUsageSetting.pointer) - .reference); + return _new$1(_class.reference.pointer, _id_new$1.pointer, + _$memUsageSetting.pointer) + .object(); } static final _id_new$2 = _class.constructorId( @@ -163,9 +148,8 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? doc, ) { final _$doc = doc?.reference ?? jni$_.jNullReference; - return PDDocument.fromReference(_new$2(_class.reference.pointer, - _id_new$2 as jni$_.JMethodIDPtr, _$doc.pointer) - .reference); + return _new$2(_class.reference.pointer, _id_new$2.pointer, _$doc.pointer) + .object(); } static final _id_new$3 = _class.constructorId( @@ -201,9 +185,9 @@ class PDDocument extends jni$_.JObject { ) { final _$doc = doc?.reference ?? jni$_.jNullReference; final _$source = source?.reference ?? jni$_.jNullReference; - return PDDocument.fromReference(_new$3(_class.reference.pointer, - _id_new$3 as jni$_.JMethodIDPtr, _$doc.pointer, _$source.pointer) - .reference); + return _new$3(_class.reference.pointer, _id_new$3.pointer, _$doc.pointer, + _$source.pointer) + .object(); } static final _id_new$4 = _class.constructorId( @@ -244,182 +228,136 @@ class PDDocument extends jni$_.JObject { final _$doc = doc?.reference ?? jni$_.jNullReference; final _$source = source?.reference ?? jni$_.jNullReference; final _$permission = permission?.reference ?? jni$_.jNullReference; - return PDDocument.fromReference(_new$4( - _class.reference.pointer, - _id_new$4 as jni$_.JMethodIDPtr, - _$doc.pointer, - _$source.pointer, - _$permission.pointer) - .reference); - } - - static final _id_addPage = _class.instanceMethodId( - r'addPage', - r'(Lorg/apache/pdfbox/pdmodel/PDPage;)V', - ); - - static final _addPage = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public void addPage(org.apache.pdfbox.pdmodel.PDPage page)` - /// - /// This will add a page to the document. This is a convenience method, that will add the page to the root of the - /// hierarchy and set the parent of the page to the root. - ///@param page The page to add to the document. - void addPage( - jni$_.JObject? page, - ) { - final _$page = page?.reference ?? jni$_.jNullReference; - _addPage(reference.pointer, _id_addPage as jni$_.JMethodIDPtr, - _$page.pointer) - .check(); + return _new$4(_class.reference.pointer, _id_new$4.pointer, _$doc.pointer, + _$source.pointer, _$permission.pointer) + .object(); } - static final _id_addSignature = _class.instanceMethodId( - r'addSignature', - r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;)V', + static final _id_load = _class.staticMethodId( + r'load', + r'(Ljava/io/File;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _addSignature = jni$_.ProtectedJniExtensions.lookup< + static final _load = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') + 'globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject)` - /// - /// Add parameters of signature to be created externally using default signature options. See - /// \#saveIncrementalForExternalSigning(OutputStream) method description on external - /// signature creation scenario details. + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file)` + /// The returned object must be released after use, by calling the [release] method. /// - /// Only one signature may be added in a document. To sign several times, - /// load document, add signature, save incremental and close again. - ///@param sigObject is the PDSignatureField model - ///@throws IOException if there is an error creating required fields - ///@throws IllegalStateException if one attempts to add several signature - /// fields. - void addSignature( - jni$_.JObject? sigObject, + /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. + ///@param file file to be loaded + ///@return loaded document + ///@throws InvalidPasswordException If the file required a non-empty password. + ///@throws IOException in case of a file reading or parsing error + static PDDocument? load( + jni$_.JObject? file, ) { - final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; - _addSignature(reference.pointer, _id_addSignature as jni$_.JMethodIDPtr, - _$sigObject.pointer) - .check(); + final _$file = file?.reference ?? jni$_.jNullReference; + return _load(_class.reference.pointer, _id_load.pointer, _$file.pointer) + .object(); } - static final _id_addSignature$1 = _class.instanceMethodId( - r'addSignature', - r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V', + static final _id_load$1 = _class.staticMethodId( + r'load', + r'(Ljava/io/File;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _addSignature$1 = jni$_.ProtectedJniExtensions.lookup< + static final _load$1 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallVoidMethod') + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions options)` - /// - /// Add parameters of signature to be created externally. See - /// \#saveIncrementalForExternalSigning(OutputStream) method description on external - /// signature creation scenario details. + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// The returned object must be released after use, by calling the [release] method. /// - /// Only one signature may be added in a document. To sign several times, - /// load document, add signature, save incremental and close again. - ///@param sigObject is the PDSignatureField model - ///@param options signature options - ///@throws IOException if there is an error creating required fields - ///@throws IllegalStateException if one attempts to add several signature - /// fields. - void addSignature$1( - jni$_.JObject? sigObject, - jni$_.JObject? options, + /// Parses a PDF. + ///@param file file to be loaded + ///@param memUsageSetting defines how memory is used for buffering PDF streams + ///@return loaded document + ///@throws InvalidPasswordException If the file required a non-empty password. + ///@throws IOException in case of a file reading or parsing error + static PDDocument? load$1( + jni$_.JObject? file, + jni$_.JObject? memUsageSetting, ) { - final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; - final _$options = options?.reference ?? jni$_.jNullReference; - _addSignature$1(reference.pointer, _id_addSignature$1 as jni$_.JMethodIDPtr, - _$sigObject.pointer, _$options.pointer) - .check(); + final _$file = file?.reference ?? jni$_.jNullReference; + final _$memUsageSetting = + memUsageSetting?.reference ?? jni$_.jNullReference; + return _load$1(_class.reference.pointer, _id_load$1.pointer, _$file.pointer, + _$memUsageSetting.pointer) + .object(); } - static final _id_addSignature$2 = _class.instanceMethodId( - r'addSignature', - r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;)V', + static final _id_load$2 = _class.staticMethodId( + r'load', + r'(Ljava/io/File;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _addSignature$2 = jni$_.ProtectedJniExtensions.lookup< + static final _load$2 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallVoidMethod') + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signatureInterface)` - /// - /// Add a signature to be created using the instance of given interface. + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password)` + /// The returned object must be released after use, by calling the [release] method. /// - /// Only one signature may be added in a document. To sign several times, - /// load document, add signature, save incremental and close again. - ///@param sigObject is the PDSignatureField model - ///@param signatureInterface is an interface whose implementation provides - /// signing capabilities. Can be null if external signing if used. - ///@throws IOException if there is an error creating required fields - ///@throws IllegalStateException if one attempts to add several signature - /// fields. - void addSignature$2( - jni$_.JObject? sigObject, - jni$_.JObject? signatureInterface, + /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. + ///@param file file to be loaded + ///@param password password to be used for decryption + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException in case of a file reading or parsing error + static PDDocument? load$2( + jni$_.JObject? file, + jni$_.JString? password, ) { - final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; - final _$signatureInterface = - signatureInterface?.reference ?? jni$_.jNullReference; - _addSignature$2(reference.pointer, _id_addSignature$2 as jni$_.JMethodIDPtr, - _$sigObject.pointer, _$signatureInterface.pointer) - .check(); + final _$file = file?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + return _load$2(_class.reference.pointer, _id_load$2.pointer, _$file.pointer, + _$password.pointer) + .object(); } - static final _id_addSignature$3 = _class.instanceMethodId( - r'addSignature', - r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V', + static final _id_load$3 = _class.staticMethodId( + r'load', + r'(Ljava/io/File;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _addSignature$3 = jni$_.ProtectedJniExtensions.lookup< + static final _load$3 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< @@ -427,591 +365,592 @@ class PDDocument extends jni$_.JObject { jni$_.Pointer, jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallVoidMethod') + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signatureInterface, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions options)` - /// - /// This will add a signature to the document. If the 0-based page number in the options - /// parameter is smaller than 0 or larger than max, the nearest valid page number will be used - /// (i.e. 0 or max) and no exception will be thrown. + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// The returned object must be released after use, by calling the [release] method. /// - /// Only one signature may be added in a document. To sign several times, - /// load document, add signature, save incremental and close again. - ///@param sigObject is the PDSignatureField model - ///@param signatureInterface is an interface whose implementation provides - /// signing capabilities. Can be null if external signing if used. - ///@param options signature options - ///@throws IOException if there is an error creating required fields - ///@throws IllegalStateException if one attempts to add several signature - /// fields. - void addSignature$3( - jni$_.JObject? sigObject, - jni$_.JObject? signatureInterface, - jni$_.JObject? options, + /// Parses a PDF. + ///@param file file to be loaded + ///@param password password to be used for decryption + ///@param memUsageSetting defines how memory is used for buffering PDF streams + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException in case of a file reading or parsing error + static PDDocument? load$3( + jni$_.JObject? file, + jni$_.JString? password, + jni$_.JObject? memUsageSetting, ) { - final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; - final _$signatureInterface = - signatureInterface?.reference ?? jni$_.jNullReference; - final _$options = options?.reference ?? jni$_.jNullReference; - _addSignature$3( - reference.pointer, - _id_addSignature$3 as jni$_.JMethodIDPtr, - _$sigObject.pointer, - _$signatureInterface.pointer, - _$options.pointer) - .check(); + final _$file = file?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$memUsageSetting = + memUsageSetting?.reference ?? jni$_.jNullReference; + return _load$3(_class.reference.pointer, _id_load$3.pointer, _$file.pointer, + _$password.pointer, _$memUsageSetting.pointer) + .object(); } - static final _id_addSignatureField = _class.instanceMethodId( - r'addSignatureField', - r'(Ljava/util/List;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V', + static final _id_load$4 = _class.staticMethodId( + r'load', + r'(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _addSignatureField = jni$_.ProtectedJniExtensions.lookup< + static final _load$4 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( + jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallVoidMethod') + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void addSignatureField(java.util.List sigFields, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signatureInterface, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions options)` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias)` + /// The returned object must be released after use, by calling the [release] method. /// - /// This will add a list of signature fields to the document. - ///@param sigFields are the PDSignatureFields that should be added to the document - ///@param signatureInterface is an interface whose implementation provides - /// signing capabilities. Can be null if external signing if used. - ///@param options signature options - ///@throws IOException if there is an error creating required fields - ///@deprecated The method is misleading, because only one signature may be - /// added in a document. The method will be removed in the future. - void addSignatureField( - jni$_.JList? sigFields, - jni$_.JObject? signatureInterface, - jni$_.JObject? options, - ) { - final _$sigFields = sigFields?.reference ?? jni$_.jNullReference; - final _$signatureInterface = - signatureInterface?.reference ?? jni$_.jNullReference; - final _$options = options?.reference ?? jni$_.jNullReference; - _addSignatureField( - reference.pointer, - _id_addSignatureField as jni$_.JMethodIDPtr, - _$sigFields.pointer, - _$signatureInterface.pointer, - _$options.pointer) - .check(); - } - - static final _id_removePage = _class.instanceMethodId( - r'removePage', - r'(Lorg/apache/pdfbox/pdmodel/PDPage;)V', - ); - - static final _removePage = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public void removePage(org.apache.pdfbox.pdmodel.PDPage page)` - /// - /// Remove the page from the document. - ///@param page The page to remove from the document. - void removePage( - jni$_.JObject? page, + /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. + ///@param file file to be loaded + ///@param password password to be used for decryption + ///@param keyStore key store to be used for decryption when using public key security + ///@param alias alias to be used for decryption when using public key security + ///@return loaded document + ///@throws IOException in case of a file reading or parsing error + static PDDocument? load$4( + jni$_.JObject? file, + jni$_.JString? password, + jni$_.JObject? keyStore, + jni$_.JString? alias, ) { - final _$page = page?.reference ?? jni$_.jNullReference; - _removePage(reference.pointer, _id_removePage as jni$_.JMethodIDPtr, - _$page.pointer) - .check(); + final _$file = file?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; + final _$alias = alias?.reference ?? jni$_.jNullReference; + return _load$4(_class.reference.pointer, _id_load$4.pointer, _$file.pointer, + _$password.pointer, _$keyStore.pointer, _$alias.pointer) + .object(); } - static final _id_removePage$1 = _class.instanceMethodId( - r'removePage', - r'(I)V', + static final _id_load$5 = _class.staticMethodId( + r'load', + r'(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _removePage$1 = jni$_.ProtectedJniExtensions.lookup< + static final _load$5 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public void removePage(int pageNumber)` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// The returned object must be released after use, by calling the [release] method. /// - /// Remove the page from the document. - ///@param pageNumber 0 based index to page number. - void removePage$1( - int pageNumber, + /// Parses a PDF. + ///@param file file to be loaded + ///@param password password to be used for decryption + ///@param keyStore key store to be used for decryption when using public key security + ///@param alias alias to be used for decryption when using public key security + ///@param memUsageSetting defines how memory is used for buffering PDF streams + ///@return loaded document + ///@throws IOException in case of a file reading or parsing error + static PDDocument? load$5( + jni$_.JObject? file, + jni$_.JString? password, + jni$_.JObject? keyStore, + jni$_.JString? alias, + jni$_.JObject? memUsageSetting, ) { - _removePage$1(reference.pointer, _id_removePage$1 as jni$_.JMethodIDPtr, - pageNumber) - .check(); + final _$file = file?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; + final _$alias = alias?.reference ?? jni$_.jNullReference; + final _$memUsageSetting = + memUsageSetting?.reference ?? jni$_.jNullReference; + return _load$5( + _class.reference.pointer, + _id_load$5.pointer, + _$file.pointer, + _$password.pointer, + _$keyStore.pointer, + _$alias.pointer, + _$memUsageSetting.pointer) + .object(); } - static final _id_importPage = _class.instanceMethodId( - r'importPage', - r'(Lorg/apache/pdfbox/pdmodel/PDPage;)Lorg/apache/pdfbox/pdmodel/PDPage;', + static final _id_load$6 = _class.staticMethodId( + r'load', + r'(Ljava/io/InputStream;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _importPage = jni$_.ProtectedJniExtensions.lookup< + static final _load$6 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallObjectMethod') + 'globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public org.apache.pdfbox.pdmodel.PDPage importPage(org.apache.pdfbox.pdmodel.PDPage page)` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input)` /// The returned object must be released after use, by calling the [release] method. /// - /// This will import and copy the contents from another location. Currently the content stream is - /// stored in a scratch file. The scratch file is associated with the document. If you are adding - /// a page to this document from another document and want to copy the contents to this - /// document's scratch file then use this method otherwise just use the \#addPage addPage() - /// method. - /// - /// Unlike \#addPage addPage(), this method creates a new PDPage object. If your page has - /// annotations, and if these link to pages not in the target document, then the target document - /// might become huge. What you need to do is to delete page references of such annotations. See - /// here for how to do this. - /// - /// Inherited (global) resources are ignored because these can contain resources not needed for - /// this page which could bloat your document, see - /// PDFBOX-28 and related issues. - /// If you need them, call importedPage.setResources(page.getResources()); - /// - /// This method should only be used to import a page from a loaded document, not from a generated - /// document because these can contain unfinished parts, e.g. font subsetting information. - ///@param page The page to import. - ///@return The page that was imported. - ///@throws IOException If there is an error copying the page. - jni$_.JObject? importPage( - jni$_.JObject? page, + /// Parses a PDF. The given input stream is copied to the memory to enable random access to the + /// pdf. Unrestricted main memory will be used for buffering PDF streams. + ///@param input stream that contains the document. Don't forget to close it after loading. + ///@return loaded document + ///@throws InvalidPasswordException If the PDF required a non-empty password. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$6( + jni$_.JObject? input, ) { - final _$page = page?.reference ?? jni$_.jNullReference; - return _importPage(reference.pointer, _id_importPage as jni$_.JMethodIDPtr, - _$page.pointer) - .object(const jni$_.$JObject$NullableType$()); + final _$input = input?.reference ?? jni$_.jNullReference; + return _load$6( + _class.reference.pointer, _id_load$6.pointer, _$input.pointer) + .object(); } - static final _id_getDocument = _class.instanceMethodId( - r'getDocument', - r'()Lorg/apache/pdfbox/cos/COSDocument;', + static final _id_load$7 = _class.staticMethodId( + r'load', + r'(Ljava/io/InputStream;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _getDocument = jni$_.ProtectedJniExtensions.lookup< + static final _load$7 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public org.apache.pdfbox.cos.COSDocument getDocument()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` /// The returned object must be released after use, by calling the [release] method. /// - /// This will get the low level document. - ///@return The document that this layer sits on top of. - jni$_.JObject? getDocument() { - return _getDocument( - reference.pointer, _id_getDocument as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + /// Parses a PDF. Depending on the memory settings parameter the given input stream is either + /// copied to main memory or to a temporary file to enable random access to the pdf. + ///@param input stream that contains the document. Don't forget to close it after loading. + ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams + ///@return loaded document + ///@throws InvalidPasswordException If the PDF required a non-empty password. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$7( + jni$_.JObject? input, + jni$_.JObject? memUsageSetting, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + final _$memUsageSetting = + memUsageSetting?.reference ?? jni$_.jNullReference; + return _load$7(_class.reference.pointer, _id_load$7.pointer, + _$input.pointer, _$memUsageSetting.pointer) + .object(); } - static final _id_getDocumentInformation = _class.instanceMethodId( - r'getDocumentInformation', - r'()Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;', + static final _id_load$8 = _class.staticMethodId( + r'load', + r'(Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _getDocumentInformation = jni$_.ProtectedJniExtensions.lookup< + static final _load$8 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public org.apache.pdfbox.pdmodel.PDDocumentInformation getDocumentInformation()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password)` /// The returned object must be released after use, by calling the [release] method. /// - /// This will get the document info dictionary. If it doesn't exist, an empty document info - /// dictionary is created in the document trailer. - /// - /// In PDF 2.0 this is deprecated except for two entries, /CreationDate and /ModDate. For any other - /// document level metadata, a metadata stream should be used instead, see - /// PDDocumentCatalog\#getMetadata(). - ///@return The documents /Info dictionary, never null. - pddocumentinformation$_.PDDocumentInformation? getDocumentInformation() { - return _getDocumentInformation( - reference.pointer, _id_getDocumentInformation as jni$_.JMethodIDPtr) - .object( - const pddocumentinformation$_ - .$PDDocumentInformation$NullableType$()); + /// Parses a PDF. The given input stream is copied to the memory to enable random access to the + /// pdf. Unrestricted main memory will be used for buffering PDF streams. + ///@param input stream that contains the document. Don't forget to close it after loading. + ///@param password password to be used for decryption + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$8( + jni$_.JObject? input, + jni$_.JString? password, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + return _load$8(_class.reference.pointer, _id_load$8.pointer, + _$input.pointer, _$password.pointer) + .object(); } - static final _id_setDocumentInformation = _class.instanceMethodId( - r'setDocumentInformation', - r'(Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;)V', + static final _id_load$9 = _class.staticMethodId( + r'load', + r'(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _setDocumentInformation = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public void setDocumentInformation(org.apache.pdfbox.pdmodel.PDDocumentInformation info)` - /// - /// This will set the document information for this document. - /// - /// In PDF 2.0 this is deprecated except for two entries, /CreationDate and /ModDate. For any other - /// document level metadata, a metadata stream should be used instead, see - /// PDDocumentCatalog\#setMetadata(org.apache.pdfbox.pdmodel.common.PDMetadata) PDDocumentCatalog\#setMetadata(PDMetadata). - ///@param info The updated document information. - void setDocumentInformation( - pddocumentinformation$_.PDDocumentInformation? info, - ) { - final _$info = info?.reference ?? jni$_.jNullReference; - _setDocumentInformation(reference.pointer, - _id_setDocumentInformation as jni$_.JMethodIDPtr, _$info.pointer) - .check(); - } - - static final _id_getDocumentCatalog = _class.instanceMethodId( - r'getDocumentCatalog', - r'()Lorg/apache/pdfbox/pdmodel/PDDocumentCatalog;', - ); - - static final _getDocumentCatalog = jni$_.ProtectedJniExtensions.lookup< + static final _load$9 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public org.apache.pdfbox.pdmodel.PDDocumentCatalog getDocumentCatalog()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias)` /// The returned object must be released after use, by calling the [release] method. /// - /// This will get the document CATALOG. This is guaranteed to not return null. - ///@return The documents /Root dictionary - jni$_.JObject? getDocumentCatalog() { - return _getDocumentCatalog( - reference.pointer, _id_getDocumentCatalog as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + /// Parses a PDF. The given input stream is copied to the memory to enable random access to the + /// pdf. Unrestricted main memory will be used for buffering PDF streams. + ///@param input stream that contains the document. Don't forget to close it after loading. + ///@param password password to be used for decryption + ///@param keyStore key store to be used for decryption when using public key security + ///@param alias alias to be used for decryption when using public key security + ///@return loaded document + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$9( + jni$_.JObject? input, + jni$_.JString? password, + jni$_.JObject? keyStore, + jni$_.JString? alias, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; + final _$alias = alias?.reference ?? jni$_.jNullReference; + return _load$9( + _class.reference.pointer, + _id_load$9.pointer, + _$input.pointer, + _$password.pointer, + _$keyStore.pointer, + _$alias.pointer) + .object(); } - static final _id_isEncrypted = _class.instanceMethodId( - r'isEncrypted', - r'()Z', + static final _id_load$10 = _class.staticMethodId( + r'load', + r'(Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _isEncrypted = jni$_.ProtectedJniExtensions.lookup< + static final _load$10 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallBooleanMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public boolean isEncrypted()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// The returned object must be released after use, by calling the [release] method. /// - /// This will tell if this document is encrypted or not. - ///@return true If this document is encrypted. - core$_.bool isEncrypted() { - return _isEncrypted( - reference.pointer, _id_isEncrypted as jni$_.JMethodIDPtr) - .boolean; + /// Parses a PDF. Depending on the memory settings parameter the given input stream is either + /// copied to main memory or to a temporary file to enable random access to the pdf. + ///@param input stream that contains the document. Don't forget to close it after loading. + ///@param password password to be used for decryption + ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$10( + jni$_.JObject? input, + jni$_.JString? password, + jni$_.JObject? memUsageSetting, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$memUsageSetting = + memUsageSetting?.reference ?? jni$_.jNullReference; + return _load$10(_class.reference.pointer, _id_load$10.pointer, + _$input.pointer, _$password.pointer, _$memUsageSetting.pointer) + .object(); } - static final _id_getEncryption = _class.instanceMethodId( - r'getEncryption', - r'()Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;', + static final _id_load$11 = _class.staticMethodId( + r'load', + r'(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _getEncryption = jni$_.ProtectedJniExtensions.lookup< + static final _load$11 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public org.apache.pdfbox.pdmodel.encryption.PDEncryption getEncryption()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` /// The returned object must be released after use, by calling the [release] method. /// - /// This will get the encryption dictionary for this document. This will still return the parameters if the document - /// was decrypted. As the encryption architecture in PDF documents is pluggable this returns an abstract class, - /// but the only supported subclass at this time is a - /// PDStandardEncryption object. - ///@return The encryption dictionary(most likely a PDStandardEncryption object) - jni$_.JObject? getEncryption() { - return _getEncryption( - reference.pointer, _id_getEncryption as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + /// Parses a PDF. Depending on the memory settings parameter the given input stream is either + /// copied to memory or to a temporary file to enable random access to the pdf. + ///@param input stream that contains the document. Don't forget to close it after loading. + ///@param password password to be used for decryption + ///@param keyStore key store to be used for decryption when using public key security + ///@param alias alias to be used for decryption when using public key security + ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$11( + jni$_.JObject? input, + jni$_.JString? password, + jni$_.JObject? keyStore, + jni$_.JString? alias, + jni$_.JObject? memUsageSetting, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; + final _$alias = alias?.reference ?? jni$_.jNullReference; + final _$memUsageSetting = + memUsageSetting?.reference ?? jni$_.jNullReference; + return _load$11( + _class.reference.pointer, + _id_load$11.pointer, + _$input.pointer, + _$password.pointer, + _$keyStore.pointer, + _$alias.pointer, + _$memUsageSetting.pointer) + .object(); } - static final _id_setEncryptionDictionary = _class.instanceMethodId( - r'setEncryptionDictionary', - r'(Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;)V', + static final _id_load$12 = _class.staticMethodId( + r'load', + r'([B)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _setEncryptionDictionary = jni$_.ProtectedJniExtensions.lookup< + static final _load$12 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') + 'globalEnv_CallStaticObjectMethod') .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public void setEncryptionDictionary(org.apache.pdfbox.pdmodel.encryption.PDEncryption encryption)` - /// - /// This will set the encryption dictionary for this document. - ///@param encryption The encryption dictionary(most likely a PDStandardEncryption object) - ///@throws IOException If there is an error determining which security handler to use. - void setEncryptionDictionary( - jni$_.JObject? encryption, - ) { - final _$encryption = encryption?.reference ?? jni$_.jNullReference; - _setEncryptionDictionary( - reference.pointer, - _id_setEncryptionDictionary as jni$_.JMethodIDPtr, - _$encryption.pointer) - .check(); - } - - static final _id_getLastSignatureDictionary = _class.instanceMethodId( - r'getLastSignatureDictionary', - r'()Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;', - ); - - static final _getLastSignatureDictionary = - jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getLastSignatureDictionary()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input)` /// The returned object must be released after use, by calling the [release] method. /// - /// This will return the last signature from the field tree. Note that this may not be the - /// last in time when empty signature fields are created first but signed after other fields. - ///@return the last signature as PDSignatureField. - ///@throws IOException if no document catalog can be found. - jni$_.JObject? getLastSignatureDictionary() { - return _getLastSignatureDictionary(reference.pointer, - _id_getLastSignatureDictionary as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. + ///@param input byte array that contains the document. + ///@return loaded document + ///@throws InvalidPasswordException If the PDF required a non-empty password. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$12( + jni$_.JByteArray? input, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + return _load$12( + _class.reference.pointer, _id_load$12.pointer, _$input.pointer) + .object(); } - static final _id_getSignatureFields = _class.instanceMethodId( - r'getSignatureFields', - r'()Ljava/util/List;', + static final _id_load$13 = _class.staticMethodId( + r'load', + r'([BLjava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _getSignatureFields = jni$_.ProtectedJniExtensions.lookup< + static final _load$13 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `public java.util.List getSignatureFields()` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password)` /// The returned object must be released after use, by calling the [release] method. /// - /// Retrieve all signature fields from the document. - ///@return a List of PDSignatureFields - ///@throws IOException if no document catalog can be found. - jni$_.JList? getSignatureFields() { - return _getSignatureFields( - reference.pointer, _id_getSignatureFields as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JList$NullableType$( - jni$_.$JObject$NullableType$())); + /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. + ///@param input byte array that contains the document. + ///@param password password to be used for decryption + ///@return loaded document + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$13( + jni$_.JByteArray? input, + jni$_.JString? password, + ) { + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + return _load$13(_class.reference.pointer, _id_load$13.pointer, + _$input.pointer, _$password.pointer) + .object(); } - static final _id_getSignatureDictionaries = _class.instanceMethodId( - r'getSignatureDictionaries', - r'()Ljava/util/List;', + static final _id_load$14 = _class.staticMethodId( + r'load', + r'([BLjava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _getSignatureDictionaries = jni$_.ProtectedJniExtensions.lookup< + static final _load$14 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public java.util.List getSignatureDictionaries()` - /// The returned object must be released after use, by calling the [release] method. - /// - /// Retrieve all signature dictionaries from the document. - ///@return a List of PDSignatureFields - ///@throws IOException if no document catalog can be found. - jni$_.JList? getSignatureDictionaries() { - return _getSignatureDictionaries(reference.pointer, - _id_getSignatureDictionaries as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JList$NullableType$( - jni$_.$JObject$NullableType$())); - } - - static final _id_registerTrueTypeFontForClosing = _class.instanceMethodId( - r'registerTrueTypeFontForClosing', - r'(Lorg/apache/fontbox/ttf/TrueTypeFont;)V', - ); - - static final _registerTrueTypeFontForClosing = - jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public void registerTrueTypeFontForClosing(org.apache.fontbox.ttf.TrueTypeFont ttf)` - /// - /// For internal PDFBox use when creating PDF documents: register a TrueTypeFont to make sure it - /// is closed when the PDDocument is closed to avoid memory leaks. Users don't have to call this - /// method, it is done by the appropriate PDFont classes. - ///@param ttf - void registerTrueTypeFontForClosing( - jni$_.JObject? ttf, - ) { - final _$ttf = ttf?.reference ?? jni$_.jNullReference; - _registerTrueTypeFontForClosing( - reference.pointer, - _id_registerTrueTypeFontForClosing as jni$_.JMethodIDPtr, - _$ttf.pointer) - .check(); - } - - static final _id_load = _class.staticMethodId( - r'load', - r'(Ljava/io/File;)Lorg/apache/pdfbox/pdmodel/PDDocument;', - ); - - static final _load = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallStaticObjectMethod') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file)` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias)` /// The returned object must be released after use, by calling the [release] method. /// /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. - ///@param file file to be loaded + ///@param input byte array that contains the document. + ///@param password password to be used for decryption + ///@param keyStore key store to be used for decryption when using public key security + ///@param alias alias to be used for decryption when using public key security ///@return loaded document - ///@throws InvalidPasswordException If the file required a non-empty password. - ///@throws IOException in case of a file reading or parsing error - static PDDocument? load( - jni$_.JObject? file, + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$14( + jni$_.JByteArray? input, + jni$_.JString? password, + jni$_.JObject? keyStore, + jni$_.JString? alias, ) { - final _$file = file?.reference ?? jni$_.jNullReference; - return _load(_class.reference.pointer, _id_load as jni$_.JMethodIDPtr, - _$file.pointer) - .object(const $PDDocument$NullableType$()); + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; + final _$alias = alias?.reference ?? jni$_.jNullReference; + return _load$14( + _class.reference.pointer, + _id_load$14.pointer, + _$input.pointer, + _$password.pointer, + _$keyStore.pointer, + _$alias.pointer) + .object(); } - static final _id_load$1 = _class.staticMethodId( + static final _id_load$15 = _class.staticMethodId( r'load', - r'(Ljava/io/File;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + r'([BLjava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', ); - static final _load$1 = jni$_.ProtectedJniExtensions.lookup< + static final _load$15 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer, jni$_.Pointer )>)>>('globalEnv_CallStaticObjectMethod') @@ -1020,727 +959,749 @@ class PDDocument extends jni$_.JObject { jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` /// The returned object must be released after use, by calling the [release] method. /// /// Parses a PDF. - ///@param file file to be loaded - ///@param memUsageSetting defines how memory is used for buffering PDF streams + ///@param input byte array that contains the document. + ///@param password password to be used for decryption + ///@param keyStore key store to be used for decryption when using public key security + ///@param alias alias to be used for decryption when using public key security + ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams ///@return loaded document - ///@throws InvalidPasswordException If the file required a non-empty password. - ///@throws IOException in case of a file reading or parsing error - static PDDocument? load$1( - jni$_.JObject? file, + ///@throws InvalidPasswordException If the password is incorrect. + ///@throws IOException In case of a reading or parsing error. + static PDDocument? load$15( + jni$_.JByteArray? input, + jni$_.JString? password, + jni$_.JObject? keyStore, + jni$_.JString? alias, jni$_.JObject? memUsageSetting, ) { - final _$file = file?.reference ?? jni$_.jNullReference; + final _$input = input?.reference ?? jni$_.jNullReference; + final _$password = password?.reference ?? jni$_.jNullReference; + final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; + final _$alias = alias?.reference ?? jni$_.jNullReference; final _$memUsageSetting = memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$1(_class.reference.pointer, _id_load$1 as jni$_.JMethodIDPtr, - _$file.pointer, _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + return _load$15( + _class.reference.pointer, + _id_load$15.pointer, + _$input.pointer, + _$password.pointer, + _$keyStore.pointer, + _$alias.pointer, + _$memUsageSetting.pointer) + .object(); } +} - static final _id_load$2 = _class.staticMethodId( - r'load', - r'(Ljava/io/File;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', +extension PDDocument$$Methods on PDDocument { + static final _id_addPage = PDDocument._class.instanceMethodId( + r'addPage', + r'(Lorg/apache/pdfbox/pdmodel/PDPage;)V', ); - static final _load$2 = jni$_.ProtectedJniExtensions.lookup< + static final _addPage = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void addPage(org.apache.pdfbox.pdmodel.PDPage page)` + /// + /// This will add a page to the document. This is a convenience method, that will add the page to the root of the + /// hierarchy and set the parent of the page to the root. + ///@param page The page to add to the document. + void addPage( + jni$_.JObject? page, + ) { + final _$page = page?.reference ?? jni$_.jNullReference; + _addPage(reference.pointer, _id_addPage.pointer, _$page.pointer).check(); + } + + static final _id_addSignature = PDDocument._class.instanceMethodId( + r'addSignature', + r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;)V', + ); + + static final _addSignature = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject)` + /// + /// Add parameters of signature to be created externally using default signature options. See + /// \#saveIncrementalForExternalSigning(OutputStream) method description on external + /// signature creation scenario details. + /// + /// Only one signature may be added in a document. To sign several times, + /// load document, add signature, save incremental and close again. + ///@param sigObject is the PDSignatureField model + ///@throws IOException if there is an error creating required fields + ///@throws IllegalStateException if one attempts to add several signature + /// fields. + void addSignature( + jni$_.JObject? sigObject, + ) { + final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; + _addSignature( + reference.pointer, _id_addSignature.pointer, _$sigObject.pointer) + .check(); + } + + static final _id_addSignature$1 = PDDocument._class.instanceMethodId( + r'addSignature', + r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V', + ); + + static final _addSignature$1 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + )>)>>('globalEnv_CallVoidMethod') .asFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions options)` /// - /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. - ///@param file file to be loaded - ///@param password password to be used for decryption - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException in case of a file reading or parsing error - static PDDocument? load$2( - jni$_.JObject? file, - jni$_.JString? password, + /// Add parameters of signature to be created externally. See + /// \#saveIncrementalForExternalSigning(OutputStream) method description on external + /// signature creation scenario details. + /// + /// Only one signature may be added in a document. To sign several times, + /// load document, add signature, save incremental and close again. + ///@param sigObject is the PDSignatureField model + ///@param options signature options + ///@throws IOException if there is an error creating required fields + ///@throws IllegalStateException if one attempts to add several signature + /// fields. + void addSignature$1( + jni$_.JObject? sigObject, + jni$_.JObject? options, ) { - final _$file = file?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - return _load$2(_class.reference.pointer, _id_load$2 as jni$_.JMethodIDPtr, - _$file.pointer, _$password.pointer) - .object(const $PDDocument$NullableType$()); + final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + _addSignature$1(reference.pointer, _id_addSignature$1.pointer, + _$sigObject.pointer, _$options.pointer) + .check(); } - static final _id_load$3 = _class.staticMethodId( - r'load', - r'(Ljava/io/File;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_addSignature$2 = PDDocument._class.instanceMethodId( + r'addSignature', + r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;)V', ); - static final _load$3 = jni$_.ProtectedJniExtensions.lookup< + static final _addSignature$2 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( - jni$_.Pointer, jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + )>)>>('globalEnv_CallVoidMethod') .asFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, - jni$_.Pointer, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signatureInterface)` /// - /// Parses a PDF. - ///@param file file to be loaded - ///@param password password to be used for decryption - ///@param memUsageSetting defines how memory is used for buffering PDF streams - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException in case of a file reading or parsing error - static PDDocument? load$3( - jni$_.JObject? file, - jni$_.JString? password, - jni$_.JObject? memUsageSetting, + /// Add a signature to be created using the instance of given interface. + /// + /// Only one signature may be added in a document. To sign several times, + /// load document, add signature, save incremental and close again. + ///@param sigObject is the PDSignatureField model + ///@param signatureInterface is an interface whose implementation provides + /// signing capabilities. Can be null if external signing if used. + ///@throws IOException if there is an error creating required fields + ///@throws IllegalStateException if one attempts to add several signature + /// fields. + void addSignature$2( + jni$_.JObject? sigObject, + jni$_.JObject? signatureInterface, ) { - final _$file = file?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$memUsageSetting = - memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$3(_class.reference.pointer, _id_load$3 as jni$_.JMethodIDPtr, - _$file.pointer, _$password.pointer, _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; + final _$signatureInterface = + signatureInterface?.reference ?? jni$_.jNullReference; + _addSignature$2(reference.pointer, _id_addSignature$2.pointer, + _$sigObject.pointer, _$signatureInterface.pointer) + .check(); } - static final _id_load$4 = _class.staticMethodId( - r'load', - r'(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_addSignature$3 = PDDocument._class.instanceMethodId( + r'addSignature', + r'(Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V', ); - static final _load$4 = jni$_.ProtectedJniExtensions.lookup< + static final _addSignature$3 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( - jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + )>)>>('globalEnv_CallVoidMethod') .asFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer, - jni$_.Pointer, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public void addSignature(org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature sigObject, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signatureInterface, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions options)` /// - /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. - ///@param file file to be loaded - ///@param password password to be used for decryption - ///@param keyStore key store to be used for decryption when using public key security - ///@param alias alias to be used for decryption when using public key security - ///@return loaded document - ///@throws IOException in case of a file reading or parsing error - static PDDocument? load$4( - jni$_.JObject? file, - jni$_.JString? password, - jni$_.JObject? keyStore, - jni$_.JString? alias, + /// This will add a signature to the document. If the 0-based page number in the options + /// parameter is smaller than 0 or larger than max, the nearest valid page number will be used + /// (i.e. 0 or max) and no exception will be thrown. + /// + /// Only one signature may be added in a document. To sign several times, + /// load document, add signature, save incremental and close again. + ///@param sigObject is the PDSignatureField model + ///@param signatureInterface is an interface whose implementation provides + /// signing capabilities. Can be null if external signing if used. + ///@param options signature options + ///@throws IOException if there is an error creating required fields + ///@throws IllegalStateException if one attempts to add several signature + /// fields. + void addSignature$3( + jni$_.JObject? sigObject, + jni$_.JObject? signatureInterface, + jni$_.JObject? options, ) { - final _$file = file?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; - final _$alias = alias?.reference ?? jni$_.jNullReference; - return _load$4( - _class.reference.pointer, - _id_load$4 as jni$_.JMethodIDPtr, - _$file.pointer, - _$password.pointer, - _$keyStore.pointer, - _$alias.pointer) - .object(const $PDDocument$NullableType$()); + final _$sigObject = sigObject?.reference ?? jni$_.jNullReference; + final _$signatureInterface = + signatureInterface?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + _addSignature$3( + reference.pointer, + _id_addSignature$3.pointer, + _$sigObject.pointer, + _$signatureInterface.pointer, + _$options.pointer) + .check(); } - static final _id_load$5 = _class.staticMethodId( - r'load', - r'(Ljava/io/File;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_addSignatureField = PDDocument._class.instanceMethodId( + r'addSignatureField', + r'(Ljava/util/List;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureInterface;Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/SignatureOptions;)V', ); - static final _load$5 = jni$_.ProtectedJniExtensions.lookup< + static final _addSignatureField = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs< ( - jni$_.Pointer, - jni$_.Pointer, jni$_.Pointer, jni$_.Pointer, jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + )>)>>('globalEnv_CallVoidMethod') .asFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.File file, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public void addSignatureField(java.util.List sigFields, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureInterface signatureInterface, org.apache.pdfbox.pdmodel.interactive.digitalsignature.SignatureOptions options)` /// - /// Parses a PDF. - ///@param file file to be loaded - ///@param password password to be used for decryption - ///@param keyStore key store to be used for decryption when using public key security - ///@param alias alias to be used for decryption when using public key security - ///@param memUsageSetting defines how memory is used for buffering PDF streams - ///@return loaded document - ///@throws IOException in case of a file reading or parsing error - static PDDocument? load$5( - jni$_.JObject? file, - jni$_.JString? password, - jni$_.JObject? keyStore, - jni$_.JString? alias, - jni$_.JObject? memUsageSetting, + /// This will add a list of signature fields to the document. + ///@param sigFields are the PDSignatureFields that should be added to the document + ///@param signatureInterface is an interface whose implementation provides + /// signing capabilities. Can be null if external signing if used. + ///@param options signature options + ///@throws IOException if there is an error creating required fields + ///@deprecated The method is misleading, because only one signature may be + /// added in a document. The method will be removed in the future. + void addSignatureField( + jni$_.JList? sigFields, + jni$_.JObject? signatureInterface, + jni$_.JObject? options, ) { - final _$file = file?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; - final _$alias = alias?.reference ?? jni$_.jNullReference; - final _$memUsageSetting = - memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$5( - _class.reference.pointer, - _id_load$5 as jni$_.JMethodIDPtr, - _$file.pointer, - _$password.pointer, - _$keyStore.pointer, - _$alias.pointer, - _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + final _$sigFields = sigFields?.reference ?? jni$_.jNullReference; + final _$signatureInterface = + signatureInterface?.reference ?? jni$_.jNullReference; + final _$options = options?.reference ?? jni$_.jNullReference; + _addSignatureField( + reference.pointer, + _id_addSignatureField.pointer, + _$sigFields.pointer, + _$signatureInterface.pointer, + _$options.pointer) + .check(); } - static final _id_load$6 = _class.staticMethodId( - r'load', - r'(Ljava/io/InputStream;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_removePage = PDDocument._class.instanceMethodId( + r'removePage', + r'(Lorg/apache/pdfbox/pdmodel/PDPage;)V', ); - static final _load$6 = jni$_.ProtectedJniExtensions.lookup< + static final _removePage = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void removePage(org.apache.pdfbox.pdmodel.PDPage page)` + /// + /// Remove the page from the document. + ///@param page The page to remove from the document. + void removePage( + jni$_.JObject? page, + ) { + final _$page = page?.reference ?? jni$_.jNullReference; + _removePage(reference.pointer, _id_removePage.pointer, _$page.pointer) + .check(); + } + + static final _id_removePage$1 = PDDocument._class.instanceMethodId( + r'removePage', + r'(I)V', + ); + + static final _removePage$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void removePage(int pageNumber)` + /// + /// Remove the page from the document. + ///@param pageNumber 0 based index to page number. + void removePage$1( + int pageNumber, + ) { + _removePage$1(reference.pointer, _id_removePage$1.pointer, pageNumber) + .check(); + } + + static final _id_importPage = PDDocument._class.instanceMethodId( + r'importPage', + r'(Lorg/apache/pdfbox/pdmodel/PDPage;)Lorg/apache/pdfbox/pdmodel/PDPage;', + ); + + static final _importPage = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallStaticObjectMethod') + 'globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input)` + /// from: `public org.apache.pdfbox.pdmodel.PDPage importPage(org.apache.pdfbox.pdmodel.PDPage page)` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. The given input stream is copied to the memory to enable random access to the - /// pdf. Unrestricted main memory will be used for buffering PDF streams. - ///@param input stream that contains the document. Don't forget to close it after loading. - ///@return loaded document - ///@throws InvalidPasswordException If the PDF required a non-empty password. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$6( - jni$_.JObject? input, + /// This will import and copy the contents from another location. Currently the content stream is + /// stored in a scratch file. The scratch file is associated with the document. If you are adding + /// a page to this document from another document and want to copy the contents to this + /// document's scratch file then use this method otherwise just use the \#addPage addPage() + /// method. + /// + /// Unlike \#addPage addPage(), this method creates a new PDPage object. If your page has + /// annotations, and if these link to pages not in the target document, then the target document + /// might become huge. What you need to do is to delete page references of such annotations. See + /// here for how to do this. + /// + /// Inherited (global) resources are ignored because these can contain resources not needed for + /// this page which could bloat your document, see + /// PDFBOX-28 and related issues. + /// If you need them, call importedPage.setResources(page.getResources()); + /// + /// This method should only be used to import a page from a loaded document, not from a generated + /// document because these can contain unfinished parts, e.g. font subsetting information. + ///@param page The page to import. + ///@return The page that was imported. + ///@throws IOException If there is an error copying the page. + jni$_.JObject? importPage( + jni$_.JObject? page, ) { - final _$input = input?.reference ?? jni$_.jNullReference; - return _load$6(_class.reference.pointer, _id_load$6 as jni$_.JMethodIDPtr, - _$input.pointer) - .object(const $PDDocument$NullableType$()); + final _$page = page?.reference ?? jni$_.jNullReference; + return _importPage( + reference.pointer, _id_importPage.pointer, _$page.pointer) + .object(); } - static final _id_load$7 = _class.staticMethodId( - r'load', - r'(Ljava/io/InputStream;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_getDocument = PDDocument._class.instanceMethodId( + r'getDocument', + r'()Lorg/apache/pdfbox/cos/COSDocument;', ); - static final _load$7 = jni$_.ProtectedJniExtensions.lookup< + static final _getDocument = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// from: `public org.apache.pdfbox.cos.COSDocument getDocument()` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. Depending on the memory settings parameter the given input stream is either - /// copied to main memory or to a temporary file to enable random access to the pdf. - ///@param input stream that contains the document. Don't forget to close it after loading. - ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams - ///@return loaded document - ///@throws InvalidPasswordException If the PDF required a non-empty password. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$7( - jni$_.JObject? input, - jni$_.JObject? memUsageSetting, - ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$memUsageSetting = - memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$7(_class.reference.pointer, _id_load$7 as jni$_.JMethodIDPtr, - _$input.pointer, _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + /// This will get the low level document. + ///@return The document that this layer sits on top of. + jni$_.JObject? getDocument() { + return _getDocument(reference.pointer, _id_getDocument.pointer) + .object(); + } + + static final _id_getDocumentInformation = PDDocument._class.instanceMethodId( + r'getDocumentInformation', + r'()Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;', + ); + + static final _getDocumentInformation = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public org.apache.pdfbox.pdmodel.PDDocumentInformation getDocumentInformation()` + /// The returned object must be released after use, by calling the [release] method. + /// + /// This will get the document info dictionary. If it doesn't exist, an empty document info + /// dictionary is created in the document trailer. + /// + /// In PDF 2.0 this is deprecated except for two entries, /CreationDate and /ModDate. For any other + /// document level metadata, a metadata stream should be used instead, see + /// PDDocumentCatalog\#getMetadata(). + ///@return The documents /Info dictionary, never null. + pddocumentinformation$_.PDDocumentInformation? getDocumentInformation() { + return _getDocumentInformation( + reference.pointer, _id_getDocumentInformation.pointer) + .object(); } - static final _id_load$8 = _class.staticMethodId( - r'load', - r'(Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_setDocumentInformation = PDDocument._class.instanceMethodId( + r'setDocumentInformation', + r'(Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;)V', ); - static final _load$8 = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + static final _setDocumentInformation = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public void setDocumentInformation(org.apache.pdfbox.pdmodel.PDDocumentInformation info)` /// - /// Parses a PDF. The given input stream is copied to the memory to enable random access to the - /// pdf. Unrestricted main memory will be used for buffering PDF streams. - ///@param input stream that contains the document. Don't forget to close it after loading. - ///@param password password to be used for decryption - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$8( - jni$_.JObject? input, - jni$_.JString? password, + /// This will set the document information for this document. + /// + /// In PDF 2.0 this is deprecated except for two entries, /CreationDate and /ModDate. For any other + /// document level metadata, a metadata stream should be used instead, see + /// PDDocumentCatalog\#setMetadata(org.apache.pdfbox.pdmodel.common.PDMetadata) PDDocumentCatalog\#setMetadata(PDMetadata). + ///@param info The updated document information. + void setDocumentInformation( + pddocumentinformation$_.PDDocumentInformation? info, ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - return _load$8(_class.reference.pointer, _id_load$8 as jni$_.JMethodIDPtr, - _$input.pointer, _$password.pointer) - .object(const $PDDocument$NullableType$()); + final _$info = info?.reference ?? jni$_.jNullReference; + _setDocumentInformation(reference.pointer, + _id_setDocumentInformation.pointer, _$info.pointer) + .check(); } - static final _id_load$9 = _class.staticMethodId( - r'load', - r'(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_getDocumentCatalog = PDDocument._class.instanceMethodId( + r'getDocumentCatalog', + r'()Lorg/apache/pdfbox/pdmodel/PDDocumentCatalog;', ); - static final _load$9 = jni$_.ProtectedJniExtensions.lookup< + static final _getDocumentCatalog = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias)` + /// from: `public org.apache.pdfbox.pdmodel.PDDocumentCatalog getDocumentCatalog()` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. The given input stream is copied to the memory to enable random access to the - /// pdf. Unrestricted main memory will be used for buffering PDF streams. - ///@param input stream that contains the document. Don't forget to close it after loading. - ///@param password password to be used for decryption - ///@param keyStore key store to be used for decryption when using public key security - ///@param alias alias to be used for decryption when using public key security - ///@return loaded document - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$9( - jni$_.JObject? input, - jni$_.JString? password, - jni$_.JObject? keyStore, - jni$_.JString? alias, - ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; - final _$alias = alias?.reference ?? jni$_.jNullReference; - return _load$9( - _class.reference.pointer, - _id_load$9 as jni$_.JMethodIDPtr, - _$input.pointer, - _$password.pointer, - _$keyStore.pointer, - _$alias.pointer) - .object(const $PDDocument$NullableType$()); + /// This will get the document CATALOG. This is guaranteed to not return null. + ///@return The documents /Root dictionary + jni$_.JObject? getDocumentCatalog() { + return _getDocumentCatalog( + reference.pointer, _id_getDocumentCatalog.pointer) + .object(); } - static final _id_load$10 = _class.staticMethodId( - r'load', - r'(Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_isEncrypted = PDDocument._class.instanceMethodId( + r'isEncrypted', + r'()Z', ); - static final _load$10 = jni$_.ProtectedJniExtensions.lookup< + static final _isEncrypted = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public boolean isEncrypted()` /// - /// Parses a PDF. Depending on the memory settings parameter the given input stream is either - /// copied to main memory or to a temporary file to enable random access to the pdf. - ///@param input stream that contains the document. Don't forget to close it after loading. - ///@param password password to be used for decryption - ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$10( - jni$_.JObject? input, - jni$_.JString? password, - jni$_.JObject? memUsageSetting, - ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$memUsageSetting = - memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$10(_class.reference.pointer, _id_load$10 as jni$_.JMethodIDPtr, - _$input.pointer, _$password.pointer, _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + /// This will tell if this document is encrypted or not. + ///@return true If this document is encrypted. + core$_.bool isEncrypted() { + return _isEncrypted(reference.pointer, _id_isEncrypted.pointer).boolean; } - static final _id_load$11 = _class.staticMethodId( - r'load', - r'(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_getEncryption = PDDocument._class.instanceMethodId( + r'getEncryption', + r'()Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;', ); - static final _load$11 = jni$_.ProtectedJniExtensions.lookup< + static final _getEncryption = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(java.io.InputStream input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// from: `public org.apache.pdfbox.pdmodel.encryption.PDEncryption getEncryption()` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. Depending on the memory settings parameter the given input stream is either - /// copied to memory or to a temporary file to enable random access to the pdf. - ///@param input stream that contains the document. Don't forget to close it after loading. - ///@param password password to be used for decryption - ///@param keyStore key store to be used for decryption when using public key security - ///@param alias alias to be used for decryption when using public key security - ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$11( - jni$_.JObject? input, - jni$_.JString? password, - jni$_.JObject? keyStore, - jni$_.JString? alias, - jni$_.JObject? memUsageSetting, - ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; - final _$alias = alias?.reference ?? jni$_.jNullReference; - final _$memUsageSetting = - memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$11( - _class.reference.pointer, - _id_load$11 as jni$_.JMethodIDPtr, - _$input.pointer, - _$password.pointer, - _$keyStore.pointer, - _$alias.pointer, - _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + /// This will get the encryption dictionary for this document. This will still return the parameters if the document + /// was decrypted. As the encryption architecture in PDF documents is pluggable this returns an abstract class, + /// but the only supported subclass at this time is a + /// PDStandardEncryption object. + ///@return The encryption dictionary(most likely a PDStandardEncryption object) + jni$_.JObject? getEncryption() { + return _getEncryption(reference.pointer, _id_getEncryption.pointer) + .object(); } - static final _id_load$12 = _class.staticMethodId( - r'load', - r'([B)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_setEncryptionDictionary = PDDocument._class.instanceMethodId( + r'setEncryptionDictionary', + r'(Lorg/apache/pdfbox/pdmodel/encryption/PDEncryption;)V', ); - static final _load$12 = jni$_.ProtectedJniExtensions.lookup< + static final _setEncryptionDictionary = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JniResult Function( + jni$_.JThrowablePtr Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallStaticObjectMethod') + 'globalEnv_CallVoidMethod') .asFunction< - jni$_.JniResult Function(jni$_.Pointer, + jni$_.JThrowablePtr Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input)` - /// The returned object must be released after use, by calling the [release] method. + /// from: `public void setEncryptionDictionary(org.apache.pdfbox.pdmodel.encryption.PDEncryption encryption)` /// - /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. - ///@param input byte array that contains the document. - ///@return loaded document - ///@throws InvalidPasswordException If the PDF required a non-empty password. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$12( - jni$_.JByteArray? input, + /// This will set the encryption dictionary for this document. + ///@param encryption The encryption dictionary(most likely a PDStandardEncryption object) + ///@throws IOException If there is an error determining which security handler to use. + void setEncryptionDictionary( + jni$_.JObject? encryption, ) { - final _$input = input?.reference ?? jni$_.jNullReference; - return _load$12(_class.reference.pointer, _id_load$12 as jni$_.JMethodIDPtr, - _$input.pointer) - .object(const $PDDocument$NullableType$()); + final _$encryption = encryption?.reference ?? jni$_.jNullReference; + _setEncryptionDictionary(reference.pointer, + _id_setEncryptionDictionary.pointer, _$encryption.pointer) + .check(); } - static final _id_load$13 = _class.staticMethodId( - r'load', - r'([BLjava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_getLastSignatureDictionary = + PDDocument._class.instanceMethodId( + r'getLastSignatureDictionary', + r'()Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/PDSignature;', ); - static final _load$13 = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< + static final _getLastSignatureDictionary = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password)` + /// from: `public org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature getLastSignatureDictionary()` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. - ///@param input byte array that contains the document. - ///@param password password to be used for decryption - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$13( - jni$_.JByteArray? input, - jni$_.JString? password, - ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - return _load$13(_class.reference.pointer, _id_load$13 as jni$_.JMethodIDPtr, - _$input.pointer, _$password.pointer) - .object(const $PDDocument$NullableType$()); + /// This will return the last signature from the field tree. Note that this may not be the + /// last in time when empty signature fields are created first but signed after other fields. + ///@return the last signature as PDSignatureField. + ///@throws IOException if no document catalog can be found. + jni$_.JObject? getLastSignatureDictionary() { + return _getLastSignatureDictionary( + reference.pointer, _id_getLastSignatureDictionary.pointer) + .object(); } - static final _id_load$14 = _class.staticMethodId( - r'load', - r'([BLjava/lang/String;Ljava/io/InputStream;Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_getSignatureFields = PDDocument._class.instanceMethodId( + r'getSignatureFields', + r'()Ljava/util/List;', ); - static final _load$14 = jni$_.ProtectedJniExtensions.lookup< + static final _getSignatureFields = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias)` + /// from: `public java.util.List getSignatureFields()` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. Unrestricted main memory will be used for buffering PDF streams. - ///@param input byte array that contains the document. - ///@param password password to be used for decryption - ///@param keyStore key store to be used for decryption when using public key security - ///@param alias alias to be used for decryption when using public key security - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$14( - jni$_.JByteArray? input, - jni$_.JString? password, - jni$_.JObject? keyStore, - jni$_.JString? alias, - ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; - final _$alias = alias?.reference ?? jni$_.jNullReference; - return _load$14( - _class.reference.pointer, - _id_load$14 as jni$_.JMethodIDPtr, - _$input.pointer, - _$password.pointer, - _$keyStore.pointer, - _$alias.pointer) - .object(const $PDDocument$NullableType$()); + /// Retrieve all signature fields from the document. + ///@return a List of PDSignatureFields + ///@throws IOException if no document catalog can be found. + jni$_.JList? getSignatureFields() { + return _getSignatureFields( + reference.pointer, _id_getSignatureFields.pointer) + .object?>(); } - static final _id_load$15 = _class.staticMethodId( - r'load', - r'([BLjava/lang/String;Ljava/io/InputStream;Ljava/lang/String;Lorg/apache/pdfbox/io/MemoryUsageSetting;)Lorg/apache/pdfbox/pdmodel/PDDocument;', + static final _id_getSignatureDictionaries = + PDDocument._class.instanceMethodId( + r'getSignatureDictionaries', + r'()Ljava/util/List;', ); - static final _load$15 = jni$_.ProtectedJniExtensions.lookup< + static final _getSignatureDictionaries = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_CallStaticObjectMethod') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `static public org.apache.pdfbox.pdmodel.PDDocument load(byte[] input, java.lang.String password, java.io.InputStream keyStore, java.lang.String alias, org.apache.pdfbox.io.MemoryUsageSetting memUsageSetting)` + /// from: `public java.util.List getSignatureDictionaries()` /// The returned object must be released after use, by calling the [release] method. /// - /// Parses a PDF. - ///@param input byte array that contains the document. - ///@param password password to be used for decryption - ///@param keyStore key store to be used for decryption when using public key security - ///@param alias alias to be used for decryption when using public key security - ///@param memUsageSetting defines how memory is used for buffering input stream and PDF streams - ///@return loaded document - ///@throws InvalidPasswordException If the password is incorrect. - ///@throws IOException In case of a reading or parsing error. - static PDDocument? load$15( - jni$_.JByteArray? input, - jni$_.JString? password, - jni$_.JObject? keyStore, - jni$_.JString? alias, - jni$_.JObject? memUsageSetting, + /// Retrieve all signature dictionaries from the document. + ///@return a List of PDSignatureFields + ///@throws IOException if no document catalog can be found. + jni$_.JList? getSignatureDictionaries() { + return _getSignatureDictionaries( + reference.pointer, _id_getSignatureDictionaries.pointer) + .object?>(); + } + + static final _id_registerTrueTypeFontForClosing = + PDDocument._class.instanceMethodId( + r'registerTrueTypeFontForClosing', + r'(Lorg/apache/fontbox/ttf/TrueTypeFont;)V', + ); + + static final _registerTrueTypeFontForClosing = + jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public void registerTrueTypeFontForClosing(org.apache.fontbox.ttf.TrueTypeFont ttf)` + /// + /// For internal PDFBox use when creating PDF documents: register a TrueTypeFont to make sure it + /// is closed when the PDDocument is closed to avoid memory leaks. Users don't have to call this + /// method, it is done by the appropriate PDFont classes. + ///@param ttf + void registerTrueTypeFontForClosing( + jni$_.JObject? ttf, ) { - final _$input = input?.reference ?? jni$_.jNullReference; - final _$password = password?.reference ?? jni$_.jNullReference; - final _$keyStore = keyStore?.reference ?? jni$_.jNullReference; - final _$alias = alias?.reference ?? jni$_.jNullReference; - final _$memUsageSetting = - memUsageSetting?.reference ?? jni$_.jNullReference; - return _load$15( - _class.reference.pointer, - _id_load$15 as jni$_.JMethodIDPtr, - _$input.pointer, - _$password.pointer, - _$keyStore.pointer, - _$alias.pointer, - _$memUsageSetting.pointer) - .object(const $PDDocument$NullableType$()); + final _$ttf = ttf?.reference ?? jni$_.jNullReference; + _registerTrueTypeFontForClosing(reference.pointer, + _id_registerTrueTypeFontForClosing.pointer, _$ttf.pointer) + .check(); } - static final _id_save = _class.instanceMethodId( + static final _id_save = PDDocument._class.instanceMethodId( r'save', r'(Ljava/lang/String;)V', ); @@ -1769,11 +1730,10 @@ class PDDocument extends jni$_.JObject { jni$_.JString? fileName, ) { final _$fileName = fileName?.reference ?? jni$_.jNullReference; - _save(reference.pointer, _id_save as jni$_.JMethodIDPtr, _$fileName.pointer) - .check(); + _save(reference.pointer, _id_save.pointer, _$fileName.pointer).check(); } - static final _id_save$1 = _class.instanceMethodId( + static final _id_save$1 = PDDocument._class.instanceMethodId( r'save', r'(Ljava/io/File;)V', ); @@ -1802,11 +1762,10 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? file, ) { final _$file = file?.reference ?? jni$_.jNullReference; - _save$1(reference.pointer, _id_save$1 as jni$_.JMethodIDPtr, _$file.pointer) - .check(); + _save$1(reference.pointer, _id_save$1.pointer, _$file.pointer).check(); } - static final _id_save$2 = _class.instanceMethodId( + static final _id_save$2 = PDDocument._class.instanceMethodId( r'save', r'(Ljava/io/OutputStream;)V', ); @@ -1836,12 +1795,10 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? output, ) { final _$output = output?.reference ?? jni$_.jNullReference; - _save$2(reference.pointer, _id_save$2 as jni$_.JMethodIDPtr, - _$output.pointer) - .check(); + _save$2(reference.pointer, _id_save$2.pointer, _$output.pointer).check(); } - static final _id_saveIncremental = _class.instanceMethodId( + static final _id_saveIncremental = PDDocument._class.instanceMethodId( r'saveIncremental', r'(Ljava/io/OutputStream;)V', ); @@ -1876,12 +1833,12 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? output, ) { final _$output = output?.reference ?? jni$_.jNullReference; - _saveIncremental(reference.pointer, - _id_saveIncremental as jni$_.JMethodIDPtr, _$output.pointer) + _saveIncremental( + reference.pointer, _id_saveIncremental.pointer, _$output.pointer) .check(); } - static final _id_saveIncremental$1 = _class.instanceMethodId( + static final _id_saveIncremental$1 = PDDocument._class.instanceMethodId( r'saveIncremental', r'(Ljava/io/OutputStream;Ljava/util/Set;)V', ); @@ -1929,15 +1886,13 @@ class PDDocument extends jni$_.JObject { ) { final _$output = output?.reference ?? jni$_.jNullReference; final _$objectsToWrite = objectsToWrite?.reference ?? jni$_.jNullReference; - _saveIncremental$1( - reference.pointer, - _id_saveIncremental$1 as jni$_.JMethodIDPtr, - _$output.pointer, - _$objectsToWrite.pointer) + _saveIncremental$1(reference.pointer, _id_saveIncremental$1.pointer, + _$output.pointer, _$objectsToWrite.pointer) .check(); } - static final _id_saveIncrementalForExternalSigning = _class.instanceMethodId( + static final _id_saveIncrementalForExternalSigning = + PDDocument._class.instanceMethodId( r'saveIncrementalForExternalSigning', r'(Ljava/io/OutputStream;)Lorg/apache/pdfbox/pdmodel/interactive/digitalsignature/ExternalSigningSupport;', ); @@ -1998,14 +1953,12 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? output, ) { final _$output = output?.reference ?? jni$_.jNullReference; - return _saveIncrementalForExternalSigning( - reference.pointer, - _id_saveIncrementalForExternalSigning as jni$_.JMethodIDPtr, - _$output.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _saveIncrementalForExternalSigning(reference.pointer, + _id_saveIncrementalForExternalSigning.pointer, _$output.pointer) + .object(); } - static final _id_getPage = _class.instanceMethodId( + static final _id_getPage = PDDocument._class.instanceMethodId( r'getPage', r'(I)Lorg/apache/pdfbox/pdmodel/PDPage;', ); @@ -2033,12 +1986,11 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? getPage( int pageIndex, ) { - return _getPage( - reference.pointer, _id_getPage as jni$_.JMethodIDPtr, pageIndex) - .object(const jni$_.$JObject$NullableType$()); + return _getPage(reference.pointer, _id_getPage.pointer, pageIndex) + .object(); } - static final _id_getPages = _class.instanceMethodId( + static final _id_getPages = PDDocument._class.instanceMethodId( r'getPages', r'()Lorg/apache/pdfbox/pdmodel/PDPageTree;', ); @@ -2061,11 +2013,11 @@ class PDDocument extends jni$_.JObject { /// Returns the page tree. ///@return the page tree jni$_.JObject? getPages() { - return _getPages(reference.pointer, _id_getPages as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getPages(reference.pointer, _id_getPages.pointer) + .object(); } - static final _id_getNumberOfPages = _class.instanceMethodId( + static final _id_getNumberOfPages = PDDocument._class.instanceMethodId( r'getNumberOfPages', r'()I', ); @@ -2087,12 +2039,11 @@ class PDDocument extends jni$_.JObject { /// This will return the total page count of the PDF document. ///@return The total number of pages in the PDF document. int getNumberOfPages() { - return _getNumberOfPages( - reference.pointer, _id_getNumberOfPages as jni$_.JMethodIDPtr) + return _getNumberOfPages(reference.pointer, _id_getNumberOfPages.pointer) .integer; } - static final _id_close = _class.instanceMethodId( + static final _id_close = PDDocument._class.instanceMethodId( r'close', r'()V', ); @@ -2114,10 +2065,10 @@ class PDDocument extends jni$_.JObject { /// This will close the underlying COSDocument object. ///@throws IOException If there is an error releasing resources. void close() { - _close(reference.pointer, _id_close as jni$_.JMethodIDPtr).check(); + _close(reference.pointer, _id_close.pointer).check(); } - static final _id_protect = _class.instanceMethodId( + static final _id_protect = PDDocument._class.instanceMethodId( r'protect', r'(Lorg/apache/pdfbox/pdmodel/encryption/ProtectionPolicy;)V', ); @@ -2149,12 +2100,11 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? policy, ) { final _$policy = policy?.reference ?? jni$_.jNullReference; - _protect(reference.pointer, _id_protect as jni$_.JMethodIDPtr, - _$policy.pointer) - .check(); + _protect(reference.pointer, _id_protect.pointer, _$policy.pointer).check(); } - static final _id_getCurrentAccessPermission = _class.instanceMethodId( + static final _id_getCurrentAccessPermission = + PDDocument._class.instanceMethodId( r'getCurrentAccessPermission', r'()Lorg/apache/pdfbox/pdmodel/encryption/AccessPermission;', ); @@ -2181,12 +2131,13 @@ class PDDocument extends jni$_.JObject { /// to verify if the current user is allowed to proceed. ///@return the access permissions for the current user on the document. jni$_.JObject? getCurrentAccessPermission() { - return _getCurrentAccessPermission(reference.pointer, - _id_getCurrentAccessPermission as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getCurrentAccessPermission( + reference.pointer, _id_getCurrentAccessPermission.pointer) + .object(); } - static final _id_isAllSecurityToBeRemoved = _class.instanceMethodId( + static final _id_isAllSecurityToBeRemoved = + PDDocument._class.instanceMethodId( r'isAllSecurityToBeRemoved', r'()Z', ); @@ -2208,12 +2159,13 @@ class PDDocument extends jni$_.JObject { /// Indicates if all security is removed or not when writing the pdf. ///@return returns true if all security shall be removed otherwise false core$_.bool isAllSecurityToBeRemoved() { - return _isAllSecurityToBeRemoved(reference.pointer, - _id_isAllSecurityToBeRemoved as jni$_.JMethodIDPtr) + return _isAllSecurityToBeRemoved( + reference.pointer, _id_isAllSecurityToBeRemoved.pointer) .boolean; } - static final _id_setAllSecurityToBeRemoved = _class.instanceMethodId( + static final _id_setAllSecurityToBeRemoved = + PDDocument._class.instanceMethodId( r'setAllSecurityToBeRemoved', r'(Z)V', ); @@ -2235,14 +2187,12 @@ class PDDocument extends jni$_.JObject { void setAllSecurityToBeRemoved( core$_.bool removeAllSecurity, ) { - _setAllSecurityToBeRemoved( - reference.pointer, - _id_setAllSecurityToBeRemoved as jni$_.JMethodIDPtr, - removeAllSecurity ? 1 : 0) + _setAllSecurityToBeRemoved(reference.pointer, + _id_setAllSecurityToBeRemoved.pointer, removeAllSecurity ? 1 : 0) .check(); } - static final _id_getDocumentId = _class.instanceMethodId( + static final _id_getDocumentId = PDDocument._class.instanceMethodId( r'getDocumentId', r'()Ljava/lang/Long;', ); @@ -2265,12 +2215,11 @@ class PDDocument extends jni$_.JObject { /// Provides the document ID. ///@return the document ID jni$_.JLong? getDocumentId() { - return _getDocumentId( - reference.pointer, _id_getDocumentId as jni$_.JMethodIDPtr) - .object(const jni$_.$JLong$NullableType$()); + return _getDocumentId(reference.pointer, _id_getDocumentId.pointer) + .object(); } - static final _id_setDocumentId = _class.instanceMethodId( + static final _id_setDocumentId = PDDocument._class.instanceMethodId( r'setDocumentId', r'(Ljava/lang/Long;)V', ); @@ -2294,12 +2243,12 @@ class PDDocument extends jni$_.JObject { jni$_.JLong? docId, ) { final _$docId = docId?.reference ?? jni$_.jNullReference; - _setDocumentId(reference.pointer, _id_setDocumentId as jni$_.JMethodIDPtr, - _$docId.pointer) + _setDocumentId( + reference.pointer, _id_setDocumentId.pointer, _$docId.pointer) .check(); } - static final _id_getVersion = _class.instanceMethodId( + static final _id_getVersion = PDDocument._class.instanceMethodId( r'getVersion', r'()F', ); @@ -2321,11 +2270,10 @@ class PDDocument extends jni$_.JObject { /// Returns the PDF specification version this document conforms to. ///@return the PDF version (e.g. 1.4f) double getVersion() { - return _getVersion(reference.pointer, _id_getVersion as jni$_.JMethodIDPtr) - .float; + return _getVersion(reference.pointer, _id_getVersion.pointer).float; } - static final _id_setVersion = _class.instanceMethodId( + static final _id_setVersion = PDDocument._class.instanceMethodId( r'setVersion', r'(F)V', ); @@ -2347,12 +2295,10 @@ class PDDocument extends jni$_.JObject { void setVersion( double newVersion, ) { - _setVersion( - reference.pointer, _id_setVersion as jni$_.JMethodIDPtr, newVersion) - .check(); + _setVersion(reference.pointer, _id_setVersion.pointer, newVersion).check(); } - static final _id_getResourceCache = _class.instanceMethodId( + static final _id_getResourceCache = PDDocument._class.instanceMethodId( r'getResourceCache', r'()Lorg/apache/pdfbox/pdmodel/ResourceCache;', ); @@ -2375,12 +2321,11 @@ class PDDocument extends jni$_.JObject { /// Returns the resource cache associated with this document, or null if there is none. ///@return the resource cache or null. jni$_.JObject? getResourceCache() { - return _getResourceCache( - reference.pointer, _id_getResourceCache as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getResourceCache(reference.pointer, _id_getResourceCache.pointer) + .object(); } - static final _id_setResourceCache = _class.instanceMethodId( + static final _id_setResourceCache = PDDocument._class.instanceMethodId( r'setResourceCache', r'(Lorg/apache/pdfbox/pdmodel/ResourceCache;)V', ); @@ -2404,49 +2349,12 @@ class PDDocument extends jni$_.JObject { jni$_.JObject? resourceCache, ) { final _$resourceCache = resourceCache?.reference ?? jni$_.jNullReference; - _setResourceCache(reference.pointer, - _id_setResourceCache as jni$_.JMethodIDPtr, _$resourceCache.pointer) + _setResourceCache(reference.pointer, _id_setResourceCache.pointer, + _$resourceCache.pointer) .check(); } } -final class $PDDocument$NullableType$ extends jni$_.JType { - @jni$_.internal - const $PDDocument$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lorg/apache/pdfbox/pdmodel/PDDocument;'; - - @jni$_.internal - @core$_.override - PDDocument? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : PDDocument.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($PDDocument$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($PDDocument$NullableType$) && - other is $PDDocument$NullableType$; - } -} - final class $PDDocument$Type$ extends jni$_.JType { @jni$_.internal const $PDDocument$Type$(); @@ -2454,32 +2362,4 @@ final class $PDDocument$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lorg/apache/pdfbox/pdmodel/PDDocument;'; - - @jni$_.internal - @core$_.override - PDDocument fromReference(jni$_.JReference reference) => - PDDocument.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $PDDocument$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($PDDocument$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($PDDocument$Type$) && - other is $PDDocument$Type$; - } } diff --git a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocumentInformation.dart b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocumentInformation.dart index 2023c10520..147aa46b5c 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocumentInformation.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/PDDocumentInformation.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Generated from Apache PDFBox library which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. @@ -61,24 +61,11 @@ import 'package:jni/jni.dart' as jni$_; /// method then it will clear the value. ///@author Ben Litchfield ///@author Gerardo Ortiz -class PDDocumentInformation extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - PDDocumentInformation.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type PDDocumentInformation._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'org/apache/pdfbox/pdmodel/PDDocumentInformation'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $PDDocumentInformation$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $PDDocumentInformation$Type$(); @@ -103,9 +90,8 @@ class PDDocumentInformation extends jni$_.JObject { /// /// Default Constructor. factory PDDocumentInformation() { - return PDDocumentInformation.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_new$1 = _class.constructorId( @@ -132,12 +118,13 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JObject? dic, ) { final _$dic = dic?.reference ?? jni$_.jNullReference; - return PDDocumentInformation.fromReference(_new$1(_class.reference.pointer, - _id_new$1 as jni$_.JMethodIDPtr, _$dic.pointer) - .reference); + return _new$1(_class.reference.pointer, _id_new$1.pointer, _$dic.pointer) + .object(); } +} - static final _id_getCOSObject = _class.instanceMethodId( +extension PDDocumentInformation$$Methods on PDDocumentInformation { + static final _id_getCOSObject = PDDocumentInformation._class.instanceMethodId( r'getCOSObject', r'()Lorg/apache/pdfbox/cos/COSDictionary;', ); @@ -160,12 +147,12 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the underlying dictionary that this object wraps. ///@return The underlying info dictionary. jni$_.JObject? getCOSObject() { - return _getCOSObject( - reference.pointer, _id_getCOSObject as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getCOSObject(reference.pointer, _id_getCOSObject.pointer) + .object(); } - static final _id_getPropertyStringValue = _class.instanceMethodId( + static final _id_getPropertyStringValue = + PDDocumentInformation._class.instanceMethodId( r'getPropertyStringValue', r'(Ljava/lang/String;)Ljava/lang/Object;', ); @@ -196,14 +183,12 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? propertyKey, ) { final _$propertyKey = propertyKey?.reference ?? jni$_.jNullReference; - return _getPropertyStringValue( - reference.pointer, - _id_getPropertyStringValue as jni$_.JMethodIDPtr, - _$propertyKey.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _getPropertyStringValue(reference.pointer, + _id_getPropertyStringValue.pointer, _$propertyKey.pointer) + .object(); } - static final _id_getTitle = _class.instanceMethodId( + static final _id_getTitle = PDDocumentInformation._class.instanceMethodId( r'getTitle', r'()Ljava/lang/String;', ); @@ -226,11 +211,11 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the title of the document. This will return null if no title exists. ///@return The title of the document. jni$_.JString? getTitle() { - return _getTitle(reference.pointer, _id_getTitle as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getTitle(reference.pointer, _id_getTitle.pointer) + .object(); } - static final _id_setTitle = _class.instanceMethodId( + static final _id_setTitle = PDDocumentInformation._class.instanceMethodId( r'setTitle', r'(Ljava/lang/String;)V', ); @@ -254,12 +239,10 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? title, ) { final _$title = title?.reference ?? jni$_.jNullReference; - _setTitle(reference.pointer, _id_setTitle as jni$_.JMethodIDPtr, - _$title.pointer) - .check(); + _setTitle(reference.pointer, _id_setTitle.pointer, _$title.pointer).check(); } - static final _id_getAuthor = _class.instanceMethodId( + static final _id_getAuthor = PDDocumentInformation._class.instanceMethodId( r'getAuthor', r'()Ljava/lang/String;', ); @@ -282,11 +265,11 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the author of the document. This will return null if no author exists. ///@return The author of the document. jni$_.JString? getAuthor() { - return _getAuthor(reference.pointer, _id_getAuthor as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getAuthor(reference.pointer, _id_getAuthor.pointer) + .object(); } - static final _id_setAuthor = _class.instanceMethodId( + static final _id_setAuthor = PDDocumentInformation._class.instanceMethodId( r'setAuthor', r'(Ljava/lang/String;)V', ); @@ -310,12 +293,11 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? author, ) { final _$author = author?.reference ?? jni$_.jNullReference; - _setAuthor(reference.pointer, _id_setAuthor as jni$_.JMethodIDPtr, - _$author.pointer) + _setAuthor(reference.pointer, _id_setAuthor.pointer, _$author.pointer) .check(); } - static final _id_getSubject = _class.instanceMethodId( + static final _id_getSubject = PDDocumentInformation._class.instanceMethodId( r'getSubject', r'()Ljava/lang/String;', ); @@ -338,11 +320,11 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the subject of the document. This will return null if no subject exists. ///@return The subject of the document. jni$_.JString? getSubject() { - return _getSubject(reference.pointer, _id_getSubject as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getSubject(reference.pointer, _id_getSubject.pointer) + .object(); } - static final _id_setSubject = _class.instanceMethodId( + static final _id_setSubject = PDDocumentInformation._class.instanceMethodId( r'setSubject', r'(Ljava/lang/String;)V', ); @@ -366,12 +348,11 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? subject, ) { final _$subject = subject?.reference ?? jni$_.jNullReference; - _setSubject(reference.pointer, _id_setSubject as jni$_.JMethodIDPtr, - _$subject.pointer) + _setSubject(reference.pointer, _id_setSubject.pointer, _$subject.pointer) .check(); } - static final _id_getKeywords = _class.instanceMethodId( + static final _id_getKeywords = PDDocumentInformation._class.instanceMethodId( r'getKeywords', r'()Ljava/lang/String;', ); @@ -394,12 +375,11 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the keywords of the document. This will return null if no keywords exists. ///@return The keywords of the document. jni$_.JString? getKeywords() { - return _getKeywords( - reference.pointer, _id_getKeywords as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getKeywords(reference.pointer, _id_getKeywords.pointer) + .object(); } - static final _id_setKeywords = _class.instanceMethodId( + static final _id_setKeywords = PDDocumentInformation._class.instanceMethodId( r'setKeywords', r'(Ljava/lang/String;)V', ); @@ -423,12 +403,11 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? keywords, ) { final _$keywords = keywords?.reference ?? jni$_.jNullReference; - _setKeywords(reference.pointer, _id_setKeywords as jni$_.JMethodIDPtr, - _$keywords.pointer) + _setKeywords(reference.pointer, _id_setKeywords.pointer, _$keywords.pointer) .check(); } - static final _id_getCreator = _class.instanceMethodId( + static final _id_getCreator = PDDocumentInformation._class.instanceMethodId( r'getCreator', r'()Ljava/lang/String;', ); @@ -451,11 +430,11 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the creator of the document. This will return null if no creator exists. ///@return The creator of the document. jni$_.JString? getCreator() { - return _getCreator(reference.pointer, _id_getCreator as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getCreator(reference.pointer, _id_getCreator.pointer) + .object(); } - static final _id_setCreator = _class.instanceMethodId( + static final _id_setCreator = PDDocumentInformation._class.instanceMethodId( r'setCreator', r'(Ljava/lang/String;)V', ); @@ -479,12 +458,11 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? creator, ) { final _$creator = creator?.reference ?? jni$_.jNullReference; - _setCreator(reference.pointer, _id_setCreator as jni$_.JMethodIDPtr, - _$creator.pointer) + _setCreator(reference.pointer, _id_setCreator.pointer, _$creator.pointer) .check(); } - static final _id_getProducer = _class.instanceMethodId( + static final _id_getProducer = PDDocumentInformation._class.instanceMethodId( r'getProducer', r'()Ljava/lang/String;', ); @@ -507,12 +485,11 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the producer of the document. This will return null if no producer exists. ///@return The producer of the document. jni$_.JString? getProducer() { - return _getProducer( - reference.pointer, _id_getProducer as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getProducer(reference.pointer, _id_getProducer.pointer) + .object(); } - static final _id_setProducer = _class.instanceMethodId( + static final _id_setProducer = PDDocumentInformation._class.instanceMethodId( r'setProducer', r'(Ljava/lang/String;)V', ); @@ -536,12 +513,12 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? producer, ) { final _$producer = producer?.reference ?? jni$_.jNullReference; - _setProducer(reference.pointer, _id_setProducer as jni$_.JMethodIDPtr, - _$producer.pointer) + _setProducer(reference.pointer, _id_setProducer.pointer, _$producer.pointer) .check(); } - static final _id_getCreationDate = _class.instanceMethodId( + static final _id_getCreationDate = + PDDocumentInformation._class.instanceMethodId( r'getCreationDate', r'()Ljava/util/Calendar;', ); @@ -564,12 +541,12 @@ class PDDocumentInformation extends jni$_.JObject { /// This will get the creation date of the document. This will return null if no creation date exists. ///@return The creation date of the document. jni$_.JObject? getCreationDate() { - return _getCreationDate( - reference.pointer, _id_getCreationDate as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getCreationDate(reference.pointer, _id_getCreationDate.pointer) + .object(); } - static final _id_setCreationDate = _class.instanceMethodId( + static final _id_setCreationDate = + PDDocumentInformation._class.instanceMethodId( r'setCreationDate', r'(Ljava/util/Calendar;)V', ); @@ -593,12 +570,13 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JObject? date, ) { final _$date = date?.reference ?? jni$_.jNullReference; - _setCreationDate(reference.pointer, - _id_setCreationDate as jni$_.JMethodIDPtr, _$date.pointer) + _setCreationDate( + reference.pointer, _id_setCreationDate.pointer, _$date.pointer) .check(); } - static final _id_getModificationDate = _class.instanceMethodId( + static final _id_getModificationDate = + PDDocumentInformation._class.instanceMethodId( r'getModificationDate', r'()Ljava/util/Calendar;', ); @@ -622,11 +600,12 @@ class PDDocumentInformation extends jni$_.JObject { ///@return The modification date of the document. jni$_.JObject? getModificationDate() { return _getModificationDate( - reference.pointer, _id_getModificationDate as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_getModificationDate.pointer) + .object(); } - static final _id_setModificationDate = _class.instanceMethodId( + static final _id_setModificationDate = + PDDocumentInformation._class.instanceMethodId( r'setModificationDate', r'(Ljava/util/Calendar;)V', ); @@ -650,12 +629,12 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JObject? date, ) { final _$date = date?.reference ?? jni$_.jNullReference; - _setModificationDate(reference.pointer, - _id_setModificationDate as jni$_.JMethodIDPtr, _$date.pointer) + _setModificationDate( + reference.pointer, _id_setModificationDate.pointer, _$date.pointer) .check(); } - static final _id_getTrapped = _class.instanceMethodId( + static final _id_getTrapped = PDDocumentInformation._class.instanceMethodId( r'getTrapped', r'()Ljava/lang/String;', ); @@ -679,11 +658,12 @@ class PDDocumentInformation extends jni$_.JObject { /// This will return null if one is not found. ///@return The trapped value for the document. jni$_.JString? getTrapped() { - return _getTrapped(reference.pointer, _id_getTrapped as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getTrapped(reference.pointer, _id_getTrapped.pointer) + .object(); } - static final _id_getMetadataKeys = _class.instanceMethodId( + static final _id_getMetadataKeys = + PDDocumentInformation._class.instanceMethodId( r'getMetadataKeys', r'()Ljava/util/Set;', ); @@ -707,14 +687,12 @@ class PDDocumentInformation extends jni$_.JObject { ///@return all metadata key strings. ///@since Apache PDFBox 1.3.0 jni$_.JSet? getMetadataKeys() { - return _getMetadataKeys( - reference.pointer, _id_getMetadataKeys as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JSet$NullableType$( - jni$_.$JString$NullableType$())); + return _getMetadataKeys(reference.pointer, _id_getMetadataKeys.pointer) + .object?>(); } - static final _id_getCustomMetadataValue = _class.instanceMethodId( + static final _id_getCustomMetadataValue = + PDDocumentInformation._class.instanceMethodId( r'getCustomMetadataValue', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -741,14 +719,13 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? fieldName, ) { final _$fieldName = fieldName?.reference ?? jni$_.jNullReference; - return _getCustomMetadataValue( - reference.pointer, - _id_getCustomMetadataValue as jni$_.JMethodIDPtr, - _$fieldName.pointer) - .object(const jni$_.$JString$NullableType$()); + return _getCustomMetadataValue(reference.pointer, + _id_getCustomMetadataValue.pointer, _$fieldName.pointer) + .object(); } - static final _id_setCustomMetadataValue = _class.instanceMethodId( + static final _id_setCustomMetadataValue = + PDDocumentInformation._class.instanceMethodId( r'setCustomMetadataValue', r'(Ljava/lang/String;Ljava/lang/String;)V', ); @@ -783,13 +760,13 @@ class PDDocumentInformation extends jni$_.JObject { final _$fieldValue = fieldValue?.reference ?? jni$_.jNullReference; _setCustomMetadataValue( reference.pointer, - _id_setCustomMetadataValue as jni$_.JMethodIDPtr, + _id_setCustomMetadataValue.pointer, _$fieldName.pointer, _$fieldValue.pointer) .check(); } - static final _id_setTrapped = _class.instanceMethodId( + static final _id_setTrapped = PDDocumentInformation._class.instanceMethodId( r'setTrapped', r'(Ljava/lang/String;)V', ); @@ -815,51 +792,11 @@ class PDDocumentInformation extends jni$_.JObject { jni$_.JString? value, ) { final _$value = value?.reference ?? jni$_.jNullReference; - _setTrapped(reference.pointer, _id_setTrapped as jni$_.JMethodIDPtr, - _$value.pointer) + _setTrapped(reference.pointer, _id_setTrapped.pointer, _$value.pointer) .check(); } } -final class $PDDocumentInformation$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $PDDocumentInformation$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;'; - - @jni$_.internal - @core$_.override - PDDocumentInformation? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : PDDocumentInformation.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($PDDocumentInformation$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($PDDocumentInformation$NullableType$) && - other is $PDDocumentInformation$NullableType$; - } -} - final class $PDDocumentInformation$Type$ extends jni$_.JType { @jni$_.internal @@ -868,32 +805,4 @@ final class $PDDocumentInformation$Type$ @jni$_.internal @core$_.override String get signature => r'Lorg/apache/pdfbox/pdmodel/PDDocumentInformation;'; - - @jni$_.internal - @core$_.override - PDDocumentInformation fromReference(jni$_.JReference reference) => - PDDocumentInformation.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $PDDocumentInformation$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($PDDocumentInformation$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($PDDocumentInformation$Type$) && - other is $PDDocumentInformation$Type$; - } } diff --git a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/_package.dart b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/_package.dart index 1a77d350a1..f715e26637 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/_package.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/pdmodel/_package.dart @@ -1,3 +1,3 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! export 'PDDocument.dart'; export 'PDDocumentInformation.dart'; diff --git a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/PDFTextStripper.dart b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/PDFTextStripper.dart index d261e65c10..5f99b4f17e 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/PDFTextStripper.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/PDFTextStripper.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Generated from Apache PDFBox library which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. @@ -65,24 +65,11 @@ import '../pdmodel/PDDocument.dart' as pddocument$_; /// The basic flow of this process is that we get a document and use a series of processXXX() functions that work on /// smaller and smaller chunks of the page. Eventually, we fully process each page and then print it. ///@author Ben Litchfield -class PDFTextStripper extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - PDFTextStripper.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type PDFTextStripper._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'org/apache/pdfbox/text/PDFTextStripper'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $PDFTextStripper$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $PDFTextStripper$Type$(); static final _id_new$ = _class.constructorId( @@ -107,12 +94,13 @@ class PDFTextStripper extends jni$_.JObject { /// Instantiate a new PDFTextStripper object. ///@throws IOException If there is an error loading the properties. factory PDFTextStripper() { - return PDFTextStripper.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } +} - static final _id_getText = _class.instanceMethodId( +extension PDFTextStripper$$Methods on PDFTextStripper { + static final _id_getText = PDFTextStripper._class.instanceMethodId( r'getText', r'(Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;', ); @@ -145,12 +133,11 @@ class PDFTextStripper extends jni$_.JObject { pddocument$_.PDDocument? doc, ) { final _$doc = doc?.reference ?? jni$_.jNullReference; - return _getText( - reference.pointer, _id_getText as jni$_.JMethodIDPtr, _$doc.pointer) - .object(const jni$_.$JString$NullableType$()); + return _getText(reference.pointer, _id_getText.pointer, _$doc.pointer) + .object(); } - static final _id_writeText = _class.instanceMethodId( + static final _id_writeText = PDFTextStripper._class.instanceMethodId( r'writeText', r'(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/io/Writer;)V', ); @@ -184,12 +171,12 @@ class PDFTextStripper extends jni$_.JObject { ) { final _$doc = doc?.reference ?? jni$_.jNullReference; final _$outputStream = outputStream?.reference ?? jni$_.jNullReference; - _writeText(reference.pointer, _id_writeText as jni$_.JMethodIDPtr, - _$doc.pointer, _$outputStream.pointer) + _writeText(reference.pointer, _id_writeText.pointer, _$doc.pointer, + _$outputStream.pointer) .check(); } - static final _id_processPage = _class.instanceMethodId( + static final _id_processPage = PDFTextStripper._class.instanceMethodId( r'processPage', r'(Lorg/apache/pdfbox/pdmodel/PDPage;)V', ); @@ -214,12 +201,11 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JObject? page, ) { final _$page = page?.reference ?? jni$_.jNullReference; - _processPage(reference.pointer, _id_processPage as jni$_.JMethodIDPtr, - _$page.pointer) + _processPage(reference.pointer, _id_processPage.pointer, _$page.pointer) .check(); } - static final _id_getStartPage = _class.instanceMethodId( + static final _id_getStartPage = PDFTextStripper._class.instanceMethodId( r'getStartPage', r'()I', ); @@ -243,12 +229,10 @@ class PDFTextStripper extends jni$_.JObject { /// be extracted. The default value is 1. ///@return Value of property startPage. int getStartPage() { - return _getStartPage( - reference.pointer, _id_getStartPage as jni$_.JMethodIDPtr) - .integer; + return _getStartPage(reference.pointer, _id_getStartPage.pointer).integer; } - static final _id_setStartPage = _class.instanceMethodId( + static final _id_setStartPage = PDFTextStripper._class.instanceMethodId( r'setStartPage', r'(I)V', ); @@ -270,12 +254,11 @@ class PDFTextStripper extends jni$_.JObject { void setStartPage( int startPageValue, ) { - _setStartPage(reference.pointer, _id_setStartPage as jni$_.JMethodIDPtr, - startPageValue) + _setStartPage(reference.pointer, _id_setStartPage.pointer, startPageValue) .check(); } - static final _id_getEndPage = _class.instanceMethodId( + static final _id_getEndPage = PDFTextStripper._class.instanceMethodId( r'getEndPage', r'()I', ); @@ -299,11 +282,10 @@ class PDFTextStripper extends jni$_.JObject { /// Integer.MAX_VALUE such that all pages of the pdf will be extracted. ///@return Value of property endPage. int getEndPage() { - return _getEndPage(reference.pointer, _id_getEndPage as jni$_.JMethodIDPtr) - .integer; + return _getEndPage(reference.pointer, _id_getEndPage.pointer).integer; } - static final _id_setEndPage = _class.instanceMethodId( + static final _id_setEndPage = PDFTextStripper._class.instanceMethodId( r'setEndPage', r'(I)V', ); @@ -325,12 +307,11 @@ class PDFTextStripper extends jni$_.JObject { void setEndPage( int endPageValue, ) { - _setEndPage(reference.pointer, _id_setEndPage as jni$_.JMethodIDPtr, - endPageValue) + _setEndPage(reference.pointer, _id_setEndPage.pointer, endPageValue) .check(); } - static final _id_setLineSeparator = _class.instanceMethodId( + static final _id_setLineSeparator = PDFTextStripper._class.instanceMethodId( r'setLineSeparator', r'(Ljava/lang/String;)V', ); @@ -355,12 +336,12 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JString? separator, ) { final _$separator = separator?.reference ?? jni$_.jNullReference; - _setLineSeparator(reference.pointer, - _id_setLineSeparator as jni$_.JMethodIDPtr, _$separator.pointer) + _setLineSeparator(reference.pointer, _id_setLineSeparator.pointer, + _$separator.pointer) .check(); } - static final _id_getLineSeparator = _class.instanceMethodId( + static final _id_getLineSeparator = PDFTextStripper._class.instanceMethodId( r'getLineSeparator', r'()Ljava/lang/String;', ); @@ -383,12 +364,11 @@ class PDFTextStripper extends jni$_.JObject { /// This will get the line separator. ///@return The desired line separator string. jni$_.JString? getLineSeparator() { - return _getLineSeparator( - reference.pointer, _id_getLineSeparator as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getLineSeparator(reference.pointer, _id_getLineSeparator.pointer) + .object(); } - static final _id_getWordSeparator = _class.instanceMethodId( + static final _id_getWordSeparator = PDFTextStripper._class.instanceMethodId( r'getWordSeparator', r'()Ljava/lang/String;', ); @@ -411,12 +391,11 @@ class PDFTextStripper extends jni$_.JObject { /// This will get the word separator. ///@return The desired word separator string. jni$_.JString? getWordSeparator() { - return _getWordSeparator( - reference.pointer, _id_getWordSeparator as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getWordSeparator(reference.pointer, _id_getWordSeparator.pointer) + .object(); } - static final _id_setWordSeparator = _class.instanceMethodId( + static final _id_setWordSeparator = PDFTextStripper._class.instanceMethodId( r'setWordSeparator', r'(Ljava/lang/String;)V', ); @@ -443,13 +422,13 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JString? separator, ) { final _$separator = separator?.reference ?? jni$_.jNullReference; - _setWordSeparator(reference.pointer, - _id_setWordSeparator as jni$_.JMethodIDPtr, _$separator.pointer) + _setWordSeparator(reference.pointer, _id_setWordSeparator.pointer, + _$separator.pointer) .check(); } static final _id_getSuppressDuplicateOverlappingText = - _class.instanceMethodId( + PDFTextStripper._class.instanceMethodId( r'getSuppressDuplicateOverlappingText', r'()Z', ); @@ -471,13 +450,13 @@ class PDFTextStripper extends jni$_.JObject { /// /// @return Returns the suppressDuplicateOverlappingText. core$_.bool getSuppressDuplicateOverlappingText() { - return _getSuppressDuplicateOverlappingText(reference.pointer, - _id_getSuppressDuplicateOverlappingText as jni$_.JMethodIDPtr) + return _getSuppressDuplicateOverlappingText( + reference.pointer, _id_getSuppressDuplicateOverlappingText.pointer) .boolean; } static final _id_setSuppressDuplicateOverlappingText = - _class.instanceMethodId( + PDFTextStripper._class.instanceMethodId( r'setSuppressDuplicateOverlappingText', r'(Z)V', ); @@ -503,12 +482,12 @@ class PDFTextStripper extends jni$_.JObject { ) { _setSuppressDuplicateOverlappingText( reference.pointer, - _id_setSuppressDuplicateOverlappingText as jni$_.JMethodIDPtr, + _id_setSuppressDuplicateOverlappingText.pointer, suppressDuplicateOverlappingTextValue ? 1 : 0) .check(); } - static final _id_getSeparateByBeads = _class.instanceMethodId( + static final _id_getSeparateByBeads = PDFTextStripper._class.instanceMethodId( r'getSeparateByBeads', r'()Z', ); @@ -531,11 +510,12 @@ class PDFTextStripper extends jni$_.JObject { ///@return If the text will be grouped by beads. core$_.bool getSeparateByBeads() { return _getSeparateByBeads( - reference.pointer, _id_getSeparateByBeads as jni$_.JMethodIDPtr) + reference.pointer, _id_getSeparateByBeads.pointer) .boolean; } - static final _id_setShouldSeparateByBeads = _class.instanceMethodId( + static final _id_setShouldSeparateByBeads = + PDFTextStripper._class.instanceMethodId( r'setShouldSeparateByBeads', r'(Z)V', ); @@ -559,12 +539,12 @@ class PDFTextStripper extends jni$_.JObject { ) { _setShouldSeparateByBeads( reference.pointer, - _id_setShouldSeparateByBeads as jni$_.JMethodIDPtr, + _id_setShouldSeparateByBeads.pointer, aShouldSeparateByBeads ? 1 : 0) .check(); } - static final _id_getEndBookmark = _class.instanceMethodId( + static final _id_getEndBookmark = PDFTextStripper._class.instanceMethodId( r'getEndBookmark', r'()Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;', ); @@ -587,12 +567,11 @@ class PDFTextStripper extends jni$_.JObject { /// Get the bookmark where text extraction should end, inclusive. Default is null. ///@return The ending bookmark. jni$_.JObject? getEndBookmark() { - return _getEndBookmark( - reference.pointer, _id_getEndBookmark as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getEndBookmark(reference.pointer, _id_getEndBookmark.pointer) + .object(); } - static final _id_setEndBookmark = _class.instanceMethodId( + static final _id_setEndBookmark = PDFTextStripper._class.instanceMethodId( r'setEndBookmark', r'(Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;)V', ); @@ -616,12 +595,12 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JObject? aEndBookmark, ) { final _$aEndBookmark = aEndBookmark?.reference ?? jni$_.jNullReference; - _setEndBookmark(reference.pointer, _id_setEndBookmark as jni$_.JMethodIDPtr, + _setEndBookmark(reference.pointer, _id_setEndBookmark.pointer, _$aEndBookmark.pointer) .check(); } - static final _id_getStartBookmark = _class.instanceMethodId( + static final _id_getStartBookmark = PDFTextStripper._class.instanceMethodId( r'getStartBookmark', r'()Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;', ); @@ -644,12 +623,11 @@ class PDFTextStripper extends jni$_.JObject { /// Get the bookmark where text extraction should start, inclusive. Default is null. ///@return The starting bookmark. jni$_.JObject? getStartBookmark() { - return _getStartBookmark( - reference.pointer, _id_getStartBookmark as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getStartBookmark(reference.pointer, _id_getStartBookmark.pointer) + .object(); } - static final _id_setStartBookmark = _class.instanceMethodId( + static final _id_setStartBookmark = PDFTextStripper._class.instanceMethodId( r'setStartBookmark', r'(Lorg/apache/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem;)V', ); @@ -673,14 +651,13 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JObject? aStartBookmark, ) { final _$aStartBookmark = aStartBookmark?.reference ?? jni$_.jNullReference; - _setStartBookmark( - reference.pointer, - _id_setStartBookmark as jni$_.JMethodIDPtr, + _setStartBookmark(reference.pointer, _id_setStartBookmark.pointer, _$aStartBookmark.pointer) .check(); } - static final _id_getAddMoreFormatting = _class.instanceMethodId( + static final _id_getAddMoreFormatting = + PDFTextStripper._class.instanceMethodId( r'getAddMoreFormatting', r'()Z', ); @@ -703,11 +680,12 @@ class PDFTextStripper extends jni$_.JObject { ///@return true if some more text formatting will be added core$_.bool getAddMoreFormatting() { return _getAddMoreFormatting( - reference.pointer, _id_getAddMoreFormatting as jni$_.JMethodIDPtr) + reference.pointer, _id_getAddMoreFormatting.pointer) .boolean; } - static final _id_setAddMoreFormatting = _class.instanceMethodId( + static final _id_setAddMoreFormatting = + PDFTextStripper._class.instanceMethodId( r'setAddMoreFormatting', r'(Z)V', ); @@ -729,14 +707,12 @@ class PDFTextStripper extends jni$_.JObject { void setAddMoreFormatting( core$_.bool newAddMoreFormatting, ) { - _setAddMoreFormatting( - reference.pointer, - _id_setAddMoreFormatting as jni$_.JMethodIDPtr, + _setAddMoreFormatting(reference.pointer, _id_setAddMoreFormatting.pointer, newAddMoreFormatting ? 1 : 0) .check(); } - static final _id_getSortByPosition = _class.instanceMethodId( + static final _id_getSortByPosition = PDFTextStripper._class.instanceMethodId( r'getSortByPosition', r'()Z', ); @@ -758,12 +734,11 @@ class PDFTextStripper extends jni$_.JObject { /// This will tell if the text stripper should sort the text tokens before writing to the stream. ///@return true If the text tokens will be sorted before being written. core$_.bool getSortByPosition() { - return _getSortByPosition( - reference.pointer, _id_getSortByPosition as jni$_.JMethodIDPtr) + return _getSortByPosition(reference.pointer, _id_getSortByPosition.pointer) .boolean; } - static final _id_setSortByPosition = _class.instanceMethodId( + static final _id_setSortByPosition = PDFTextStripper._class.instanceMethodId( r'setSortByPosition', r'(Z)V', ); @@ -791,14 +766,13 @@ class PDFTextStripper extends jni$_.JObject { void setSortByPosition( core$_.bool newSortByPosition, ) { - _setSortByPosition( - reference.pointer, - _id_setSortByPosition as jni$_.JMethodIDPtr, + _setSortByPosition(reference.pointer, _id_setSortByPosition.pointer, newSortByPosition ? 1 : 0) .check(); } - static final _id_getSpacingTolerance = _class.instanceMethodId( + static final _id_getSpacingTolerance = + PDFTextStripper._class.instanceMethodId( r'getSpacingTolerance', r'()F', ); @@ -822,11 +796,12 @@ class PDFTextStripper extends jni$_.JObject { ///@return The current tolerance / scaling factor double getSpacingTolerance() { return _getSpacingTolerance( - reference.pointer, _id_getSpacingTolerance as jni$_.JMethodIDPtr) + reference.pointer, _id_getSpacingTolerance.pointer) .float; } - static final _id_setSpacingTolerance = _class.instanceMethodId( + static final _id_setSpacingTolerance = + PDFTextStripper._class.instanceMethodId( r'setSpacingTolerance', r'(F)V', ); @@ -850,14 +825,13 @@ class PDFTextStripper extends jni$_.JObject { void setSpacingTolerance( double spacingToleranceValue, ) { - _setSpacingTolerance( - reference.pointer, - _id_setSpacingTolerance as jni$_.JMethodIDPtr, + _setSpacingTolerance(reference.pointer, _id_setSpacingTolerance.pointer, spacingToleranceValue) .check(); } - static final _id_getAverageCharTolerance = _class.instanceMethodId( + static final _id_getAverageCharTolerance = + PDFTextStripper._class.instanceMethodId( r'getAverageCharTolerance', r'()F', ); @@ -880,12 +854,13 @@ class PDFTextStripper extends jni$_.JObject { /// be added. Note that the default value for this has been determined from trial and error. ///@return The current tolerance / scaling factor double getAverageCharTolerance() { - return _getAverageCharTolerance(reference.pointer, - _id_getAverageCharTolerance as jni$_.JMethodIDPtr) + return _getAverageCharTolerance( + reference.pointer, _id_getAverageCharTolerance.pointer) .float; } - static final _id_setAverageCharTolerance = _class.instanceMethodId( + static final _id_setAverageCharTolerance = + PDFTextStripper._class.instanceMethodId( r'setAverageCharTolerance', r'(F)V', ); @@ -909,14 +884,12 @@ class PDFTextStripper extends jni$_.JObject { void setAverageCharTolerance( double averageCharToleranceValue, ) { - _setAverageCharTolerance( - reference.pointer, - _id_setAverageCharTolerance as jni$_.JMethodIDPtr, - averageCharToleranceValue) + _setAverageCharTolerance(reference.pointer, + _id_setAverageCharTolerance.pointer, averageCharToleranceValue) .check(); } - static final _id_getIndentThreshold = _class.instanceMethodId( + static final _id_getIndentThreshold = PDFTextStripper._class.instanceMethodId( r'getIndentThreshold', r'()F', ); @@ -940,11 +913,11 @@ class PDFTextStripper extends jni$_.JObject { ///@return the number of whitespace character widths to use when detecting paragraph indents. double getIndentThreshold() { return _getIndentThreshold( - reference.pointer, _id_getIndentThreshold as jni$_.JMethodIDPtr) + reference.pointer, _id_getIndentThreshold.pointer) .float; } - static final _id_setIndentThreshold = _class.instanceMethodId( + static final _id_setIndentThreshold = PDFTextStripper._class.instanceMethodId( r'setIndentThreshold', r'(F)V', ); @@ -968,12 +941,12 @@ class PDFTextStripper extends jni$_.JObject { void setIndentThreshold( double indentThresholdValue, ) { - _setIndentThreshold(reference.pointer, - _id_setIndentThreshold as jni$_.JMethodIDPtr, indentThresholdValue) + _setIndentThreshold(reference.pointer, _id_setIndentThreshold.pointer, + indentThresholdValue) .check(); } - static final _id_getDropThreshold = _class.instanceMethodId( + static final _id_getDropThreshold = PDFTextStripper._class.instanceMethodId( r'getDropThreshold', r'()F', ); @@ -996,12 +969,11 @@ class PDFTextStripper extends jni$_.JObject { /// start is considered to be a paragraph start. ///@return the character height multiple for max allowed whitespace between lines in the same paragraph. double getDropThreshold() { - return _getDropThreshold( - reference.pointer, _id_getDropThreshold as jni$_.JMethodIDPtr) + return _getDropThreshold(reference.pointer, _id_getDropThreshold.pointer) .float; } - static final _id_setDropThreshold = _class.instanceMethodId( + static final _id_setDropThreshold = PDFTextStripper._class.instanceMethodId( r'setDropThreshold', r'(F)V', ); @@ -1025,12 +997,12 @@ class PDFTextStripper extends jni$_.JObject { void setDropThreshold( double dropThresholdValue, ) { - _setDropThreshold(reference.pointer, - _id_setDropThreshold as jni$_.JMethodIDPtr, dropThresholdValue) + _setDropThreshold( + reference.pointer, _id_setDropThreshold.pointer, dropThresholdValue) .check(); } - static final _id_getParagraphStart = _class.instanceMethodId( + static final _id_getParagraphStart = PDFTextStripper._class.instanceMethodId( r'getParagraphStart', r'()Ljava/lang/String;', ); @@ -1053,12 +1025,11 @@ class PDFTextStripper extends jni$_.JObject { /// Returns the string which will be used at the beginning of a paragraph. ///@return the paragraph start string jni$_.JString? getParagraphStart() { - return _getParagraphStart( - reference.pointer, _id_getParagraphStart as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getParagraphStart(reference.pointer, _id_getParagraphStart.pointer) + .object(); } - static final _id_setParagraphStart = _class.instanceMethodId( + static final _id_setParagraphStart = PDFTextStripper._class.instanceMethodId( r'setParagraphStart', r'(Ljava/lang/String;)V', ); @@ -1082,12 +1053,12 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JString? s, ) { final _$s = s?.reference ?? jni$_.jNullReference; - _setParagraphStart(reference.pointer, - _id_setParagraphStart as jni$_.JMethodIDPtr, _$s.pointer) + _setParagraphStart( + reference.pointer, _id_setParagraphStart.pointer, _$s.pointer) .check(); } - static final _id_getParagraphEnd = _class.instanceMethodId( + static final _id_getParagraphEnd = PDFTextStripper._class.instanceMethodId( r'getParagraphEnd', r'()Ljava/lang/String;', ); @@ -1110,12 +1081,11 @@ class PDFTextStripper extends jni$_.JObject { /// Returns the string which will be used at the end of a paragraph. ///@return the paragraph end string jni$_.JString? getParagraphEnd() { - return _getParagraphEnd( - reference.pointer, _id_getParagraphEnd as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getParagraphEnd(reference.pointer, _id_getParagraphEnd.pointer) + .object(); } - static final _id_setParagraphEnd = _class.instanceMethodId( + static final _id_setParagraphEnd = PDFTextStripper._class.instanceMethodId( r'setParagraphEnd', r'(Ljava/lang/String;)V', ); @@ -1139,12 +1109,12 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JString? s, ) { final _$s = s?.reference ?? jni$_.jNullReference; - _setParagraphEnd(reference.pointer, - _id_setParagraphEnd as jni$_.JMethodIDPtr, _$s.pointer) + _setParagraphEnd( + reference.pointer, _id_setParagraphEnd.pointer, _$s.pointer) .check(); } - static final _id_getPageStart = _class.instanceMethodId( + static final _id_getPageStart = PDFTextStripper._class.instanceMethodId( r'getPageStart', r'()Ljava/lang/String;', ); @@ -1167,12 +1137,11 @@ class PDFTextStripper extends jni$_.JObject { /// Returns the string which will be used at the beginning of a page. ///@return the page start string jni$_.JString? getPageStart() { - return _getPageStart( - reference.pointer, _id_getPageStart as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getPageStart(reference.pointer, _id_getPageStart.pointer) + .object(); } - static final _id_setPageStart = _class.instanceMethodId( + static final _id_setPageStart = PDFTextStripper._class.instanceMethodId( r'setPageStart', r'(Ljava/lang/String;)V', ); @@ -1196,12 +1165,12 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JString? pageStartValue, ) { final _$pageStartValue = pageStartValue?.reference ?? jni$_.jNullReference; - _setPageStart(reference.pointer, _id_setPageStart as jni$_.JMethodIDPtr, + _setPageStart(reference.pointer, _id_setPageStart.pointer, _$pageStartValue.pointer) .check(); } - static final _id_getPageEnd = _class.instanceMethodId( + static final _id_getPageEnd = PDFTextStripper._class.instanceMethodId( r'getPageEnd', r'()Ljava/lang/String;', ); @@ -1224,11 +1193,11 @@ class PDFTextStripper extends jni$_.JObject { /// Returns the string which will be used at the end of a page. ///@return the page end string jni$_.JString? getPageEnd() { - return _getPageEnd(reference.pointer, _id_getPageEnd as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getPageEnd(reference.pointer, _id_getPageEnd.pointer) + .object(); } - static final _id_setPageEnd = _class.instanceMethodId( + static final _id_setPageEnd = PDFTextStripper._class.instanceMethodId( r'setPageEnd', r'(Ljava/lang/String;)V', ); @@ -1252,12 +1221,12 @@ class PDFTextStripper extends jni$_.JObject { jni$_.JString? pageEndValue, ) { final _$pageEndValue = pageEndValue?.reference ?? jni$_.jNullReference; - _setPageEnd(reference.pointer, _id_setPageEnd as jni$_.JMethodIDPtr, - _$pageEndValue.pointer) + _setPageEnd( + reference.pointer, _id_setPageEnd.pointer, _$pageEndValue.pointer) .check(); } - static final _id_getArticleStart = _class.instanceMethodId( + static final _id_getArticleStart = PDFTextStripper._class.instanceMethodId( r'getArticleStart', r'()Ljava/lang/String;', ); @@ -1280,12 +1249,11 @@ class PDFTextStripper extends jni$_.JObject { /// Returns the string which will be used at the beginning of an article. ///@return the article start string jni$_.JString? getArticleStart() { - return _getArticleStart( - reference.pointer, _id_getArticleStart as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getArticleStart(reference.pointer, _id_getArticleStart.pointer) + .object(); } - static final _id_setArticleStart = _class.instanceMethodId( + static final _id_setArticleStart = PDFTextStripper._class.instanceMethodId( r'setArticleStart', r'(Ljava/lang/String;)V', ); @@ -1310,14 +1278,12 @@ class PDFTextStripper extends jni$_.JObject { ) { final _$articleStartValue = articleStartValue?.reference ?? jni$_.jNullReference; - _setArticleStart( - reference.pointer, - _id_setArticleStart as jni$_.JMethodIDPtr, + _setArticleStart(reference.pointer, _id_setArticleStart.pointer, _$articleStartValue.pointer) .check(); } - static final _id_getArticleEnd = _class.instanceMethodId( + static final _id_getArticleEnd = PDFTextStripper._class.instanceMethodId( r'getArticleEnd', r'()Ljava/lang/String;', ); @@ -1340,12 +1306,11 @@ class PDFTextStripper extends jni$_.JObject { /// Returns the string which will be used at the end of an article. ///@return the article end string jni$_.JString? getArticleEnd() { - return _getArticleEnd( - reference.pointer, _id_getArticleEnd as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getArticleEnd(reference.pointer, _id_getArticleEnd.pointer) + .object(); } - static final _id_setArticleEnd = _class.instanceMethodId( + static final _id_setArticleEnd = PDFTextStripper._class.instanceMethodId( r'setArticleEnd', r'(Ljava/lang/String;)V', ); @@ -1370,50 +1335,12 @@ class PDFTextStripper extends jni$_.JObject { ) { final _$articleEndValue = articleEndValue?.reference ?? jni$_.jNullReference; - _setArticleEnd(reference.pointer, _id_setArticleEnd as jni$_.JMethodIDPtr, + _setArticleEnd(reference.pointer, _id_setArticleEnd.pointer, _$articleEndValue.pointer) .check(); } } -final class $PDFTextStripper$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $PDFTextStripper$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lorg/apache/pdfbox/text/PDFTextStripper;'; - - @jni$_.internal - @core$_.override - PDFTextStripper? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : PDFTextStripper.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($PDFTextStripper$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($PDFTextStripper$NullableType$) && - other is $PDFTextStripper$NullableType$; - } -} - final class $PDFTextStripper$Type$ extends jni$_.JType { @jni$_.internal const $PDFTextStripper$Type$(); @@ -1421,32 +1348,4 @@ final class $PDFTextStripper$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lorg/apache/pdfbox/text/PDFTextStripper;'; - - @jni$_.internal - @core$_.override - PDFTextStripper fromReference(jni$_.JReference reference) => - PDFTextStripper.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $PDFTextStripper$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($PDFTextStripper$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($PDFTextStripper$Type$) && - other is $PDFTextStripper$Type$; - } } diff --git a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/_package.dart b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/_package.dart index cc769fd552..39dec06ebf 100644 --- a/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/_package.dart +++ b/pkgs/jnigen/example/pdfbox_plugin/lib/src/third_party/org/apache/pdfbox/text/_package.dart @@ -1,2 +1,2 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! export 'PDFTextStripper.dart'; diff --git a/pkgs/jnigen/lib/src/bindings/dart_generator.dart b/pkgs/jnigen/lib/src/bindings/dart_generator.dart index f5f0d46fab..ac82c42c01 100644 --- a/pkgs/jnigen/lib/src/bindings/dart_generator.dart +++ b/pkgs/jnigen/lib/src/bindings/dart_generator.dart @@ -17,7 +17,7 @@ import 'visitor.dart'; /// Version of jnigen. Keep in sync with `pubspec.yaml` removing the `-wip` /// suffix. @visibleForTesting -const String version = '0.15.1'; +const String version = '0.16.0'; // Import prefixes. const _jni = r'jni$_'; @@ -29,10 +29,8 @@ const _override = '@$_core.override'; // package:jni types. const _jType = '$_jni.JType'; const _jPointer = '$_jni.JObjectPtr'; -const _jReference = '$_jni.JReference'; const _jGlobalReference = '$_jni.JGlobalReference'; const _jArray = '$_jni.JArray'; -const _jArrayTypePrefix = '$_jni.\$JArray\$'; const _jObject = '$_jni.JObject'; const _jObjectTypePrefix = '$_jni.\$JObject\$'; const _jResult = '$_jni.JniResult'; @@ -83,10 +81,13 @@ extension on DeclaredType { extension on Method { bool get isSuspendFun => asyncReturnType != null; + bool get isAsyncVoid => asyncReturnType?.name == 'kotlin.Unit'; - String returnTypeMaybeAsync(TypeVisitor generator) => isSuspendFun - ? '$_core.Future<${asyncReturnType!.accept(generator)}>' - : returnType.accept(generator); + String returnTypeMaybeAsync(TypeVisitor generator) => isAsyncVoid + ? '$_core.Future' + : isSuspendFun + ? '$_core.Future<${asyncReturnType!.accept(generator)}>' + : returnType.accept(generator); List get paramsMaybeAsync { final p = params.toList(); @@ -101,33 +102,6 @@ String _newLine({int depth = 0}) { return '\n${' ' * depth}'; } -/// Merges two maps. For the same keys, their value lists will be concatenated. -/// -/// ** After calling this, the original maps might get modified! ** -Map> _mergeMapValues(Map> a, Map> b) { - final merged = >{}; - for (final key in {...a.keys, ...b.keys}) { - if (!a.containsKey(key)) { - merged[key] = b[key]!; - continue; - } - if (!b.containsKey(key)) { - merged[key] = a[key]!; - continue; - } - - // Merging the smaller one to the bigger one - if (a[key]!.length > b[key]!.length) { - merged[key] = a[key]!; - merged[key]!.addAll(b[key]!); - } else { - merged[key] = b[key]!; - merged[key]!.addAll(a[key]!); - } - } - return merged; -} - /// **Naming Convention** /// /// Let's take the following code as an example: @@ -329,29 +303,49 @@ class _ClassGenerator extends Visitor { _ClassGenerator(this.config, this.s, this.resolver); - static const staticTypeGetter = 'type'; - static const instanceTypeGetter = '\$$staticTypeGetter'; - - void generateFieldsAndMethods(ClassDecl node, String classRef) { - final fieldGenerator = _FieldGenerator( + void generateFieldsAndMethods( + ClassDecl node, + String classRef, { + required StringSink staticSink, + required StringSink instanceSink, + }) { + final instanceClassRef = '${node.finalName}.$classRef'; + final staticFieldGenerator = _FieldGenerator( config, resolver, - s, + staticSink, isTopLevel: node.isTopLevel, classRef: classRef, ); + final instanceFieldGenerator = _FieldGenerator( + config, + resolver, + instanceSink, + isTopLevel: node.isTopLevel, + classRef: instanceClassRef, + ); for (final field in node.fields) { - field.accept(fieldGenerator); + field.accept( + field.isStatic ? staticFieldGenerator : instanceFieldGenerator); } - final methodGenerator = _MethodGenerator( + final staticMethodGenerator = _MethodGenerator( config, resolver, - s, + staticSink, isTopLevel: node.isTopLevel, classRef: classRef, ); + final instanceMethodGenerator = _MethodGenerator( + config, + resolver, + instanceSink, + isTopLevel: node.isTopLevel, + classRef: instanceClassRef, + ); for (final method in node.methods) { - method.accept(methodGenerator); + method.accept(method.isStatic || method.isConstructor + ? staticMethodGenerator + : instanceMethodGenerator); } } @@ -371,7 +365,14 @@ ${modifier}final $classRef = $_jni.JClass.forName(r'$internalName'); if (node.isTopLevel) { // If the class is top-level, only generate its methods and fields. final classRef = writeClassRef(node); - generateFieldsAndMethods(node, classRef); + final sink = StringBuffer(); + generateFieldsAndMethods( + node, + classRef, + staticSink: s, + instanceSink: sink, + ); + s.write(sink); return; } // Docs. @@ -383,6 +384,12 @@ ${modifier}final $classRef = $_jni.JClass.forName(r'$internalName'); final superName = node.superclass!.accept( _TypeGenerator(resolver, includeNullability: false), ); + final interfaces = node.interfaces.map( + (interface) => interface.accept( + _TypeGenerator(resolver, includeNullability: false), + ), + ); + final implementsClause = {superName, ...interfaces}.join(', '); final implClassName = '\$$name'; final typeParamsDef = node.allTypeParams .accept(const _TypeParamDef()) @@ -393,97 +400,38 @@ ${modifier}final $classRef = $_jni.JClass.forName(r'$internalName'); .map((typeParam) => '$_typeParamPrefix$typeParam') .join(', ') .encloseIfNotEmpty('<', '>'); - final staticTypeGetterCallArgs = - typeParams.join(', ').encloseIfNotEmpty('(', ')'); - final typeClassesDef = typeParams - .map( - (typeParam) => ''' - $_internal - final $_jType<$_typeParamPrefix$typeParam> $typeParam; -''', - ) - .join('\n'); - final ctorTypeClassesDef = typeParams - .map((typeParam) => 'this.$typeParam,') - .join(_newLine(depth: 2)); - final superClass = node.classDecl.superclass! as DeclaredType; - final superTypeClassesCall = superClass.classDecl.isObject - ? '' - : superClass.params - .accept(_TypeClassGenerator(resolver)) - .map((typeClass) => '${typeClass.name},') - .join(_newLine(depth: 2)); s.write(''' -class $name$typeParamsDef extends $superName { - $_internal - $_override - final $_jType<$name$typeParamsCall> $instanceTypeGetter; - - $typeClassesDef - - $_internal - $name.fromReference( - $ctorTypeClassesDef - $_jReference reference, - ) : - $instanceTypeGetter = $staticTypeGetter$typeParamsCall$staticTypeGetterCallArgs, - super.fromReference( - $superTypeClassesCall - reference - ); - +extension type $name$typeParamsDef._($_jObject _\$this) implements $implementsClause { '''); final classRef = writeClassRef(node); // Static TypeClass getter. - void generateTypeClassGetter({required bool isNullable}) { - s.writeln( - ' /// The type which includes information such as the signature of this class.', - ); - final typeClassName = - isNullable ? node.nullableTypeClassName : node.typeClassName; - final typeClassGetterName = - isNullable ? 'nullableType' : staticTypeGetter; - final questionMark = isNullable ? '?' : ''; - if (typeParams.isEmpty) { - s.write(''' - static const $_jType<$name$typeParamsCall$questionMark> $typeClassGetterName = $typeClassName$typeParamsCall(); -'''); - } else { - final staticTypeGetterTypeClassesDef = typeParams - .map( - (typeParam) => '$_jType<$_typeParamPrefix$typeParam> $typeParam,', - ) - .join(_newLine(depth: 2)); - final typeClassesCall = typeParams - .map((typeParam) => '$typeParam,') - .join(_newLine(depth: 3)); - s.write(''' - static $_jType<$name$typeParamsCall$questionMark> $typeClassGetterName$typeParamsDef( - $staticTypeGetterTypeClassesDef - ) { - return $typeClassName$typeParamsCall( - $typeClassesCall + s.writeln( + ' /// The type which includes information such as the signature of this class.', ); - } - + final typeClassName = node.typeClassName; + s.write(''' + static const $_jType<$name> type = $typeClassName(); '''); - } - } - generateTypeClassGetter(isNullable: true); - generateTypeClassGetter(isNullable: false); + final instanceSink = StringBuffer(); // Fields and Methods - generateFieldsAndMethods(node, classRef); + generateFieldsAndMethods( + node, + classRef, + staticSink: s, + instanceSink: instanceSink, + ); // Operators for (final MapEntry(key: operator, value: method) in node.operators.entries) { - method.accept(_OperatorGenerator(resolver, s, operator: operator)); + method.accept( + _OperatorGenerator(resolver, instanceSink, operator: operator)); } - node.compareTo?.accept(_ComparatorGenerator(resolver, s)); + node.compareTo?.accept(_ComparatorGenerator(resolver, instanceSink)); if (node.declKind == DeclKind.interfaceKind) { s.write(''' @@ -563,26 +511,18 @@ class $name$typeParamsDef extends $superName { s.write(''' ], ); - final \$a = \$p.sendPort.nativePort; + final \$a = \$p.sendPort.nativePort; _\$impls[\$a] = \$impl; } factory $name.implement( $implClassName$typeParamsCall \$impl, ) { -'''); - final typeClassesCall = typeParams - .map((typeParam) => '\$impl.$typeParam,') - .join(_newLine(depth: 3)); - s.write(''' final \$i = $_jni.JImplementer(); implementIn(\$i, \$impl); - return $name$typeParamsCall.fromReference( - $typeClassesCall - \$i.implementReference(), - ); + return \$i.implement<$name$typeParamsCall>(); } - '''); +'''); } // Writing any custom code provided for this class. @@ -590,33 +530,33 @@ class $name$typeParamsDef extends $superName { s.writeln(config.customClassBody![node.binaryName]); } - // End of Class definition. - s.writeln('}'); + s.write(''' +} +'''); + + final instanceMethods = instanceSink.toString(); + if (instanceMethods.isNotEmpty) { + s.write(''' + extension $name\$\$Methods$typeParamsDef on $name$typeParamsCall { + $instanceMethods + } + '''); + } // Abstract and concrete Impl class definition. // Used for interface implementation. if (node.declKind == DeclKind.interfaceKind) { // Abstract Impl class. - final typeClassGetters = typeParams - .map( - (typeParam) => - '$_jType<$_typeParamPrefix$typeParam> get $typeParam;', - ) - .join(_newLine(depth: 1)); - final abstractFactoryArgs = [ - ...typeParams.map( - (typeParam) => 'required $_jType<\$$typeParam> $typeParam,', - ), - ...node.methods.accept(_AbstractImplFactoryArg(resolver)), - ].join(_newLine(depth: 2)).encloseIfNotEmpty('{', '}'); + final abstractFactoryArgs = node.methods + .accept(_AbstractImplFactoryArg(resolver)) + .join(_newLine(depth: 2)) + .encloseIfNotEmpty('{', '}'); s.write(''' abstract base mixin class $implClassName$typeParamsDef { factory $implClassName( $abstractFactoryArgs ) = _$implClassName$typeParamsCall; - $typeClassGetters - '''); final abstractImplMethod = _AbstractImplMethod(resolver, s); for (final method in node.methods) { @@ -626,22 +566,14 @@ abstract base mixin class $implClassName$typeParamsDef { // Concrete Impl class. // This is for passing closures instead of implementing the class. - final concreteCtorArgs = [ - ...typeParams.map((typeParam) => 'required this.$typeParam,'), - ...node.methods.accept(_ConcreteImplClosureCtorArg(resolver)), - ].join(_newLine(depth: 2)).encloseIfNotEmpty('{', '}'); + final concreteCtorArgs = node.methods + .accept(_ConcreteImplClosureCtorArg(resolver)) + .join(_newLine(depth: 2)) + .encloseIfNotEmpty('{', '}'); final setClosures = node.methods .map((method) => '_${method.finalName} = ${method.finalName}') .join(', ') .encloseIfNotEmpty(' : ', ''); - final typeClassesDef = typeParams - .map( - (typeParam) => ''' -$_override -final $_jType<\$$typeParam> $typeParam; -''', - ) - .join(_newLine(depth: 1)); s.write(''' final class _$implClassName$typeParamsDef with $implClassName$typeParamsCall { @@ -649,8 +581,6 @@ final class _$implClassName$typeParamsDef with $implClassName$typeParamsCall { $concreteCtorArgs )$setClosures; - $typeClassesDef - '''); final concreteClosureDef = _ConcreteImplClosureDef(resolver, s); for (final method in node.methods) { @@ -664,99 +594,18 @@ final class _$implClassName$typeParamsDef with $implClassName$typeParamsCall { s.writeln('}'); } // TypeClass definition. - void generateTypeClass({required bool isNullable}) { - final typeClassName = - isNullable ? node.nullableTypeClassName : node.typeClassName; - final typeClassesCall = - typeParams.map((typeParam) => '$typeParam,').join(_newLine(depth: 2)); - final signature = node.signature; - final superType = superClass.accept(_TypeClassGenerator(resolver)).name; - final hashCodeTypeClasses = typeParams.join(', '); - final equalityTypeClasses = typeParams - .map((typeParam) => ' &&\n $typeParam == other.$typeParam') - .join(); - final hashCode = typeParams.isEmpty - ? '($typeClassName).hashCode' - : 'Object.hash($typeClassName, $hashCodeTypeClasses)'; - final nullableType = isNullable - ? 'this' - : (DeclaredType( - binaryName: node.binaryName, - annotations: [Annotation.nullable], - params: node.allTypeParams - .map( - (typeParam) => TypeVar(name: typeParam.name) - ..origin = TypeParam( - name: typeParam.name, - annotations: [Annotation.nonNull], - bounds: typeParam.bounds, - ), - ) - .toList(), - )..classDecl = node) - .accept(_TypeClassGenerator(resolver)) - .name; - final nullable = isNullable ? '?' : ''; - s.write(''' -final class $typeClassName$typeParamsDef extends $_jType<$name$typeParamsCall$nullable> { - $typeClassesDef - + final signature = node.signature; + s.write(''' +final class $typeClassName extends $_jType<$name> { $_internal - const $typeClassName( - $ctorTypeClassesDef - ); + const $typeClassName(); $_internal $_override String get signature => r'$signature'; - - $_internal - $_override - $name$typeParamsCall$nullable fromReference($_jReference reference) => - '''); - if (isNullable) { - s.write(''' - reference.isNull ? null : $name$typeParamsCall.fromReference( - $typeClassesCall - reference, - ); -'''); - } else { - s.write(''' - $name$typeParamsCall.fromReference( - $typeClassesCall - reference, - ); -'''); - } - s.write(''' - $_internal - $_override - $_jType get superType => $superType; - - $_internal - $_override - $_jType<$name$typeParamsCall?> get nullableType => $nullableType; - - $_internal - $_override - final superCount = ${node.superCount}; - - $_override - int get hashCode => $hashCode; - - $_override - $_core.bool operator ==(Object other) { - return other.runtimeType == ($typeClassName$typeParamsCall) && - other is $typeClassName$typeParamsCall$equalityTypeClasses; - } } '''); - } - - generateTypeClass(isNullable: true); - generateTypeClass(isNullable: false); log.finest('Generated bindings for class ${node.binaryName}'); } @@ -802,6 +651,11 @@ class _TypeGenerator extends TypeVisitor { final bool isTopTypeNullable; final bool forInterfaceImplementation; + final bool forInterfaceInvoker; + + /// Whether or not to return the equivalent boxed type class for primitives. + /// Only for interface implemetation. + final bool boxPrimitives; /// Whether the generic types should be erased. final bool typeErasure; @@ -814,6 +668,8 @@ class _TypeGenerator extends TypeVisitor { const _TypeGenerator( this.resolver, { this.forInterfaceImplementation = false, + this.forInterfaceInvoker = false, + this.boxPrimitives = false, this.typeErasure = false, this.includeNullability = true, this.arrayType = false, @@ -861,7 +717,8 @@ class _TypeGenerator extends TypeVisitor { }, ); - final typeParams = allTypeParams.join(', ').encloseIfNotEmpty('<', '>'); + final typeParams = + typeErasure ? '' : allTypeParams.join(', ').encloseIfNotEmpty('<', '>'); final prefix = resolver?.resolvePrefix(node.classDecl) ?? ''; return '$prefix${node.classDecl.finalName}$typeParams$nullable'; } @@ -871,6 +728,12 @@ class _TypeGenerator extends TypeVisitor { if (arrayType) { return node.name.capitalize(); } + if (node.name == 'void') { + return 'void'; + } + if (boxPrimitives) { + return '$_jni.J${node.boxedName}'; + } if (node.name == 'boolean') { return '$_core.${node.dartType}'; } @@ -884,14 +747,14 @@ class _TypeGenerator extends TypeVisitor { { final nullable = includeNullability && node.isNullable && isTopTypeNullable ? '?' : ''; - if (typeErasure) { + if (typeErasure || forInterfaceInvoker) { return '$_jObject$nullable'; } if (forInterfaceImplementation && node.origin.parent is Method) { return '$_jObject$nullable'; } } - final nullable = includeNullability && node.hasQuestionMark ? '?' : ''; + final nullable = includeNullability && node.isNullable ? '?' : ''; return '$_typeParamPrefix${node.name}$nullable'; } @@ -922,17 +785,8 @@ class _TypeGenerator extends TypeVisitor { } } -class _TypeClass { - final String name; - final bool canBeConst; - - const _TypeClass(this.name, this.canBeConst); -} - /// Generates the type class. -class _TypeClassGenerator extends TypeVisitor<_TypeClass> { - final bool isConst; - +class _TypeClassGenerator extends TypeVisitor { /// Whether the top-type of the current type being visited is nullable. /// /// For example the top-type of `T` in `Foo` is `Bar`, this @@ -956,7 +810,6 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { _TypeClassGenerator( this.resolver, { - this.isConst = true, this.boxPrimitives = false, this.forInterfaceImplementation = false, this.includeNullability = true, @@ -965,11 +818,10 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { }); @override - _TypeClass visitArrayType(ArrayType node) { + String visitArrayType(ArrayType node) { final innerTypeClass = node.elementType.accept( _TypeClassGenerator( resolver, - isConst: false, boxPrimitives: false, forInterfaceImplementation: forInterfaceImplementation, // Do type erasure for interface implementation. @@ -987,115 +839,32 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { isTopTypeNullable: true, ), ); - final ifConst = innerTypeClass.canBeConst && isConst ? 'const ' : ''; - final type = includeNullability && node.isNullable && isTopTypeNullable - ? 'NullableType' - : 'Type'; if (node.elementType is PrimitiveType) { - return _TypeClass( - '$ifConst$_jni.\$J${innerType}Array\$$type\$()', - innerTypeClass.canBeConst, - ); + return '$_jni.J${innerType}Array.type'; } - return _TypeClass( - '$ifConst$_jArrayTypePrefix$type\$<$innerType>(${innerTypeClass.name})', - innerTypeClass.canBeConst, - ); + return '$_jArray.type<$innerType>($innerTypeClass)'; } @override - _TypeClass visitDeclaredType(DeclaredType node) { + String visitDeclaredType(DeclaredType node) { if (node.classDecl.isObject) { // The class is not generated, fall back to `JObject`. return super.visitDeclaredType(node); } - final allTypeClasses = node.mapTypeParameters( - (isNullable, definedType) { - return definedType.accept(_TypeClassGenerator( - resolver, - isConst: false, - boxPrimitives: false, - forInterfaceImplementation: forInterfaceImplementation, - typeErasure: forInterfaceImplementation, - isTopTypeNullable: isNullable, - )); - }, - ); - - // Can be const if all the type parameters are defined and each of them are - // also const. - final canBeConst = allTypeClasses.every((e) => e.canBeConst); - - // Add const to subexpressions if the entire expression is not const. - final allTypeParams = allTypeClasses - .map((typeClass) => - '${typeClass.canBeConst && !canBeConst ? 'const ' : ''}' - '${typeClass.name}') - .toList(); - - final args = allTypeParams.join(', '); - final ifConst = isConst && canBeConst ? 'const ' : ''; - final type = includeNullability && node.isNullable && isTopTypeNullable - ? node.classDecl.nullableTypeClassName - : node.classDecl.typeClassName; - - final typeArgsList = node.mapTypeParameters( - (isNullable, definedType) { - return definedType.accept( - _TypeGenerator( - resolver, - forInterfaceImplementation: forInterfaceImplementation, - // Do type erasure for interface implementation. - typeErasure: forInterfaceImplementation, - isTopTypeNullable: isNullable, - ), - ); - }, - ); - final typeArgs = typeArgsList.join(', ').encloseIfNotEmpty('<', '>'); + final type = node.classDecl.finalName; final prefix = resolver.resolvePrefix(node.classDecl); - return _TypeClass('$ifConst$prefix$type$typeArgs($args)', canBeConst); + return '$prefix$type.type'; } @override - _TypeClass visitPrimitiveType(PrimitiveType node) { - final ifConst = isConst ? 'const ' : ''; - final name = boxPrimitives - ? '$_jni.\$J${node.boxedName}\$Type\$' - : '$_jni.j${node.name}Type'; - return _TypeClass('$ifConst$name()', true); - } - - @override - _TypeClass visitTypeVar(TypeVar node) { - // TODO(https://github.com/dart-lang/native/issues/704): Tighten to typevar - // bounds instead. - final type = includeNullability && node.hasQuestionMark && isTopTypeNullable - ? 'NullableType' - : 'Type'; - final convertToNullable = - includeNullability && node.hasQuestionMark && isTopTypeNullable - ? '.nullableType' - : ''; - if (typeErasure) { - final ifConst = isConst ? 'const ' : ''; - return _TypeClass('$ifConst$_jObjectTypePrefix$type\$()', true); - } - if (forInterfaceImplementation) { - if (node.origin.parent is ClassDecl) { - return _TypeClass( - '_\$impls[\$p]!.${node.name}$convertToNullable', - false, - ); - } - final ifConst = isConst ? 'const ' : ''; - return _TypeClass('$ifConst$_jObjectTypePrefix$type\$()', true); - } - return _TypeClass('${node.name}$convertToNullable', false); + String visitPrimitiveType(PrimitiveType node) { + return boxPrimitives + ? '$_jni.J${node.boxedName}.type' + : '$_jni.j${node.name}.type'; } @override - _TypeClass visitWildcard(Wildcard node) { + String visitWildcard(Wildcard node) { // TODO(https://github.com/dart-lang/native/issues/701): Support wildcards. if (node.superBound != null || node.extendsBound == null) { // Dart does not support `* super T` wildcards. Fall back to Object?. @@ -1107,7 +876,6 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { forInterfaceImplementation: forInterfaceImplementation, includeNullability: includeNullability && node.isNullable && isTopTypeNullable, - isConst: isConst, typeErasure: typeErasure, isTopTypeNullable: true, ); @@ -1115,12 +883,8 @@ class _TypeClassGenerator extends TypeVisitor<_TypeClass> { } @override - _TypeClass visitNonPrimitiveType(ReferredType node) { - final ifConst = isConst ? 'const ' : ''; - final type = includeNullability && node.isNullable && isTopTypeNullable - ? 'NullableType' - : 'Type'; - return _TypeClass('$ifConst$_jObjectTypePrefix$type\$()', true); + String visitNonPrimitiveType(ReferredType node) { + return '$_jObjectTypePrefix$Type\$()'; } } @@ -1151,9 +915,8 @@ class _JniResultGetter extends TypeVisitor { @override String visitNonPrimitiveType(ReferredType node) { - final typeClass = node.accept(_TypeClassGenerator(resolver)).name; final type = node.accept(_TypeGenerator(resolver)); - return 'object<$type>($typeClass)'; + return 'object<$type>()'; } } @@ -1227,18 +990,33 @@ ${modifier}final _id_$name = '''); } - String dartOnlyGetter(Field node) { + String getter(Field node) { final name = node.finalName; final self = node.isStatic ? classRef : _self; - final type = node.type.accept(_TypeClassGenerator(resolver)).name; - return '_id_$name.get($self, $type)'; + final String typeClass; + if (node.type is PrimitiveType || node.type is ArrayType) { + typeClass = node.type.accept(_TypeClassGenerator(resolver)); + } else { + final type = node.type.accept(_TypeGenerator(resolver, + typeErasure: true, includeNullability: false)); + typeClass = '$type.type'; + } + final getter = node.type.isNullable ? 'getNullable' : 'get'; + return '_id_$name.$getter($self, $typeClass)'; } - String dartOnlySetter(Field node) { + String setter(Field node) { final name = node.finalName; final self = node.isStatic ? classRef : _self; - final type = node.type.accept(_TypeClassGenerator(resolver)).name; - return '_id_$name.set($self, $type, value)'; + final String typeClass; + if (node.type is PrimitiveType || node.type is ArrayType) { + typeClass = node.type.accept(_TypeClassGenerator(resolver)); + } else { + final type = node.type.accept(_TypeGenerator(resolver, + typeErasure: true, includeNullability: false)); + typeClass = '$type.type'; + } + return '_id_$name.set($self, $typeClass, value)'; } void writeDocs(Field node, {required bool writeReleaseInstructions}) { @@ -1273,14 +1051,14 @@ ${modifier}final _id_$name = final ifStatic = node.isStatic && !isTopLevel ? 'static ' : ''; final type = node.type.accept(_TypeGenerator(resolver)); s.write('$ifStatic$type get $name => '); - s.write(dartOnlyGetter(node)); - s.writeln(';\n'); + s.write(getter(node)); + s.writeln(' as $type;\n'); if (!node.isFinal) { // Setter docs. writeDocs(node, writeReleaseInstructions: true); s.write('${ifStatic}set $name($type value) => '); - s.write(dartOnlySetter(node)); + s.write(setter(node)); s.writeln(';\n'); } } @@ -1360,17 +1138,22 @@ ${modifier}final _$name = $_protectedExtension final name = node.finalName; final params = [ '$classRef.reference.pointer', - '_id_$name as $_jni.JMethodIDPtr', + '_id_$name.pointer', ...node.params.accept(const _ParamCall()), ].join(', '); - return '_$name($params).reference'; + final typeParamsCall = node.classDecl.allTypeParams + .map((typeParam) => '$_typeParamPrefix${typeParam.name}') + .join(', ') + .encloseIfNotEmpty('<', '>'); + return '_$name($params).object' + '<${node.classDecl.finalName}$typeParamsCall>()'; } String methodCall(Method node) { final name = node.finalName; final params = [ node.isStatic ? '$classRef.reference.pointer' : 'reference.pointer', - '_id_$name as $_jni.JMethodIDPtr', + '_id_$name.pointer', ...node.params.accept(const _ParamCall()), ].join(', '); final resultGetter = node.returnType.accept(_JniResultGetter(resolver)); @@ -1398,27 +1181,6 @@ ${modifier}final _$name = $_protectedExtension } node.javadoc?.accept(_DocGenerator(s, depth: 1)); - // Used for inferring the type parameter from the given parameters. - final typeLocators = node.params - .accept(_ParamTypeLocator(resolver: resolver)) - .fold(>{}, _mergeMapValues).map( - (key, value) => - MapEntry(key, value.delimited(', ').encloseIfNotEmpty('[', ']')), - ); - - bool isRequired(TypeParam typeParam) { - return (typeLocators[typeParam.name] ?? '').isEmpty; - } - - final typeInference = - (node.isConstructor ? node.classDecl.allTypeParams : node.typeParams) - .where((tp) => !isRequired(tp)) - .map((tp) => tp.name) - .map( - (tp) => '$tp ??= $_jni.lowestCommonSuperType' - '(${typeLocators[tp]}) as $_jType<$_typeParamPrefix$tp>;', - ) - .join(_newLine(depth: 2)); // This is needed to keep the references alive in the scope while waiting // for the FFI call. final localReferences = node.params @@ -1430,31 +1192,11 @@ ${modifier}final _$name = $_protectedExtension final name = node.finalName; final ctorName = name == 'new\$' ? className : '$className.$name'; final paramsDef = node.params.accept(_ParamDef(resolver)).delimited(', '); - final typeParamsCall = node.classDecl.allTypeParams - .map((typeParam) => '$_typeParamPrefix${typeParam.name}') - .join(', ') - .encloseIfNotEmpty('<', '>'); - final typeClassDef = node.classDecl.allTypeParams - .map( - (typeParam) => typeParam.accept( - _CtorTypeClassDef(isRequired: isRequired(typeParam)), - ), - ) - .delimited(', ') - .encloseIfNotEmpty('{', '}'); - final typeClassCall = node.classDecl.allTypeParams - .map((typeParam) => typeParam.name) - .delimited(', '); - final ctorExpr = constructor(node); s.write(''' - factory $ctorName($paramsDef$typeClassDef) { - $typeInference + factory $ctorName($paramsDef) { ${localReferences.join(_newLine(depth: 2))} - return ${node.classDecl.finalName}$typeParamsCall.fromReference( - $typeClassCall - $ctorExpr - ); + return $ctorExpr; } '''); @@ -1465,14 +1207,6 @@ ${modifier}final _$name = $_protectedExtension final returnType = node.returnTypeMaybeAsync(_TypeGenerator(resolver)); final ifStatic = node.isStatic && !isTopLevel ? 'static ' : ''; final defArgs = node.params.accept(_ParamDef(resolver)).toList(); - final typeClassDef = node.typeParams - .map( - (typeParam) => typeParam.accept( - _MethodTypeClassDef(isRequired: isRequired(typeParam)), - ), - ) - .delimited(', ') - .encloseIfNotEmpty('{', '}'); final typeParamsDef = node.typeParams .accept(const _TypeParamDef()) .join(', ') @@ -1482,17 +1216,13 @@ ${modifier}final _$name = $_protectedExtension localReferences.removeLast(); } final params = defArgs.delimited(', '); - s.write(' $ifStatic$returnType $name$typeParamsDef($params$typeClassDef)'); + s.write(' $ifStatic$returnType $name$typeParamsDef($params)'); final callExpr = methodCall(node); if (node.isSuspendFun) { - final returningType = - node.asyncReturnType!.accept(_TypeGenerator(resolver)); - final returningTypeClass = - node.asyncReturnType!.accept(_TypeClassGenerator(resolver)).name; - final isNullable = node.asyncReturnType!.isNullable; + final asyncReturnType = node.asyncReturnType!; + final isNullable = asyncReturnType.isNullable; final continuation = node.params.last.finalName; s.write('''async { - $typeInference final \$p = $_jni.ReceivePort(); final _\$$continuation = $_protectedExtension.newPortContinuation(\$p); ${localReferences.join(_newLine(depth: 2))} @@ -1515,17 +1245,29 @@ ${modifier}final _$name = $_protectedExtension } else { \$o = \$r; } +'''); + + if (node.isAsyncVoid) { + s.write(' return;'); + } else { + final returningType = asyncReturnType + .accept(_TypeGenerator(resolver, includeNullability: false)); + final returningTypeClass = + asyncReturnType.accept(_TypeClassGenerator(resolver)); + s.write(''' return \$o${isNullable ? '?' : ''}.as<$returningType>( $returningTypeClass, releaseOriginal: true, - ); + );'''); + } + + s.write(''' } '''); } else { final returning = returnType == 'void' ? callExpr : 'return $callExpr'; s.writeln('''{ - $typeInference ${localReferences.join(_newLine(depth: 2))} $returning; } @@ -1595,45 +1337,6 @@ ${modifier}final _$name = $_protectedExtension } } -/// Generates the method type param definition. -/// -/// For example `required JObjType $T` in: -/// ```dart -/// void bar(..., {required JObjType $T}) => ... -/// ``` -class _MethodTypeClassDef extends Visitor { - final bool isRequired; - - const _MethodTypeClassDef({required this.isRequired}); - - @override - String visit(TypeParam node) { - return '${isRequired ? 'required ' : ''}$_jType' - '<$_typeParamPrefix${node.name}>${isRequired ? '' : '?'} ${node.name}'; - } -} - -/// Generates the class type param definition. Used only in constructors. -/// -/// For example `required this.$T` in: -/// ```dart -/// class Foo { -/// final JObjType $T; -/// Foo(..., {required this.$T}) => ... -/// } -/// ``` -class _CtorTypeClassDef extends Visitor { - final bool isRequired; - - const _CtorTypeClassDef({required this.isRequired}); - - @override - String visit(TypeParam node) { - return '${isRequired ? 'required ' : ''} $_jType' - '<$_typeParamPrefix${node.name}>${isRequired ? '' : '?'} ${node.name}'; - } -} - /// Method parameter's definition. /// /// For example `Foo foo` in: @@ -1738,112 +1441,6 @@ class OutsideInBuffer { } } -/// The ways to locate each type parameter. -/// -/// For example in `JArray> a`, `T` can be retreived using -/// ```dart -/// ((((a.$type as JArrayType).elementType) as $JMapType).K) -/// as JObjType<$T> -/// ``` -/// and -/// ```dart -/// ((((a.$type as JArrayType).elementType) as $JMapType).V) -/// as JObjType<$T> -/// ``` -class _ParamTypeLocator extends Visitor>> { - final Resolver resolver; - - _ParamTypeLocator({required this.resolver}); - - @override - Map> visit(Param node) { - if (node.isNullable) { - return {}; - } - return node.type.accept(_TypeVarLocator(resolver: resolver)).map( - (key, value) => MapEntry( - key, - value - .map( - (e) => (e..appendLeft('${node.finalName}.\$type')).toString(), - ) - .toList(), - ), - ); - } -} - -class _TypeVarLocator extends TypeVisitor>> { - final Resolver resolver; - - _TypeVarLocator({required this.resolver}); - - @override - Map> visitNonPrimitiveType(ReferredType node) { - return {}; - } - - @override - Map> visitWildcard(Wildcard node) { - // TODO(https://github.com/dart-lang/native/issues/701): Support wildcards. - if (node.superBound != null || node.extendsBound == null) { - // Dart does not support `* super T` wildcards. Fall back to Object?. - return super.visitWildcard(node); - } - return node.extendsBound!.accept(this); - } - - @override - Map> visitTypeVar(TypeVar node) { - return { - node.name: [OutsideInBuffer()], - }; - } - - @override - Map> visitDeclaredType(DeclaredType node) { - if (node.classDecl.isObject) { - // The class is not generated, fall back to `JObject`. - return super.visitDeclaredType(node); - } - final offset = node.classDecl.allTypeParams.length - node.params.length; - final result = >{}; - final prefix = resolver.resolvePrefix(node.classDecl); - final typeClass = '$prefix${node.classDecl.typeClassName}'; - final typeClassParams = List.filled( - node.classDecl.allTypeParams.length, - '$_core.dynamic', - ).join(', ').encloseIfNotEmpty('<', '>'); - for (var i = 0; i < node.params.length; ++i) { - final typeParam = node.classDecl.allTypeParams[i + offset].name; - final exprs = node.params[i].accept(this); - for (final expr in exprs.entries) { - for (final buffer in expr.value) { - buffer.appendLeft('('); - buffer.prependRight(' as $typeClass$typeClassParams).$typeParam'); - result[expr.key] = (result[expr.key] ?? [])..add(buffer); - } - } - } - return result; - } - - @override - Map> visitArrayType(ArrayType node) { - final exprs = node.elementType.accept(this); - for (final e in exprs.values.expand((i) => i)) { - e.appendLeft('(('); - e.prependRight(' as ${_jArray}Type).elementType as $_jType)'); - } - return exprs; - } - - @override - Map> visitPrimitiveType(PrimitiveType node) { - return {}; - } -} - /// Method defintion for Impl abstract class used for interface implementation. class _AbstractImplMethod extends Visitor { final Resolver resolver; @@ -1993,12 +1590,14 @@ class _InterfaceMethodIf extends Visitor { final returnValue = node.returnType.accept(returnBox); if (node.isSuspendFun) { + final resume = + node.isAsyncVoid ? 'resumeWithVoidFuture' : 'resumeWithFuture'; final contArg = StringBuffer(); node.params.last.accept(_InterfaceParamCast(resolver, contArg, paramIndex: node.params.length - 1)); s.write(''' final \$r = $_jni.KotlinContinuation.fromReference($contArg.reference) - .resumeWithFuture($result); + .$resume($result); return $returnValue; '''); } else { @@ -2049,18 +1648,13 @@ class _InterfaceParamCast extends Visitor { @override void visit(Param node) { - final typeClass = node.type - .accept( - _TypeClassGenerator( - resolver, - boxPrimitives: true, - forInterfaceImplementation: true, - includeNullability: false, - ), - ) - .name; - final nullable = node.isNullable && node.type is! PrimitiveType ? '?' : '!'; - s.write('\$a![$paramIndex]$nullable.as($typeClass, releaseOriginal: true)'); + final type = node.type.accept(_TypeGenerator( + resolver, + forInterfaceImplementation: true, + forInterfaceInvoker: true, + boxPrimitives: true, + )); + s.write('(\$a![$paramIndex] as $type)'); if (node.type is PrimitiveType) { // Convert to Dart type. final name = node.type.name; diff --git a/pkgs/jnigen/lib/src/bindings/linker.dart b/pkgs/jnigen/lib/src/bindings/linker.dart index 512ee4607b..3b3d9a757a 100644 --- a/pkgs/jnigen/lib/src/bindings/linker.dart +++ b/pkgs/jnigen/lib/src/bindings/linker.dart @@ -154,8 +154,6 @@ class _ClassLinker extends Visitor { } } - node.superCount = superclass.superCount + 1; - final fieldLinker = _FieldLinker(typeLinker); for (final field in node.fields) { field.classDecl = node; diff --git a/pkgs/jnigen/lib/src/config/config_types.dart b/pkgs/jnigen/lib/src/config/config_types.dart index e65bd6523b..863fa1dce3 100644 --- a/pkgs/jnigen/lib/src/config/config_types.dart +++ b/pkgs/jnigen/lib/src/config/config_types.dart @@ -274,6 +274,7 @@ class Config { this.logLevel = Level.INFO, this.dumpJsonTo, this.imports, + this.hide, this.visitors}) { for (final className in classes) { _validateClassName(className); @@ -323,6 +324,9 @@ class Config { /// List of dependencies. final List? imports; + /// Hide concrete classes from the imports + final List? hide; + /// Call [importClasses] before using this. late final Map importedClasses; @@ -387,6 +391,9 @@ class Config { final classes = entry.value as YamlMap; for (final classEntry in classes.entries) { final binaryName = classEntry.key as String; + if (hide?.contains(binaryName) ?? false) { + continue; + } final decl = classEntry.value as YamlMap; if (importedClasses.containsKey(binaryName)) { log.fatal( @@ -400,7 +407,6 @@ class Config { ) ..path = '$importPath/$filePath' ..finalName = decl['name'] as String - ..superCount = decl['super_count'] as int ..allTypeParams = [] // TODO(https://github.com/dart-lang/native/issues/746): include // outerClass in the interop information. diff --git a/pkgs/jnigen/lib/src/elements/elements.dart b/pkgs/jnigen/lib/src/elements/elements.dart index 268d2d04ce..73531004af 100644 --- a/pkgs/jnigen/lib/src/elements/elements.dart +++ b/pkgs/jnigen/lib/src/elements/elements.dart @@ -132,12 +132,6 @@ class ClassDecl with ClassMember, Annotated implements Element { String get packageName => (binaryName.split('.')..removeLast()).join('.'); - /// The number of super classes this type has. - /// - /// Populated by [Linker]. - @JsonKey(includeFromJson: false) - late int superCount; - /// Final name of this class. /// /// Populated by [Renamer]. @@ -149,9 +143,6 @@ class ClassDecl with ClassMember, Annotated implements Element { @JsonKey(includeFromJson: false) String get typeClassName => '\$$finalName\$Type\$'; - /// Name of the nullable type class. - String get nullableTypeClassName => '\$$finalName\$NullableType\$'; - /// Type parameters including the ones from its outer classes. /// /// For `Foo.Bar.Baz` it is [T, U, V, W]. @@ -217,7 +208,7 @@ class ClassDecl with ClassMember, Annotated implements Element { .split('.') .last; - bool get isObject => superCount == 0; + bool get isObject => binaryName == DeclaredType.object.binaryName; @JsonKey(includeFromJson: false) bool get isNested => outerClassBinaryName != null; diff --git a/pkgs/jnigen/lib/src/summary/summary.dart b/pkgs/jnigen/lib/src/summary/summary.dart index d1ed80a091..f063471063 100644 --- a/pkgs/jnigen/lib/src/summary/summary.dart +++ b/pkgs/jnigen/lib/src/summary/summary.dart @@ -22,6 +22,25 @@ class SummaryParseException implements Exception { String toString() => message; } +final _unsupportedClassFileVersionRegex = RegExp( + r'Unsupported class file major version\s+(\d+)', +); + +String? getActionableSummaryParseMessage(String stderr) { + final match = _unsupportedClassFileVersionRegex.firstMatch(stderr); + if (match == null) { + return null; + } + + final majorVersion = match.group(1); + return 'Cannot generate summary: Java class file version $majorVersion is ' + 'not supported by the summarizer. This usually means your input classes ' + 'were compiled with a newer JDK target than JNIgen supports. Use a ' + 'supported JDK version (11 to 17) (see JNIgen README), or recompile ' + 'your Java inputs with a lower target (for example: javac --release ' + '17 ).'; +} + /// A command based summary source which calls the ApiSummarizer command. /// [sourcePaths] and [classPaths] can be provided for the summarizer to find /// required dependencies. The [classes] argument specifies the fully qualified @@ -179,9 +198,12 @@ Future getSummary(Config config) async { log.info('Parsing inputs took ${stopwatch.elapsedMilliseconds} ms'); } on Exception catch (e) { await process.exitCode; + final stderr = stderrBuffer.toString(); + final message = getActionableSummaryParseMessage(stderr) ?? + 'Cannot generate summary: $e'; throw SummaryParseException.withStderr( - stderrBuffer.toString(), - 'Cannot generate summary: $e', + stderr, + message, ); } finally { log.writeSectionToFile('summarizer logs', stderrBuffer.toString()); diff --git a/pkgs/jnigen/lib/src/tools/gradle_tools.dart b/pkgs/jnigen/lib/src/tools/gradle_tools.dart index afe2f9e187..2ee3ef892d 100644 --- a/pkgs/jnigen/lib/src/tools/gradle_tools.dart +++ b/pkgs/jnigen/lib/src/tools/gradle_tools.dart @@ -1,6 +1,10 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; import 'dart:io'; -import 'package:http/http.dart' as http; import 'package:path/path.dart'; import '../logging/logging.dart'; @@ -35,7 +39,7 @@ class GradleTools { static Future _runGradleCommand( List deps, String targetDir, - {bool extractSources = false}) async { + {String taskName = 'copyJars'}) async { final gradleWrapper = await getGradleWExecutable(); // Paths in Gradle files on Windows get improperly escaped final targetPath = Platform.isWindows @@ -47,13 +51,14 @@ class GradleTools { ); final tempDir = await currentDir.createTemp('maven_temp_'); await createStubProject(tempDir); + final tempGradle = join(tempDir.path, 'temp_build.gradle.kts'); log.finer('using Gradle stub:\n$gradle'); await File(tempGradle).writeAsString(gradle); final gradleArgs = [ '-b', // specify gradle file to run tempGradle, - extractSources ? 'extractSourceJars' : 'copyJars', + taskName, '-q' // quiet mode ]; await _runCmd(gradleWrapper!.toFilePath(), gradleArgs); @@ -68,16 +73,8 @@ class GradleTools { /// Downloads and unpacks source files of [deps] into [targetDir]. static Future downloadMavenSources( List deps, String targetDir) async { - // TODO(https://github.com/dart-lang/native/issues/2579): Make this use - // gradle as well, instead of manually downloading deps via http. - for (final dep in deps) { - final targetFile = File(join(targetDir, dep.filename())); - await targetFile.parent.create(recursive: true); - final sourceJarLocation = dep.toURLString(repoLocation); - await targetFile - .writeAsBytes(await http.readBytes(Uri.parse(sourceJarLocation))); - } - await _runGradleCommand(deps, extractSources: true, targetDir); + await _runGradleCommand(deps, taskName: 'downloadSources', targetDir); + await _runGradleCommand(deps, taskName: 'extractSourceJars', targetDir); } static Future createStubProject(Directory rootTempDir) async { @@ -103,19 +100,23 @@ class GradleTools { /// Downloads JAR files of all [deps] transitively into [targetDir]. static Future downloadMavenJars( List deps, String targetDir) async { - await _runGradleCommand(deps, targetDir); + await _runGradleCommand(deps, taskName: 'copyJars', targetDir); + await _runGradleCommand(deps, taskName: 'extractSourceJars', targetDir); } static String _getStubGradle(List deps, String targetDir, {String javaVersion = '11'}) { final depDecls = []; + final sourceDecls = []; // Use implementation configuration for (var dep in deps) { depDecls.add(dep.toGradleDependency('implementation')); + sourceDecls.add(dep.toURLString(repoLocation)); } return ''' plugins { java + id("de.undercouch.download") version "5.7.0" } repositories { @@ -146,6 +147,14 @@ class GradleTools { into("$targetDir") } + tasks.register("downloadSources") { + src(listOf( + ${jsonEncode(sourceDecls).replaceAll("[", "").replaceAll("]", "")} + )) + dest("$targetDir") + overwrite(true) + } + dependencies { ${depDecls.join("\n ")} }'''; diff --git a/pkgs/jnigen/pubspec.yaml b/pkgs/jnigen/pubspec.yaml index 0a65a56b7d..8e5abafb0f 100644 --- a/pkgs/jnigen/pubspec.yaml +++ b/pkgs/jnigen/pubspec.yaml @@ -5,7 +5,7 @@ name: jnigen description: A Dart bindings generator for Java and Kotlin that uses JNI under the hood to interop with Java virtual machine. # Keep in sync with `version` in `dart_generator.dart`. -version: 0.15.1-wip +version: 0.16.0-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/jnigen issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Ajnigen diff --git a/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart b/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart index df2aad4f5a..50556b8a78 100644 --- a/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/jackson_core_test/runtime_test_registrant.dart @@ -30,13 +30,13 @@ void registerTests(String groupName, TestRunnerCallback test) { obj.release(); } }); - test('parsing invalid JSON throws JniException', () { + test('parsing invalid JSON throws JThrowable', () { using((arena) { final factory = JsonFactory()..releasedBy(arena); final erroneous = factory .createParser$6(''.toJString()..releasedBy(arena))! ..releasedBy(arena); - expect(erroneous.nextToken, throwsA(isA())); + expect(erroneous.nextToken, throwsA(isA())); }); }); }); diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonFactory.dart b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonFactory.dart index 099396b1c8..59d54640dd 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonFactory.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonFactory.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Generated from jackson-core which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. @@ -59,24 +59,11 @@ import 'JsonParser.dart' as jsonparser$_; /// /// Enumeration that defines all on/off features that can only be /// changed for JsonFactory. -class JsonFactory$Feature extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonFactory$Feature.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonFactory$Feature._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/fasterxml/jackson/core/JsonFactory$Feature'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonFactory$Feature$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonFactory$Feature$Type$(); @@ -102,7 +89,8 @@ class JsonFactory$Feature extends jni$_.JObject { /// /// This setting is enabled by default. static JsonFactory$Feature get INTERN_FIELD_NAMES => - _id_INTERN_FIELD_NAMES.get(_class, const $JsonFactory$Feature$Type$()); + _id_INTERN_FIELD_NAMES.get(_class, JsonFactory$Feature.type) + as JsonFactory$Feature; static final _id_CANONICALIZE_FIELD_NAMES = _class.staticFieldId( r'CANONICALIZE_FIELD_NAMES', @@ -119,8 +107,8 @@ class JsonFactory$Feature extends jni$_.JObject { /// /// This setting is enabled by default. static JsonFactory$Feature get CANONICALIZE_FIELD_NAMES => - _id_CANONICALIZE_FIELD_NAMES.get( - _class, const $JsonFactory$Feature$Type$()); + _id_CANONICALIZE_FIELD_NAMES.get(_class, JsonFactory$Feature.type) + as JsonFactory$Feature; static final _id_FAIL_ON_SYMBOL_HASH_OVERFLOW = _class.staticFieldId( r'FAIL_ON_SYMBOL_HASH_OVERFLOW', @@ -142,8 +130,8 @@ class JsonFactory$Feature extends jni$_.JObject { /// This setting is enabled by default. ///@since 2.4 static JsonFactory$Feature get FAIL_ON_SYMBOL_HASH_OVERFLOW => - _id_FAIL_ON_SYMBOL_HASH_OVERFLOW.get( - _class, const $JsonFactory$Feature$Type$()); + _id_FAIL_ON_SYMBOL_HASH_OVERFLOW.get(_class, JsonFactory$Feature.type) + as JsonFactory$Feature; static final _id_USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING = _class.staticFieldId( r'USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING', @@ -167,7 +155,7 @@ class JsonFactory$Feature extends jni$_.JObject { ///@since 2.6 static JsonFactory$Feature get USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING => _id_USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING.get( - _class, const $JsonFactory$Feature$Type$()); + _class, JsonFactory$Feature.type) as JsonFactory$Feature; static final _id_values = _class.staticMethodId( r'values', @@ -189,10 +177,8 @@ class JsonFactory$Feature extends jni$_.JObject { /// from: `static public com.fasterxml.jackson.core.JsonFactory$Feature[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $JsonFactory$Feature$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -217,10 +203,9 @@ class JsonFactory$Feature extends jni$_.JObject { jni$_.JString? name, ) { final _$name = name?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$name.pointer) - .object( - const $JsonFactory$Feature$NullableType$()); + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$name.pointer) + .object(); } static final _id_collectDefaults = _class.staticMethodId( @@ -247,11 +232,14 @@ class JsonFactory$Feature extends jni$_.JObject { ///@return Bit field of features enabled by default static int collectDefaults() { return _collectDefaults( - _class.reference.pointer, _id_collectDefaults as jni$_.JMethodIDPtr) + _class.reference.pointer, _id_collectDefaults.pointer) .integer; } +} - static final _id_enabledByDefault = _class.instanceMethodId( +extension JsonFactory$Feature$$Methods on JsonFactory$Feature { + static final _id_enabledByDefault = + JsonFactory$Feature._class.instanceMethodId( r'enabledByDefault', r'()Z', ); @@ -270,12 +258,11 @@ class JsonFactory$Feature extends jni$_.JObject { /// from: `public boolean enabledByDefault()` core$_.bool enabledByDefault() { - return _enabledByDefault( - reference.pointer, _id_enabledByDefault as jni$_.JMethodIDPtr) + return _enabledByDefault(reference.pointer, _id_enabledByDefault.pointer) .boolean; } - static final _id_enabledIn = _class.instanceMethodId( + static final _id_enabledIn = JsonFactory$Feature._class.instanceMethodId( r'enabledIn', r'(I)Z', ); @@ -295,12 +282,10 @@ class JsonFactory$Feature extends jni$_.JObject { core$_.bool enabledIn( int flags, ) { - return _enabledIn( - reference.pointer, _id_enabledIn as jni$_.JMethodIDPtr, flags) - .boolean; + return _enabledIn(reference.pointer, _id_enabledIn.pointer, flags).boolean; } - static final _id_getMask = _class.instanceMethodId( + static final _id_getMask = JsonFactory$Feature._class.instanceMethodId( r'getMask', r'()I', ); @@ -319,47 +304,7 @@ class JsonFactory$Feature extends jni$_.JObject { /// from: `public int getMask()` int getMask() { - return _getMask(reference.pointer, _id_getMask as jni$_.JMethodIDPtr) - .integer; - } -} - -final class $JsonFactory$Feature$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $JsonFactory$Feature$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/fasterxml/jackson/core/JsonFactory$Feature;'; - - @jni$_.internal - @core$_.override - JsonFactory$Feature? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : JsonFactory$Feature.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonFactory$Feature$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonFactory$Feature$NullableType$) && - other is $JsonFactory$Feature$NullableType$; + return _getMask(reference.pointer, _id_getMask.pointer).integer; } } @@ -371,34 +316,6 @@ final class $JsonFactory$Feature$Type$ @jni$_.internal @core$_.override String get signature => r'Lcom/fasterxml/jackson/core/JsonFactory$Feature;'; - - @jni$_.internal - @core$_.override - JsonFactory$Feature fromReference(jni$_.JReference reference) => - JsonFactory$Feature.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonFactory$Feature$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonFactory$Feature$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonFactory$Feature$Type$) && - other is $JsonFactory$Feature$Type$; - } } /// from: `com.fasterxml.jackson.core.JsonFactory` @@ -420,24 +337,10 @@ final class $JsonFactory$Feature$Type$ /// the default constructor is used for constructing factory /// instances. ///@author Tatu Saloranta -class JsonFactory extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonFactory.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonFactory._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/fasterxml/jackson/core/JsonFactory'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonFactory$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonFactory$Type$(); static final _id_FORMAT_NAME_JSON = _class.staticFieldId( @@ -451,7 +354,8 @@ class JsonFactory extends jni$_.JObject { /// Name used to identify JSON format /// (and returned by \#getFormatName() static jni$_.JString? get FORMAT_NAME_JSON => - _id_FORMAT_NAME_JSON.get(_class, const jni$_.$JString$NullableType$()); + _id_FORMAT_NAME_JSON.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_DEFAULT_ROOT_VALUE_SEPARATOR = _class.staticFieldId( r'DEFAULT_ROOT_VALUE_SEPARATOR', @@ -461,8 +365,8 @@ class JsonFactory extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.SerializableString DEFAULT_ROOT_VALUE_SEPARATOR` /// The returned object must be released after use, by calling the [release] method. static jni$_.JObject? get DEFAULT_ROOT_VALUE_SEPARATOR => - _id_DEFAULT_ROOT_VALUE_SEPARATOR.get( - _class, const jni$_.$JObject$NullableType$()); + _id_DEFAULT_ROOT_VALUE_SEPARATOR.getNullable(_class, jni$_.JObject.type) + as jni$_.JObject?; /// from: `static public final char DEFAULT_QUOTE_CHAR` /// @@ -496,9 +400,8 @@ class JsonFactory extends jni$_.JObject { /// and this reuse only works within context of a single /// factory instance. factory JsonFactory() { - return JsonFactory.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_new$1 = _class.constructorId( @@ -522,9 +425,8 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? oc, ) { final _$oc = oc?.reference ?? jni$_.jNullReference; - return JsonFactory.fromReference(_new$1(_class.reference.pointer, - _id_new$1 as jni$_.JMethodIDPtr, _$oc.pointer) - .reference); + return _new$1(_class.reference.pointer, _id_new$1.pointer, _$oc.pointer) + .object(); } static final _id_new$2 = _class.constructorId( @@ -552,74 +454,75 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? b, ) { final _$b = b?.reference ?? jni$_.jNullReference; - return JsonFactory.fromReference(_new$2(_class.reference.pointer, - _id_new$2 as jni$_.JMethodIDPtr, _$b.pointer) - .reference); + return _new$2(_class.reference.pointer, _id_new$2.pointer, _$b.pointer) + .object(); } - static final _id_rebuild = _class.instanceMethodId( - r'rebuild', + static final _id_builder = _class.staticMethodId( + r'builder', r'()Lcom/fasterxml/jackson/core/TSFBuilder;', ); - static final _rebuild = jni$_.ProtectedJniExtensions.lookup< + static final _builder = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + )>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `public com.fasterxml.jackson.core.TSFBuilder rebuild()` + /// from: `static public com.fasterxml.jackson.core.TSFBuilder builder()` /// The returned object must be released after use, by calling the [release] method. /// - /// Method that allows construction of differently configured factory, starting - /// with settings of this factory. + /// Main factory method to use for constructing JsonFactory instances with + /// different configuration: creates and returns a builder for collecting configuration + /// settings; instance created by calling {@code build()} after all configuration + /// set. + /// + /// NOTE: signature unfortunately does not expose true implementation type; this + /// will be fixed in 3.0. ///@return Builder instance to use - ///@since 2.10 - jni$_.JObject? rebuild() { - return _rebuild(reference.pointer, _id_rebuild as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + static jni$_.JObject? builder() { + return _builder(_class.reference.pointer, _id_builder.pointer) + .object(); } +} - static final _id_builder = _class.staticMethodId( - r'builder', +extension JsonFactory$$Methods on JsonFactory { + static final _id_rebuild = JsonFactory._class.instanceMethodId( + r'rebuild', r'()Lcom/fasterxml/jackson/core/TSFBuilder;', ); - static final _builder = jni$_.ProtectedJniExtensions.lookup< + static final _rebuild = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_CallStaticObjectMethod') + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `static public com.fasterxml.jackson.core.TSFBuilder builder()` + /// from: `public com.fasterxml.jackson.core.TSFBuilder rebuild()` /// The returned object must be released after use, by calling the [release] method. /// - /// Main factory method to use for constructing JsonFactory instances with - /// different configuration: creates and returns a builder for collecting configuration - /// settings; instance created by calling {@code build()} after all configuration - /// set. - /// - /// NOTE: signature unfortunately does not expose true implementation type; this - /// will be fixed in 3.0. + /// Method that allows construction of differently configured factory, starting + /// with settings of this factory. ///@return Builder instance to use - static jni$_.JObject? builder() { - return _builder(_class.reference.pointer, _id_builder as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + ///@since 2.10 + jni$_.JObject? rebuild() { + return _rebuild(reference.pointer, _id_rebuild.pointer) + .object(); } - static final _id_copy = _class.instanceMethodId( + static final _id_copy = JsonFactory._class.instanceMethodId( r'copy', r'()Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -652,11 +555,11 @@ class JsonFactory extends jni$_.JObject { ///@return Copy of this factory instance ///@since 2.1 JsonFactory? copy() { - return _copy(reference.pointer, _id_copy as jni$_.JMethodIDPtr) - .object(const $JsonFactory$NullableType$()); + return _copy(reference.pointer, _id_copy.pointer).object(); } - static final _id_requiresPropertyOrdering = _class.instanceMethodId( + static final _id_requiresPropertyOrdering = + JsonFactory._class.instanceMethodId( r'requiresPropertyOrdering', r'()Z', ); @@ -690,12 +593,13 @@ class JsonFactory extends jni$_.JObject { /// requires Object properties to be ordered. ///@since 2.3 core$_.bool requiresPropertyOrdering() { - return _requiresPropertyOrdering(reference.pointer, - _id_requiresPropertyOrdering as jni$_.JMethodIDPtr) + return _requiresPropertyOrdering( + reference.pointer, _id_requiresPropertyOrdering.pointer) .boolean; } - static final _id_canHandleBinaryNatively = _class.instanceMethodId( + static final _id_canHandleBinaryNatively = + JsonFactory._class.instanceMethodId( r'canHandleBinaryNatively', r'()Z', ); @@ -726,12 +630,12 @@ class JsonFactory extends jni$_.JObject { /// supports native binary content ///@since 2.3 core$_.bool canHandleBinaryNatively() { - return _canHandleBinaryNatively(reference.pointer, - _id_canHandleBinaryNatively as jni$_.JMethodIDPtr) + return _canHandleBinaryNatively( + reference.pointer, _id_canHandleBinaryNatively.pointer) .boolean; } - static final _id_canUseCharArrays = _class.instanceMethodId( + static final _id_canUseCharArrays = JsonFactory._class.instanceMethodId( r'canUseCharArrays', r'()Z', ); @@ -762,12 +666,11 @@ class JsonFactory extends jni$_.JObject { /// accessed using parser method {@code getTextCharacters()}. ///@since 2.4 core$_.bool canUseCharArrays() { - return _canUseCharArrays( - reference.pointer, _id_canUseCharArrays as jni$_.JMethodIDPtr) + return _canUseCharArrays(reference.pointer, _id_canUseCharArrays.pointer) .boolean; } - static final _id_canParseAsync = _class.instanceMethodId( + static final _id_canParseAsync = JsonFactory._class.instanceMethodId( r'canParseAsync', r'()Z', ); @@ -794,12 +697,11 @@ class JsonFactory extends jni$_.JObject { /// not (and consequently whether {@code createNonBlockingXxx()} method(s) work) ///@since 2.9 core$_.bool canParseAsync() { - return _canParseAsync( - reference.pointer, _id_canParseAsync as jni$_.JMethodIDPtr) - .boolean; + return _canParseAsync(reference.pointer, _id_canParseAsync.pointer).boolean; } - static final _id_getFormatReadFeatureType = _class.instanceMethodId( + static final _id_getFormatReadFeatureType = + JsonFactory._class.instanceMethodId( r'getFormatReadFeatureType', r'()Ljava/lang/Class;', ); @@ -819,12 +721,13 @@ class JsonFactory extends jni$_.JObject { /// from: `public java.lang.Class getFormatReadFeatureType()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? getFormatReadFeatureType() { - return _getFormatReadFeatureType(reference.pointer, - _id_getFormatReadFeatureType as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getFormatReadFeatureType( + reference.pointer, _id_getFormatReadFeatureType.pointer) + .object(); } - static final _id_getFormatWriteFeatureType = _class.instanceMethodId( + static final _id_getFormatWriteFeatureType = + JsonFactory._class.instanceMethodId( r'getFormatWriteFeatureType', r'()Ljava/lang/Class;', ); @@ -844,12 +747,12 @@ class JsonFactory extends jni$_.JObject { /// from: `public java.lang.Class getFormatWriteFeatureType()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? getFormatWriteFeatureType() { - return _getFormatWriteFeatureType(reference.pointer, - _id_getFormatWriteFeatureType as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getFormatWriteFeatureType( + reference.pointer, _id_getFormatWriteFeatureType.pointer) + .object(); } - static final _id_canUseSchema = _class.instanceMethodId( + static final _id_canUseSchema = JsonFactory._class.instanceMethodId( r'canUseSchema', r'(Lcom/fasterxml/jackson/core/FormatSchema;)Z', ); @@ -880,12 +783,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? schema, ) { final _$schema = schema?.reference ?? jni$_.jNullReference; - return _canUseSchema(reference.pointer, - _id_canUseSchema as jni$_.JMethodIDPtr, _$schema.pointer) + return _canUseSchema( + reference.pointer, _id_canUseSchema.pointer, _$schema.pointer) .boolean; } - static final _id_getFormatName = _class.instanceMethodId( + static final _id_getFormatName = JsonFactory._class.instanceMethodId( r'getFormatName', r'()Ljava/lang/String;', ); @@ -912,12 +815,11 @@ class JsonFactory extends jni$_.JObject { /// implementation will return null for all sub-classes ///@return Name of the format handled by parsers, generators this factory creates jni$_.JString? getFormatName() { - return _getFormatName( - reference.pointer, _id_getFormatName as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getFormatName(reference.pointer, _id_getFormatName.pointer) + .object(); } - static final _id_hasFormat = _class.instanceMethodId( + static final _id_hasFormat = JsonFactory._class.instanceMethodId( r'hasFormat', r'(Lcom/fasterxml/jackson/core/format/InputAccessor;)Lcom/fasterxml/jackson/core/format/MatchStrength;', ); @@ -939,12 +841,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? acc, ) { final _$acc = acc?.reference ?? jni$_.jNullReference; - return _hasFormat(reference.pointer, _id_hasFormat as jni$_.JMethodIDPtr, - _$acc.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _hasFormat(reference.pointer, _id_hasFormat.pointer, _$acc.pointer) + .object(); } - static final _id_requiresCustomCodec = _class.instanceMethodId( + static final _id_requiresCustomCodec = JsonFactory._class.instanceMethodId( r'requiresCustomCodec', r'()Z', ); @@ -974,11 +875,11 @@ class JsonFactory extends jni$_.JObject { ///@since 2.1 core$_.bool requiresCustomCodec() { return _requiresCustomCodec( - reference.pointer, _id_requiresCustomCodec as jni$_.JMethodIDPtr) + reference.pointer, _id_requiresCustomCodec.pointer) .boolean; } - static final _id_version = _class.instanceMethodId( + static final _id_version = JsonFactory._class.instanceMethodId( r'version', r'()Lcom/fasterxml/jackson/core/Version;', ); @@ -998,11 +899,11 @@ class JsonFactory extends jni$_.JObject { /// from: `public com.fasterxml.jackson.core.Version version()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? version() { - return _version(reference.pointer, _id_version as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _version(reference.pointer, _id_version.pointer) + .object(); } - static final _id_configure = _class.instanceMethodId( + static final _id_configure = JsonFactory._class.instanceMethodId( r'configure', r'(Lcom/fasterxml/jackson/core/JsonFactory$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1033,12 +934,12 @@ class JsonFactory extends jni$_.JObject { core$_.bool state, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _configure(reference.pointer, _id_configure as jni$_.JMethodIDPtr, - _$f.pointer, state ? 1 : 0) - .object(const $JsonFactory$NullableType$()); + return _configure(reference.pointer, _id_configure.pointer, _$f.pointer, + state ? 1 : 0) + .object(); } - static final _id_enable = _class.instanceMethodId( + static final _id_enable = JsonFactory._class.instanceMethodId( r'enable', r'(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1066,12 +967,11 @@ class JsonFactory extends jni$_.JObject { JsonFactory$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _enable( - reference.pointer, _id_enable as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonFactory$NullableType$()); + return _enable(reference.pointer, _id_enable.pointer, _$f.pointer) + .object(); } - static final _id_disable = _class.instanceMethodId( + static final _id_disable = JsonFactory._class.instanceMethodId( r'disable', r'(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1099,12 +999,11 @@ class JsonFactory extends jni$_.JObject { JsonFactory$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _disable( - reference.pointer, _id_disable as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonFactory$NullableType$()); + return _disable(reference.pointer, _id_disable.pointer, _$f.pointer) + .object(); } - static final _id_isEnabled = _class.instanceMethodId( + static final _id_isEnabled = JsonFactory._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/JsonFactory$Feature;)Z', ); @@ -1129,12 +1028,11 @@ class JsonFactory extends jni$_.JObject { JsonFactory$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled( - reference.pointer, _id_isEnabled as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled(reference.pointer, _id_isEnabled.pointer, _$f.pointer) .boolean; } - static final _id_getParserFeatures = _class.instanceMethodId( + static final _id_getParserFeatures = JsonFactory._class.instanceMethodId( r'getParserFeatures', r'()I', ); @@ -1153,12 +1051,11 @@ class JsonFactory extends jni$_.JObject { /// from: `public final int getParserFeatures()` int getParserFeatures() { - return _getParserFeatures( - reference.pointer, _id_getParserFeatures as jni$_.JMethodIDPtr) + return _getParserFeatures(reference.pointer, _id_getParserFeatures.pointer) .integer; } - static final _id_getGeneratorFeatures = _class.instanceMethodId( + static final _id_getGeneratorFeatures = JsonFactory._class.instanceMethodId( r'getGeneratorFeatures', r'()I', ); @@ -1178,11 +1075,12 @@ class JsonFactory extends jni$_.JObject { /// from: `public final int getGeneratorFeatures()` int getGeneratorFeatures() { return _getGeneratorFeatures( - reference.pointer, _id_getGeneratorFeatures as jni$_.JMethodIDPtr) + reference.pointer, _id_getGeneratorFeatures.pointer) .integer; } - static final _id_getFormatParserFeatures = _class.instanceMethodId( + static final _id_getFormatParserFeatures = + JsonFactory._class.instanceMethodId( r'getFormatParserFeatures', r'()I', ); @@ -1201,12 +1099,13 @@ class JsonFactory extends jni$_.JObject { /// from: `public int getFormatParserFeatures()` int getFormatParserFeatures() { - return _getFormatParserFeatures(reference.pointer, - _id_getFormatParserFeatures as jni$_.JMethodIDPtr) + return _getFormatParserFeatures( + reference.pointer, _id_getFormatParserFeatures.pointer) .integer; } - static final _id_getFormatGeneratorFeatures = _class.instanceMethodId( + static final _id_getFormatGeneratorFeatures = + JsonFactory._class.instanceMethodId( r'getFormatGeneratorFeatures', r'()I', ); @@ -1226,12 +1125,12 @@ class JsonFactory extends jni$_.JObject { /// from: `public int getFormatGeneratorFeatures()` int getFormatGeneratorFeatures() { - return _getFormatGeneratorFeatures(reference.pointer, - _id_getFormatGeneratorFeatures as jni$_.JMethodIDPtr) + return _getFormatGeneratorFeatures( + reference.pointer, _id_getFormatGeneratorFeatures.pointer) .integer; } - static final _id_configure$1 = _class.instanceMethodId( + static final _id_configure$1 = JsonFactory._class.instanceMethodId( r'configure', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1261,12 +1160,12 @@ class JsonFactory extends jni$_.JObject { core$_.bool state, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _configure$1(reference.pointer, - _id_configure$1 as jni$_.JMethodIDPtr, _$f.pointer, state ? 1 : 0) - .object(const $JsonFactory$NullableType$()); + return _configure$1(reference.pointer, _id_configure$1.pointer, _$f.pointer, + state ? 1 : 0) + .object(); } - static final _id_enable$1 = _class.instanceMethodId( + static final _id_enable$1 = JsonFactory._class.instanceMethodId( r'enable', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1293,12 +1192,11 @@ class JsonFactory extends jni$_.JObject { jsonparser$_.JsonParser$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _enable$1( - reference.pointer, _id_enable$1 as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonFactory$NullableType$()); + return _enable$1(reference.pointer, _id_enable$1.pointer, _$f.pointer) + .object(); } - static final _id_disable$1 = _class.instanceMethodId( + static final _id_disable$1 = JsonFactory._class.instanceMethodId( r'disable', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1325,12 +1223,11 @@ class JsonFactory extends jni$_.JObject { jsonparser$_.JsonParser$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _disable$1( - reference.pointer, _id_disable$1 as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonFactory$NullableType$()); + return _disable$1(reference.pointer, _id_disable$1.pointer, _$f.pointer) + .object(); } - static final _id_isEnabled$1 = _class.instanceMethodId( + static final _id_isEnabled$1 = JsonFactory._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z', ); @@ -1355,12 +1252,11 @@ class JsonFactory extends jni$_.JObject { jsonparser$_.JsonParser$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled$1(reference.pointer, - _id_isEnabled$1 as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled$1(reference.pointer, _id_isEnabled$1.pointer, _$f.pointer) .boolean; } - static final _id_isEnabled$2 = _class.instanceMethodId( + static final _id_isEnabled$2 = JsonFactory._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z', ); @@ -1386,12 +1282,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled$2(reference.pointer, - _id_isEnabled$2 as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled$2(reference.pointer, _id_isEnabled$2.pointer, _$f.pointer) .boolean; } - static final _id_getInputDecorator = _class.instanceMethodId( + static final _id_getInputDecorator = JsonFactory._class.instanceMethodId( r'getInputDecorator', r'()Lcom/fasterxml/jackson/core/io/InputDecorator;', ); @@ -1415,12 +1310,11 @@ class JsonFactory extends jni$_.JObject { /// there is no default decorator). ///@return InputDecorator configured, if any jni$_.JObject? getInputDecorator() { - return _getInputDecorator( - reference.pointer, _id_getInputDecorator as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getInputDecorator(reference.pointer, _id_getInputDecorator.pointer) + .object(); } - static final _id_setInputDecorator = _class.instanceMethodId( + static final _id_setInputDecorator = JsonFactory._class.instanceMethodId( r'setInputDecorator', r'(Lcom/fasterxml/jackson/core/io/InputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1447,12 +1341,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? d, ) { final _$d = d?.reference ?? jni$_.jNullReference; - return _setInputDecorator(reference.pointer, - _id_setInputDecorator as jni$_.JMethodIDPtr, _$d.pointer) - .object(const $JsonFactory$NullableType$()); + return _setInputDecorator( + reference.pointer, _id_setInputDecorator.pointer, _$d.pointer) + .object(); } - static final _id_configure$2 = _class.instanceMethodId( + static final _id_configure$2 = JsonFactory._class.instanceMethodId( r'configure', r'(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;Z)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1482,12 +1376,12 @@ class JsonFactory extends jni$_.JObject { core$_.bool state, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _configure$2(reference.pointer, - _id_configure$2 as jni$_.JMethodIDPtr, _$f.pointer, state ? 1 : 0) - .object(const $JsonFactory$NullableType$()); + return _configure$2(reference.pointer, _id_configure$2.pointer, _$f.pointer, + state ? 1 : 0) + .object(); } - static final _id_enable$2 = _class.instanceMethodId( + static final _id_enable$2 = JsonFactory._class.instanceMethodId( r'enable', r'(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1514,12 +1408,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _enable$2( - reference.pointer, _id_enable$2 as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonFactory$NullableType$()); + return _enable$2(reference.pointer, _id_enable$2.pointer, _$f.pointer) + .object(); } - static final _id_disable$2 = _class.instanceMethodId( + static final _id_disable$2 = JsonFactory._class.instanceMethodId( r'disable', r'(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1546,12 +1439,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _disable$2( - reference.pointer, _id_disable$2 as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonFactory$NullableType$()); + return _disable$2(reference.pointer, _id_disable$2.pointer, _$f.pointer) + .object(); } - static final _id_isEnabled$3 = _class.instanceMethodId( + static final _id_isEnabled$3 = JsonFactory._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/JsonGenerator$Feature;)Z', ); @@ -1576,12 +1468,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled$3(reference.pointer, - _id_isEnabled$3 as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled$3(reference.pointer, _id_isEnabled$3.pointer, _$f.pointer) .boolean; } - static final _id_isEnabled$4 = _class.instanceMethodId( + static final _id_isEnabled$4 = JsonFactory._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/StreamWriteFeature;)Z', ); @@ -1607,12 +1498,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled$4(reference.pointer, - _id_isEnabled$4 as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled$4(reference.pointer, _id_isEnabled$4.pointer, _$f.pointer) .boolean; } - static final _id_getCharacterEscapes = _class.instanceMethodId( + static final _id_getCharacterEscapes = JsonFactory._class.instanceMethodId( r'getCharacterEscapes', r'()Lcom/fasterxml/jackson/core/io/CharacterEscapes;', ); @@ -1637,11 +1527,11 @@ class JsonFactory extends jni$_.JObject { ///@return Configured {@code CharacterEscapes}, if any; {@code null} if none jni$_.JObject? getCharacterEscapes() { return _getCharacterEscapes( - reference.pointer, _id_getCharacterEscapes as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_getCharacterEscapes.pointer) + .object(); } - static final _id_setCharacterEscapes = _class.instanceMethodId( + static final _id_setCharacterEscapes = JsonFactory._class.instanceMethodId( r'setCharacterEscapes', r'(Lcom/fasterxml/jackson/core/io/CharacterEscapes;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1668,12 +1558,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? esc, ) { final _$esc = esc?.reference ?? jni$_.jNullReference; - return _setCharacterEscapes(reference.pointer, - _id_setCharacterEscapes as jni$_.JMethodIDPtr, _$esc.pointer) - .object(const $JsonFactory$NullableType$()); + return _setCharacterEscapes( + reference.pointer, _id_setCharacterEscapes.pointer, _$esc.pointer) + .object(); } - static final _id_getOutputDecorator = _class.instanceMethodId( + static final _id_getOutputDecorator = JsonFactory._class.instanceMethodId( r'getOutputDecorator', r'()Lcom/fasterxml/jackson/core/io/OutputDecorator;', ); @@ -1699,11 +1589,11 @@ class JsonFactory extends jni$_.JObject { /// {@code null} if none. jni$_.JObject? getOutputDecorator() { return _getOutputDecorator( - reference.pointer, _id_getOutputDecorator as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_getOutputDecorator.pointer) + .object(); } - static final _id_setOutputDecorator = _class.instanceMethodId( + static final _id_setOutputDecorator = JsonFactory._class.instanceMethodId( r'setOutputDecorator', r'(Lcom/fasterxml/jackson/core/io/OutputDecorator;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1730,12 +1620,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? d, ) { final _$d = d?.reference ?? jni$_.jNullReference; - return _setOutputDecorator(reference.pointer, - _id_setOutputDecorator as jni$_.JMethodIDPtr, _$d.pointer) - .object(const $JsonFactory$NullableType$()); + return _setOutputDecorator( + reference.pointer, _id_setOutputDecorator.pointer, _$d.pointer) + .object(); } - static final _id_setRootValueSeparator = _class.instanceMethodId( + static final _id_setRootValueSeparator = JsonFactory._class.instanceMethodId( r'setRootValueSeparator', r'(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1763,12 +1653,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JString? sep, ) { final _$sep = sep?.reference ?? jni$_.jNullReference; - return _setRootValueSeparator(reference.pointer, - _id_setRootValueSeparator as jni$_.JMethodIDPtr, _$sep.pointer) - .object(const $JsonFactory$NullableType$()); + return _setRootValueSeparator( + reference.pointer, _id_setRootValueSeparator.pointer, _$sep.pointer) + .object(); } - static final _id_getRootValueSeparator = _class.instanceMethodId( + static final _id_getRootValueSeparator = JsonFactory._class.instanceMethodId( r'getRootValueSeparator', r'()Ljava/lang/String;', ); @@ -1791,11 +1681,11 @@ class JsonFactory extends jni$_.JObject { /// @return Root value separator configured, if any jni$_.JString? getRootValueSeparator() { return _getRootValueSeparator( - reference.pointer, _id_getRootValueSeparator as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + reference.pointer, _id_getRootValueSeparator.pointer) + .object(); } - static final _id_setCodec = _class.instanceMethodId( + static final _id_setCodec = JsonFactory._class.instanceMethodId( r'setCodec', r'(Lcom/fasterxml/jackson/core/ObjectCodec;)Lcom/fasterxml/jackson/core/JsonFactory;', ); @@ -1825,12 +1715,11 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? oc, ) { final _$oc = oc?.reference ?? jni$_.jNullReference; - return _setCodec( - reference.pointer, _id_setCodec as jni$_.JMethodIDPtr, _$oc.pointer) - .object(const $JsonFactory$NullableType$()); + return _setCodec(reference.pointer, _id_setCodec.pointer, _$oc.pointer) + .object(); } - static final _id_getCodec = _class.instanceMethodId( + static final _id_getCodec = JsonFactory._class.instanceMethodId( r'getCodec', r'()Lcom/fasterxml/jackson/core/ObjectCodec;', ); @@ -1850,11 +1739,11 @@ class JsonFactory extends jni$_.JObject { /// from: `public com.fasterxml.jackson.core.ObjectCodec getCodec()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? getCodec() { - return _getCodec(reference.pointer, _id_getCodec as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getCodec(reference.pointer, _id_getCodec.pointer) + .object(); } - static final _id_createParser = _class.instanceMethodId( + static final _id_createParser = JsonFactory._class.instanceMethodId( r'createParser', r'(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -1893,13 +1782,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _createParser(reference.pointer, - _id_createParser as jni$_.JMethodIDPtr, _$f.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser( + reference.pointer, _id_createParser.pointer, _$f.pointer) + .object(); } - static final _id_createParser$1 = _class.instanceMethodId( + static final _id_createParser$1 = JsonFactory._class.instanceMethodId( r'createParser', r'(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -1936,13 +1824,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? url, ) { final _$url = url?.reference ?? jni$_.jNullReference; - return _createParser$1(reference.pointer, - _id_createParser$1 as jni$_.JMethodIDPtr, _$url.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$1( + reference.pointer, _id_createParser$1.pointer, _$url.pointer) + .object(); } - static final _id_createParser$2 = _class.instanceMethodId( + static final _id_createParser$2 = JsonFactory._class.instanceMethodId( r'createParser', r'(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -1982,13 +1869,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? in$, ) { final _$in$ = in$?.reference ?? jni$_.jNullReference; - return _createParser$2(reference.pointer, - _id_createParser$2 as jni$_.JMethodIDPtr, _$in$.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$2( + reference.pointer, _id_createParser$2.pointer, _$in$.pointer) + .object(); } - static final _id_createParser$3 = _class.instanceMethodId( + static final _id_createParser$3 = JsonFactory._class.instanceMethodId( r'createParser', r'(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2021,13 +1907,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? r, ) { final _$r = r?.reference ?? jni$_.jNullReference; - return _createParser$3(reference.pointer, - _id_createParser$3 as jni$_.JMethodIDPtr, _$r.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$3( + reference.pointer, _id_createParser$3.pointer, _$r.pointer) + .object(); } - static final _id_createParser$4 = _class.instanceMethodId( + static final _id_createParser$4 = JsonFactory._class.instanceMethodId( r'createParser', r'([B)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2053,13 +1938,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JByteArray? data, ) { final _$data = data?.reference ?? jni$_.jNullReference; - return _createParser$4(reference.pointer, - _id_createParser$4 as jni$_.JMethodIDPtr, _$data.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$4( + reference.pointer, _id_createParser$4.pointer, _$data.pointer) + .object(); } - static final _id_createParser$5 = _class.instanceMethodId( + static final _id_createParser$5 = JsonFactory._class.instanceMethodId( r'createParser', r'([BII)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2094,17 +1978,12 @@ class JsonFactory extends jni$_.JObject { int len, ) { final _$data = data?.reference ?? jni$_.jNullReference; - return _createParser$5( - reference.pointer, - _id_createParser$5 as jni$_.JMethodIDPtr, - _$data.pointer, - offset, - len) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$5(reference.pointer, _id_createParser$5.pointer, + _$data.pointer, offset, len) + .object(); } - static final _id_createParser$6 = _class.instanceMethodId( + static final _id_createParser$6 = JsonFactory._class.instanceMethodId( r'createParser', r'(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2130,13 +2009,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JString? content, ) { final _$content = content?.reference ?? jni$_.jNullReference; - return _createParser$6(reference.pointer, - _id_createParser$6 as jni$_.JMethodIDPtr, _$content.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$6( + reference.pointer, _id_createParser$6.pointer, _$content.pointer) + .object(); } - static final _id_createParser$7 = _class.instanceMethodId( + static final _id_createParser$7 = JsonFactory._class.instanceMethodId( r'createParser', r'([C)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2162,13 +2040,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JCharArray? content, ) { final _$content = content?.reference ?? jni$_.jNullReference; - return _createParser$7(reference.pointer, - _id_createParser$7 as jni$_.JMethodIDPtr, _$content.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$7( + reference.pointer, _id_createParser$7.pointer, _$content.pointer) + .object(); } - static final _id_createParser$8 = _class.instanceMethodId( + static final _id_createParser$8 = JsonFactory._class.instanceMethodId( r'createParser', r'([CII)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2199,17 +2076,12 @@ class JsonFactory extends jni$_.JObject { int len, ) { final _$content = content?.reference ?? jni$_.jNullReference; - return _createParser$8( - reference.pointer, - _id_createParser$8 as jni$_.JMethodIDPtr, - _$content.pointer, - offset, - len) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$8(reference.pointer, _id_createParser$8.pointer, + _$content.pointer, offset, len) + .object(); } - static final _id_createParser$9 = _class.instanceMethodId( + static final _id_createParser$9 = JsonFactory._class.instanceMethodId( r'createParser', r'(Ljava/io/DataInput;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2238,13 +2110,13 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? in$, ) { final _$in$ = in$?.reference ?? jni$_.jNullReference; - return _createParser$9(reference.pointer, - _id_createParser$9 as jni$_.JMethodIDPtr, _$in$.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createParser$9( + reference.pointer, _id_createParser$9.pointer, _$in$.pointer) + .object(); } - static final _id_createNonBlockingByteArrayParser = _class.instanceMethodId( + static final _id_createNonBlockingByteArrayParser = + JsonFactory._class.instanceMethodId( r'createNonBlockingByteArrayParser', r'()Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2279,13 +2151,12 @@ class JsonFactory extends jni$_.JObject { /// at this point. ///@since 2.9 jsonparser$_.JsonParser? createNonBlockingByteArrayParser() { - return _createNonBlockingByteArrayParser(reference.pointer, - _id_createNonBlockingByteArrayParser as jni$_.JMethodIDPtr) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createNonBlockingByteArrayParser( + reference.pointer, _id_createNonBlockingByteArrayParser.pointer) + .object(); } - static final _id_createGenerator = _class.instanceMethodId( + static final _id_createGenerator = JsonFactory._class.instanceMethodId( r'createGenerator', r'(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2334,15 +2205,12 @@ class JsonFactory extends jni$_.JObject { ) { final _$out = out?.reference ?? jni$_.jNullReference; final _$enc = enc?.reference ?? jni$_.jNullReference; - return _createGenerator( - reference.pointer, - _id_createGenerator as jni$_.JMethodIDPtr, - _$out.pointer, - _$enc.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createGenerator(reference.pointer, _id_createGenerator.pointer, + _$out.pointer, _$enc.pointer) + .object(); } - static final _id_createGenerator$1 = _class.instanceMethodId( + static final _id_createGenerator$1 = JsonFactory._class.instanceMethodId( r'createGenerator', r'(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2370,12 +2238,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? out, ) { final _$out = out?.reference ?? jni$_.jNullReference; - return _createGenerator$1(reference.pointer, - _id_createGenerator$1 as jni$_.JMethodIDPtr, _$out.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createGenerator$1( + reference.pointer, _id_createGenerator$1.pointer, _$out.pointer) + .object(); } - static final _id_createGenerator$2 = _class.instanceMethodId( + static final _id_createGenerator$2 = JsonFactory._class.instanceMethodId( r'createGenerator', r'(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2409,12 +2277,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? w, ) { final _$w = w?.reference ?? jni$_.jNullReference; - return _createGenerator$2(reference.pointer, - _id_createGenerator$2 as jni$_.JMethodIDPtr, _$w.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createGenerator$2( + reference.pointer, _id_createGenerator$2.pointer, _$w.pointer) + .object(); } - static final _id_createGenerator$3 = _class.instanceMethodId( + static final _id_createGenerator$3 = JsonFactory._class.instanceMethodId( r'createGenerator', r'(Ljava/io/File;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2457,15 +2325,12 @@ class JsonFactory extends jni$_.JObject { ) { final _$f = f?.reference ?? jni$_.jNullReference; final _$enc = enc?.reference ?? jni$_.jNullReference; - return _createGenerator$3( - reference.pointer, - _id_createGenerator$3 as jni$_.JMethodIDPtr, - _$f.pointer, - _$enc.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createGenerator$3(reference.pointer, _id_createGenerator$3.pointer, + _$f.pointer, _$enc.pointer) + .object(); } - static final _id_createGenerator$4 = _class.instanceMethodId( + static final _id_createGenerator$4 = JsonFactory._class.instanceMethodId( r'createGenerator', r'(Ljava/io/DataOutput;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2499,15 +2364,12 @@ class JsonFactory extends jni$_.JObject { ) { final _$out = out?.reference ?? jni$_.jNullReference; final _$enc = enc?.reference ?? jni$_.jNullReference; - return _createGenerator$4( - reference.pointer, - _id_createGenerator$4 as jni$_.JMethodIDPtr, - _$out.pointer, - _$enc.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createGenerator$4(reference.pointer, _id_createGenerator$4.pointer, + _$out.pointer, _$enc.pointer) + .object(); } - static final _id_createGenerator$5 = _class.instanceMethodId( + static final _id_createGenerator$5 = JsonFactory._class.instanceMethodId( r'createGenerator', r'(Ljava/io/DataOutput;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2535,12 +2397,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? out, ) { final _$out = out?.reference ?? jni$_.jNullReference; - return _createGenerator$5(reference.pointer, - _id_createGenerator$5 as jni$_.JMethodIDPtr, _$out.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createGenerator$5( + reference.pointer, _id_createGenerator$5.pointer, _$out.pointer) + .object(); } - static final _id_createJsonParser = _class.instanceMethodId( + static final _id_createJsonParser = JsonFactory._class.instanceMethodId( r'createJsonParser', r'(Ljava/io/File;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2581,13 +2443,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _createJsonParser(reference.pointer, - _id_createJsonParser as jni$_.JMethodIDPtr, _$f.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createJsonParser( + reference.pointer, _id_createJsonParser.pointer, _$f.pointer) + .object(); } - static final _id_createJsonParser$1 = _class.instanceMethodId( + static final _id_createJsonParser$1 = JsonFactory._class.instanceMethodId( r'createJsonParser', r'(Ljava/net/URL;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2627,13 +2488,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? url, ) { final _$url = url?.reference ?? jni$_.jNullReference; - return _createJsonParser$1(reference.pointer, - _id_createJsonParser$1 as jni$_.JMethodIDPtr, _$url.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createJsonParser$1( + reference.pointer, _id_createJsonParser$1.pointer, _$url.pointer) + .object(); } - static final _id_createJsonParser$2 = _class.instanceMethodId( + static final _id_createJsonParser$2 = JsonFactory._class.instanceMethodId( r'createJsonParser', r'(Ljava/io/InputStream;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2676,13 +2536,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? in$, ) { final _$in$ = in$?.reference ?? jni$_.jNullReference; - return _createJsonParser$2(reference.pointer, - _id_createJsonParser$2 as jni$_.JMethodIDPtr, _$in$.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createJsonParser$2( + reference.pointer, _id_createJsonParser$2.pointer, _$in$.pointer) + .object(); } - static final _id_createJsonParser$3 = _class.instanceMethodId( + static final _id_createJsonParser$3 = JsonFactory._class.instanceMethodId( r'createJsonParser', r'(Ljava/io/Reader;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2718,13 +2577,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? r, ) { final _$r = r?.reference ?? jni$_.jNullReference; - return _createJsonParser$3(reference.pointer, - _id_createJsonParser$3 as jni$_.JMethodIDPtr, _$r.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createJsonParser$3( + reference.pointer, _id_createJsonParser$3.pointer, _$r.pointer) + .object(); } - static final _id_createJsonParser$4 = _class.instanceMethodId( + static final _id_createJsonParser$4 = JsonFactory._class.instanceMethodId( r'createJsonParser', r'([B)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2753,13 +2611,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JByteArray? data, ) { final _$data = data?.reference ?? jni$_.jNullReference; - return _createJsonParser$4(reference.pointer, - _id_createJsonParser$4 as jni$_.JMethodIDPtr, _$data.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createJsonParser$4( + reference.pointer, _id_createJsonParser$4.pointer, _$data.pointer) + .object(); } - static final _id_createJsonParser$5 = _class.instanceMethodId( + static final _id_createJsonParser$5 = JsonFactory._class.instanceMethodId( r'createJsonParser', r'([BII)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2797,17 +2654,12 @@ class JsonFactory extends jni$_.JObject { int len, ) { final _$data = data?.reference ?? jni$_.jNullReference; - return _createJsonParser$5( - reference.pointer, - _id_createJsonParser$5 as jni$_.JMethodIDPtr, - _$data.pointer, - offset, - len) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + return _createJsonParser$5(reference.pointer, + _id_createJsonParser$5.pointer, _$data.pointer, offset, len) + .object(); } - static final _id_createJsonParser$6 = _class.instanceMethodId( + static final _id_createJsonParser$6 = JsonFactory._class.instanceMethodId( r'createJsonParser', r'(Ljava/lang/String;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2838,12 +2690,11 @@ class JsonFactory extends jni$_.JObject { ) { final _$content = content?.reference ?? jni$_.jNullReference; return _createJsonParser$6(reference.pointer, - _id_createJsonParser$6 as jni$_.JMethodIDPtr, _$content.pointer) - .object( - const jsonparser$_.$JsonParser$NullableType$()); + _id_createJsonParser$6.pointer, _$content.pointer) + .object(); } - static final _id_createJsonGenerator = _class.instanceMethodId( + static final _id_createJsonGenerator = JsonFactory._class.instanceMethodId( r'createJsonGenerator', r'(Ljava/io/OutputStream;Lcom/fasterxml/jackson/core/JsonEncoding;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2894,15 +2745,12 @@ class JsonFactory extends jni$_.JObject { ) { final _$out = out?.reference ?? jni$_.jNullReference; final _$enc = enc?.reference ?? jni$_.jNullReference; - return _createJsonGenerator( - reference.pointer, - _id_createJsonGenerator as jni$_.JMethodIDPtr, - _$out.pointer, - _$enc.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createJsonGenerator(reference.pointer, + _id_createJsonGenerator.pointer, _$out.pointer, _$enc.pointer) + .object(); } - static final _id_createJsonGenerator$1 = _class.instanceMethodId( + static final _id_createJsonGenerator$1 = JsonFactory._class.instanceMethodId( r'createJsonGenerator', r'(Ljava/io/Writer;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2938,12 +2786,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? out, ) { final _$out = out?.reference ?? jni$_.jNullReference; - return _createJsonGenerator$1(reference.pointer, - _id_createJsonGenerator$1 as jni$_.JMethodIDPtr, _$out.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createJsonGenerator$1( + reference.pointer, _id_createJsonGenerator$1.pointer, _$out.pointer) + .object(); } - static final _id_createJsonGenerator$2 = _class.instanceMethodId( + static final _id_createJsonGenerator$2 = JsonFactory._class.instanceMethodId( r'createJsonGenerator', r'(Ljava/io/OutputStream;)Lcom/fasterxml/jackson/core/JsonGenerator;', ); @@ -2974,12 +2822,12 @@ class JsonFactory extends jni$_.JObject { jni$_.JObject? out, ) { final _$out = out?.reference ?? jni$_.jNullReference; - return _createJsonGenerator$2(reference.pointer, - _id_createJsonGenerator$2 as jni$_.JMethodIDPtr, _$out.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _createJsonGenerator$2( + reference.pointer, _id_createJsonGenerator$2.pointer, _$out.pointer) + .object(); } - static final _id_$_getBufferRecycler = _class.instanceMethodId( + static final _id_$_getBufferRecycler = JsonFactory._class.instanceMethodId( r'_getBufferRecycler', r'()Lcom/fasterxml/jackson/core/util/BufferRecycler;', ); @@ -3006,45 +2854,8 @@ class JsonFactory extends jni$_.JObject { ///@return Buffer recycler instance to use jni$_.JObject? $_getBufferRecycler() { return _$_getBufferRecycler( - reference.pointer, _id_$_getBufferRecycler as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); - } -} - -final class $JsonFactory$NullableType$ extends jni$_.JType { - @jni$_.internal - const $JsonFactory$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/fasterxml/jackson/core/JsonFactory;'; - - @jni$_.internal - @core$_.override - JsonFactory? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : JsonFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonFactory$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonFactory$NullableType$) && - other is $JsonFactory$NullableType$; + reference.pointer, _id_$_getBufferRecycler.pointer) + .object(); } } @@ -3055,32 +2866,4 @@ final class $JsonFactory$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/fasterxml/jackson/core/JsonFactory;'; - - @jni$_.internal - @core$_.override - JsonFactory fromReference(jni$_.JReference reference) => - JsonFactory.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonFactory$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonFactory$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonFactory$Type$) && - other is $JsonFactory$Type$; - } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonParser.dart b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonParser.dart index ef413f8833..cfa99061a7 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonParser.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonParser.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Generated from jackson-core which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. @@ -58,24 +58,11 @@ import 'JsonToken.dart' as jsontoken$_; /// from: `com.fasterxml.jackson.core.JsonParser$Feature` /// /// Enumeration that defines all on/off features for parsers. -class JsonParser$Feature extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonParser$Feature.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonParser$Feature._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/fasterxml/jackson/core/JsonParser$Feature'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonParser$Feature$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonParser$Feature$Type$(); @@ -98,7 +85,8 @@ class JsonParser$Feature extends jni$_.JObject { /// /// Feature is enabled by default. static JsonParser$Feature get AUTO_CLOSE_SOURCE => - _id_AUTO_CLOSE_SOURCE.get(_class, const $JsonParser$Feature$Type$()); + _id_AUTO_CLOSE_SOURCE.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_COMMENTS = _class.staticFieldId( r'ALLOW_COMMENTS', @@ -122,7 +110,8 @@ class JsonParser$Feature extends jni$_.JObject { /// NOTE: while not technically deprecated, since 2.10 recommended to use /// com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_JAVA_COMMENTS instead. static JsonParser$Feature get ALLOW_COMMENTS => - _id_ALLOW_COMMENTS.get(_class, const $JsonParser$Feature$Type$()); + _id_ALLOW_COMMENTS.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_YAML_COMMENTS = _class.staticFieldId( r'ALLOW_YAML_COMMENTS', @@ -146,7 +135,8 @@ class JsonParser$Feature extends jni$_.JObject { /// NOTE: while not technically deprecated, since 2.10 recommended to use /// com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_YAML_COMMENTS instead. static JsonParser$Feature get ALLOW_YAML_COMMENTS => - _id_ALLOW_YAML_COMMENTS.get(_class, const $JsonParser$Feature$Type$()); + _id_ALLOW_YAML_COMMENTS.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_UNQUOTED_FIELD_NAMES = _class.staticFieldId( r'ALLOW_UNQUOTED_FIELD_NAMES', @@ -167,8 +157,8 @@ class JsonParser$Feature extends jni$_.JObject { /// NOTE: while not technically deprecated, since 2.10 recommended to use /// com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_UNQUOTED_FIELD_NAMES instead. static JsonParser$Feature get ALLOW_UNQUOTED_FIELD_NAMES => - _id_ALLOW_UNQUOTED_FIELD_NAMES.get( - _class, const $JsonParser$Feature$Type$()); + _id_ALLOW_UNQUOTED_FIELD_NAMES.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_SINGLE_QUOTES = _class.staticFieldId( r'ALLOW_SINGLE_QUOTES', @@ -191,7 +181,8 @@ class JsonParser$Feature extends jni$_.JObject { /// NOTE: while not technically deprecated, since 2.10 recommended to use /// com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_SINGLE_QUOTES instead. static JsonParser$Feature get ALLOW_SINGLE_QUOTES => - _id_ALLOW_SINGLE_QUOTES.get(_class, const $JsonParser$Feature$Type$()); + _id_ALLOW_SINGLE_QUOTES.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_UNQUOTED_CONTROL_CHARS = _class.staticFieldId( r'ALLOW_UNQUOTED_CONTROL_CHARS', @@ -212,8 +203,8 @@ class JsonParser$Feature extends jni$_.JObject { /// this is a non-standard feature, and as such disabled by default. ///@deprecated Since 2.10 use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_UNESCAPED_CONTROL_CHARS instead static JsonParser$Feature get ALLOW_UNQUOTED_CONTROL_CHARS => - _id_ALLOW_UNQUOTED_CONTROL_CHARS.get( - _class, const $JsonParser$Feature$Type$()); + _id_ALLOW_UNQUOTED_CONTROL_CHARS.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER = _class.staticFieldId( @@ -234,7 +225,7 @@ class JsonParser$Feature extends jni$_.JObject { ///@deprecated Since 2.10 use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER instead static JsonParser$Feature get ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER => _id_ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.get( - _class, const $JsonParser$Feature$Type$()); + _class, JsonParser$Feature.type) as JsonParser$Feature; static final _id_ALLOW_NUMERIC_LEADING_ZEROS = _class.staticFieldId( r'ALLOW_NUMERIC_LEADING_ZEROS', @@ -254,8 +245,8 @@ class JsonParser$Feature extends jni$_.JObject { /// this is a non-standard feature, and as such disabled by default. ///@deprecated Since 2.10 use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_LEADING_ZEROS_FOR_NUMBERS instead static JsonParser$Feature get ALLOW_NUMERIC_LEADING_ZEROS => - _id_ALLOW_NUMERIC_LEADING_ZEROS.get( - _class, const $JsonParser$Feature$Type$()); + _id_ALLOW_NUMERIC_LEADING_ZEROS.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS = _class.staticFieldId( @@ -269,7 +260,7 @@ class JsonParser$Feature extends jni$_.JObject { /// @deprecated Use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS instead static JsonParser$Feature get ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS => _id_ALLOW_LEADING_DECIMAL_POINT_FOR_NUMBERS.get( - _class, const $JsonParser$Feature$Type$()); + _class, JsonParser$Feature.type) as JsonParser$Feature; static final _id_ALLOW_NON_NUMERIC_NUMBERS = _class.staticFieldId( r'ALLOW_NON_NUMERIC_NUMBERS', @@ -297,8 +288,8 @@ class JsonParser$Feature extends jni$_.JObject { /// this is a non-standard feature, and as such disabled by default. ///@deprecated Since 2.10 use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_NON_NUMERIC_NUMBERS instead static JsonParser$Feature get ALLOW_NON_NUMERIC_NUMBERS => - _id_ALLOW_NON_NUMERIC_NUMBERS.get( - _class, const $JsonParser$Feature$Type$()); + _id_ALLOW_NON_NUMERIC_NUMBERS.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_MISSING_VALUES = _class.staticFieldId( r'ALLOW_MISSING_VALUES', @@ -323,7 +314,8 @@ class JsonParser$Feature extends jni$_.JObject { ///@since 2.8 ///@deprecated Since 2.10 use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_MISSING_VALUES instead static JsonParser$Feature get ALLOW_MISSING_VALUES => - _id_ALLOW_MISSING_VALUES.get(_class, const $JsonParser$Feature$Type$()); + _id_ALLOW_MISSING_VALUES.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_ALLOW_TRAILING_COMMA = _class.staticFieldId( r'ALLOW_TRAILING_COMMA', @@ -353,7 +345,8 @@ class JsonParser$Feature extends jni$_.JObject { ///@since 2.9 ///@deprecated Since 2.10 use com.fasterxml.jackson.core.json.JsonReadFeature\#ALLOW_TRAILING_COMMA instead static JsonParser$Feature get ALLOW_TRAILING_COMMA => - _id_ALLOW_TRAILING_COMMA.get(_class, const $JsonParser$Feature$Type$()); + _id_ALLOW_TRAILING_COMMA.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_STRICT_DUPLICATE_DETECTION = _class.staticFieldId( r'STRICT_DUPLICATE_DETECTION', @@ -377,8 +370,8 @@ class JsonParser$Feature extends jni$_.JObject { /// adds 20-30% to execution time for basic parsing. ///@since 2.3 static JsonParser$Feature get STRICT_DUPLICATE_DETECTION => - _id_STRICT_DUPLICATE_DETECTION.get( - _class, const $JsonParser$Feature$Type$()); + _id_STRICT_DUPLICATE_DETECTION.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_IGNORE_UNDEFINED = _class.staticFieldId( r'IGNORE_UNDEFINED', @@ -408,7 +401,8 @@ class JsonParser$Feature extends jni$_.JObject { /// property will result in a JsonProcessingException ///@since 2.6 static JsonParser$Feature get IGNORE_UNDEFINED => - _id_IGNORE_UNDEFINED.get(_class, const $JsonParser$Feature$Type$()); + _id_IGNORE_UNDEFINED.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_INCLUDE_SOURCE_IN_LOCATION = _class.staticFieldId( r'INCLUDE_SOURCE_IN_LOCATION', @@ -435,8 +429,8 @@ class JsonParser$Feature extends jni$_.JObject { /// constructed either when requested explicitly, or when needed for an exception. ///@since 2.9 static JsonParser$Feature get INCLUDE_SOURCE_IN_LOCATION => - _id_INCLUDE_SOURCE_IN_LOCATION.get( - _class, const $JsonParser$Feature$Type$()); + _id_INCLUDE_SOURCE_IN_LOCATION.get(_class, JsonParser$Feature.type) + as JsonParser$Feature; static final _id_values = _class.staticMethodId( r'values', @@ -458,10 +452,8 @@ class JsonParser$Feature extends jni$_.JObject { /// from: `static public com.fasterxml.jackson.core.JsonParser$Feature[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $JsonParser$Feature$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -486,9 +478,9 @@ class JsonParser$Feature extends jni$_.JObject { jni$_.JString? name, ) { final _$name = name?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$name.pointer) - .object(const $JsonParser$Feature$NullableType$()); + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$name.pointer) + .object(); } static final _id_collectDefaults = _class.staticMethodId( @@ -515,11 +507,14 @@ class JsonParser$Feature extends jni$_.JObject { ///@return Bit mask of all features that are enabled by default static int collectDefaults() { return _collectDefaults( - _class.reference.pointer, _id_collectDefaults as jni$_.JMethodIDPtr) + _class.reference.pointer, _id_collectDefaults.pointer) .integer; } +} - static final _id_enabledByDefault = _class.instanceMethodId( +extension JsonParser$Feature$$Methods on JsonParser$Feature { + static final _id_enabledByDefault = + JsonParser$Feature._class.instanceMethodId( r'enabledByDefault', r'()Z', ); @@ -538,12 +533,11 @@ class JsonParser$Feature extends jni$_.JObject { /// from: `public boolean enabledByDefault()` core$_.bool enabledByDefault() { - return _enabledByDefault( - reference.pointer, _id_enabledByDefault as jni$_.JMethodIDPtr) + return _enabledByDefault(reference.pointer, _id_enabledByDefault.pointer) .boolean; } - static final _id_enabledIn = _class.instanceMethodId( + static final _id_enabledIn = JsonParser$Feature._class.instanceMethodId( r'enabledIn', r'(I)Z', ); @@ -563,12 +557,10 @@ class JsonParser$Feature extends jni$_.JObject { core$_.bool enabledIn( int flags, ) { - return _enabledIn( - reference.pointer, _id_enabledIn as jni$_.JMethodIDPtr, flags) - .boolean; + return _enabledIn(reference.pointer, _id_enabledIn.pointer, flags).boolean; } - static final _id_getMask = _class.instanceMethodId( + static final _id_getMask = JsonParser$Feature._class.instanceMethodId( r'getMask', r'()I', ); @@ -587,47 +579,7 @@ class JsonParser$Feature extends jni$_.JObject { /// from: `public int getMask()` int getMask() { - return _getMask(reference.pointer, _id_getMask as jni$_.JMethodIDPtr) - .integer; - } -} - -final class $JsonParser$Feature$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $JsonParser$Feature$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/fasterxml/jackson/core/JsonParser$Feature;'; - - @jni$_.internal - @core$_.override - JsonParser$Feature? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : JsonParser$Feature.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonParser$Feature$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonParser$Feature$NullableType$) && - other is $JsonParser$Feature$NullableType$; + return _getMask(reference.pointer, _id_getMask.pointer).integer; } } @@ -638,58 +590,17 @@ final class $JsonParser$Feature$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/fasterxml/jackson/core/JsonParser$Feature;'; - - @jni$_.internal - @core$_.override - JsonParser$Feature fromReference(jni$_.JReference reference) => - JsonParser$Feature.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonParser$Feature$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonParser$Feature$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonParser$Feature$Type$) && - other is $JsonParser$Feature$Type$; - } } /// from: `com.fasterxml.jackson.core.JsonParser$NumberType` /// /// Enumeration of possible "native" (optimal) types that can be /// used for numbers. -class JsonParser$NumberType extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonParser$NumberType.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonParser$NumberType._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/fasterxml/jackson/core/JsonParser$NumberType'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonParser$NumberType$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonParser$NumberType$Type$(); @@ -701,7 +612,7 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.JsonParser$NumberType INT` /// The returned object must be released after use, by calling the [release] method. static JsonParser$NumberType get INT => - _id_INT.get(_class, const $JsonParser$NumberType$Type$()); + _id_INT.get(_class, JsonParser$NumberType.type) as JsonParser$NumberType; static final _id_LONG = _class.staticFieldId( r'LONG', @@ -711,7 +622,7 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.JsonParser$NumberType LONG` /// The returned object must be released after use, by calling the [release] method. static JsonParser$NumberType get LONG => - _id_LONG.get(_class, const $JsonParser$NumberType$Type$()); + _id_LONG.get(_class, JsonParser$NumberType.type) as JsonParser$NumberType; static final _id_BIG_INTEGER = _class.staticFieldId( r'BIG_INTEGER', @@ -721,7 +632,8 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.JsonParser$NumberType BIG_INTEGER` /// The returned object must be released after use, by calling the [release] method. static JsonParser$NumberType get BIG_INTEGER => - _id_BIG_INTEGER.get(_class, const $JsonParser$NumberType$Type$()); + _id_BIG_INTEGER.get(_class, JsonParser$NumberType.type) + as JsonParser$NumberType; static final _id_FLOAT = _class.staticFieldId( r'FLOAT', @@ -731,7 +643,8 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.JsonParser$NumberType FLOAT` /// The returned object must be released after use, by calling the [release] method. static JsonParser$NumberType get FLOAT => - _id_FLOAT.get(_class, const $JsonParser$NumberType$Type$()); + _id_FLOAT.get(_class, JsonParser$NumberType.type) + as JsonParser$NumberType; static final _id_DOUBLE = _class.staticFieldId( r'DOUBLE', @@ -741,7 +654,8 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.JsonParser$NumberType DOUBLE` /// The returned object must be released after use, by calling the [release] method. static JsonParser$NumberType get DOUBLE => - _id_DOUBLE.get(_class, const $JsonParser$NumberType$Type$()); + _id_DOUBLE.get(_class, JsonParser$NumberType.type) + as JsonParser$NumberType; static final _id_BIG_DECIMAL = _class.staticFieldId( r'BIG_DECIMAL', @@ -751,7 +665,8 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public final com.fasterxml.jackson.core.JsonParser$NumberType BIG_DECIMAL` /// The returned object must be released after use, by calling the [release] method. static JsonParser$NumberType get BIG_DECIMAL => - _id_BIG_DECIMAL.get(_class, const $JsonParser$NumberType$Type$()); + _id_BIG_DECIMAL.get(_class, JsonParser$NumberType.type) + as JsonParser$NumberType; static final _id_values = _class.staticMethodId( r'values', @@ -773,10 +688,8 @@ class JsonParser$NumberType extends jni$_.JObject { /// from: `static public com.fasterxml.jackson.core.JsonParser$NumberType[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $JsonParser$NumberType$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -801,49 +714,9 @@ class JsonParser$NumberType extends jni$_.JObject { jni$_.JString? name, ) { final _$name = name?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$name.pointer) - .object( - const $JsonParser$NumberType$NullableType$()); - } -} - -final class $JsonParser$NumberType$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $JsonParser$NumberType$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/fasterxml/jackson/core/JsonParser$NumberType;'; - - @jni$_.internal - @core$_.override - JsonParser$NumberType? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : JsonParser$NumberType.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonParser$NumberType$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonParser$NumberType$NullableType$) && - other is $JsonParser$NumberType$NullableType$; + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$name.pointer) + .object(); } } @@ -855,34 +728,6 @@ final class $JsonParser$NumberType$Type$ @jni$_.internal @core$_.override String get signature => r'Lcom/fasterxml/jackson/core/JsonParser$NumberType;'; - - @jni$_.internal - @core$_.override - JsonParser$NumberType fromReference(jni$_.JReference reference) => - JsonParser$NumberType.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonParser$NumberType$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonParser$NumberType$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonParser$NumberType$Type$) && - other is $JsonParser$NumberType$Type$; - } } /// from: `com.fasterxml.jackson.core.JsonParser` @@ -891,27 +736,16 @@ final class $JsonParser$NumberType$Type$ /// Instances are created using factory methods of /// a JsonFactory instance. ///@author Tatu Saloranta -class JsonParser extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonParser.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonParser._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/fasterxml/jackson/core/JsonParser'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonParser$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonParser$Type$(); - static final _id_getCodec = _class.instanceMethodId( +} + +extension JsonParser$$Methods on JsonParser { + static final _id_getCodec = JsonParser._class.instanceMethodId( r'getCodec', r'()Lcom/fasterxml/jackson/core/ObjectCodec;', ); @@ -936,11 +770,11 @@ class JsonParser extends jni$_.JObject { /// method (and its variants). ///@return Codec assigned to this parser, if any; {@code null} if none jni$_.JObject? getCodec() { - return _getCodec(reference.pointer, _id_getCodec as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getCodec(reference.pointer, _id_getCodec.pointer) + .object(); } - static final _id_setCodec = _class.instanceMethodId( + static final _id_setCodec = JsonParser._class.instanceMethodId( r'setCodec', r'(Lcom/fasterxml/jackson/core/ObjectCodec;)V', ); @@ -966,12 +800,10 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? oc, ) { final _$oc = oc?.reference ?? jni$_.jNullReference; - _setCodec( - reference.pointer, _id_setCodec as jni$_.JMethodIDPtr, _$oc.pointer) - .check(); + _setCodec(reference.pointer, _id_setCodec.pointer, _$oc.pointer).check(); } - static final _id_getInputSource = _class.instanceMethodId( + static final _id_getInputSource = JsonParser._class.instanceMethodId( r'getInputSource', r'()Ljava/lang/Object;', ); @@ -1006,12 +838,12 @@ class JsonParser extends jni$_.JObject { /// "last effort", i.e. only used if no other mechanism is applicable. ///@return Input source this parser was configured with jni$_.JObject? getInputSource() { - return _getInputSource( - reference.pointer, _id_getInputSource as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getInputSource(reference.pointer, _id_getInputSource.pointer) + .object(); } - static final _id_setRequestPayloadOnError = _class.instanceMethodId( + static final _id_setRequestPayloadOnError = + JsonParser._class.instanceMethodId( r'setRequestPayloadOnError', r'(Lcom/fasterxml/jackson/core/util/RequestPayload;)V', ); @@ -1036,14 +868,13 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? payload, ) { final _$payload = payload?.reference ?? jni$_.jNullReference; - _setRequestPayloadOnError( - reference.pointer, - _id_setRequestPayloadOnError as jni$_.JMethodIDPtr, - _$payload.pointer) + _setRequestPayloadOnError(reference.pointer, + _id_setRequestPayloadOnError.pointer, _$payload.pointer) .check(); } - static final _id_setRequestPayloadOnError$1 = _class.instanceMethodId( + static final _id_setRequestPayloadOnError$1 = + JsonParser._class.instanceMethodId( r'setRequestPayloadOnError', r'([BLjava/lang/String;)V', ); @@ -1080,13 +911,14 @@ class JsonParser extends jni$_.JObject { final _$charset = charset?.reference ?? jni$_.jNullReference; _setRequestPayloadOnError$1( reference.pointer, - _id_setRequestPayloadOnError$1 as jni$_.JMethodIDPtr, + _id_setRequestPayloadOnError$1.pointer, _$payload.pointer, _$charset.pointer) .check(); } - static final _id_setRequestPayloadOnError$2 = _class.instanceMethodId( + static final _id_setRequestPayloadOnError$2 = + JsonParser._class.instanceMethodId( r'setRequestPayloadOnError', r'(Ljava/lang/String;)V', ); @@ -1112,14 +944,12 @@ class JsonParser extends jni$_.JObject { jni$_.JString? payload, ) { final _$payload = payload?.reference ?? jni$_.jNullReference; - _setRequestPayloadOnError$2( - reference.pointer, - _id_setRequestPayloadOnError$2 as jni$_.JMethodIDPtr, - _$payload.pointer) + _setRequestPayloadOnError$2(reference.pointer, + _id_setRequestPayloadOnError$2.pointer, _$payload.pointer) .check(); } - static final _id_setSchema = _class.instanceMethodId( + static final _id_setSchema = JsonParser._class.instanceMethodId( r'setSchema', r'(Lcom/fasterxml/jackson/core/FormatSchema;)V', ); @@ -1151,12 +981,11 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? schema, ) { final _$schema = schema?.reference ?? jni$_.jNullReference; - _setSchema(reference.pointer, _id_setSchema as jni$_.JMethodIDPtr, - _$schema.pointer) + _setSchema(reference.pointer, _id_setSchema.pointer, _$schema.pointer) .check(); } - static final _id_getSchema = _class.instanceMethodId( + static final _id_getSchema = JsonParser._class.instanceMethodId( r'getSchema', r'()Lcom/fasterxml/jackson/core/FormatSchema;', ); @@ -1181,11 +1010,11 @@ class JsonParser extends jni$_.JObject { ///@return Schema in use by this parser, if any; {@code null} if none ///@since 2.1 jni$_.JObject? getSchema() { - return _getSchema(reference.pointer, _id_getSchema as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getSchema(reference.pointer, _id_getSchema.pointer) + .object(); } - static final _id_canUseSchema = _class.instanceMethodId( + static final _id_canUseSchema = JsonParser._class.instanceMethodId( r'canUseSchema', r'(Lcom/fasterxml/jackson/core/FormatSchema;)Z', ); @@ -1211,12 +1040,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? schema, ) { final _$schema = schema?.reference ?? jni$_.jNullReference; - return _canUseSchema(reference.pointer, - _id_canUseSchema as jni$_.JMethodIDPtr, _$schema.pointer) + return _canUseSchema( + reference.pointer, _id_canUseSchema.pointer, _$schema.pointer) .boolean; } - static final _id_requiresCustomCodec = _class.instanceMethodId( + static final _id_requiresCustomCodec = JsonParser._class.instanceMethodId( r'requiresCustomCodec', r'()Z', ); @@ -1245,11 +1074,11 @@ class JsonParser extends jni$_.JObject { ///@since 2.1 core$_.bool requiresCustomCodec() { return _requiresCustomCodec( - reference.pointer, _id_requiresCustomCodec as jni$_.JMethodIDPtr) + reference.pointer, _id_requiresCustomCodec.pointer) .boolean; } - static final _id_canParseAsync = _class.instanceMethodId( + static final _id_canParseAsync = JsonParser._class.instanceMethodId( r'canParseAsync', r'()Z', ); @@ -1280,12 +1109,11 @@ class JsonParser extends jni$_.JObject { ///@return True if this is a non-blocking ("asynchronous") parser ///@since 2.9 core$_.bool canParseAsync() { - return _canParseAsync( - reference.pointer, _id_canParseAsync as jni$_.JMethodIDPtr) - .boolean; + return _canParseAsync(reference.pointer, _id_canParseAsync.pointer).boolean; } - static final _id_getNonBlockingInputFeeder = _class.instanceMethodId( + static final _id_getNonBlockingInputFeeder = + JsonParser._class.instanceMethodId( r'getNonBlockingInputFeeder', r'()Lcom/fasterxml/jackson/core/async/NonBlockingInputFeeder;', ); @@ -1311,12 +1139,12 @@ class JsonParser extends jni$_.JObject { ///@return Input feeder to use with non-blocking (async) parsing ///@since 2.9 jni$_.JObject? getNonBlockingInputFeeder() { - return _getNonBlockingInputFeeder(reference.pointer, - _id_getNonBlockingInputFeeder as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getNonBlockingInputFeeder( + reference.pointer, _id_getNonBlockingInputFeeder.pointer) + .object(); } - static final _id_getReadCapabilities = _class.instanceMethodId( + static final _id_getReadCapabilities = JsonParser._class.instanceMethodId( r'getReadCapabilities', r'()Lcom/fasterxml/jackson/core/util/JacksonFeatureSet;', ); @@ -1342,11 +1170,11 @@ class JsonParser extends jni$_.JObject { ///@since 2.12 jni$_.JObject? getReadCapabilities() { return _getReadCapabilities( - reference.pointer, _id_getReadCapabilities as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_getReadCapabilities.pointer) + .object(); } - static final _id_version = _class.instanceMethodId( + static final _id_version = JsonParser._class.instanceMethodId( r'version', r'()Lcom/fasterxml/jackson/core/Version;', ); @@ -1371,11 +1199,11 @@ class JsonParser extends jni$_.JObject { ///@return Version of this generator (derived from version declared for /// {@code jackson-core} jar that contains the class jni$_.JObject? version() { - return _version(reference.pointer, _id_version as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _version(reference.pointer, _id_version.pointer) + .object(); } - static final _id_close = _class.instanceMethodId( + static final _id_close = JsonParser._class.instanceMethodId( r'close', r'()V', ); @@ -1409,10 +1237,10 @@ class JsonParser extends jni$_.JObject { /// stream or reader it does own them. ///@throws IOException if there is either an underlying I/O problem void close() { - _close(reference.pointer, _id_close as jni$_.JMethodIDPtr).check(); + _close(reference.pointer, _id_close.pointer).check(); } - static final _id_isClosed = _class.instanceMethodId( + static final _id_isClosed = JsonParser._class.instanceMethodId( r'isClosed', r'()Z', ); @@ -1439,11 +1267,10 @@ class JsonParser extends jni$_.JObject { /// end of input. ///@return {@code True} if this parser instance has been closed core$_.bool isClosed() { - return _isClosed(reference.pointer, _id_isClosed as jni$_.JMethodIDPtr) - .boolean; + return _isClosed(reference.pointer, _id_isClosed.pointer).boolean; } - static final _id_getParsingContext = _class.instanceMethodId( + static final _id_getParsingContext = JsonParser._class.instanceMethodId( r'getParsingContext', r'()Lcom/fasterxml/jackson/core/JsonStreamContext;', ); @@ -1473,12 +1300,11 @@ class JsonParser extends jni$_.JObject { /// input, if so desired. ///@return Stream input context (JsonStreamContext) associated with this parser jni$_.JObject? getParsingContext() { - return _getParsingContext( - reference.pointer, _id_getParsingContext as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getParsingContext(reference.pointer, _id_getParsingContext.pointer) + .object(); } - static final _id_currentLocation = _class.instanceMethodId( + static final _id_currentLocation = JsonParser._class.instanceMethodId( r'currentLocation', r'()Lcom/fasterxml/jackson/core/JsonLocation;', ); @@ -1511,12 +1337,11 @@ class JsonParser extends jni$_.JObject { ///@return Location of the last processed input unit (byte or character) ///@since 2.13 jni$_.JObject? currentLocation() { - return _currentLocation( - reference.pointer, _id_currentLocation as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _currentLocation(reference.pointer, _id_currentLocation.pointer) + .object(); } - static final _id_currentTokenLocation = _class.instanceMethodId( + static final _id_currentTokenLocation = JsonParser._class.instanceMethodId( r'currentTokenLocation', r'()Lcom/fasterxml/jackson/core/JsonLocation;', ); @@ -1550,11 +1375,11 @@ class JsonParser extends jni$_.JObject { ///@since 2.13 (will eventually replace \#getTokenLocation) jni$_.JObject? currentTokenLocation() { return _currentTokenLocation( - reference.pointer, _id_currentTokenLocation as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_currentTokenLocation.pointer) + .object(); } - static final _id_getCurrentLocation = _class.instanceMethodId( + static final _id_getCurrentLocation = JsonParser._class.instanceMethodId( r'getCurrentLocation', r'()Lcom/fasterxml/jackson/core/JsonLocation;', ); @@ -1579,11 +1404,11 @@ class JsonParser extends jni$_.JObject { ///@return Location of the last processed input unit (byte or character) jni$_.JObject? getCurrentLocation() { return _getCurrentLocation( - reference.pointer, _id_getCurrentLocation as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_getCurrentLocation.pointer) + .object(); } - static final _id_getTokenLocation = _class.instanceMethodId( + static final _id_getTokenLocation = JsonParser._class.instanceMethodId( r'getTokenLocation', r'()Lcom/fasterxml/jackson/core/JsonLocation;', ); @@ -1607,12 +1432,11 @@ class JsonParser extends jni$_.JObject { /// Jackson 2.x versions (and removed from Jackson 3.0). ///@return Starting location of the token parser currently points to jni$_.JObject? getTokenLocation() { - return _getTokenLocation( - reference.pointer, _id_getTokenLocation as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getTokenLocation(reference.pointer, _id_getTokenLocation.pointer) + .object(); } - static final _id_currentValue = _class.instanceMethodId( + static final _id_currentValue = JsonParser._class.instanceMethodId( r'currentValue', r'()Ljava/lang/Object;', ); @@ -1644,12 +1468,11 @@ class JsonParser extends jni$_.JObject { ///@return "Current value" associated with the current input context (state) of this parser ///@since 2.13 (added as replacement for older \#getCurrentValue() jni$_.JObject? currentValue() { - return _currentValue( - reference.pointer, _id_currentValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _currentValue(reference.pointer, _id_currentValue.pointer) + .object(); } - static final _id_assignCurrentValue = _class.instanceMethodId( + static final _id_assignCurrentValue = JsonParser._class.instanceMethodId( r'assignCurrentValue', r'(Ljava/lang/Object;)V', ); @@ -1677,12 +1500,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? v, ) { final _$v = v?.reference ?? jni$_.jNullReference; - _assignCurrentValue(reference.pointer, - _id_assignCurrentValue as jni$_.JMethodIDPtr, _$v.pointer) + _assignCurrentValue( + reference.pointer, _id_assignCurrentValue.pointer, _$v.pointer) .check(); } - static final _id_getCurrentValue = _class.instanceMethodId( + static final _id_getCurrentValue = JsonParser._class.instanceMethodId( r'getCurrentValue', r'()Ljava/lang/Object;', ); @@ -1706,12 +1529,11 @@ class JsonParser extends jni$_.JObject { /// Jackson 2.x versions (and removed from Jackson 3.0). ///@return Location of the last processed input unit (byte or character) jni$_.JObject? getCurrentValue() { - return _getCurrentValue( - reference.pointer, _id_getCurrentValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getCurrentValue(reference.pointer, _id_getCurrentValue.pointer) + .object(); } - static final _id_setCurrentValue = _class.instanceMethodId( + static final _id_setCurrentValue = JsonParser._class.instanceMethodId( r'setCurrentValue', r'(Ljava/lang/Object;)V', ); @@ -1736,12 +1558,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? v, ) { final _$v = v?.reference ?? jni$_.jNullReference; - _setCurrentValue(reference.pointer, - _id_setCurrentValue as jni$_.JMethodIDPtr, _$v.pointer) + _setCurrentValue( + reference.pointer, _id_setCurrentValue.pointer, _$v.pointer) .check(); } - static final _id_releaseBuffered = _class.instanceMethodId( + static final _id_releaseBuffered = JsonParser._class.instanceMethodId( r'releaseBuffered', r'(Ljava/io/OutputStream;)I', ); @@ -1774,12 +1596,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? out, ) { final _$out = out?.reference ?? jni$_.jNullReference; - return _releaseBuffered(reference.pointer, - _id_releaseBuffered as jni$_.JMethodIDPtr, _$out.pointer) + return _releaseBuffered( + reference.pointer, _id_releaseBuffered.pointer, _$out.pointer) .integer; } - static final _id_releaseBuffered$1 = _class.instanceMethodId( + static final _id_releaseBuffered$1 = JsonParser._class.instanceMethodId( r'releaseBuffered', r'(Ljava/io/Writer;)I', ); @@ -1813,12 +1635,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? w, ) { final _$w = w?.reference ?? jni$_.jNullReference; - return _releaseBuffered$1(reference.pointer, - _id_releaseBuffered$1 as jni$_.JMethodIDPtr, _$w.pointer) + return _releaseBuffered$1( + reference.pointer, _id_releaseBuffered$1.pointer, _$w.pointer) .integer; } - static final _id_enable = _class.instanceMethodId( + static final _id_enable = JsonParser._class.instanceMethodId( r'enable', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -1845,12 +1667,11 @@ class JsonParser extends jni$_.JObject { JsonParser$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _enable( - reference.pointer, _id_enable as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonParser$NullableType$()); + return _enable(reference.pointer, _id_enable.pointer, _$f.pointer) + .object(); } - static final _id_disable = _class.instanceMethodId( + static final _id_disable = JsonParser._class.instanceMethodId( r'disable', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -1877,12 +1698,11 @@ class JsonParser extends jni$_.JObject { JsonParser$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _disable( - reference.pointer, _id_disable as jni$_.JMethodIDPtr, _$f.pointer) - .object(const $JsonParser$NullableType$()); + return _disable(reference.pointer, _id_disable.pointer, _$f.pointer) + .object(); } - static final _id_configure = _class.instanceMethodId( + static final _id_configure = JsonParser._class.instanceMethodId( r'configure', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;Z)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -1912,12 +1732,12 @@ class JsonParser extends jni$_.JObject { core$_.bool state, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _configure(reference.pointer, _id_configure as jni$_.JMethodIDPtr, - _$f.pointer, state ? 1 : 0) - .object(const $JsonParser$NullableType$()); + return _configure(reference.pointer, _id_configure.pointer, _$f.pointer, + state ? 1 : 0) + .object(); } - static final _id_isEnabled = _class.instanceMethodId( + static final _id_isEnabled = JsonParser._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/JsonParser$Feature;)Z', ); @@ -1942,12 +1762,11 @@ class JsonParser extends jni$_.JObject { JsonParser$Feature? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled( - reference.pointer, _id_isEnabled as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled(reference.pointer, _id_isEnabled.pointer, _$f.pointer) .boolean; } - static final _id_isEnabled$1 = _class.instanceMethodId( + static final _id_isEnabled$1 = JsonParser._class.instanceMethodId( r'isEnabled', r'(Lcom/fasterxml/jackson/core/StreamReadFeature;)Z', ); @@ -1973,12 +1792,11 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? f, ) { final _$f = f?.reference ?? jni$_.jNullReference; - return _isEnabled$1(reference.pointer, - _id_isEnabled$1 as jni$_.JMethodIDPtr, _$f.pointer) + return _isEnabled$1(reference.pointer, _id_isEnabled$1.pointer, _$f.pointer) .boolean; } - static final _id_getFeatureMask = _class.instanceMethodId( + static final _id_getFeatureMask = JsonParser._class.instanceMethodId( r'getFeatureMask', r'()I', ); @@ -2001,12 +1819,11 @@ class JsonParser extends jni$_.JObject { ///@return Bit mask that defines current states of all standard Features. ///@since 2.3 int getFeatureMask() { - return _getFeatureMask( - reference.pointer, _id_getFeatureMask as jni$_.JMethodIDPtr) + return _getFeatureMask(reference.pointer, _id_getFeatureMask.pointer) .integer; } - static final _id_setFeatureMask = _class.instanceMethodId( + static final _id_setFeatureMask = JsonParser._class.instanceMethodId( r'setFeatureMask', r'(I)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2032,12 +1849,11 @@ class JsonParser extends jni$_.JObject { JsonParser? setFeatureMask( int mask, ) { - return _setFeatureMask( - reference.pointer, _id_setFeatureMask as jni$_.JMethodIDPtr, mask) - .object(const $JsonParser$NullableType$()); + return _setFeatureMask(reference.pointer, _id_setFeatureMask.pointer, mask) + .object(); } - static final _id_overrideStdFeatures = _class.instanceMethodId( + static final _id_overrideStdFeatures = JsonParser._class.instanceMethodId( r'overrideStdFeatures', r'(II)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2072,12 +1888,12 @@ class JsonParser extends jni$_.JObject { int values, int mask, ) { - return _overrideStdFeatures(reference.pointer, - _id_overrideStdFeatures as jni$_.JMethodIDPtr, values, mask) - .object(const $JsonParser$NullableType$()); + return _overrideStdFeatures( + reference.pointer, _id_overrideStdFeatures.pointer, values, mask) + .object(); } - static final _id_getFormatFeatures = _class.instanceMethodId( + static final _id_getFormatFeatures = JsonParser._class.instanceMethodId( r'getFormatFeatures', r'()I', ); @@ -2101,12 +1917,11 @@ class JsonParser extends jni$_.JObject { ///@return Bit mask that defines current states of all standard FormatFeatures. ///@since 2.6 int getFormatFeatures() { - return _getFormatFeatures( - reference.pointer, _id_getFormatFeatures as jni$_.JMethodIDPtr) + return _getFormatFeatures(reference.pointer, _id_getFormatFeatures.pointer) .integer; } - static final _id_overrideFormatFeatures = _class.instanceMethodId( + static final _id_overrideFormatFeatures = JsonParser._class.instanceMethodId( r'overrideFormatFeatures', r'(II)Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2139,12 +1954,12 @@ class JsonParser extends jni$_.JObject { int values, int mask, ) { - return _overrideFormatFeatures(reference.pointer, - _id_overrideFormatFeatures as jni$_.JMethodIDPtr, values, mask) - .object(const $JsonParser$NullableType$()); + return _overrideFormatFeatures( + reference.pointer, _id_overrideFormatFeatures.pointer, values, mask) + .object(); } - static final _id_nextToken = _class.instanceMethodId( + static final _id_nextToken = JsonParser._class.instanceMethodId( r'nextToken', r'()Lcom/fasterxml/jackson/core/JsonToken;', ); @@ -2173,12 +1988,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jsontoken$_.JsonToken? nextToken() { - return _nextToken(reference.pointer, _id_nextToken as jni$_.JMethodIDPtr) - .object( - const jsontoken$_.$JsonToken$NullableType$()); + return _nextToken(reference.pointer, _id_nextToken.pointer) + .object(); } - static final _id_nextValue = _class.instanceMethodId( + static final _id_nextValue = JsonParser._class.instanceMethodId( r'nextValue', r'()Lcom/fasterxml/jackson/core/JsonToken;', ); @@ -2215,12 +2029,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jsontoken$_.JsonToken? nextValue() { - return _nextValue(reference.pointer, _id_nextValue as jni$_.JMethodIDPtr) - .object( - const jsontoken$_.$JsonToken$NullableType$()); + return _nextValue(reference.pointer, _id_nextValue.pointer) + .object(); } - static final _id_nextFieldName = _class.instanceMethodId( + static final _id_nextFieldName = JsonParser._class.instanceMethodId( r'nextFieldName', r'(Lcom/fasterxml/jackson/core/SerializableString;)Z', ); @@ -2257,12 +2070,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? str, ) { final _$str = str?.reference ?? jni$_.jNullReference; - return _nextFieldName(reference.pointer, - _id_nextFieldName as jni$_.JMethodIDPtr, _$str.pointer) + return _nextFieldName( + reference.pointer, _id_nextFieldName.pointer, _$str.pointer) .boolean; } - static final _id_nextFieldName$1 = _class.instanceMethodId( + static final _id_nextFieldName$1 = JsonParser._class.instanceMethodId( r'nextFieldName', r'()Ljava/lang/String;', ); @@ -2291,12 +2104,11 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.5 jni$_.JString? nextFieldName$1() { - return _nextFieldName$1( - reference.pointer, _id_nextFieldName$1 as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _nextFieldName$1(reference.pointer, _id_nextFieldName$1.pointer) + .object(); } - static final _id_nextTextValue = _class.instanceMethodId( + static final _id_nextTextValue = JsonParser._class.instanceMethodId( r'nextTextValue', r'()Ljava/lang/String;', ); @@ -2330,12 +2142,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JString? nextTextValue() { - return _nextTextValue( - reference.pointer, _id_nextTextValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _nextTextValue(reference.pointer, _id_nextTextValue.pointer) + .object(); } - static final _id_nextIntValue = _class.instanceMethodId( + static final _id_nextIntValue = JsonParser._class.instanceMethodId( r'nextIntValue', r'(I)I', ); @@ -2372,12 +2183,12 @@ class JsonParser extends jni$_.JObject { int nextIntValue( int defaultValue, ) { - return _nextIntValue(reference.pointer, - _id_nextIntValue as jni$_.JMethodIDPtr, defaultValue) + return _nextIntValue( + reference.pointer, _id_nextIntValue.pointer, defaultValue) .integer; } - static final _id_nextLongValue = _class.instanceMethodId( + static final _id_nextLongValue = JsonParser._class.instanceMethodId( r'nextLongValue', r'(J)J', ); @@ -2414,12 +2225,12 @@ class JsonParser extends jni$_.JObject { int nextLongValue( int defaultValue, ) { - return _nextLongValue(reference.pointer, - _id_nextLongValue as jni$_.JMethodIDPtr, defaultValue) + return _nextLongValue( + reference.pointer, _id_nextLongValue.pointer, defaultValue) .long; } - static final _id_nextBooleanValue = _class.instanceMethodId( + static final _id_nextBooleanValue = JsonParser._class.instanceMethodId( r'nextBooleanValue', r'()Ljava/lang/Boolean;', ); @@ -2456,12 +2267,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JBoolean? nextBooleanValue() { - return _nextBooleanValue( - reference.pointer, _id_nextBooleanValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JBoolean$NullableType$()); + return _nextBooleanValue(reference.pointer, _id_nextBooleanValue.pointer) + .object(); } - static final _id_skipChildren = _class.instanceMethodId( + static final _id_skipChildren = JsonParser._class.instanceMethodId( r'skipChildren', r'()Lcom/fasterxml/jackson/core/JsonParser;', ); @@ -2497,12 +2307,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems JsonParser? skipChildren() { - return _skipChildren( - reference.pointer, _id_skipChildren as jni$_.JMethodIDPtr) - .object(const $JsonParser$NullableType$()); + return _skipChildren(reference.pointer, _id_skipChildren.pointer) + .object(); } - static final _id_finishToken = _class.instanceMethodId( + static final _id_finishToken = JsonParser._class.instanceMethodId( r'finishToken', r'()V', ); @@ -2535,11 +2344,10 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.8 void finishToken() { - _finishToken(reference.pointer, _id_finishToken as jni$_.JMethodIDPtr) - .check(); + _finishToken(reference.pointer, _id_finishToken.pointer).check(); } - static final _id_currentToken = _class.instanceMethodId( + static final _id_currentToken = JsonParser._class.instanceMethodId( r'currentToken', r'()Lcom/fasterxml/jackson/core/JsonToken;', ); @@ -2569,13 +2377,11 @@ class JsonParser extends jni$_.JObject { /// if the current token has been explicitly cleared. ///@since 2.8 jsontoken$_.JsonToken? currentToken() { - return _currentToken( - reference.pointer, _id_currentToken as jni$_.JMethodIDPtr) - .object( - const jsontoken$_.$JsonToken$NullableType$()); + return _currentToken(reference.pointer, _id_currentToken.pointer) + .object(); } - static final _id_currentTokenId = _class.instanceMethodId( + static final _id_currentTokenId = JsonParser._class.instanceMethodId( r'currentTokenId', r'()I', ); @@ -2604,12 +2410,11 @@ class JsonParser extends jni$_.JObject { ///@since 2.8 ///@return {@code int} matching one of constants from JsonTokenId. int currentTokenId() { - return _currentTokenId( - reference.pointer, _id_currentTokenId as jni$_.JMethodIDPtr) + return _currentTokenId(reference.pointer, _id_currentTokenId.pointer) .integer; } - static final _id_getCurrentToken = _class.instanceMethodId( + static final _id_getCurrentToken = JsonParser._class.instanceMethodId( r'getCurrentToken', r'()Lcom/fasterxml/jackson/core/JsonToken;', ); @@ -2634,13 +2439,11 @@ class JsonParser extends jni$_.JObject { ///@return Type of the token this parser currently points to, /// if any: null before any tokens have been read, and jsontoken$_.JsonToken? getCurrentToken() { - return _getCurrentToken( - reference.pointer, _id_getCurrentToken as jni$_.JMethodIDPtr) - .object( - const jsontoken$_.$JsonToken$NullableType$()); + return _getCurrentToken(reference.pointer, _id_getCurrentToken.pointer) + .object(); } - static final _id_getCurrentTokenId = _class.instanceMethodId( + static final _id_getCurrentTokenId = JsonParser._class.instanceMethodId( r'getCurrentTokenId', r'()I', ); @@ -2663,12 +2466,11 @@ class JsonParser extends jni$_.JObject { ///@return {@code int} matching one of constants from JsonTokenId. ///@deprecated Since 2.12 use \#currentTokenId instead int getCurrentTokenId() { - return _getCurrentTokenId( - reference.pointer, _id_getCurrentTokenId as jni$_.JMethodIDPtr) + return _getCurrentTokenId(reference.pointer, _id_getCurrentTokenId.pointer) .integer; } - static final _id_hasCurrentToken = _class.instanceMethodId( + static final _id_hasCurrentToken = JsonParser._class.instanceMethodId( r'hasCurrentToken', r'()Z', ); @@ -2696,12 +2498,11 @@ class JsonParser extends jni$_.JObject { /// and returned null from \#nextToken, or the token /// has been consumed) core$_.bool hasCurrentToken() { - return _hasCurrentToken( - reference.pointer, _id_hasCurrentToken as jni$_.JMethodIDPtr) + return _hasCurrentToken(reference.pointer, _id_hasCurrentToken.pointer) .boolean; } - static final _id_hasTokenId = _class.instanceMethodId( + static final _id_hasTokenId = JsonParser._class.instanceMethodId( r'hasTokenId', r'(I)Z', ); @@ -2734,12 +2535,10 @@ class JsonParser extends jni$_.JObject { core$_.bool hasTokenId( int id, ) { - return _hasTokenId( - reference.pointer, _id_hasTokenId as jni$_.JMethodIDPtr, id) - .boolean; + return _hasTokenId(reference.pointer, _id_hasTokenId.pointer, id).boolean; } - static final _id_hasToken = _class.instanceMethodId( + static final _id_hasToken = JsonParser._class.instanceMethodId( r'hasToken', r'(Lcom/fasterxml/jackson/core/JsonToken;)Z', ); @@ -2773,12 +2572,12 @@ class JsonParser extends jni$_.JObject { jsontoken$_.JsonToken? t, ) { final _$t = t?.reference ?? jni$_.jNullReference; - return _hasToken( - reference.pointer, _id_hasToken as jni$_.JMethodIDPtr, _$t.pointer) + return _hasToken(reference.pointer, _id_hasToken.pointer, _$t.pointer) .boolean; } - static final _id_isExpectedStartArrayToken = _class.instanceMethodId( + static final _id_isExpectedStartArrayToken = + JsonParser._class.instanceMethodId( r'isExpectedStartArrayToken', r'()Z', ); @@ -2814,12 +2613,13 @@ class JsonParser extends jni$_.JObject { /// start-array marker (such JsonToken\#START_ARRAY); /// {@code false} if not core$_.bool isExpectedStartArrayToken() { - return _isExpectedStartArrayToken(reference.pointer, - _id_isExpectedStartArrayToken as jni$_.JMethodIDPtr) + return _isExpectedStartArrayToken( + reference.pointer, _id_isExpectedStartArrayToken.pointer) .boolean; } - static final _id_isExpectedStartObjectToken = _class.instanceMethodId( + static final _id_isExpectedStartObjectToken = + JsonParser._class.instanceMethodId( r'isExpectedStartObjectToken', r'()Z', ); @@ -2846,12 +2646,13 @@ class JsonParser extends jni$_.JObject { /// {@code false} if not ///@since 2.5 core$_.bool isExpectedStartObjectToken() { - return _isExpectedStartObjectToken(reference.pointer, - _id_isExpectedStartObjectToken as jni$_.JMethodIDPtr) + return _isExpectedStartObjectToken( + reference.pointer, _id_isExpectedStartObjectToken.pointer) .boolean; } - static final _id_isExpectedNumberIntToken = _class.instanceMethodId( + static final _id_isExpectedNumberIntToken = + JsonParser._class.instanceMethodId( r'isExpectedNumberIntToken', r'()Z', ); @@ -2880,12 +2681,12 @@ class JsonParser extends jni$_.JObject { /// {@code false} if not ///@since 2.12 core$_.bool isExpectedNumberIntToken() { - return _isExpectedNumberIntToken(reference.pointer, - _id_isExpectedNumberIntToken as jni$_.JMethodIDPtr) + return _isExpectedNumberIntToken( + reference.pointer, _id_isExpectedNumberIntToken.pointer) .boolean; } - static final _id_isNaN = _class.instanceMethodId( + static final _id_isNaN = JsonParser._class.instanceMethodId( r'isNaN', r'()Z', ); @@ -2917,10 +2718,10 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.9 core$_.bool isNaN() { - return _isNaN(reference.pointer, _id_isNaN as jni$_.JMethodIDPtr).boolean; + return _isNaN(reference.pointer, _id_isNaN.pointer).boolean; } - static final _id_clearCurrentToken = _class.instanceMethodId( + static final _id_clearCurrentToken = JsonParser._class.instanceMethodId( r'clearCurrentToken', r'()V', ); @@ -2950,12 +2751,11 @@ class JsonParser extends jni$_.JObject { /// it has to be able to consume last token used for binding (so that /// it will not be used again). void clearCurrentToken() { - _clearCurrentToken( - reference.pointer, _id_clearCurrentToken as jni$_.JMethodIDPtr) + _clearCurrentToken(reference.pointer, _id_clearCurrentToken.pointer) .check(); } - static final _id_getLastClearedToken = _class.instanceMethodId( + static final _id_getLastClearedToken = JsonParser._class.instanceMethodId( r'getLastClearedToken', r'()Lcom/fasterxml/jackson/core/JsonToken;', ); @@ -2983,12 +2783,11 @@ class JsonParser extends jni$_.JObject { ///@return Last cleared token, if any; {@code null} otherwise jsontoken$_.JsonToken? getLastClearedToken() { return _getLastClearedToken( - reference.pointer, _id_getLastClearedToken as jni$_.JMethodIDPtr) - .object( - const jsontoken$_.$JsonToken$NullableType$()); + reference.pointer, _id_getLastClearedToken.pointer) + .object(); } - static final _id_overrideCurrentName = _class.instanceMethodId( + static final _id_overrideCurrentName = JsonParser._class.instanceMethodId( r'overrideCurrentName', r'(Ljava/lang/String;)V', ); @@ -3018,12 +2817,12 @@ class JsonParser extends jni$_.JObject { jni$_.JString? name, ) { final _$name = name?.reference ?? jni$_.jNullReference; - _overrideCurrentName(reference.pointer, - _id_overrideCurrentName as jni$_.JMethodIDPtr, _$name.pointer) + _overrideCurrentName( + reference.pointer, _id_overrideCurrentName.pointer, _$name.pointer) .check(); } - static final _id_getCurrentName = _class.instanceMethodId( + static final _id_getCurrentName = JsonParser._class.instanceMethodId( r'getCurrentName', r'()Ljava/lang/String;', ); @@ -3048,12 +2847,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JString? getCurrentName() { - return _getCurrentName( - reference.pointer, _id_getCurrentName as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getCurrentName(reference.pointer, _id_getCurrentName.pointer) + .object(); } - static final _id_currentName = _class.instanceMethodId( + static final _id_currentName = JsonParser._class.instanceMethodId( r'currentName', r'()Ljava/lang/String;', ); @@ -3083,12 +2881,11 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.10 jni$_.JString? currentName() { - return _currentName( - reference.pointer, _id_currentName as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _currentName(reference.pointer, _id_currentName.pointer) + .object(); } - static final _id_getText = _class.instanceMethodId( + static final _id_getText = JsonParser._class.instanceMethodId( r'getText', r'()Ljava/lang/String;', ); @@ -3117,11 +2914,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JString? getText() { - return _getText(reference.pointer, _id_getText as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getText(reference.pointer, _id_getText.pointer) + .object(); } - static final _id_getText$1 = _class.instanceMethodId( + static final _id_getText$1 = JsonParser._class.instanceMethodId( r'getText', r'(Ljava/io/Writer;)I', ); @@ -3158,12 +2955,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? writer, ) { final _$writer = writer?.reference ?? jni$_.jNullReference; - return _getText$1(reference.pointer, _id_getText$1 as jni$_.JMethodIDPtr, - _$writer.pointer) + return _getText$1( + reference.pointer, _id_getText$1.pointer, _$writer.pointer) .integer; } - static final _id_getTextCharacters = _class.instanceMethodId( + static final _id_getTextCharacters = JsonParser._class.instanceMethodId( r'getTextCharacters', r'()[C', ); @@ -3211,12 +3008,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JCharArray? getTextCharacters() { - return _getTextCharacters( - reference.pointer, _id_getTextCharacters as jni$_.JMethodIDPtr) - .object(const jni$_.$JCharArray$NullableType$()); + return _getTextCharacters(reference.pointer, _id_getTextCharacters.pointer) + .object(); } - static final _id_getTextLength = _class.instanceMethodId( + static final _id_getTextLength = JsonParser._class.instanceMethodId( r'getTextLength', r'()I', ); @@ -3243,12 +3039,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getTextLength() { - return _getTextLength( - reference.pointer, _id_getTextLength as jni$_.JMethodIDPtr) - .integer; + return _getTextLength(reference.pointer, _id_getTextLength.pointer).integer; } - static final _id_getTextOffset = _class.instanceMethodId( + static final _id_getTextOffset = JsonParser._class.instanceMethodId( r'getTextOffset', r'()I', ); @@ -3275,12 +3069,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getTextOffset() { - return _getTextOffset( - reference.pointer, _id_getTextOffset as jni$_.JMethodIDPtr) - .integer; + return _getTextOffset(reference.pointer, _id_getTextOffset.pointer).integer; } - static final _id_hasTextCharacters = _class.instanceMethodId( + static final _id_hasTextCharacters = JsonParser._class.instanceMethodId( r'hasTextCharacters', r'()Z', ); @@ -3314,12 +3106,11 @@ class JsonParser extends jni$_.JObject { /// be efficiently returned via \#getTextCharacters; false /// means that it may or may not exist core$_.bool hasTextCharacters() { - return _hasTextCharacters( - reference.pointer, _id_hasTextCharacters as jni$_.JMethodIDPtr) + return _hasTextCharacters(reference.pointer, _id_hasTextCharacters.pointer) .boolean; } - static final _id_getNumberValue = _class.instanceMethodId( + static final _id_getNumberValue = JsonParser._class.instanceMethodId( r'getNumberValue', r'()Ljava/lang/Number;', ); @@ -3350,12 +3141,11 @@ class JsonParser extends jni$_.JObject { /// (invalid format for numbers); plain IOException if underlying /// content read fails (possible if values are extracted lazily) jni$_.JNumber? getNumberValue() { - return _getNumberValue( - reference.pointer, _id_getNumberValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JNumber$NullableType$()); + return _getNumberValue(reference.pointer, _id_getNumberValue.pointer) + .object(); } - static final _id_getNumberValueExact = _class.instanceMethodId( + static final _id_getNumberValueExact = JsonParser._class.instanceMethodId( r'getNumberValueExact', r'()Ljava/lang/Number;', ); @@ -3391,11 +3181,11 @@ class JsonParser extends jni$_.JObject { ///@since 2.12 jni$_.JNumber? getNumberValueExact() { return _getNumberValueExact( - reference.pointer, _id_getNumberValueExact as jni$_.JMethodIDPtr) - .object(const jni$_.$JNumber$NullableType$()); + reference.pointer, _id_getNumberValueExact.pointer) + .object(); } - static final _id_getNumberType = _class.instanceMethodId( + static final _id_getNumberType = JsonParser._class.instanceMethodId( r'getNumberType', r'()Lcom/fasterxml/jackson/core/JsonParser$NumberType;', ); @@ -3423,13 +3213,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems JsonParser$NumberType? getNumberType() { - return _getNumberType( - reference.pointer, _id_getNumberType as jni$_.JMethodIDPtr) - .object( - const $JsonParser$NumberType$NullableType$()); + return _getNumberType(reference.pointer, _id_getNumberType.pointer) + .object(); } - static final _id_getByteValue = _class.instanceMethodId( + static final _id_getByteValue = JsonParser._class.instanceMethodId( r'getByteValue', r'()B', ); @@ -3470,12 +3258,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getByteValue() { - return _getByteValue( - reference.pointer, _id_getByteValue as jni$_.JMethodIDPtr) - .byte; + return _getByteValue(reference.pointer, _id_getByteValue.pointer).byte; } - static final _id_getShortValue = _class.instanceMethodId( + static final _id_getShortValue = JsonParser._class.instanceMethodId( r'getShortValue', r'()S', ); @@ -3510,12 +3296,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getShortValue() { - return _getShortValue( - reference.pointer, _id_getShortValue as jni$_.JMethodIDPtr) - .short; + return _getShortValue(reference.pointer, _id_getShortValue.pointer).short; } - static final _id_getIntValue = _class.instanceMethodId( + static final _id_getIntValue = JsonParser._class.instanceMethodId( r'getIntValue', r'()I', ); @@ -3550,12 +3334,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getIntValue() { - return _getIntValue( - reference.pointer, _id_getIntValue as jni$_.JMethodIDPtr) - .integer; + return _getIntValue(reference.pointer, _id_getIntValue.pointer).integer; } - static final _id_getLongValue = _class.instanceMethodId( + static final _id_getLongValue = JsonParser._class.instanceMethodId( r'getLongValue', r'()J', ); @@ -3590,12 +3372,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getLongValue() { - return _getLongValue( - reference.pointer, _id_getLongValue as jni$_.JMethodIDPtr) - .long; + return _getLongValue(reference.pointer, _id_getLongValue.pointer).long; } - static final _id_getBigIntegerValue = _class.instanceMethodId( + static final _id_getBigIntegerValue = JsonParser._class.instanceMethodId( r'getBigIntegerValue', r'()Ljava/math/BigInteger;', ); @@ -3628,11 +3408,11 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems jni$_.JObject? getBigIntegerValue() { return _getBigIntegerValue( - reference.pointer, _id_getBigIntegerValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + reference.pointer, _id_getBigIntegerValue.pointer) + .object(); } - static final _id_getFloatValue = _class.instanceMethodId( + static final _id_getFloatValue = JsonParser._class.instanceMethodId( r'getFloatValue', r'()F', ); @@ -3667,12 +3447,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems double getFloatValue() { - return _getFloatValue( - reference.pointer, _id_getFloatValue as jni$_.JMethodIDPtr) - .float; + return _getFloatValue(reference.pointer, _id_getFloatValue.pointer).float; } - static final _id_getDoubleValue = _class.instanceMethodId( + static final _id_getDoubleValue = JsonParser._class.instanceMethodId( r'getDoubleValue', r'()D', ); @@ -3707,12 +3485,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems double getDoubleValue() { - return _getDoubleValue( - reference.pointer, _id_getDoubleValue as jni$_.JMethodIDPtr) + return _getDoubleValue(reference.pointer, _id_getDoubleValue.pointer) .doubleFloat; } - static final _id_getDecimalValue = _class.instanceMethodId( + static final _id_getDecimalValue = JsonParser._class.instanceMethodId( r'getDecimalValue', r'()Ljava/math/BigDecimal;', ); @@ -3741,12 +3518,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JObject? getDecimalValue() { - return _getDecimalValue( - reference.pointer, _id_getDecimalValue as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getDecimalValue(reference.pointer, _id_getDecimalValue.pointer) + .object(); } - static final _id_getBooleanValue = _class.instanceMethodId( + static final _id_getBooleanValue = JsonParser._class.instanceMethodId( r'getBooleanValue', r'()Z', ); @@ -3777,12 +3553,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems core$_.bool getBooleanValue() { - return _getBooleanValue( - reference.pointer, _id_getBooleanValue as jni$_.JMethodIDPtr) + return _getBooleanValue(reference.pointer, _id_getBooleanValue.pointer) .boolean; } - static final _id_getEmbeddedObject = _class.instanceMethodId( + static final _id_getEmbeddedObject = JsonParser._class.instanceMethodId( r'getEmbeddedObject', r'()Ljava/lang/Object;', ); @@ -3817,12 +3592,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JObject? getEmbeddedObject() { - return _getEmbeddedObject( - reference.pointer, _id_getEmbeddedObject as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getEmbeddedObject(reference.pointer, _id_getEmbeddedObject.pointer) + .object(); } - static final _id_getBinaryValue = _class.instanceMethodId( + static final _id_getBinaryValue = JsonParser._class.instanceMethodId( r'getBinaryValue', r'(Lcom/fasterxml/jackson/core/Base64Variant;)[B', ); @@ -3865,12 +3639,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? bv, ) { final _$bv = bv?.reference ?? jni$_.jNullReference; - return _getBinaryValue(reference.pointer, - _id_getBinaryValue as jni$_.JMethodIDPtr, _$bv.pointer) - .object(const jni$_.$JByteArray$NullableType$()); + return _getBinaryValue( + reference.pointer, _id_getBinaryValue.pointer, _$bv.pointer) + .object(); } - static final _id_getBinaryValue$1 = _class.instanceMethodId( + static final _id_getBinaryValue$1 = JsonParser._class.instanceMethodId( r'getBinaryValue', r'()[B', ); @@ -3897,12 +3671,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems jni$_.JByteArray? getBinaryValue$1() { - return _getBinaryValue$1( - reference.pointer, _id_getBinaryValue$1 as jni$_.JMethodIDPtr) - .object(const jni$_.$JByteArray$NullableType$()); + return _getBinaryValue$1(reference.pointer, _id_getBinaryValue$1.pointer) + .object(); } - static final _id_readBinaryValue = _class.instanceMethodId( + static final _id_readBinaryValue = JsonParser._class.instanceMethodId( r'readBinaryValue', r'(Ljava/io/OutputStream;)I', ); @@ -3935,12 +3708,12 @@ class JsonParser extends jni$_.JObject { jni$_.JObject? out, ) { final _$out = out?.reference ?? jni$_.jNullReference; - return _readBinaryValue(reference.pointer, - _id_readBinaryValue as jni$_.JMethodIDPtr, _$out.pointer) + return _readBinaryValue( + reference.pointer, _id_readBinaryValue.pointer, _$out.pointer) .integer; } - static final _id_readBinaryValue$1 = _class.instanceMethodId( + static final _id_readBinaryValue$1 = JsonParser._class.instanceMethodId( r'readBinaryValue', r'(Lcom/fasterxml/jackson/core/Base64Variant;Ljava/io/OutputStream;)I', ); @@ -3978,15 +3751,12 @@ class JsonParser extends jni$_.JObject { ) { final _$bv = bv?.reference ?? jni$_.jNullReference; final _$out = out?.reference ?? jni$_.jNullReference; - return _readBinaryValue$1( - reference.pointer, - _id_readBinaryValue$1 as jni$_.JMethodIDPtr, - _$bv.pointer, - _$out.pointer) + return _readBinaryValue$1(reference.pointer, _id_readBinaryValue$1.pointer, + _$bv.pointer, _$out.pointer) .integer; } - static final _id_getValueAsInt = _class.instanceMethodId( + static final _id_getValueAsInt = JsonParser._class.instanceMethodId( r'getValueAsInt', r'()I', ); @@ -4019,12 +3789,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getValueAsInt() { - return _getValueAsInt( - reference.pointer, _id_getValueAsInt as jni$_.JMethodIDPtr) - .integer; + return _getValueAsInt(reference.pointer, _id_getValueAsInt.pointer).integer; } - static final _id_getValueAsInt$1 = _class.instanceMethodId( + static final _id_getValueAsInt$1 = JsonParser._class.instanceMethodId( r'getValueAsInt', r'(I)I', ); @@ -4057,12 +3825,11 @@ class JsonParser extends jni$_.JObject { int getValueAsInt$1( int def, ) { - return _getValueAsInt$1( - reference.pointer, _id_getValueAsInt$1 as jni$_.JMethodIDPtr, def) + return _getValueAsInt$1(reference.pointer, _id_getValueAsInt$1.pointer, def) .integer; } - static final _id_getValueAsLong = _class.instanceMethodId( + static final _id_getValueAsLong = JsonParser._class.instanceMethodId( r'getValueAsLong', r'()J', ); @@ -4095,12 +3862,10 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems int getValueAsLong() { - return _getValueAsLong( - reference.pointer, _id_getValueAsLong as jni$_.JMethodIDPtr) - .long; + return _getValueAsLong(reference.pointer, _id_getValueAsLong.pointer).long; } - static final _id_getValueAsLong$1 = _class.instanceMethodId( + static final _id_getValueAsLong$1 = JsonParser._class.instanceMethodId( r'getValueAsLong', r'(J)J', ); @@ -4134,11 +3899,11 @@ class JsonParser extends jni$_.JObject { int def, ) { return _getValueAsLong$1( - reference.pointer, _id_getValueAsLong$1 as jni$_.JMethodIDPtr, def) + reference.pointer, _id_getValueAsLong$1.pointer, def) .long; } - static final _id_getValueAsDouble = _class.instanceMethodId( + static final _id_getValueAsDouble = JsonParser._class.instanceMethodId( r'getValueAsDouble', r'()D', ); @@ -4171,12 +3936,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems double getValueAsDouble() { - return _getValueAsDouble( - reference.pointer, _id_getValueAsDouble as jni$_.JMethodIDPtr) + return _getValueAsDouble(reference.pointer, _id_getValueAsDouble.pointer) .doubleFloat; } - static final _id_getValueAsDouble$1 = _class.instanceMethodId( + static final _id_getValueAsDouble$1 = JsonParser._class.instanceMethodId( r'getValueAsDouble', r'(D)D', ); @@ -4210,12 +3974,12 @@ class JsonParser extends jni$_.JObject { double getValueAsDouble$1( double def, ) { - return _getValueAsDouble$1(reference.pointer, - _id_getValueAsDouble$1 as jni$_.JMethodIDPtr, def) + return _getValueAsDouble$1( + reference.pointer, _id_getValueAsDouble$1.pointer, def) .doubleFloat; } - static final _id_getValueAsBoolean = _class.instanceMethodId( + static final _id_getValueAsBoolean = JsonParser._class.instanceMethodId( r'getValueAsBoolean', r'()Z', ); @@ -4248,12 +4012,11 @@ class JsonParser extends jni$_.JObject { ///@throws IOException for low-level read issues, or /// JsonParseException for decoding problems core$_.bool getValueAsBoolean() { - return _getValueAsBoolean( - reference.pointer, _id_getValueAsBoolean as jni$_.JMethodIDPtr) + return _getValueAsBoolean(reference.pointer, _id_getValueAsBoolean.pointer) .boolean; } - static final _id_getValueAsBoolean$1 = _class.instanceMethodId( + static final _id_getValueAsBoolean$1 = JsonParser._class.instanceMethodId( r'getValueAsBoolean', r'(Z)Z', ); @@ -4287,12 +4050,12 @@ class JsonParser extends jni$_.JObject { core$_.bool getValueAsBoolean$1( core$_.bool def, ) { - return _getValueAsBoolean$1(reference.pointer, - _id_getValueAsBoolean$1 as jni$_.JMethodIDPtr, def ? 1 : 0) + return _getValueAsBoolean$1( + reference.pointer, _id_getValueAsBoolean$1.pointer, def ? 1 : 0) .boolean; } - static final _id_getValueAsString = _class.instanceMethodId( + static final _id_getValueAsString = JsonParser._class.instanceMethodId( r'getValueAsString', r'()Ljava/lang/String;', ); @@ -4324,12 +4087,11 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.1 jni$_.JString? getValueAsString() { - return _getValueAsString( - reference.pointer, _id_getValueAsString as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getValueAsString(reference.pointer, _id_getValueAsString.pointer) + .object(); } - static final _id_getValueAsString$1 = _class.instanceMethodId( + static final _id_getValueAsString$1 = JsonParser._class.instanceMethodId( r'getValueAsString', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -4364,12 +4126,12 @@ class JsonParser extends jni$_.JObject { jni$_.JString? def, ) { final _$def = def?.reference ?? jni$_.jNullReference; - return _getValueAsString$1(reference.pointer, - _id_getValueAsString$1 as jni$_.JMethodIDPtr, _$def.pointer) - .object(const jni$_.$JString$NullableType$()); + return _getValueAsString$1( + reference.pointer, _id_getValueAsString$1.pointer, _$def.pointer) + .object(); } - static final _id_canReadObjectId = _class.instanceMethodId( + static final _id_canReadObjectId = JsonParser._class.instanceMethodId( r'canReadObjectId', r'()Z', ); @@ -4400,12 +4162,11 @@ class JsonParser extends jni$_.JObject { /// {@code false} if not ///@since 2.3 core$_.bool canReadObjectId() { - return _canReadObjectId( - reference.pointer, _id_canReadObjectId as jni$_.JMethodIDPtr) + return _canReadObjectId(reference.pointer, _id_canReadObjectId.pointer) .boolean; } - static final _id_canReadTypeId = _class.instanceMethodId( + static final _id_canReadTypeId = JsonParser._class.instanceMethodId( r'canReadTypeId', r'()Z', ); @@ -4436,12 +4197,10 @@ class JsonParser extends jni$_.JObject { /// {@code false} if not ///@since 2.3 core$_.bool canReadTypeId() { - return _canReadTypeId( - reference.pointer, _id_canReadTypeId as jni$_.JMethodIDPtr) - .boolean; + return _canReadTypeId(reference.pointer, _id_canReadTypeId.pointer).boolean; } - static final _id_getObjectId = _class.instanceMethodId( + static final _id_getObjectId = JsonParser._class.instanceMethodId( r'getObjectId', r'()Ljava/lang/Object;', ); @@ -4475,12 +4234,11 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.3 jni$_.JObject? getObjectId() { - return _getObjectId( - reference.pointer, _id_getObjectId as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getObjectId(reference.pointer, _id_getObjectId.pointer) + .object(); } - static final _id_getTypeId = _class.instanceMethodId( + static final _id_getTypeId = JsonParser._class.instanceMethodId( r'getTypeId', r'()Ljava/lang/Object;', ); @@ -4514,11 +4272,11 @@ class JsonParser extends jni$_.JObject { /// JsonParseException for decoding problems ///@since 2.3 jni$_.JObject? getTypeId() { - return _getTypeId(reference.pointer, _id_getTypeId as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getTypeId(reference.pointer, _id_getTypeId.pointer) + .object(); } - static final _id_readValueAs = _class.instanceMethodId( + static final _id_readValueAs = JsonParser._class.instanceMethodId( r'readValueAs', r'(Ljava/lang/Class;)Ljava/lang/Object;', ); @@ -4563,16 +4321,15 @@ class JsonParser extends jni$_.JObject { ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer $T? readValueAs<$T extends jni$_.JObject?>( - jni$_.JObject? valueType, { - required jni$_.JType<$T> T, - }) { + jni$_.JObject? valueType, + ) { final _$valueType = valueType?.reference ?? jni$_.jNullReference; - return _readValueAs(reference.pointer, - _id_readValueAs as jni$_.JMethodIDPtr, _$valueType.pointer) - .object<$T?>(T.nullableType); + return _readValueAs( + reference.pointer, _id_readValueAs.pointer, _$valueType.pointer) + .object<$T?>(); } - static final _id_readValueAs$1 = _class.instanceMethodId( + static final _id_readValueAs$1 = JsonParser._class.instanceMethodId( r'readValueAs', r'(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/lang/Object;', ); @@ -4614,16 +4371,15 @@ class JsonParser extends jni$_.JObject { ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer $T? readValueAs$1<$T extends jni$_.JObject?>( - jni$_.JObject? valueTypeRef, { - required jni$_.JType<$T> T, - }) { + jni$_.JObject? valueTypeRef, + ) { final _$valueTypeRef = valueTypeRef?.reference ?? jni$_.jNullReference; - return _readValueAs$1(reference.pointer, - _id_readValueAs$1 as jni$_.JMethodIDPtr, _$valueTypeRef.pointer) - .object<$T?>(T.nullableType); + return _readValueAs$1(reference.pointer, _id_readValueAs$1.pointer, + _$valueTypeRef.pointer) + .object<$T?>(); } - static final _id_readValuesAs = _class.instanceMethodId( + static final _id_readValuesAs = JsonParser._class.instanceMethodId( r'readValuesAs', r'(Ljava/lang/Class;)Ljava/util/Iterator;', ); @@ -4651,17 +4407,15 @@ class JsonParser extends jni$_.JObject { ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer jni$_.JIterator<$T?>? readValuesAs<$T extends jni$_.JObject?>( - jni$_.JObject? valueType, { - required jni$_.JType<$T> T, - }) { + jni$_.JObject? valueType, + ) { final _$valueType = valueType?.reference ?? jni$_.jNullReference; - return _readValuesAs(reference.pointer, - _id_readValuesAs as jni$_.JMethodIDPtr, _$valueType.pointer) - .object?>( - jni$_.$JIterator$NullableType$<$T?>(T.nullableType)); + return _readValuesAs( + reference.pointer, _id_readValuesAs.pointer, _$valueType.pointer) + .object?>(); } - static final _id_readValuesAs$1 = _class.instanceMethodId( + static final _id_readValuesAs$1 = JsonParser._class.instanceMethodId( r'readValuesAs', r'(Lcom/fasterxml/jackson/core/type/TypeReference;)Ljava/util/Iterator;', ); @@ -4689,17 +4443,15 @@ class JsonParser extends jni$_.JObject { ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer jni$_.JIterator<$T?>? readValuesAs$1<$T extends jni$_.JObject?>( - jni$_.JObject? valueTypeRef, { - required jni$_.JType<$T> T, - }) { + jni$_.JObject? valueTypeRef, + ) { final _$valueTypeRef = valueTypeRef?.reference ?? jni$_.jNullReference; - return _readValuesAs$1(reference.pointer, - _id_readValuesAs$1 as jni$_.JMethodIDPtr, _$valueTypeRef.pointer) - .object?>( - jni$_.$JIterator$NullableType$<$T?>(T.nullableType)); + return _readValuesAs$1(reference.pointer, _id_readValuesAs$1.pointer, + _$valueTypeRef.pointer) + .object?>(); } - static final _id_readValueAsTree = _class.instanceMethodId( + static final _id_readValueAsTree = JsonParser._class.instanceMethodId( r'readValueAsTree', r'()Lcom/fasterxml/jackson/core/TreeNode;', ); @@ -4728,49 +4480,9 @@ class JsonParser extends jni$_.JObject { ///@return root of the document, or null if empty or whitespace. ///@throws IOException if there is either an underlying I/O problem or decoding /// issue at format layer - $T? readValueAsTree<$T extends jni$_.JObject?>({ - required jni$_.JType<$T> T, - }) { - return _readValueAsTree( - reference.pointer, _id_readValueAsTree as jni$_.JMethodIDPtr) - .object<$T?>(T.nullableType); - } -} - -final class $JsonParser$NullableType$ extends jni$_.JType { - @jni$_.internal - const $JsonParser$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/fasterxml/jackson/core/JsonParser;'; - - @jni$_.internal - @core$_.override - JsonParser? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : JsonParser.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonParser$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonParser$NullableType$) && - other is $JsonParser$NullableType$; + $T? readValueAsTree<$T extends jni$_.JObject?>() { + return _readValueAsTree(reference.pointer, _id_readValueAsTree.pointer) + .object<$T?>(); } } @@ -4781,32 +4493,4 @@ final class $JsonParser$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/fasterxml/jackson/core/JsonParser;'; - - @jni$_.internal - @core$_.override - JsonParser fromReference(jni$_.JReference reference) => - JsonParser.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonParser$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonParser$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonParser$Type$) && - other is $JsonParser$Type$; - } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonToken.dart b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonToken.dart index fe88517378..ca70c56c55 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonToken.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/JsonToken.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Generated from jackson-core which is licensed under the Apache License 2.0. // The following copyright from the original authors applies. @@ -57,24 +57,10 @@ import 'package:jni/jni.dart' as jni$_; /// /// Enumeration for basic token types used for returning results /// of parsing JSON content. -class JsonToken extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonToken.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonToken._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/fasterxml/jackson/core/JsonToken'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonToken$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonToken$Type$(); static final _id_NOT_AVAILABLE = _class.staticFieldId( @@ -93,7 +79,7 @@ class JsonToken extends jni$_.JObject { /// they can not block to wait for more data to parse and /// must return something. static JsonToken get NOT_AVAILABLE => - _id_NOT_AVAILABLE.get(_class, const $JsonToken$Type$()); + _id_NOT_AVAILABLE.get(_class, JsonToken.type) as JsonToken; static final _id_START_OBJECT = _class.staticFieldId( r'START_OBJECT', @@ -106,7 +92,7 @@ class JsonToken extends jni$_.JObject { /// START_OBJECT is returned when encountering '{' /// which signals starting of an Object value. static JsonToken get START_OBJECT => - _id_START_OBJECT.get(_class, const $JsonToken$Type$()); + _id_START_OBJECT.get(_class, JsonToken.type) as JsonToken; static final _id_END_OBJECT = _class.staticFieldId( r'END_OBJECT', @@ -119,7 +105,7 @@ class JsonToken extends jni$_.JObject { /// END_OBJECT is returned when encountering '}' /// which signals ending of an Object value static JsonToken get END_OBJECT => - _id_END_OBJECT.get(_class, const $JsonToken$Type$()); + _id_END_OBJECT.get(_class, JsonToken.type) as JsonToken; static final _id_START_ARRAY = _class.staticFieldId( r'START_ARRAY', @@ -132,7 +118,7 @@ class JsonToken extends jni$_.JObject { /// START_ARRAY is returned when encountering '[' /// which signals starting of an Array value static JsonToken get START_ARRAY => - _id_START_ARRAY.get(_class, const $JsonToken$Type$()); + _id_START_ARRAY.get(_class, JsonToken.type) as JsonToken; static final _id_END_ARRAY = _class.staticFieldId( r'END_ARRAY', @@ -145,7 +131,7 @@ class JsonToken extends jni$_.JObject { /// END_ARRAY is returned when encountering ']' /// which signals ending of an Array value static JsonToken get END_ARRAY => - _id_END_ARRAY.get(_class, const $JsonToken$Type$()); + _id_END_ARRAY.get(_class, JsonToken.type) as JsonToken; static final _id_FIELD_NAME = _class.staticFieldId( r'FIELD_NAME', @@ -158,7 +144,7 @@ class JsonToken extends jni$_.JObject { /// FIELD_NAME is returned when a String token is encountered /// as a field name (same lexical value, different function) static JsonToken get FIELD_NAME => - _id_FIELD_NAME.get(_class, const $JsonToken$Type$()); + _id_FIELD_NAME.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_EMBEDDED_OBJECT = _class.staticFieldId( r'VALUE_EMBEDDED_OBJECT', @@ -177,7 +163,7 @@ class JsonToken extends jni$_.JObject { /// only by readers that expose other kinds of source (like /// JsonNode-based JSON trees, Maps, Lists and such). static JsonToken get VALUE_EMBEDDED_OBJECT => - _id_VALUE_EMBEDDED_OBJECT.get(_class, const $JsonToken$Type$()); + _id_VALUE_EMBEDDED_OBJECT.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_STRING = _class.staticFieldId( r'VALUE_STRING', @@ -191,7 +177,7 @@ class JsonToken extends jni$_.JObject { /// in value context (array element, field value, or root-level /// stand-alone value) static JsonToken get VALUE_STRING => - _id_VALUE_STRING.get(_class, const $JsonToken$Type$()); + _id_VALUE_STRING.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_NUMBER_INT = _class.staticFieldId( r'VALUE_NUMBER_INT', @@ -208,7 +194,7 @@ class JsonToken extends jni$_.JObject { /// or, for binary formats, is indicated as integral number /// by internal representation). static JsonToken get VALUE_NUMBER_INT => - _id_VALUE_NUMBER_INT.get(_class, const $JsonToken$Type$()); + _id_VALUE_NUMBER_INT.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_NUMBER_FLOAT = _class.staticFieldId( r'VALUE_NUMBER_FLOAT', @@ -224,7 +210,7 @@ class JsonToken extends jni$_.JObject { /// to one or more digits (or, for non-textual formats, /// has internal floating-point representation). static JsonToken get VALUE_NUMBER_FLOAT => - _id_VALUE_NUMBER_FLOAT.get(_class, const $JsonToken$Type$()); + _id_VALUE_NUMBER_FLOAT.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_TRUE = _class.staticFieldId( r'VALUE_TRUE', @@ -237,7 +223,7 @@ class JsonToken extends jni$_.JObject { /// VALUE_TRUE is returned when encountering literal "true" in /// value context static JsonToken get VALUE_TRUE => - _id_VALUE_TRUE.get(_class, const $JsonToken$Type$()); + _id_VALUE_TRUE.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_FALSE = _class.staticFieldId( r'VALUE_FALSE', @@ -250,7 +236,7 @@ class JsonToken extends jni$_.JObject { /// VALUE_FALSE is returned when encountering literal "false" in /// value context static JsonToken get VALUE_FALSE => - _id_VALUE_FALSE.get(_class, const $JsonToken$Type$()); + _id_VALUE_FALSE.get(_class, JsonToken.type) as JsonToken; static final _id_VALUE_NULL = _class.staticFieldId( r'VALUE_NULL', @@ -263,7 +249,7 @@ class JsonToken extends jni$_.JObject { /// VALUE_NULL is returned when encountering literal "null" in /// value context static JsonToken get VALUE_NULL => - _id_VALUE_NULL.get(_class, const $JsonToken$Type$()); + _id_VALUE_NULL.get(_class, JsonToken.type) as JsonToken; static final _id_values = _class.staticMethodId( r'values', @@ -285,10 +271,8 @@ class JsonToken extends jni$_.JObject { /// from: `static public com.fasterxml.jackson.core.JsonToken[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $JsonToken$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -313,12 +297,14 @@ class JsonToken extends jni$_.JObject { jni$_.JString? name, ) { final _$name = name?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$name.pointer) - .object(const $JsonToken$NullableType$()); + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$name.pointer) + .object(); } +} - static final _id_id = _class.instanceMethodId( +extension JsonToken$$Methods on JsonToken { + static final _id_id = JsonToken._class.instanceMethodId( r'id', r'()I', ); @@ -337,10 +323,10 @@ class JsonToken extends jni$_.JObject { /// from: `public final int id()` int id() { - return _id(reference.pointer, _id_id as jni$_.JMethodIDPtr).integer; + return _id(reference.pointer, _id_id.pointer).integer; } - static final _id_asString = _class.instanceMethodId( + static final _id_asString = JsonToken._class.instanceMethodId( r'asString', r'()Ljava/lang/String;', ); @@ -360,11 +346,11 @@ class JsonToken extends jni$_.JObject { /// from: `public final java.lang.String asString()` /// The returned object must be released after use, by calling the [release] method. jni$_.JString? asString() { - return _asString(reference.pointer, _id_asString as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _asString(reference.pointer, _id_asString.pointer) + .object(); } - static final _id_asCharArray = _class.instanceMethodId( + static final _id_asCharArray = JsonToken._class.instanceMethodId( r'asCharArray', r'()[C', ); @@ -384,12 +370,11 @@ class JsonToken extends jni$_.JObject { /// from: `public final char[] asCharArray()` /// The returned object must be released after use, by calling the [release] method. jni$_.JCharArray? asCharArray() { - return _asCharArray( - reference.pointer, _id_asCharArray as jni$_.JMethodIDPtr) - .object(const jni$_.$JCharArray$NullableType$()); + return _asCharArray(reference.pointer, _id_asCharArray.pointer) + .object(); } - static final _id_asByteArray = _class.instanceMethodId( + static final _id_asByteArray = JsonToken._class.instanceMethodId( r'asByteArray', r'()[B', ); @@ -409,12 +394,11 @@ class JsonToken extends jni$_.JObject { /// from: `public final byte[] asByteArray()` /// The returned object must be released after use, by calling the [release] method. jni$_.JByteArray? asByteArray() { - return _asByteArray( - reference.pointer, _id_asByteArray as jni$_.JMethodIDPtr) - .object(const jni$_.$JByteArray$NullableType$()); + return _asByteArray(reference.pointer, _id_asByteArray.pointer) + .object(); } - static final _id_isNumeric = _class.instanceMethodId( + static final _id_isNumeric = JsonToken._class.instanceMethodId( r'isNumeric', r'()Z', ); @@ -436,11 +420,10 @@ class JsonToken extends jni$_.JObject { /// @return {@code True} if this token is {@code VALUE_NUMBER_INT} or {@code VALUE_NUMBER_FLOAT}, /// {@code false} otherwise core$_.bool isNumeric() { - return _isNumeric(reference.pointer, _id_isNumeric as jni$_.JMethodIDPtr) - .boolean; + return _isNumeric(reference.pointer, _id_isNumeric.pointer).boolean; } - static final _id_isStructStart = _class.instanceMethodId( + static final _id_isStructStart = JsonToken._class.instanceMethodId( r'isStructStart', r'()Z', ); @@ -467,12 +450,10 @@ class JsonToken extends jni$_.JObject { /// {@code false} otherwise ///@since 2.3 core$_.bool isStructStart() { - return _isStructStart( - reference.pointer, _id_isStructStart as jni$_.JMethodIDPtr) - .boolean; + return _isStructStart(reference.pointer, _id_isStructStart.pointer).boolean; } - static final _id_isStructEnd = _class.instanceMethodId( + static final _id_isStructEnd = JsonToken._class.instanceMethodId( r'isStructEnd', r'()Z', ); @@ -499,12 +480,10 @@ class JsonToken extends jni$_.JObject { /// {@code false} otherwise ///@since 2.3 core$_.bool isStructEnd() { - return _isStructEnd( - reference.pointer, _id_isStructEnd as jni$_.JMethodIDPtr) - .boolean; + return _isStructEnd(reference.pointer, _id_isStructEnd.pointer).boolean; } - static final _id_isScalarValue = _class.instanceMethodId( + static final _id_isScalarValue = JsonToken._class.instanceMethodId( r'isScalarValue', r'()Z', ); @@ -530,12 +509,10 @@ class JsonToken extends jni$_.JObject { ///@return {@code True} if this token is a scalar value token (one of /// {@code VALUE_xxx} tokens), {@code false} otherwise core$_.bool isScalarValue() { - return _isScalarValue( - reference.pointer, _id_isScalarValue as jni$_.JMethodIDPtr) - .boolean; + return _isScalarValue(reference.pointer, _id_isScalarValue.pointer).boolean; } - static final _id_isBoolean = _class.instanceMethodId( + static final _id_isBoolean = JsonToken._class.instanceMethodId( r'isBoolean', r'()Z', ); @@ -557,45 +534,7 @@ class JsonToken extends jni$_.JObject { /// @return {@code True} if this token is {@code VALUE_TRUE} or {@code VALUE_FALSE}, /// {@code false} otherwise core$_.bool isBoolean() { - return _isBoolean(reference.pointer, _id_isBoolean as jni$_.JMethodIDPtr) - .boolean; - } -} - -final class $JsonToken$NullableType$ extends jni$_.JType { - @jni$_.internal - const $JsonToken$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/fasterxml/jackson/core/JsonToken;'; - - @jni$_.internal - @core$_.override - JsonToken? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : JsonToken.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonToken$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonToken$NullableType$) && - other is $JsonToken$NullableType$; + return _isBoolean(reference.pointer, _id_isBoolean.pointer).boolean; } } @@ -606,30 +545,4 @@ final class $JsonToken$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/fasterxml/jackson/core/JsonToken;'; - - @jni$_.internal - @core$_.override - JsonToken fromReference(jni$_.JReference reference) => - JsonToken.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $JsonToken$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonToken$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonToken$Type$) && other is $JsonToken$Type$; - } } diff --git a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/_package.dart b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/_package.dart index 80b986f2d4..fe8a53fa4b 100644 --- a/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/_package.dart +++ b/pkgs/jnigen/test/jackson_core_test/third_party/bindings/com/fasterxml/jackson/core/_package.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! export 'JsonFactory.dart'; export 'JsonParser.dart'; export 'JsonToken.dart'; diff --git a/pkgs/jnigen/test/kotlin_test/bindings/kotlin.dart b/pkgs/jnigen/test/kotlin_test/bindings/kotlin.dart index 6aa7b25644..6516884068 100644 --- a/pkgs/jnigen/test/kotlin_test/bindings/kotlin.dart +++ b/pkgs/jnigen/test/kotlin_test/bindings/kotlin.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a @@ -41,46 +41,12 @@ import 'package:jni/_internal.dart' as jni$_; import 'package:jni/jni.dart' as jni$_; /// from: `com.github.dart_lang.jnigen.CanDoA` -class CanDoA extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - CanDoA.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type CanDoA._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/CanDoA'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $CanDoA$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $CanDoA$Type$(); - static final _id_doA = _class.instanceMethodId( - r'doA', - r'()V', - ); - - static final _doA = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public fun doA(): kotlin.Unit` - void doA() { - _doA(reference.pointer, _id_doA as jni$_.JMethodIDPtr).check(); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -154,9 +120,31 @@ class CanDoA extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return CanDoA.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension CanDoA$$Methods on CanDoA { + static final _id_doA = CanDoA._class.instanceMethodId( + r'doA', + r'()V', + ); + + static final _doA = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public fun doA(): kotlin.Unit` + void doA() { + _doA(reference.pointer, _id_doA.pointer).check(); } } @@ -184,43 +172,6 @@ final class _$CanDoA with $CanDoA { } } -final class $CanDoA$NullableType$ extends jni$_.JType { - @jni$_.internal - const $CanDoA$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/CanDoA;'; - - @jni$_.internal - @core$_.override - CanDoA? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : CanDoA.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($CanDoA$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($CanDoA$NullableType$) && - other is $CanDoA$NullableType$; - } -} - final class $CanDoA$Type$ extends jni$_.JType { @jni$_.internal const $CanDoA$Type$(); @@ -228,74 +179,15 @@ final class $CanDoA$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/CanDoA;'; - - @jni$_.internal - @core$_.override - CanDoA fromReference(jni$_.JReference reference) => CanDoA.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $CanDoA$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($CanDoA$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($CanDoA$Type$) && other is $CanDoA$Type$; - } } /// from: `com.github.dart_lang.jnigen.CanDoB` -class CanDoB extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - CanDoB.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type CanDoB._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/CanDoB'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $CanDoB$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $CanDoB$Type$(); - static final _id_doB = _class.instanceMethodId( - r'doB', - r'()V', - ); - - static final _doB = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public fun doB(): kotlin.Unit` - void doB() { - _doB(reference.pointer, _id_doB as jni$_.JMethodIDPtr).check(); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -369,9 +261,31 @@ class CanDoB extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return CanDoB.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension CanDoB$$Methods on CanDoB { + static final _id_doB = CanDoB._class.instanceMethodId( + r'doB', + r'()V', + ); + + static final _doB = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public fun doB(): kotlin.Unit` + void doB() { + _doB(reference.pointer, _id_doB.pointer).check(); } } @@ -399,43 +313,6 @@ final class _$CanDoB with $CanDoB { } } -final class $CanDoB$NullableType$ extends jni$_.JType { - @jni$_.internal - const $CanDoB$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/CanDoB;'; - - @jni$_.internal - @core$_.override - CanDoB? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : CanDoB.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($CanDoB$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($CanDoB$NullableType$) && - other is $CanDoB$NullableType$; - } -} - final class $CanDoB$Type$ extends jni$_.JType { @jni$_.internal const $CanDoB$Type$(); @@ -443,71 +320,20 @@ final class $CanDoB$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/CanDoB;'; - - @jni$_.internal - @core$_.override - CanDoB fromReference(jni$_.JReference reference) => CanDoB.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $CanDoB$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($CanDoB$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($CanDoB$Type$) && other is $CanDoB$Type$; - } } /// from: `com.github.dart_lang.jnigen.Measure` -class Measure<$T extends jni$_.JObject> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - Measure.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type Measure<$T extends jni$_.JObject>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/Measure'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject>( - jni$_.JType<$T> T, - ) { - return $Measure$NullableType$<$T>( - T, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject>( - jni$_.JType<$T> T, - ) { - return $Measure$Type$<$T>( - T, - ); - } + static const jni$_.JType type = $Measure$Type$(); +} - static final _id_getValue = _class.instanceMethodId( +extension Measure$$Methods<$T extends jni$_.JObject> on Measure<$T> { + static final _id_getValue = Measure._class.instanceMethodId( r'getValue', r'()F', ); @@ -526,11 +352,10 @@ class Measure<$T extends jni$_.JObject> extends jni$_.JObject { /// from: `public float getValue()` double getValue() { - return _getValue(reference.pointer, _id_getValue as jni$_.JMethodIDPtr) - .float; + return _getValue(reference.pointer, _id_getValue.pointer).float; } - static final _id_getUnit = _class.instanceMethodId( + static final _id_getUnit = Measure._class.instanceMethodId( r'getUnit', r'()Lcom/github/dart_lang/jnigen/MeasureUnit;', ); @@ -550,11 +375,10 @@ class Measure<$T extends jni$_.JObject> extends jni$_.JObject { /// from: `public T getUnit()` /// The returned object must be released after use, by calling the [release] method. $T getUnit() { - return _getUnit(reference.pointer, _id_getUnit as jni$_.JMethodIDPtr) - .object<$T>(T); + return _getUnit(reference.pointer, _id_getUnit.pointer).object<$T>(); } - static final _id_convertValue = _class.instanceMethodId( + static final _id_convertValue = Measure._class.instanceMethodId( r'convertValue', r'(Lcom/github/dart_lang/jnigen/MeasureUnit;)F', ); @@ -575,169 +399,28 @@ class Measure<$T extends jni$_.JObject> extends jni$_.JObject { $T measureUnit, ) { final _$measureUnit = measureUnit.reference; - return _convertValue(reference.pointer, - _id_convertValue as jni$_.JMethodIDPtr, _$measureUnit.pointer) + return _convertValue( + reference.pointer, _id_convertValue.pointer, _$measureUnit.pointer) .float; } } -final class $Measure$NullableType$<$T extends jni$_.JObject> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $Measure$NullableType$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/Measure;'; - - @jni$_.internal - @core$_.override - Measure<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Measure<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Measure$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Measure$NullableType$<$T>) && - other is $Measure$NullableType$<$T> && - T == other.T; - } -} - -final class $Measure$Type$<$T extends jni$_.JObject> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - +final class $Measure$Type$ extends jni$_.JType { @jni$_.internal - const $Measure$Type$( - this.T, - ); + const $Measure$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/Measure;'; - - @jni$_.internal - @core$_.override - Measure<$T> fromReference(jni$_.JReference reference) => - Measure<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => $Measure$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Measure$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Measure$Type$<$T>) && - other is $Measure$Type$<$T> && - T == other.T; - } } /// from: `com.github.dart_lang.jnigen.MeasureUnit` -class MeasureUnit extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - MeasureUnit.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type MeasureUnit._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/MeasureUnit'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $MeasureUnit$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $MeasureUnit$Type$(); - static final _id_getSign = _class.instanceMethodId( - r'getSign', - r'()Ljava/lang/String;', - ); - - static final _getSign = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public abstract java.lang.String getSign()` - /// The returned object must be released after use, by calling the [release] method. - jni$_.JString getSign() { - return _getSign(reference.pointer, _id_getSign as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); - } - - static final _id_getCoefficient = _class.instanceMethodId( - r'getCoefficient', - r'()F', - ); - - static final _getCoefficient = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallFloatMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public abstract float getCoefficient()` - double getCoefficient() { - return _getCoefficient( - reference.pointer, _id_getCoefficient as jni$_.JMethodIDPtr) - .float; - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -817,9 +500,55 @@ class MeasureUnit extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return MeasureUnit.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension MeasureUnit$$Methods on MeasureUnit { + static final _id_getSign = MeasureUnit._class.instanceMethodId( + r'getSign', + r'()Ljava/lang/String;', + ); + + static final _getSign = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.lang.String getSign()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString getSign() { + return _getSign(reference.pointer, _id_getSign.pointer) + .object(); + } + + static final _id_getCoefficient = MeasureUnit._class.instanceMethodId( + r'getCoefficient', + r'()F', + ); + + static final _getCoefficient = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallFloatMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract float getCoefficient()` + double getCoefficient() { + return _getCoefficient(reference.pointer, _id_getCoefficient.pointer).float; } } @@ -852,43 +581,6 @@ final class _$MeasureUnit with $MeasureUnit { } } -final class $MeasureUnit$NullableType$ extends jni$_.JType { - @jni$_.internal - const $MeasureUnit$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/MeasureUnit;'; - - @jni$_.internal - @core$_.override - MeasureUnit? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : MeasureUnit.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MeasureUnit$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MeasureUnit$NullableType$) && - other is $MeasureUnit$NullableType$; - } -} - final class $MeasureUnit$Type$ extends jni$_.JType { @jni$_.internal const $MeasureUnit$Type$(); @@ -896,96 +588,18 @@ final class $MeasureUnit$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/MeasureUnit;'; - - @jni$_.internal - @core$_.override - MeasureUnit fromReference(jni$_.JReference reference) => - MeasureUnit.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $MeasureUnit$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MeasureUnit$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MeasureUnit$Type$) && - other is $MeasureUnit$Type$; - } } /// from: `com.github.dart_lang.jnigen.Nullability$InnerClass` -class Nullability$InnerClass<$T extends jni$_.JObject?, - $U extends jni$_.JObject, $V extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - Nullability$InnerClass.fromReference( - this.T, - this.U, - this.V, - jni$_.JReference reference, - ) : $type = type<$T, $U, $V>(T, U, V), - super.fromReference(reference); - +extension type Nullability$InnerClass<$T extends jni$_.JObject?, + $U extends jni$_.JObject, $V extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/Nullability$InnerClass'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $V extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - jni$_.JType<$V> V, - ) { - return $Nullability$InnerClass$NullableType$<$T, $U, $V>( - T, - U, - V, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $V extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - jni$_.JType<$V> V, - ) { - return $Nullability$InnerClass$Type$<$T, $U, $V>( - T, - U, - V, - ); - } - + static const jni$_.JType type = + $Nullability$InnerClass$Type$(); static final _id_new$ = _class.constructorId( r'(Lcom/github/dart_lang/jnigen/Nullability;)V', ); @@ -1004,30 +618,20 @@ class Nullability$InnerClass<$T extends jni$_.JObject?, /// from: `public void (com.github.dart_lang.jnigen.Nullability $outerClass)` /// The returned object must be released after use, by calling the [release] method. factory Nullability$InnerClass( - Nullability<$T?, $U> $outerClass, { - jni$_.JType<$T>? T, - jni$_.JType<$U>? U, - required jni$_.JType<$V> V, - }) { - T ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $Nullability$Type$) - .T, - ]) as jni$_.JType<$T>; - U ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $Nullability$Type$) - .U, - ]) as jni$_.JType<$U>; + Nullability<$T?, $U> $outerClass, + ) { final _$$outerClass = $outerClass.reference; - return Nullability$InnerClass<$T, $U, $V>.fromReference( - T, - U, - V, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$$outerClass.pointer) - .reference); + return _new$( + _class.reference.pointer, _id_new$.pointer, _$$outerClass.pointer) + .object>(); } +} - static final _id_f = _class.instanceMethodId( +extension Nullability$InnerClass$$Methods< + $T extends jni$_.JObject?, + $U extends jni$_.JObject, + $V extends jni$_.JObject?> on Nullability$InnerClass<$T, $U, $V> { + static final _id_f = Nullability$InnerClass._class.instanceMethodId( r'f', r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V', ); @@ -1053,190 +657,38 @@ class Nullability$InnerClass<$T extends jni$_.JObject?, /// from: `public fun f(t: T, u: U, v: V): kotlin.Unit` void f( - $T object, + $T? object, $U object1, - $V object2, + $V? object2, ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1.reference; final _$object2 = object2?.reference ?? jni$_.jNullReference; - _f(reference.pointer, _id_f as jni$_.JMethodIDPtr, _$object.pointer, - _$object1.pointer, _$object2.pointer) + _f(reference.pointer, _id_f.pointer, _$object.pointer, _$object1.pointer, + _$object2.pointer) .check(); } } -final class $Nullability$InnerClass$NullableType$<$T extends jni$_.JObject?, - $U extends jni$_.JObject, $V extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $Nullability$InnerClass$NullableType$( - this.T, - this.U, - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/Nullability$InnerClass;'; - - @jni$_.internal - @core$_.override - Nullability$InnerClass<$T, $U, $V>? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : Nullability$InnerClass<$T, $U, $V>.fromReference( - T, - U, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - Object.hash($Nullability$InnerClass$NullableType$, T, U, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($Nullability$InnerClass$NullableType$<$T, $U, $V>) && - other is $Nullability$InnerClass$NullableType$<$T, $U, $V> && - T == other.T && - U == other.U && - V == other.V; - } -} - -final class $Nullability$InnerClass$Type$<$T extends jni$_.JObject?, - $U extends jni$_.JObject, $V extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $Nullability$InnerClass$Type$( - this.T, - this.U, - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/Nullability$InnerClass;'; - - @jni$_.internal - @core$_.override - Nullability$InnerClass<$T, $U, $V> fromReference( - jni$_.JReference reference) => - Nullability$InnerClass<$T, $U, $V>.fromReference( - T, - U, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $Nullability$InnerClass$NullableType$<$T, $U, $V>(T, U, V); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Nullability$InnerClass$Type$, T, U, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Nullability$InnerClass$Type$<$T, $U, $V>) && - other is $Nullability$InnerClass$Type$<$T, $U, $V> && - T == other.T && - U == other.U && - V == other.V; - } -} - -/// from: `com.github.dart_lang.jnigen.Nullability` -class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - +final class $Nullability$InnerClass$Type$ + extends jni$_.JType { @jni$_.internal - final jni$_.JType<$T> T; + const $Nullability$InnerClass$Type$(); @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - Nullability.fromReference( - this.T, - this.U, - jni$_.JReference reference, - ) : $type = type<$T, $U>(T, U), - super.fromReference(reference); + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/Nullability$InnerClass;'; +} +/// from: `com.github.dart_lang.jnigen.Nullability` +extension type Nullability<$T extends jni$_.JObject?, + $U extends jni$_.JObject>._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/Nullability'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$T extends jni$_.JObject?, $U extends jni$_.JObject>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - ) { - return $Nullability$NullableType$<$T, $U>( - T, - U, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$T extends jni$_.JObject?, $U extends jni$_.JObject>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - ) { - return $Nullability$Type$<$T, $U>( - T, - U, - ); - } - + static const jni$_.JType type = $Nullability$Type$(); static final _id_new$ = _class.constructorId( r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V', ); @@ -1263,27 +715,22 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public void (T object, U object1, U object2)` /// The returned object must be released after use, by calling the [release] method. factory Nullability( - $T object, + $T? object, $U object1, - $U? object2, { - required jni$_.JType<$T> T, - jni$_.JType<$U>? U, - }) { - U ??= jni$_.lowestCommonSuperType([ - object1.$type, - ]) as jni$_.JType<$U>; + $U? object2, + ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1.reference; final _$object2 = object2?.reference ?? jni$_.jNullReference; - return Nullability<$T, $U>.fromReference( - T, - U, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer, _$object2.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer) + .object>(); } +} - static final _id_getT = _class.instanceMethodId( +extension Nullability$$Methods<$T extends jni$_.JObject?, + $U extends jni$_.JObject> on Nullability<$T, $U> { + static final _id_getT = Nullability._class.instanceMethodId( r'getT', r'()Ljava/lang/Object;', ); @@ -1302,12 +749,11 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public final T getT()` /// The returned object must be released after use, by calling the [release] method. - $T getT() { - return _getT(reference.pointer, _id_getT as jni$_.JMethodIDPtr) - .object<$T>(T); + $T? getT() { + return _getT(reference.pointer, _id_getT.pointer).object<$T?>(); } - static final _id_getU = _class.instanceMethodId( + static final _id_getU = Nullability._class.instanceMethodId( r'getU', r'()Ljava/lang/Object;', ); @@ -1327,11 +773,10 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public final U getU()` /// The returned object must be released after use, by calling the [release] method. $U getU() { - return _getU(reference.pointer, _id_getU as jni$_.JMethodIDPtr) - .object<$U>(U); + return _getU(reference.pointer, _id_getU.pointer).object<$U>(); } - static final _id_getNullableU = _class.instanceMethodId( + static final _id_getNullableU = Nullability._class.instanceMethodId( r'getNullableU', r'()Ljava/lang/Object;', ); @@ -1351,12 +796,11 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public final U getNullableU()` /// The returned object must be released after use, by calling the [release] method. $U? getNullableU() { - return _getNullableU( - reference.pointer, _id_getNullableU as jni$_.JMethodIDPtr) - .object<$U?>(U.nullableType); + return _getNullableU(reference.pointer, _id_getNullableU.pointer) + .object<$U?>(); } - static final _id_setNullableU = _class.instanceMethodId( + static final _id_setNullableU = Nullability._class.instanceMethodId( r'setNullableU', r'(Ljava/lang/Object;)V', ); @@ -1377,12 +821,11 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> $U? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - _setNullableU(reference.pointer, _id_setNullableU as jni$_.JMethodIDPtr, - _$object.pointer) + _setNullableU(reference.pointer, _id_setNullableU.pointer, _$object.pointer) .check(); } - static final _id_self = _class.instanceMethodId( + static final _id_self = Nullability._class.instanceMethodId( r'self', r'()Lcom/github/dart_lang/jnigen/Nullability;', ); @@ -1402,13 +845,11 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun self(): com.github.dart_lang.jnigen.Nullability<*, *>` /// The returned object must be released after use, by calling the [release] method. Nullability self() { - return _self(reference.pointer, _id_self as jni$_.JMethodIDPtr) - .object>( - const $Nullability$Type$( - jni$_.$JObject$NullableType$(), jni$_.$JObject$Type$())); + return _self(reference.pointer, _id_self.pointer) + .object>(); } - static final _id_hello = _class.instanceMethodId( + static final _id_hello = Nullability._class.instanceMethodId( r'hello', r'()Ljava/lang/String;', ); @@ -1428,11 +869,10 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun hello(): kotlin.String` /// The returned object must be released after use, by calling the [release] method. jni$_.JString hello() { - return _hello(reference.pointer, _id_hello as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); + return _hello(reference.pointer, _id_hello.pointer).object(); } - static final _id_nullableHello = _class.instanceMethodId( + static final _id_nullableHello = Nullability._class.instanceMethodId( r'nullableHello', r'(Z)Ljava/lang/String;', ); @@ -1452,12 +892,12 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JString? nullableHello( core$_.bool z, ) { - return _nullableHello(reference.pointer, - _id_nullableHello as jni$_.JMethodIDPtr, z ? 1 : 0) - .object(const jni$_.$JString$NullableType$()); + return _nullableHello( + reference.pointer, _id_nullableHello.pointer, z ? 1 : 0) + .object(); } - static final _id_list = _class.instanceMethodId( + static final _id_list = Nullability._class.instanceMethodId( r'list', r'()Ljava/util/List;', ); @@ -1477,13 +917,11 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun list(): kotlin.collections.List<*>` /// The returned object must be released after use, by calling the [release] method. jni$_.JList list() { - return _list(reference.pointer, _id_list as jni$_.JMethodIDPtr) - .object>( - const jni$_.$JList$Type$( - jni$_.$JObject$NullableType$())); + return _list(reference.pointer, _id_list.pointer) + .object>(); } - static final _id_methodGenericEcho = _class.instanceMethodId( + static final _id_methodGenericEcho = Nullability._class.instanceMethodId( r'methodGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -1502,19 +940,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodGenericEcho(v: V): V` /// The returned object must be released after use, by calling the [release] method. $V methodGenericEcho<$V extends jni$_.JObject>( - $V object, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - object.$type, - ]) as jni$_.JType<$V>; + $V object, + ) { final _$object = object.reference; - return _methodGenericEcho(reference.pointer, - _id_methodGenericEcho as jni$_.JMethodIDPtr, _$object.pointer) - .object<$V>(V); + return _methodGenericEcho( + reference.pointer, _id_methodGenericEcho.pointer, _$object.pointer) + .object<$V>(); } - static final _id_methodGenericNullableEcho = _class.instanceMethodId( + static final _id_methodGenericNullableEcho = + Nullability._class.instanceMethodId( r'methodGenericNullableEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -1532,19 +967,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodGenericNullableEcho(v: V): V` /// The returned object must be released after use, by calling the [release] method. - $V methodGenericNullableEcho<$V extends jni$_.JObject?>( - $V object, { - required jni$_.JType<$V> V, - }) { + $V? methodGenericNullableEcho<$V extends jni$_.JObject?>( + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _methodGenericNullableEcho( - reference.pointer, - _id_methodGenericNullableEcho as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$V>(V); + return _methodGenericNullableEcho(reference.pointer, + _id_methodGenericNullableEcho.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_classGenericEcho = _class.instanceMethodId( + static final _id_classGenericEcho = Nullability._class.instanceMethodId( r'classGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -1566,12 +998,13 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> $U object, ) { final _$object = object.reference; - return _classGenericEcho(reference.pointer, - _id_classGenericEcho as jni$_.JMethodIDPtr, _$object.pointer) - .object<$U>(U); + return _classGenericEcho( + reference.pointer, _id_classGenericEcho.pointer, _$object.pointer) + .object<$U>(); } - static final _id_classGenericNullableEcho = _class.instanceMethodId( + static final _id_classGenericNullableEcho = + Nullability._class.instanceMethodId( r'classGenericNullableEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -1589,18 +1022,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun classGenericNullableEcho(t: T): T` /// The returned object must be released after use, by calling the [release] method. - $T classGenericNullableEcho( - $T object, + $T? classGenericNullableEcho( + $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _classGenericNullableEcho( - reference.pointer, - _id_classGenericNullableEcho as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$T>(T); + return _classGenericNullableEcho(reference.pointer, + _id_classGenericNullableEcho.pointer, _$object.pointer) + .object<$T?>(); } - static final _id_firstOf = _class.instanceMethodId( + static final _id_firstOf = Nullability._class.instanceMethodId( r'firstOf', r'(Ljava/util/List;)Ljava/lang/String;', ); @@ -1622,12 +1053,11 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JList list, ) { final _$list = list.reference; - return _firstOf(reference.pointer, _id_firstOf as jni$_.JMethodIDPtr, - _$list.pointer) - .object(const jni$_.$JString$Type$()); + return _firstOf(reference.pointer, _id_firstOf.pointer, _$list.pointer) + .object(); } - static final _id_firstOfNullable = _class.instanceMethodId( + static final _id_firstOfNullable = Nullability._class.instanceMethodId( r'firstOfNullable', r'(Ljava/util/List;)Ljava/lang/String;', ); @@ -1649,12 +1079,12 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JList list, ) { final _$list = list.reference; - return _firstOfNullable(reference.pointer, - _id_firstOfNullable as jni$_.JMethodIDPtr, _$list.pointer) - .object(const jni$_.$JString$NullableType$()); + return _firstOfNullable( + reference.pointer, _id_firstOfNullable.pointer, _$list.pointer) + .object(); } - static final _id_classGenericFirstOf = _class.instanceMethodId( + static final _id_classGenericFirstOf = Nullability._class.instanceMethodId( r'classGenericFirstOf', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -1676,12 +1106,13 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JList<$U> list, ) { final _$list = list.reference; - return _classGenericFirstOf(reference.pointer, - _id_classGenericFirstOf as jni$_.JMethodIDPtr, _$list.pointer) - .object<$U>(U); + return _classGenericFirstOf( + reference.pointer, _id_classGenericFirstOf.pointer, _$list.pointer) + .object<$U>(); } - static final _id_classGenericFirstOfNullable = _class.instanceMethodId( + static final _id_classGenericFirstOfNullable = + Nullability._class.instanceMethodId( r'classGenericFirstOfNullable', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -1700,18 +1131,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun classGenericFirstOfNullable(list: kotlin.collections.List): T` /// The returned object must be released after use, by calling the [release] method. - $T classGenericFirstOfNullable( + $T? classGenericFirstOfNullable( jni$_.JList<$T> list, ) { final _$list = list.reference; - return _classGenericFirstOfNullable( - reference.pointer, - _id_classGenericFirstOfNullable as jni$_.JMethodIDPtr, - _$list.pointer) - .object<$T>(T); + return _classGenericFirstOfNullable(reference.pointer, + _id_classGenericFirstOfNullable.pointer, _$list.pointer) + .object<$T?>(); } - static final _id_methodGenericFirstOf = _class.instanceMethodId( + static final _id_methodGenericFirstOf = Nullability._class.instanceMethodId( r'methodGenericFirstOf', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -1730,19 +1159,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodGenericFirstOf(list: kotlin.collections.List): V` /// The returned object must be released after use, by calling the [release] method. $V methodGenericFirstOf<$V extends jni$_.JObject>( - jni$_.JList<$V> list, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (list.$type as jni$_.$JList$Type$).E, - ]) as jni$_.JType<$V>; + jni$_.JList<$V> list, + ) { final _$list = list.reference; - return _methodGenericFirstOf(reference.pointer, - _id_methodGenericFirstOf as jni$_.JMethodIDPtr, _$list.pointer) - .object<$V>(V); + return _methodGenericFirstOf( + reference.pointer, _id_methodGenericFirstOf.pointer, _$list.pointer) + .object<$V>(); } - static final _id_methodGenericFirstOfNullable = _class.instanceMethodId( + static final _id_methodGenericFirstOfNullable = + Nullability._class.instanceMethodId( r'methodGenericFirstOfNullable', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -1761,22 +1187,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodGenericFirstOfNullable(list: kotlin.collections.List): V` /// The returned object must be released after use, by calling the [release] method. - $V methodGenericFirstOfNullable<$V extends jni$_.JObject?>( - jni$_.JList<$V> list, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (list.$type as jni$_.$JList$Type$).E, - ]) as jni$_.JType<$V>; + $V? methodGenericFirstOfNullable<$V extends jni$_.JObject?>( + jni$_.JList<$V> list, + ) { final _$list = list.reference; - return _methodGenericFirstOfNullable( - reference.pointer, - _id_methodGenericFirstOfNullable as jni$_.JMethodIDPtr, - _$list.pointer) - .object<$V>(V); + return _methodGenericFirstOfNullable(reference.pointer, + _id_methodGenericFirstOfNullable.pointer, _$list.pointer) + .object<$V?>(); } - static final _id_stringListOf = _class.instanceMethodId( + static final _id_stringListOf = Nullability._class.instanceMethodId( r'stringListOf', r'(Ljava/lang/String;)Ljava/util/List;', ); @@ -1798,13 +1218,12 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JString string, ) { final _$string = string.reference; - return _stringListOf(reference.pointer, - _id_stringListOf as jni$_.JMethodIDPtr, _$string.pointer) - .object>( - const jni$_.$JList$Type$(jni$_.$JString$Type$())); + return _stringListOf( + reference.pointer, _id_stringListOf.pointer, _$string.pointer) + .object>(); } - static final _id_nullableListOf = _class.instanceMethodId( + static final _id_nullableListOf = Nullability._class.instanceMethodId( r'nullableListOf', r'(Ljava/lang/String;)Ljava/util/List;', ); @@ -1826,14 +1245,12 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _nullableListOf(reference.pointer, - _id_nullableListOf as jni$_.JMethodIDPtr, _$string.pointer) - .object>( - const jni$_.$JList$Type$( - jni$_.$JString$NullableType$())); + return _nullableListOf( + reference.pointer, _id_nullableListOf.pointer, _$string.pointer) + .object>(); } - static final _id_classGenericListOf = _class.instanceMethodId( + static final _id_classGenericListOf = Nullability._class.instanceMethodId( r'classGenericListOf', r'(Ljava/lang/Object;)Ljava/util/List;', ); @@ -1855,12 +1272,13 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> $U object, ) { final _$object = object.reference; - return _classGenericListOf(reference.pointer, - _id_classGenericListOf as jni$_.JMethodIDPtr, _$object.pointer) - .object>(jni$_.$JList$Type$<$U>(U)); + return _classGenericListOf( + reference.pointer, _id_classGenericListOf.pointer, _$object.pointer) + .object>(); } - static final _id_classGenericNullableListOf = _class.instanceMethodId( + static final _id_classGenericNullableListOf = + Nullability._class.instanceMethodId( r'classGenericNullableListOf', r'(Ljava/lang/Object;)Ljava/util/List;', ); @@ -1879,18 +1297,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun classGenericNullableListOf(element: T): kotlin.collections.List` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$T> classGenericNullableListOf( - $T object, + jni$_.JList<$T?> classGenericNullableListOf( + $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _classGenericNullableListOf( - reference.pointer, - _id_classGenericNullableListOf as jni$_.JMethodIDPtr, - _$object.pointer) - .object>(jni$_.$JList$Type$<$T>(T)); + return _classGenericNullableListOf(reference.pointer, + _id_classGenericNullableListOf.pointer, _$object.pointer) + .object>(); } - static final _id_methodGenericListOf = _class.instanceMethodId( + static final _id_methodGenericListOf = Nullability._class.instanceMethodId( r'methodGenericListOf', r'(Ljava/lang/Object;)Ljava/util/List;', ); @@ -1909,19 +1325,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodGenericListOf(element: V): kotlin.collections.List` /// The returned object must be released after use, by calling the [release] method. jni$_.JList<$V> methodGenericListOf<$V extends jni$_.JObject>( - $V object, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - object.$type, - ]) as jni$_.JType<$V>; + $V object, + ) { final _$object = object.reference; return _methodGenericListOf(reference.pointer, - _id_methodGenericListOf as jni$_.JMethodIDPtr, _$object.pointer) - .object>(jni$_.$JList$Type$<$V>(V)); + _id_methodGenericListOf.pointer, _$object.pointer) + .object>(); } - static final _id_methodGenericNullableListOf = _class.instanceMethodId( + static final _id_methodGenericNullableListOf = + Nullability._class.instanceMethodId( r'methodGenericNullableListOf', r'(Ljava/lang/Object;)Ljava/util/List;', ); @@ -1940,19 +1353,16 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodGenericNullableListOf(element: V): kotlin.collections.List` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$V> methodGenericNullableListOf<$V extends jni$_.JObject?>( - $V object, { - required jni$_.JType<$V> V, - }) { + jni$_.JList<$V?> methodGenericNullableListOf<$V extends jni$_.JObject?>( + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _methodGenericNullableListOf( - reference.pointer, - _id_methodGenericNullableListOf as jni$_.JMethodIDPtr, - _$object.pointer) - .object>(jni$_.$JList$Type$<$V>(V)); + return _methodGenericNullableListOf(reference.pointer, + _id_methodGenericNullableListOf.pointer, _$object.pointer) + .object>(); } - static final _id_methodWithVarArgs = _class.instanceMethodId( + static final _id_methodWithVarArgs = Nullability._class.instanceMethodId( r'methodWithVarArgs', r'([Ljava/lang/String;)I', ); @@ -1973,12 +1383,12 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> jni$_.JArray strings, ) { final _$strings = strings.reference; - return _methodWithVarArgs(reference.pointer, - _id_methodWithVarArgs as jni$_.JMethodIDPtr, _$strings.pointer) + return _methodWithVarArgs( + reference.pointer, _id_methodWithVarArgs.pointer, _$strings.pointer) .integer; } - static final _id_methodWithWhere = _class.instanceMethodId( + static final _id_methodWithWhere = Nullability._class.instanceMethodId( r'methodWithWhere', r'(Lcom/github/dart_lang/jnigen/CanDoA;)I', ); @@ -1996,141 +1406,29 @@ class Nullability<$T extends jni$_.JObject?, $U extends jni$_.JObject> /// from: `public fun methodWithWhere(element: V): kotlin.Int where V : com.github.dart_lang.jnigen.CanDoA, V : com.github.dart_lang.jnigen.CanDoB` int methodWithWhere<$V extends jni$_.JObject>( - $V canDoA, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - canDoA.$type, - ]) as jni$_.JType<$V>; + $V canDoA, + ) { final _$canDoA = canDoA.reference; - return _methodWithWhere(reference.pointer, - _id_methodWithWhere as jni$_.JMethodIDPtr, _$canDoA.pointer) + return _methodWithWhere( + reference.pointer, _id_methodWithWhere.pointer, _$canDoA.pointer) .integer; } } -final class $Nullability$NullableType$<$T extends jni$_.JObject?, - $U extends jni$_.JObject> extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - const $Nullability$NullableType$( - this.T, - this.U, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/Nullability;'; - - @jni$_.internal - @core$_.override - Nullability<$T, $U>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Nullability<$T, $U>.fromReference( - T, - U, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Nullability$NullableType$, T, U); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Nullability$NullableType$<$T, $U>) && - other is $Nullability$NullableType$<$T, $U> && - T == other.T && - U == other.U; - } -} - -final class $Nullability$Type$<$T extends jni$_.JObject?, - $U extends jni$_.JObject> extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - +final class $Nullability$Type$ extends jni$_.JType { @jni$_.internal - const $Nullability$Type$( - this.T, - this.U, - ); + const $Nullability$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/Nullability;'; - - @jni$_.internal - @core$_.override - Nullability<$T, $U> fromReference(jni$_.JReference reference) => - Nullability<$T, $U>.fromReference( - T, - U, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $Nullability$NullableType$<$T, $U>(T, U); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Nullability$Type$, T, U); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Nullability$Type$<$T, $U>) && - other is $Nullability$Type$<$T, $U> && - T == other.T && - U == other.U; - } } /// from: `com.github.dart_lang.jnigen.Operators` -class Operators extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Operators.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Operators._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/Operators'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Operators$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Operators$Type$(); static final _id_new$ = _class.constructorId( @@ -2152,12 +1450,13 @@ class Operators extends jni$_.JObject { factory Operators( int i, ) { - return Operators.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, i) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, i) + .object(); } +} - static final _id_getValue = _class.instanceMethodId( +extension Operators$$Methods on Operators { + static final _id_getValue = Operators._class.instanceMethodId( r'getValue', r'()I', ); @@ -2176,11 +1475,10 @@ class Operators extends jni$_.JObject { /// from: `public final int getValue()` int getValue() { - return _getValue(reference.pointer, _id_getValue as jni$_.JMethodIDPtr) - .integer; + return _getValue(reference.pointer, _id_getValue.pointer).integer; } - static final _id_setValue = _class.instanceMethodId( + static final _id_setValue = Operators._class.instanceMethodId( r'setValue', r'(I)V', ); @@ -2199,10 +1497,10 @@ class Operators extends jni$_.JObject { void setValue( int i, ) { - _setValue(reference.pointer, _id_setValue as jni$_.JMethodIDPtr, i).check(); + _setValue(reference.pointer, _id_setValue.pointer, i).check(); } - static final _id_plus = _class.instanceMethodId( + static final _id_plus = Operators._class.instanceMethodId( r'plus', r'(Lcom/github/dart_lang/jnigen/Operators;)Lcom/github/dart_lang/jnigen/Operators;', ); @@ -2224,12 +1522,11 @@ class Operators extends jni$_.JObject { Operators operators, ) { final _$operators = operators.reference; - return _plus(reference.pointer, _id_plus as jni$_.JMethodIDPtr, - _$operators.pointer) - .object(const $Operators$Type$()); + return _plus(reference.pointer, _id_plus.pointer, _$operators.pointer) + .object(); } - static final _id_plus$1 = _class.instanceMethodId( + static final _id_plus$1 = Operators._class.instanceMethodId( r'plus', r'(I)Lcom/github/dart_lang/jnigen/Operators;', ); @@ -2249,11 +1546,11 @@ class Operators extends jni$_.JObject { Operators plus$1( int i, ) { - return _plus$1(reference.pointer, _id_plus$1 as jni$_.JMethodIDPtr, i) - .object(const $Operators$Type$()); + return _plus$1(reference.pointer, _id_plus$1.pointer, i) + .object(); } - static final _id_minus = _class.instanceMethodId( + static final _id_minus = Operators._class.instanceMethodId( r'minus', r'(Lcom/github/dart_lang/jnigen/Operators;)Lcom/github/dart_lang/jnigen/Operators;', ); @@ -2275,12 +1572,11 @@ class Operators extends jni$_.JObject { Operators operators, ) { final _$operators = operators.reference; - return _minus(reference.pointer, _id_minus as jni$_.JMethodIDPtr, - _$operators.pointer) - .object(const $Operators$Type$()); + return _minus(reference.pointer, _id_minus.pointer, _$operators.pointer) + .object(); } - static final _id_times = _class.instanceMethodId( + static final _id_times = Operators._class.instanceMethodId( r'times', r'(Lcom/github/dart_lang/jnigen/Operators;)Lcom/github/dart_lang/jnigen/Operators;', ); @@ -2302,12 +1598,11 @@ class Operators extends jni$_.JObject { Operators operators, ) { final _$operators = operators.reference; - return _times(reference.pointer, _id_times as jni$_.JMethodIDPtr, - _$operators.pointer) - .object(const $Operators$Type$()); + return _times(reference.pointer, _id_times.pointer, _$operators.pointer) + .object(); } - static final _id_div = _class.instanceMethodId( + static final _id_div = Operators._class.instanceMethodId( r'div', r'(Lcom/github/dart_lang/jnigen/Operators;)Lcom/github/dart_lang/jnigen/Operators;', ); @@ -2329,12 +1624,11 @@ class Operators extends jni$_.JObject { Operators operators, ) { final _$operators = operators.reference; - return _div(reference.pointer, _id_div as jni$_.JMethodIDPtr, - _$operators.pointer) - .object(const $Operators$Type$()); + return _div(reference.pointer, _id_div.pointer, _$operators.pointer) + .object(); } - static final _id_rem = _class.instanceMethodId( + static final _id_rem = Operators._class.instanceMethodId( r'rem', r'(Lcom/github/dart_lang/jnigen/Operators;)Lcom/github/dart_lang/jnigen/Operators;', ); @@ -2356,12 +1650,11 @@ class Operators extends jni$_.JObject { Operators operators, ) { final _$operators = operators.reference; - return _rem(reference.pointer, _id_rem as jni$_.JMethodIDPtr, - _$operators.pointer) - .object(const $Operators$Type$()); + return _rem(reference.pointer, _id_rem.pointer, _$operators.pointer) + .object(); } - static final _id_get = _class.instanceMethodId( + static final _id_get = Operators._class.instanceMethodId( r'get', r'(I)Z', ); @@ -2381,10 +1674,10 @@ class Operators extends jni$_.JObject { core$_.bool get( int i, ) { - return _get(reference.pointer, _id_get as jni$_.JMethodIDPtr, i).boolean; + return _get(reference.pointer, _id_get.pointer, i).boolean; } - static final _id_set = _class.instanceMethodId( + static final _id_set = Operators._class.instanceMethodId( r'set', r'(IZ)V', ); @@ -2405,11 +1698,10 @@ class Operators extends jni$_.JObject { int i, core$_.bool z, ) { - _set(reference.pointer, _id_set as jni$_.JMethodIDPtr, i, z ? 1 : 0) - .check(); + _set(reference.pointer, _id_set.pointer, i, z ? 1 : 0).check(); } - static final _id_compareTo = _class.instanceMethodId( + static final _id_compareTo = Operators._class.instanceMethodId( r'compareTo', r'(Lcom/github/dart_lang/jnigen/Operators;)I', ); @@ -2430,8 +1722,8 @@ class Operators extends jni$_.JObject { Operators operators, ) { final _$operators = operators.reference; - return _compareTo(reference.pointer, _id_compareTo as jni$_.JMethodIDPtr, - _$operators.pointer) + return _compareTo( + reference.pointer, _id_compareTo.pointer, _$operators.pointer) .integer; } @@ -2480,43 +1772,6 @@ class Operators extends jni$_.JObject { } } -final class $Operators$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Operators$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/Operators;'; - - @jni$_.internal - @core$_.override - Operators? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Operators.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Operators$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Operators$NullableType$) && - other is $Operators$NullableType$; - } -} - final class $Operators$Type$ extends jni$_.JType { @jni$_.internal const $Operators$Type$(); @@ -2524,52 +1779,13 @@ final class $Operators$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/Operators;'; - - @jni$_.internal - @core$_.override - Operators fromReference(jni$_.JReference reference) => - Operators.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Operators$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Operators$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Operators$Type$) && other is $Operators$Type$; - } } /// from: `com.github.dart_lang.jnigen.Speed` -class Speed extends Measure { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Speed.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(const $SpeedUnit$Type$(), reference); - +extension type Speed._(jni$_.JObject _$this) implements Measure { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/Speed'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Speed$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Speed$Type$(); static final _id_new$ = _class.constructorId( @@ -2597,12 +1813,14 @@ class Speed extends Measure { SpeedUnit speedUnit, ) { final _$speedUnit = speedUnit.reference; - return Speed.fromReference(_new$(_class.reference.pointer, - _id_new$ as jni$_.JMethodIDPtr, f, _$speedUnit.pointer) - .reference); + return _new$( + _class.reference.pointer, _id_new$.pointer, f, _$speedUnit.pointer) + .object(); } +} - static final _id_getValue = _class.instanceMethodId( +extension Speed$$Methods on Speed { + static final _id_getValue = Speed._class.instanceMethodId( r'getValue', r'()F', ); @@ -2621,11 +1839,10 @@ class Speed extends Measure { /// from: `public float getValue()` double getValue() { - return _getValue(reference.pointer, _id_getValue as jni$_.JMethodIDPtr) - .float; + return _getValue(reference.pointer, _id_getValue.pointer).float; } - static final _id_getUnit$1 = _class.instanceMethodId( + static final _id_getUnit$1 = Speed._class.instanceMethodId( r'getUnit', r'()Lcom/github/dart_lang/jnigen/SpeedUnit;', ); @@ -2645,11 +1862,11 @@ class Speed extends Measure { /// from: `public com.github.dart_lang.jnigen.SpeedUnit getUnit()` /// The returned object must be released after use, by calling the [release] method. SpeedUnit getUnit$1() { - return _getUnit$1(reference.pointer, _id_getUnit$1 as jni$_.JMethodIDPtr) - .object(const $SpeedUnit$Type$()); + return _getUnit$1(reference.pointer, _id_getUnit$1.pointer) + .object(); } - static final _id_toString$1 = _class.instanceMethodId( + static final _id_toString$1 = Speed._class.instanceMethodId( r'toString', r'()Ljava/lang/String;', ); @@ -2669,11 +1886,11 @@ class Speed extends Measure { /// from: `public fun toString(): kotlin.String` /// The returned object must be released after use, by calling the [release] method. jni$_.JString toString$1() { - return _toString$1(reference.pointer, _id_toString$1 as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); + return _toString$1(reference.pointer, _id_toString$1.pointer) + .object(); } - static final _id_component1 = _class.instanceMethodId( + static final _id_component1 = Speed._class.instanceMethodId( r'component1', r'()F', ); @@ -2692,11 +1909,10 @@ class Speed extends Measure { /// from: `public operator fun component1(): kotlin.Float` double component1() { - return _component1(reference.pointer, _id_component1 as jni$_.JMethodIDPtr) - .float; + return _component1(reference.pointer, _id_component1.pointer).float; } - static final _id_component2 = _class.instanceMethodId( + static final _id_component2 = Speed._class.instanceMethodId( r'component2', r'()Lcom/github/dart_lang/jnigen/SpeedUnit;', ); @@ -2716,11 +1932,11 @@ class Speed extends Measure { /// from: `public operator fun component2(): com.github.dart_lang.jnigen.SpeedUnit` /// The returned object must be released after use, by calling the [release] method. SpeedUnit component2() { - return _component2(reference.pointer, _id_component2 as jni$_.JMethodIDPtr) - .object(const $SpeedUnit$Type$()); + return _component2(reference.pointer, _id_component2.pointer) + .object(); } - static final _id_copy = _class.instanceMethodId( + static final _id_copy = Speed._class.instanceMethodId( r'copy', r'(FLcom/github/dart_lang/jnigen/SpeedUnit;)Lcom/github/dart_lang/jnigen/Speed;', ); @@ -2746,12 +1962,11 @@ class Speed extends Measure { SpeedUnit speedUnit, ) { final _$speedUnit = speedUnit.reference; - return _copy(reference.pointer, _id_copy as jni$_.JMethodIDPtr, f, - _$speedUnit.pointer) - .object(const $Speed$Type$()); + return _copy(reference.pointer, _id_copy.pointer, f, _$speedUnit.pointer) + .object(); } - static final _id_hashCode$1 = _class.instanceMethodId( + static final _id_hashCode$1 = Speed._class.instanceMethodId( r'hashCode', r'()I', ); @@ -2770,11 +1985,10 @@ class Speed extends Measure { /// from: `public fun hashCode(): kotlin.Int` int hashCode$1() { - return _hashCode$1(reference.pointer, _id_hashCode$1 as jni$_.JMethodIDPtr) - .integer; + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; } - static final _id_equals = _class.instanceMethodId( + static final _id_equals = Speed._class.instanceMethodId( r'equals', r'(Ljava/lang/Object;)Z', ); @@ -2795,50 +2009,11 @@ class Speed extends Measure { jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _equals(reference.pointer, _id_equals as jni$_.JMethodIDPtr, - _$object.pointer) + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) .boolean; } } -final class $Speed$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Speed$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/Speed;'; - - @jni$_.internal - @core$_.override - Speed? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Speed.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $Measure$Type$($SpeedUnit$Type$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($Speed$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Speed$NullableType$) && - other is $Speed$NullableType$; - } -} - final class $Speed$Type$ extends jni$_.JType { @jni$_.internal const $Speed$Type$(); @@ -2846,53 +2021,14 @@ final class $Speed$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/Speed;'; - - @jni$_.internal - @core$_.override - Speed fromReference(jni$_.JReference reference) => Speed.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $Measure$Type$($SpeedUnit$Type$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Speed$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($Speed$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Speed$Type$) && other is $Speed$Type$; - } } /// from: `com.github.dart_lang.jnigen.SpeedUnit` -class SpeedUnit extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - SpeedUnit.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type SpeedUnit._(jni$_.JObject _$this) + implements jni$_.JObject, MeasureUnit { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/SpeedUnit'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $SpeedUnit$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $SpeedUnit$Type$(); static final _id_KmPerHour = _class.staticFieldId( @@ -2903,7 +2039,7 @@ class SpeedUnit extends jni$_.JObject { /// from: `static public final com.github.dart_lang.jnigen.SpeedUnit KmPerHour` /// The returned object must be released after use, by calling the [release] method. static SpeedUnit get KmPerHour => - _id_KmPerHour.get(_class, const $SpeedUnit$Type$()); + _id_KmPerHour.get(_class, SpeedUnit.type) as SpeedUnit; static final _id_MetrePerSec = _class.staticFieldId( r'MetrePerSec', @@ -2913,55 +2049,7 @@ class SpeedUnit extends jni$_.JObject { /// from: `static public final com.github.dart_lang.jnigen.SpeedUnit MetrePerSec` /// The returned object must be released after use, by calling the [release] method. static SpeedUnit get MetrePerSec => - _id_MetrePerSec.get(_class, const $SpeedUnit$Type$()); - - static final _id_getSign = _class.instanceMethodId( - r'getSign', - r'()Ljava/lang/String;', - ); - - static final _getSign = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public java.lang.String getSign()` - /// The returned object must be released after use, by calling the [release] method. - jni$_.JString getSign() { - return _getSign(reference.pointer, _id_getSign as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); - } - - static final _id_getCoefficient = _class.instanceMethodId( - r'getCoefficient', - r'()F', - ); - - static final _getCoefficient = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallFloatMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public float getCoefficient()` - double getCoefficient() { - return _getCoefficient( - reference.pointer, _id_getCoefficient as jni$_.JMethodIDPtr) - .float; - } + _id_MetrePerSec.get(_class, SpeedUnit.type) as SpeedUnit; static final _id_values = _class.staticMethodId( r'values', @@ -2983,10 +2071,8 @@ class SpeedUnit extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.SpeedUnit[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $SpeedUnit$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -3011,46 +2097,57 @@ class SpeedUnit extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$string.pointer) - .object(const $SpeedUnit$NullableType$()); + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$string.pointer) + .object(); } } -final class $SpeedUnit$NullableType$ extends jni$_.JType { - @jni$_.internal - const $SpeedUnit$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/SpeedUnit;'; +extension SpeedUnit$$Methods on SpeedUnit { + static final _id_getSign = SpeedUnit._class.instanceMethodId( + r'getSign', + r'()Ljava/lang/String;', + ); - @jni$_.internal - @core$_.override - SpeedUnit? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : SpeedUnit.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); + static final _getSign = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; + /// from: `public java.lang.String getSign()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString getSign() { + return _getSign(reference.pointer, _id_getSign.pointer) + .object(); + } - @jni$_.internal - @core$_.override - final superCount = 1; + static final _id_getCoefficient = SpeedUnit._class.instanceMethodId( + r'getCoefficient', + r'()F', + ); - @core$_.override - int get hashCode => ($SpeedUnit$NullableType$).hashCode; + static final _getCoefficient = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallFloatMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SpeedUnit$NullableType$) && - other is $SpeedUnit$NullableType$; + /// from: `public float getCoefficient()` + double getCoefficient() { + return _getCoefficient(reference.pointer, _id_getCoefficient.pointer).float; } } @@ -3061,53 +2158,13 @@ final class $SpeedUnit$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/SpeedUnit;'; - - @jni$_.internal - @core$_.override - SpeedUnit fromReference(jni$_.JReference reference) => - SpeedUnit.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $SpeedUnit$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($SpeedUnit$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SpeedUnit$Type$) && other is $SpeedUnit$Type$; - } } /// from: `com.github.dart_lang.jnigen.SuspendFun` -class SuspendFun extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - SuspendFun.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type SuspendFun._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/SuspendFun'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $SuspendFun$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $SuspendFun$Type$(); static final _id_new$ = _class.constructorId( @@ -3129,12 +2186,13 @@ class SuspendFun extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory SuspendFun() { - return SuspendFun.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } +} - static final _id_sayHelloWithoutDelay = _class.instanceMethodId( +extension SuspendFun$$Methods on SuspendFun { + static final _id_sayHelloWithoutDelay = SuspendFun._class.instanceMethodId( r'sayHelloWithoutDelay', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3156,11 +2214,9 @@ class SuspendFun extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _sayHelloWithoutDelay( - reference.pointer, - _id_sayHelloWithoutDelay as jni$_.JMethodIDPtr, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = _sayHelloWithoutDelay(reference.pointer, + _id_sayHelloWithoutDelay.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3180,12 +2236,12 @@ class SuspendFun extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_failWithoutDelay = _class.instanceMethodId( + static final _id_failWithoutDelay = SuspendFun._class.instanceMethodId( r'failWithoutDelay', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3208,8 +2264,8 @@ class SuspendFun extends jni$_.JObject { final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); final $r = _failWithoutDelay(reference.pointer, - _id_failWithoutDelay as jni$_.JMethodIDPtr, _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + _id_failWithoutDelay.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3229,12 +2285,12 @@ class SuspendFun extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_fail = _class.instanceMethodId( + static final _id_fail = SuspendFun._class.instanceMethodId( r'fail', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3256,9 +2312,9 @@ class SuspendFun extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _fail(reference.pointer, _id_fail as jni$_.JMethodIDPtr, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = + _fail(reference.pointer, _id_fail.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3278,12 +2334,12 @@ class SuspendFun extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_sayHello = _class.instanceMethodId( + static final _id_sayHello = SuspendFun._class.instanceMethodId( r'sayHello', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3305,9 +2361,9 @@ class SuspendFun extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _sayHello(reference.pointer, _id_sayHello as jni$_.JMethodIDPtr, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = _sayHello( + reference.pointer, _id_sayHello.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3327,12 +2383,12 @@ class SuspendFun extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_sayHello$1 = _class.instanceMethodId( + static final _id_sayHello$1 = SuspendFun._class.instanceMethodId( r'sayHello', r'(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3362,12 +2418,9 @@ class SuspendFun extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); final _$string = string.reference; - final $r = _sayHello$1( - reference.pointer, - _id_sayHello$1 as jni$_.JMethodIDPtr, - _$string.pointer, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = _sayHello$1(reference.pointer, _id_sayHello$1.pointer, + _$string.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3387,12 +2440,12 @@ class SuspendFun extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_nullableHello = _class.instanceMethodId( + static final _id_nullableHello = SuspendFun._class.instanceMethodId( r'nullableHello', r'(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3417,12 +2470,9 @@ class SuspendFun extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _nullableHello( - reference.pointer, - _id_nullableHello as jni$_.JMethodIDPtr, - z ? 1 : 0, - _$continuation.pointer) - .object(const jni$_.$JObject$NullableType$()); + final $r = _nullableHello(reference.pointer, _id_nullableHello.pointer, + z ? 1 : 0, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject? $o; if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3443,13 +2493,14 @@ class SuspendFun extends jni$_.JObject { } else { $o = $r; } - return $o?.as( - const jni$_.$JString$NullableType$(), + return $o?.as( + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_nullableHelloWithoutDelay = _class.instanceMethodId( + static final _id_nullableHelloWithoutDelay = + SuspendFun._class.instanceMethodId( r'nullableHelloWithoutDelay', r'(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3476,10 +2527,10 @@ class SuspendFun extends jni$_.JObject { final $r = _nullableHelloWithoutDelay( reference.pointer, - _id_nullableHelloWithoutDelay as jni$_.JMethodIDPtr, + _id_nullableHelloWithoutDelay.pointer, z ? 1 : 0, _$continuation.pointer) - .object(const jni$_.$JObject$NullableType$()); + .object(); _$continuation.release(); jni$_.JObject? $o; if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3500,47 +2551,100 @@ class SuspendFun extends jni$_.JObject { } else { $o = $r; } - return $o?.as( - const jni$_.$JString$NullableType$(), + return $o?.as( + jni$_.JString.type, releaseOriginal: true, ); } -} -final class $SuspendFun$NullableType$ extends jni$_.JType { - @jni$_.internal - const $SuspendFun$NullableType$(); + static final _id_getResult = SuspendFun._class.instanceMethodId( + r'getResult', + r'()I', + ); - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/SuspendFun;'; + static final _getResult = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - @jni$_.internal - @core$_.override - SuspendFun? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : SuspendFun.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); + /// from: `public final int getResult()` + int getResult() { + return _getResult(reference.pointer, _id_getResult.pointer).integer; + } - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; + static final _id_setResult = SuspendFun._class.instanceMethodId( + r'setResult', + r'(I)V', + ); - @jni$_.internal - @core$_.override - final superCount = 1; + static final _setResult = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - @core$_.override - int get hashCode => ($SuspendFun$NullableType$).hashCode; + /// from: `public final void setResult(int i)` + void setResult( + int i, + ) { + _setResult(reference.pointer, _id_setResult.pointer, i).check(); + } - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SuspendFun$NullableType$) && - other is $SuspendFun$NullableType$; + static final _id_noReturn = SuspendFun._class.instanceMethodId( + r'noReturn', + r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); + + static final _noReturn = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public suspend fun noReturn(): kotlin.Unit` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future noReturn() async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); + + final $r = _noReturn( + reference.pointer, _id_noReturn.pointer, _$continuation.pointer) + .object(); + _$continuation.release(); + jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o.isInstanceOf(jni$_.result$Class)) { + $o = jni$_.resultValueField.get($o, const jni$_.$JObject$Type$()); + } else if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.$JObject$Type$()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); + } + } else { + $o = $r; + } + return; } } @@ -3551,34 +2655,6 @@ final class $SuspendFun$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/SuspendFun;'; - - @jni$_.internal - @core$_.override - SuspendFun fromReference(jni$_.JReference reference) => - SuspendFun.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $SuspendFun$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($SuspendFun$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SuspendFun$Type$) && - other is $SuspendFun$Type$; - } } final _SuspendFunKtClass = @@ -3613,10 +2689,10 @@ core$_.Future consumeOnAnotherThread( final _$suspendInterface = suspendInterface.reference; final $r = _consumeOnAnotherThread( _SuspendFunKtClass.reference.pointer, - _id_consumeOnAnotherThread as jni$_.JMethodIDPtr, + _id_consumeOnAnotherThread.pointer, _$suspendInterface.pointer, _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3636,7 +2712,7 @@ core$_.Future consumeOnAnotherThread( $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } @@ -3670,10 +2746,10 @@ core$_.Future consumeOnSameThread( final _$suspendInterface = suspendInterface.reference; final $r = _consumeOnSameThread( _SuspendFunKtClass.reference.pointer, - _id_consumeOnSameThread as jni$_.JMethodIDPtr, + _id_consumeOnSameThread.pointer, _$suspendInterface.pointer, _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3689,37 +2765,180 @@ core$_.Future consumeOnSameThread( $o.release(); jni$_.Jni.throwException($e.reference.toPointer()); } - } else { - $o = $r; + } else { + $o = $r; + } + return $o.as( + jni$_.JString.type, + releaseOriginal: true, + ); +} + +/// from: `com.github.dart_lang.jnigen.SuspendInterface` +extension type SuspendInterface._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/SuspendInterface'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $SuspendInterface$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == + r'sayHello(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![0] as jni$_.JObject).reference) + .resumeWithFuture(_$impls[$p]!.sayHello()); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'sayHello(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![1] as jni$_.JObject).reference) + .resumeWithFuture(_$impls[$p]!.sayHello$1( + ($a![0] as jni$_.JString), + )); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'nullableHello(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![1] as jni$_.JObject).reference) + .resumeWithFuture(_$impls[$p]!.nullableHello( + ($a![0] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + )); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'sayInt(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![0] as jni$_.JObject).reference) + .resumeWithFuture(_$impls[$p]!.sayInt()); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'sayInt(Ljava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![1] as jni$_.JObject).reference) + .resumeWithFuture(_$impls[$p]!.sayInt$1( + ($a![0] as jni$_.JInteger), + )); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'nullableInt(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![1] as jni$_.JObject).reference) + .resumeWithFuture(_$impls[$p]!.nullableInt( + ($a![0] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + )); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == + r'noReturn(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { + final $r = jni$_.KotlinContinuation.fromReference( + ($a![0] as jni$_.JObject).reference) + .resumeWithVoidFuture(_$impls[$p]!.noReturn()); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; } - return $o.as( - const jni$_.$JString$Type$(), - releaseOriginal: true, - ); -} - -/// from: `com.github.dart_lang.jnigen.SuspendInterface` -class SuspendInterface extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - SuspendInterface.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - static final _class = - jni$_.JClass.forName(r'com/github/dart_lang/jnigen/SuspendInterface'); + static void implementIn( + jni$_.JImplementer implementer, + $SuspendInterface $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.SuspendInterface', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $SuspendInterface$NullableType$(); + factory SuspendInterface.implement( + $SuspendInterface $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement(); + } +} - /// The type which includes information such as the signature of this class. - static const jni$_.JType type = $SuspendInterface$Type$(); - static final _id_sayHello = _class.instanceMethodId( +extension SuspendInterface$$Methods on SuspendInterface { + static final _id_sayHello = SuspendInterface._class.instanceMethodId( r'sayHello', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3741,9 +2960,9 @@ class SuspendInterface extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _sayHello(reference.pointer, _id_sayHello as jni$_.JMethodIDPtr, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = _sayHello( + reference.pointer, _id_sayHello.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3763,12 +2982,12 @@ class SuspendInterface extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_sayHello$1 = _class.instanceMethodId( + static final _id_sayHello$1 = SuspendInterface._class.instanceMethodId( r'sayHello', r'(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3798,12 +3017,9 @@ class SuspendInterface extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); final _$string = string.reference; - final $r = _sayHello$1( - reference.pointer, - _id_sayHello$1 as jni$_.JMethodIDPtr, - _$string.pointer, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = _sayHello$1(reference.pointer, _id_sayHello$1.pointer, + _$string.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3823,12 +3039,12 @@ class SuspendInterface extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JString$Type$(), + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_nullableHello = _class.instanceMethodId( + static final _id_nullableHello = SuspendInterface._class.instanceMethodId( r'nullableHello', r'(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3853,12 +3069,9 @@ class SuspendInterface extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _nullableHello( - reference.pointer, - _id_nullableHello as jni$_.JMethodIDPtr, - z ? 1 : 0, - _$continuation.pointer) - .object(const jni$_.$JObject$NullableType$()); + final $r = _nullableHello(reference.pointer, _id_nullableHello.pointer, + z ? 1 : 0, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject? $o; if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3879,13 +3092,13 @@ class SuspendInterface extends jni$_.JObject { } else { $o = $r; } - return $o?.as( - const jni$_.$JString$NullableType$(), + return $o?.as( + jni$_.JString.type, releaseOriginal: true, ); } - static final _id_sayInt = _class.instanceMethodId( + static final _id_sayInt = SuspendInterface._class.instanceMethodId( r'sayInt', r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3907,9 +3120,9 @@ class SuspendInterface extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _sayInt(reference.pointer, _id_sayInt as jni$_.JMethodIDPtr, - _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + final $r = + _sayInt(reference.pointer, _id_sayInt.pointer, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3929,12 +3142,12 @@ class SuspendInterface extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JInteger$Type$(), + jni$_.JInteger.type, releaseOriginal: true, ); } - static final _id_sayInt$1 = _class.instanceMethodId( + static final _id_sayInt$1 = SuspendInterface._class.instanceMethodId( r'sayInt', r'(Ljava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -3964,9 +3177,9 @@ class SuspendInterface extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); final _$integer = integer.reference; - final $r = _sayInt$1(reference.pointer, _id_sayInt$1 as jni$_.JMethodIDPtr, + final $r = _sayInt$1(reference.pointer, _id_sayInt$1.pointer, _$integer.pointer, _$continuation.pointer) - .object(const jni$_.$JObject$Type$()); + .object(); _$continuation.release(); jni$_.JObject $o; if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -3986,12 +3199,12 @@ class SuspendInterface extends jni$_.JObject { $o = $r; } return $o.as( - const jni$_.$JInteger$Type$(), + jni$_.JInteger.type, releaseOriginal: true, ); } - static final _id_nullableInt = _class.instanceMethodId( + static final _id_nullableInt = SuspendInterface._class.instanceMethodId( r'nullableInt', r'(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;', ); @@ -4016,12 +3229,9 @@ class SuspendInterface extends jni$_.JObject { final $p = jni$_.ReceivePort(); final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - final $r = _nullableInt( - reference.pointer, - _id_nullableInt as jni$_.JMethodIDPtr, - z ? 1 : 0, - _$continuation.pointer) - .object(const jni$_.$JObject$NullableType$()); + final $r = _nullableInt(reference.pointer, _id_nullableInt.pointer, + z ? 1 : 0, _$continuation.pointer) + .object(); _$continuation.release(); jni$_.JObject? $o; if ($r != null && $r.isInstanceOf(jni$_.coroutineSingletonsClass)) { @@ -4042,164 +3252,56 @@ class SuspendInterface extends jni$_.JObject { } else { $o = $r; } - return $o?.as( - const jni$_.$JInteger$NullableType$(), + return $o?.as( + jni$_.JInteger.type, releaseOriginal: true, ); } - /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; - static jni$_.JObjectPtr _$invoke( - int port, - jni$_.JObjectPtr descriptor, - jni$_.JObjectPtr args, - ) { - return _$invokeMethod( - port, - jni$_.MethodInvocation.fromAddresses( - 0, - descriptor.address, - args.address, - ), - ); - } + static final _id_noReturn = SuspendInterface._class.instanceMethodId( + r'noReturn', + r'(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;', + ); - static final jni$_.Pointer< - jni$_.NativeFunction< - jni$_.JObjectPtr Function( - jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> - _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + static final _noReturn = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - static jni$_.Pointer _$invokeMethod( - int $p, - jni$_.MethodInvocation $i, - ) { - try { - final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); - final $a = $i.args; - if ($d == - r'sayHello(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { - final $r = jni$_.KotlinContinuation.fromReference($a![0]! - .as(const jni$_.$JObject$Type$(), releaseOriginal: true) - .reference) - .resumeWithFuture(_$impls[$p]!.sayHello()); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == - r'sayHello(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { - final $r = jni$_.KotlinContinuation.fromReference($a![1]! - .as(const jni$_.$JObject$Type$(), releaseOriginal: true) - .reference) - .resumeWithFuture(_$impls[$p]!.sayHello$1( - $a![0]!.as(const jni$_.$JString$Type$(), releaseOriginal: true), - )); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == - r'nullableHello(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;') { - final $r = jni$_.KotlinContinuation.fromReference($a![1]! - .as(const jni$_.$JObject$Type$(), releaseOriginal: true) - .reference) - .resumeWithFuture(_$impls[$p]!.nullableHello( - $a![0]! - .as(const jni$_.$JBoolean$Type$(), releaseOriginal: true) - .booleanValue(releaseOriginal: true), - )); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'sayInt(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { - final $r = jni$_.KotlinContinuation.fromReference($a![0]! - .as(const jni$_.$JObject$Type$(), releaseOriginal: true) - .reference) - .resumeWithFuture(_$impls[$p]!.sayInt()); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == - r'sayInt(Ljava/lang/Integer;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;') { - final $r = jni$_.KotlinContinuation.fromReference($a![1]! - .as(const jni$_.$JObject$Type$(), releaseOriginal: true) - .reference) - .resumeWithFuture(_$impls[$p]!.sayInt$1( - $a![0]!.as(const jni$_.$JInteger$Type$(), releaseOriginal: true), - )); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == - r'nullableInt(ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;') { - final $r = jni$_.KotlinContinuation.fromReference($a![1]! - .as(const jni$_.$JObject$Type$(), releaseOriginal: true) - .reference) - .resumeWithFuture(_$impls[$p]!.nullableInt( - $a![0]! - .as(const jni$_.$JBoolean$Type$(), releaseOriginal: true) - .booleanValue(releaseOriginal: true), - )); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - } catch (e) { - return jni$_.ProtectedJniExtensions.newDartException(e); - } - return jni$_.nullptr; - } + /// from: `public suspend fun noReturn(): kotlin.Unit` + /// The returned object must be released after use, by calling the [release] method. + core$_.Future noReturn() async { + final $p = jni$_.ReceivePort(); + final _$continuation = jni$_.ProtectedJniExtensions.newPortContinuation($p); - static void implementIn( - jni$_.JImplementer implementer, - $SuspendInterface $impl, - ) { - late final jni$_.RawReceivePort $p; - $p = jni$_.RawReceivePort(($m) { - if ($m == null) { - _$impls.remove($p.sendPort.nativePort); - $p.close(); - return; + final $r = _noReturn( + reference.pointer, _id_noReturn.pointer, _$continuation.pointer) + .object(); + _$continuation.release(); + jni$_.JObject $o; + if ($r.isInstanceOf(jni$_.coroutineSingletonsClass)) { + $r.release(); + final $a = await $p.first; + $o = jni$_.JObject.fromReference( + jni$_.JGlobalReference(jni$_.JObjectPtr.fromAddress($a))); + if ($o.isInstanceOf(jni$_.result$Class)) { + $o = jni$_.resultValueField.get($o, const jni$_.$JObject$Type$()); + } else if ($o.isInstanceOf(jni$_.result$FailureClass)) { + final $e = + jni$_.failureExceptionField.get($o, const jni$_.$JObject$Type$()); + $o.release(); + jni$_.Jni.throwException($e.reference.toPointer()); } - final $i = jni$_.MethodInvocation.fromMessage($m); - final $r = _$invokeMethod($p.sendPort.nativePort, $i); - jni$_.ProtectedJniExtensions.returnResult($i.result, $r); - }); - implementer.add( - r'com.github.dart_lang.jnigen.SuspendInterface', - $p, - _$invokePointer, - [], - ); - final $a = $p.sendPort.nativePort; - _$impls[$a] = $impl; - } - - factory SuspendInterface.implement( - $SuspendInterface $impl, - ) { - final $i = jni$_.JImplementer(); - implementIn($i, $impl); - return SuspendInterface.fromReference( - $i.implementReference(), - ); + } else { + $o = $r; + } + return; } } @@ -4214,6 +3316,7 @@ abstract base mixin class $SuspendInterface { required core$_.Future Function(jni$_.JInteger integer) sayInt$1, required core$_.Future Function(core$_.bool z) nullableInt, + required core$_.Future Function() noReturn, }) = _$SuspendInterface; core$_.Future sayHello(); @@ -4222,6 +3325,7 @@ abstract base mixin class $SuspendInterface { core$_.Future sayInt(); core$_.Future sayInt$1(jni$_.JInteger integer); core$_.Future nullableInt(core$_.bool z); + core$_.Future noReturn(); } final class _$SuspendInterface with $SuspendInterface { @@ -4235,12 +3339,14 @@ final class _$SuspendInterface with $SuspendInterface { required core$_.Future Function(jni$_.JInteger integer) sayInt$1, required core$_.Future Function(core$_.bool z) nullableInt, + required core$_.Future Function() noReturn, }) : _sayHello = sayHello, _sayHello$1 = sayHello$1, _nullableHello = nullableHello, _sayInt = sayInt, _sayInt$1 = sayInt$1, - _nullableInt = nullableInt; + _nullableInt = nullableInt, + _noReturn = noReturn; final core$_.Future Function() _sayHello; final core$_.Future Function(jni$_.JString string) _sayHello$1; @@ -4249,6 +3355,7 @@ final class _$SuspendInterface with $SuspendInterface { final core$_.Future Function(jni$_.JInteger integer) _sayInt$1; final core$_.Future Function(core$_.bool z) _nullableInt; + final core$_.Future Function() _noReturn; core$_.Future sayHello() { return _sayHello(); @@ -4273,44 +3380,9 @@ final class _$SuspendInterface with $SuspendInterface { core$_.Future nullableInt(core$_.bool z) { return _nullableInt(z); } -} - -final class $SuspendInterface$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $SuspendInterface$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/SuspendInterface;'; - - @jni$_.internal - @core$_.override - SuspendInterface? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : SuspendInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($SuspendInterface$NullableType$).hashCode; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SuspendInterface$NullableType$) && - other is $SuspendInterface$NullableType$; + core$_.Future noReturn() { + return _noReturn(); } } @@ -4321,34 +3393,6 @@ final class $SuspendInterface$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/SuspendInterface;'; - - @jni$_.internal - @core$_.override - SuspendInterface fromReference(jni$_.JReference reference) => - SuspendInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$Type$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $SuspendInterface$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($SuspendInterface$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SuspendInterface$Type$) && - other is $SuspendInterface$Type$; - } } final _TopLevelKtClass = @@ -4373,8 +3417,8 @@ final _getTopLevelField = jni$_.ProtectedJniExtensions.lookup< /// from: `static public final int getTopLevelField()` int getTopLevelField() { - return _getTopLevelField(_TopLevelKtClass.reference.pointer, - _id_getTopLevelField as jni$_.JMethodIDPtr) + return _getTopLevelField( + _TopLevelKtClass.reference.pointer, _id_getTopLevelField.pointer) .integer; } @@ -4396,8 +3440,8 @@ final _setTopLevelField = jni$_.ProtectedJniExtensions.lookup< void setTopLevelField( int i, ) { - _setTopLevelField(_TopLevelKtClass.reference.pointer, - _id_setTopLevelField as jni$_.JMethodIDPtr, i) + _setTopLevelField( + _TopLevelKtClass.reference.pointer, _id_setTopLevelField.pointer, i) .check(); } @@ -4420,8 +3464,7 @@ final _topLevel = jni$_.ProtectedJniExtensions.lookup< /// from: `public fun topLevel(): kotlin.Int` int topLevel() { - return _topLevel(_TopLevelKtClass.reference.pointer, - _id_topLevel as jni$_.JMethodIDPtr) + return _topLevel(_TopLevelKtClass.reference.pointer, _id_topLevel.pointer) .integer; } @@ -4446,8 +3489,8 @@ int topLevelSum( int i, int i1, ) { - return _topLevelSum(_TopLevelKtClass.reference.pointer, - _id_topLevelSum as jni$_.JMethodIDPtr, i, i1) + return _topLevelSum( + _TopLevelKtClass.reference.pointer, _id_topLevelSum.pointer, i, i1) .integer; } @@ -4473,8 +3516,8 @@ final _getTopLevelField$1 = jni$_.ProtectedJniExtensions.lookup< /// from: `static public final int getTopLevelField()` int getTopLevelField$1() { - return _getTopLevelField$1(_TopLevelKt$1Class.reference.pointer, - _id_getTopLevelField$1 as jni$_.JMethodIDPtr) + return _getTopLevelField$1( + _TopLevelKt$1Class.reference.pointer, _id_getTopLevelField$1.pointer) .integer; } @@ -4497,7 +3540,7 @@ void setTopLevelField$1( int i, ) { _setTopLevelField$1(_TopLevelKt$1Class.reference.pointer, - _id_setTopLevelField$1 as jni$_.JMethodIDPtr, i) + _id_setTopLevelField$1.pointer, i) .check(); } @@ -4520,7 +3563,7 @@ final _topLevel$1 = jni$_.ProtectedJniExtensions.lookup< /// from: `public fun topLevel(): kotlin.Int` int topLevel$1() { - return _topLevel$1(_TopLevelKt$1Class.reference.pointer, - _id_topLevel$1 as jni$_.JMethodIDPtr) + return _topLevel$1( + _TopLevelKt$1Class.reference.pointer, _id_topLevel$1.pointer) .integer; } diff --git a/pkgs/jnigen/test/kotlin_test/kotlin/src/main/kotlin/com/github/dart_lang/jnigen/SuspendFun.kt b/pkgs/jnigen/test/kotlin_test/kotlin/src/main/kotlin/com/github/dart_lang/jnigen/SuspendFun.kt index 1247c90bb6..982ff5bb52 100644 --- a/pkgs/jnigen/test/kotlin_test/kotlin/src/main/kotlin/com/github/dart_lang/jnigen/SuspendFun.kt +++ b/pkgs/jnigen/test/kotlin_test/kotlin/src/main/kotlin/com/github/dart_lang/jnigen/SuspendFun.kt @@ -46,6 +46,12 @@ public class SuspendFun { } return "Hello!" } + + var result: Int = 0 + suspend fun noReturn() { + delay(100L) + this.result = 123 + } } public interface SuspendInterface { @@ -55,6 +61,7 @@ public interface SuspendInterface { suspend fun sayInt(): Integer suspend fun sayInt(value: Integer): Integer suspend fun nullableInt(returnNull: Boolean): Integer? + suspend fun noReturn() } suspend fun consumeOnAnotherThread(itf: SuspendInterface): String { @@ -71,5 +78,6 @@ ${itf.nullableHello(false)} ${itf.sayInt()} ${itf.sayInt(Integer(789))} ${itf.nullableInt(false)} +${itf.noReturn()} """.trim(); } diff --git a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart index 0dc763006f..4ab8d9733a 100644 --- a/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/kotlin_test/runtime_test_registrant.dart @@ -21,9 +21,9 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(helloBob.toDartString(releaseOriginal: true), 'Hello $name!'); final noDelayHello = await suspendFun.sayHelloWithoutDelay(); expect(noDelayHello.toDartString(releaseOriginal: true), 'Hello!'); - await expectLater(suspendFun.fail, throwsA(isA())); + await expectLater(suspendFun.fail, throwsA(isA())); await expectLater( - suspendFun.failWithoutDelay, throwsA(isA())); + suspendFun.failWithoutDelay, throwsA(isA())); final noDelayNullableHello = await suspendFun.nullableHelloWithoutDelay(false); expect(noDelayNullableHello!.toDartString(releaseOriginal: true), @@ -34,6 +34,13 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(noDelayNull, null); final asyncNull = await suspendFun.nullableHello(true); expect(asyncNull, null); + + expect(suspendFun.getResult(), 0); + final voidFuture = suspendFun.noReturn(); + expect(voidFuture, isA>()); + expect(voidFuture, isNot(isA>())); + await voidFuture; + expect(suspendFun.getResult(), 123); }); }); @@ -145,8 +152,6 @@ void registerTests(String groupName, TestRunnerCallback test) { null, 'hello'.toJString(), null, - T: JString.nullableType, - U: JString.type, )..releasedBy(arena); } @@ -182,6 +187,7 @@ void registerTests(String groupName, TestRunnerCallback test) { expect( obj .list() + .asDart() .first! .as(JString.type, releaseOriginal: true) .toDartString(releaseOriginal: true), @@ -211,7 +217,6 @@ void registerTests(String groupName, TestRunnerCallback test) { obj .methodGenericEcho( 'hello'.toJString()..releasedBy(arena), - V: JString.type, ) .toDartString(releaseOriginal: true), 'hello', @@ -220,84 +225,87 @@ void registerTests(String groupName, TestRunnerCallback test) { obj .methodGenericNullableEcho( 'hello'.toJString()..releasedBy(arena), - V: JString.nullableType, - )! - .toDartString(releaseOriginal: true), + ) + ?.toDartString(releaseOriginal: true), 'hello', ); expect( - obj.methodGenericNullableEcho(null, V: JString.nullableType), + obj.methodGenericNullableEcho(null), null, ); expect( obj - .stringListOf('hello'.toJString()..releasedBy(arena))[0] + .stringListOf('hello'.toJString()..releasedBy(arena)) + .asDart()[0] .toDartString(releaseOriginal: true), 'hello', ); expect( obj - .nullableListOf('hello'.toJString()..releasedBy(arena))[0]! + .nullableListOf('hello'.toJString()..releasedBy(arena)) + .asDart()[0]! .toDartString(releaseOriginal: true), 'hello', ); - expect(obj.nullableListOf(null)[0], null); + expect(obj.nullableListOf(null).asDart()[0], null); expect( obj - .classGenericListOf('hello'.toJString()..releasedBy(arena))[0] + .classGenericListOf('hello'.toJString()..releasedBy(arena)) + .asDart()[0] .toDartString(releaseOriginal: true), 'hello', ); expect( obj .classGenericNullableListOf( - 'hello'.toJString()..releasedBy(arena))[0]! + 'hello'.toJString()..releasedBy(arena)) + .asDart()[0]! .toDartString(releaseOriginal: true), 'hello', ); - expect(obj.classGenericNullableListOf(null)[0], null); + expect(obj.classGenericNullableListOf(null).asDart()[0], null); expect( obj - .methodGenericListOf('hello'.toJString()..releasedBy(arena))[0] + .methodGenericListOf('hello'.toJString()..releasedBy(arena)) + .asDart()[0] .toDartString(releaseOriginal: true), 'hello', ); expect( obj - .methodGenericNullableListOf( + .methodGenericNullableListOf( 'hello'.toJString()..releasedBy(arena), - V: JString.nullableType, - )[0]! + ) + .asDart()[0]! .toDartString(releaseOriginal: true), 'hello', ); expect( - obj.methodGenericNullableListOf(null, V: JString.nullableType)[0], + obj.methodGenericNullableListOf(null).asDart()[0], null, ); expect( obj - .firstOf(['hello'.toJString()..releasedBy(arena)] - .toJList(JString.type)) + .firstOf(['hello'.toJString()..releasedBy(arena)].toJList()) .toDartString(releaseOriginal: true), 'hello', ); expect( obj - .firstOfNullable(['hello'.toJString()..releasedBy(arena), null] - .toJList(JString.nullableType))! + .firstOfNullable( + ['hello'.toJString()..releasedBy(arena), null].toJList())! .toDartString(releaseOriginal: true), 'hello', ); expect( - obj.firstOfNullable([null, 'hello'.toJString()..releasedBy(arena)] - .toJList(JString.nullableType)), + obj.firstOfNullable( + [null, 'hello'.toJString()..releasedBy(arena)].toJList()), null, ); expect( obj - .classGenericFirstOf(['hello'.toJString()..releasedBy(arena)] - .toJList(JString.type)) + .classGenericFirstOf( + ['hello'.toJString()..releasedBy(arena)].toJList()) .toDartString(releaseOriginal: true), 'hello', ); @@ -306,7 +314,7 @@ void registerTests(String groupName, TestRunnerCallback test) { .classGenericFirstOfNullable([ 'hello'.toJString()..releasedBy(arena), null, - ].toJList(JString.nullableType))! + ].toJList())! .toDartString(releaseOriginal: true), 'hello', ); @@ -314,13 +322,13 @@ void registerTests(String groupName, TestRunnerCallback test) { obj.classGenericFirstOfNullable([ null, 'hello'.toJString()..releasedBy(arena), - ].toJList(JString.nullableType)), + ].toJList()), null, ); expect( obj - .methodGenericFirstOf(['hello'.toJString()..releasedBy(arena)] - .toJList(JString.type)) + .methodGenericFirstOf( + ['hello'.toJString()..releasedBy(arena)].toJList()) .toDartString(releaseOriginal: true), 'hello', ); @@ -329,7 +337,7 @@ void registerTests(String groupName, TestRunnerCallback test) { .methodGenericFirstOfNullable([ 'hello'.toJString()..releasedBy(arena), null, - ].toJList(JString.nullableType))! + ].toJList())! .toDartString(releaseOriginal: true), 'hello', ); @@ -337,7 +345,7 @@ void registerTests(String groupName, TestRunnerCallback test) { obj.methodGenericFirstOfNullable([ null, 'hello'.toJString()..releasedBy(arena), - ].toJList(JString.nullableType)), + ].toJList()), null, ); }); @@ -345,9 +353,8 @@ void registerTests(String groupName, TestRunnerCallback test) { test('Inner class', () { using((arena) { final obj = testObject(arena); - final innerObj = Nullability$InnerClass( - obj, - V: JInteger.type); + final innerObj = + Nullability$InnerClass(obj); expect( innerObj.f, isA(), @@ -358,6 +365,7 @@ void registerTests(String groupName, TestRunnerCallback test) { group('Interface with suspend functions', () { test('return immediately', () async { + var result = 0; final itf = SuspendInterface.implement($SuspendInterface( sayHello: () async => JString.fromString('Hello'), sayHello$1: (JString name) async => @@ -368,6 +376,7 @@ void registerTests(String groupName, TestRunnerCallback test) { sayInt$1: (JInteger value) async => JInteger(10 * value.intValue()), nullableInt: (bool returnNull) async => returnNull ? null : JInteger(123), + noReturn: () async => result = 123, )); expect((await itf.sayHello()).toDartString(), 'Hello'); @@ -379,6 +388,8 @@ void registerTests(String groupName, TestRunnerCallback test) { expect((await itf.sayInt$1(JInteger(456))).intValue(), 4560); expect((await itf.nullableInt(false))?.intValue(), 123); expect(await itf.nullableInt(true), null); + await itf.noReturn(); + expect(result, 123); expect( (await consumeOnSameThread(itf)).toDartString(), @@ -389,6 +400,7 @@ Hello 123 7890 123 +kotlin.Unit ''' .trim()); expect( @@ -400,11 +412,13 @@ Hello 123 7890 123 +kotlin.Unit ''' .trim()); }); test('return delayed', () async { + var result = 0; final itf = SuspendInterface.implement($SuspendInterface( sayHello: () async { await Future.delayed(const Duration(milliseconds: 100)); @@ -430,6 +444,10 @@ Hello await Future.delayed(const Duration(milliseconds: 100)); return returnNull ? null : JInteger(123); }, + noReturn: () async { + await Future.delayed(const Duration(milliseconds: 100)); + result = 123; + }, )); expect((await itf.sayHello()).toDartString(), 'Hello'); @@ -441,6 +459,8 @@ Hello expect((await itf.sayInt$1(JInteger(456))).intValue(), 4560); expect((await itf.nullableInt(false))?.intValue(), 123); expect(await itf.nullableInt(true), null); + await itf.noReturn(); + expect(result, 123); expect( (await consumeOnSameThread(itf)).toDartString(), @@ -451,6 +471,7 @@ Hello 123 7890 123 +kotlin.Unit ''' .trim()); expect( @@ -462,6 +483,7 @@ Hello 123 7890 123 +kotlin.Unit ''' .trim()); }); @@ -474,22 +496,22 @@ Hello sayInt: () async => throw Exception(), sayInt$1: (JInteger value) async => throw Exception(), nullableInt: (bool returnNull) async => throw Exception(), + noReturn: () async => throw Exception(), )); - await expectLater(itf.sayHello(), throwsA(isA())); + await expectLater(itf.sayHello(), throwsA(isA())); await expectLater(itf.sayHello$1(JString.fromString('Bob')), - throwsA(isA())); - await expectLater( - itf.nullableHello(false), throwsA(isA())); - await expectLater(itf.sayInt(), throwsA(isA())); + throwsA(isA())); + await expectLater(itf.nullableHello(false), throwsA(isA())); + await expectLater(itf.sayInt(), throwsA(isA())); await expectLater( - itf.sayInt$1(JInteger(456)), throwsA(isA())); - await expectLater(itf.nullableInt(false), throwsA(isA())); + itf.sayInt$1(JInteger(456)), throwsA(isA())); + await expectLater(itf.nullableInt(false), throwsA(isA())); + await expectLater(itf.noReturn(), throwsA(isA())); + await expectLater(consumeOnSameThread(itf), throwsA(isA())); await expectLater( - consumeOnSameThread(itf), throwsA(isA())); - await expectLater( - consumeOnAnotherThread(itf), throwsA(isA())); + consumeOnAnotherThread(itf), throwsA(isA())); }); test('throw delayed', () async { @@ -518,22 +540,25 @@ Hello await Future.delayed(const Duration(milliseconds: 100)); throw Exception(); }, + noReturn: () async { + await Future.delayed(const Duration(milliseconds: 100)); + throw Exception(); + }, )); - await expectLater(itf.sayHello(), throwsA(isA())); + await expectLater(itf.sayHello(), throwsA(isA())); await expectLater(itf.sayHello$1(JString.fromString('Bob')), - throwsA(isA())); - await expectLater( - itf.nullableHello(false), throwsA(isA())); - await expectLater(itf.sayInt(), throwsA(isA())); + throwsA(isA())); + await expectLater(itf.nullableHello(false), throwsA(isA())); + await expectLater(itf.sayInt(), throwsA(isA())); await expectLater( - itf.sayInt$1(JInteger(456)), throwsA(isA())); - await expectLater(itf.nullableInt(false), throwsA(isA())); + itf.sayInt$1(JInteger(456)), throwsA(isA())); + await expectLater(itf.nullableInt(false), throwsA(isA())); + await expectLater(itf.noReturn(), throwsA(isA())); + await expectLater(consumeOnSameThread(itf), throwsA(isA())); await expectLater( - consumeOnSameThread(itf), throwsA(isA())); - await expectLater( - consumeOnAnotherThread(itf), throwsA(isA())); + consumeOnAnotherThread(itf), throwsA(isA())); }); }); }); diff --git a/pkgs/jnigen/test/simple_package_test/bindings/simple_package.dart b/pkgs/jnigen/test/simple_package_test/bindings/simple_package.dart index 8397115e89..a7b28383ec 100644 --- a/pkgs/jnigen/test/simple_package_test/bindings/simple_package.dart +++ b/pkgs/jnigen/test/simple_package_test/bindings/simple_package.dart @@ -1,4 +1,4 @@ -// AUTO GENERATED BY JNIGEN 0.15.1. DO NOT EDIT! +// AUTO GENERATED BY JNIGEN 0.16.0. DO NOT EDIT! // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a @@ -41,24 +41,11 @@ import 'package:jni/_internal.dart' as jni$_; import 'package:jni/jni.dart' as jni$_; /// from: `com.github.dart_lang.jnigen.simple_package.Example$Nested$NestedTwice` -class Example$Nested$NestedTwice extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Example$Nested$NestedTwice.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Example$Nested$NestedTwice._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Example$Nested$NestedTwice$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Example$Nested$NestedTwice$Type$(); @@ -68,11 +55,10 @@ class Example$Nested$NestedTwice extends jni$_.JObject { ); /// from: `static public int ZERO` - static int get ZERO => _id_ZERO.get(_class, const jni$_.jintType()); + static int get ZERO => _id_ZERO.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int ZERO` - static set ZERO(int value) => - _id_ZERO.set(_class, const jni$_.jintType(), value); + static set ZERO(int value) => _id_ZERO.set(_class, jni$_.jint.type, value); static final _id_new$ = _class.constructorId( r'()V', @@ -93,49 +79,8 @@ class Example$Nested$NestedTwice extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Example$Nested$NestedTwice() { - return Example$Nested$NestedTwice.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $Example$Nested$NestedTwice$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $Example$Nested$NestedTwice$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice;'; - - @jni$_.internal - @core$_.override - Example$Nested$NestedTwice? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Example$Nested$NestedTwice.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$Nested$NestedTwice$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$Nested$NestedTwice$NullableType$) && - other is $Example$Nested$NestedTwice$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -148,55 +93,13 @@ final class $Example$Nested$NestedTwice$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Example$Nested$NestedTwice;'; - - @jni$_.internal - @core$_.override - Example$Nested$NestedTwice fromReference(jni$_.JReference reference) => - Example$Nested$NestedTwice.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Example$Nested$NestedTwice$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$Nested$NestedTwice$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$Nested$NestedTwice$Type$) && - other is $Example$Nested$NestedTwice$Type$; - } } /// from: `com.github.dart_lang.jnigen.simple_package.Example$Nested` -class Example$Nested extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Example$Nested.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Example$Nested._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Example$Nested'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Example$Nested$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Example$Nested$Type$(); static final _id_new$ = _class.constructorId( @@ -218,12 +121,14 @@ class Example$Nested extends jni$_.JObject { factory Example$Nested( core$_.bool z, ) { - return Example$Nested.fromReference(_new$( - _class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, z ? 1 : 0) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, z ? 1 : 0) + .object(); } +} - static final _id_usesAnonymousInnerClass = _class.instanceMethodId( +extension Example$Nested$$Methods on Example$Nested { + static final _id_usesAnonymousInnerClass = + Example$Nested._class.instanceMethodId( r'usesAnonymousInnerClass', r'()V', ); @@ -242,12 +147,12 @@ class Example$Nested extends jni$_.JObject { /// from: `public void usesAnonymousInnerClass()` void usesAnonymousInnerClass() { - _usesAnonymousInnerClass(reference.pointer, - _id_usesAnonymousInnerClass as jni$_.JMethodIDPtr) + _usesAnonymousInnerClass( + reference.pointer, _id_usesAnonymousInnerClass.pointer) .check(); } - static final _id_getValue = _class.instanceMethodId( + static final _id_getValue = Example$Nested._class.instanceMethodId( r'getValue', r'()Z', ); @@ -266,11 +171,10 @@ class Example$Nested extends jni$_.JObject { /// from: `public boolean getValue()` core$_.bool getValue() { - return _getValue(reference.pointer, _id_getValue as jni$_.JMethodIDPtr) - .boolean; + return _getValue(reference.pointer, _id_getValue.pointer).boolean; } - static final _id_setValue = _class.instanceMethodId( + static final _id_setValue = Example$Nested._class.instanceMethodId( r'setValue', r'(Z)V', ); @@ -289,46 +193,7 @@ class Example$Nested extends jni$_.JObject { void setValue( core$_.bool z, ) { - _setValue(reference.pointer, _id_setValue as jni$_.JMethodIDPtr, z ? 1 : 0) - .check(); - } -} - -final class $Example$Nested$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Example$Nested$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;'; - - @jni$_.internal - @core$_.override - Example$Nested? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Example$Nested.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$Nested$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$Nested$NullableType$) && - other is $Example$Nested$NullableType$; + _setValue(reference.pointer, _id_setValue.pointer, z ? 1 : 0).check(); } } @@ -340,70 +205,17 @@ final class $Example$Nested$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Example$Nested;'; - - @jni$_.internal - @core$_.override - Example$Nested fromReference(jni$_.JReference reference) => - Example$Nested.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Example$Nested$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$Nested$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$Nested$Type$) && - other is $Example$Nested$Type$; - } } /// from: `com.github.dart_lang.jnigen.simple_package.Example$NonStaticNested` -class Example$NonStaticNested extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Example$NonStaticNested.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Example$NonStaticNested._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Example$NonStaticNested'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Example$NonStaticNested$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Example$NonStaticNested$Type$(); - static final _id_ok = _class.instanceFieldId( - r'ok', - r'Z', - ); - - /// from: `public boolean ok` - core$_.bool get ok => _id_ok.get(this, const jni$_.jbooleanType()); - - /// from: `public boolean ok` - set ok(core$_.bool value) => - _id_ok.set(this, const jni$_.jbooleanType(), value); - static final _id_new$ = _class.constructorId( r'(Lcom/github/dart_lang/jnigen/simple_package/Example;)V', ); @@ -425,50 +237,24 @@ class Example$NonStaticNested extends jni$_.JObject { Example $outerClass, ) { final _$$outerClass = $outerClass.reference; - return Example$NonStaticNested.fromReference(_new$(_class.reference.pointer, - _id_new$ as jni$_.JMethodIDPtr, _$$outerClass.pointer) - .reference); + return _new$( + _class.reference.pointer, _id_new$.pointer, _$$outerClass.pointer) + .object(); } } -final class $Example$NonStaticNested$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $Example$NonStaticNested$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Example$NonStaticNested;'; - - @jni$_.internal - @core$_.override - Example$NonStaticNested? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Example$NonStaticNested.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; +extension Example$NonStaticNested$$Methods on Example$NonStaticNested { + static final _id_ok = Example$NonStaticNested._class.instanceFieldId( + r'ok', + r'Z', + ); - @core$_.override - int get hashCode => ($Example$NonStaticNested$NullableType$).hashCode; + /// from: `public boolean ok` + core$_.bool get ok => + _id_ok.getNullable(this, jni$_.jboolean.type) as core$_.bool; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$NonStaticNested$NullableType$) && - other is $Example$NonStaticNested$NullableType$; - } + /// from: `public boolean ok` + set ok(core$_.bool value) => _id_ok.set(this, jni$_.jboolean.type, value); } final class $Example$NonStaticNested$Type$ @@ -480,54 +266,13 @@ final class $Example$NonStaticNested$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Example$NonStaticNested;'; - - @jni$_.internal - @core$_.override - Example$NonStaticNested fromReference(jni$_.JReference reference) => - Example$NonStaticNested.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Example$NonStaticNested$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$NonStaticNested$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$NonStaticNested$Type$) && - other is $Example$NonStaticNested$Type$; - } } /// from: `com.github.dart_lang.jnigen.simple_package.Example` -class Example extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Example.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Example._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Example'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Example$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Example$Type$(); @@ -550,7 +295,8 @@ class Example extends jni$_.JObject { /// from: `static public final java.lang.String SEMICOLON_STRING` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get SEMICOLON_STRING => - _id_SEMICOLON_STRING.get(_class, const jni$_.$JString$NullableType$()); + _id_SEMICOLON_STRING.getNullable(_class, jni$_.JString.type) + as jni$_.JString?; static final _id_unusedRandom = _class.staticFieldId( r'unusedRandom', @@ -560,7 +306,8 @@ class Example extends jni$_.JObject { /// from: `static public final java.util.Random unusedRandom` /// The returned object must be released after use, by calling the [release] method. static jni$_.JObject? get unusedRandom => - _id_unusedRandom.get(_class, const jni$_.$JObject$NullableType$()); + _id_unusedRandom.getNullable(_class, jni$_.JObject.type) + as jni$_.JObject?; static final _id_getAmount = _class.staticMethodId( r'getAmount', @@ -581,9 +328,7 @@ class Example extends jni$_.JObject { /// from: `static public int getAmount()` static int getAmount() { - return _getAmount( - _class.reference.pointer, _id_getAmount as jni$_.JMethodIDPtr) - .integer; + return _getAmount(_class.reference.pointer, _id_getAmount.pointer).integer; } static final _id_getPi = _class.staticMethodId( @@ -605,8 +350,7 @@ class Example extends jni$_.JObject { /// from: `static public double getPi()` static double getPi() { - return _getPi(_class.reference.pointer, _id_getPi as jni$_.JMethodIDPtr) - .doubleFloat; + return _getPi(_class.reference.pointer, _id_getPi.pointer).doubleFloat; } static final _id_getAsterisk = _class.staticMethodId( @@ -628,9 +372,7 @@ class Example extends jni$_.JObject { /// from: `static public char getAsterisk()` static int getAsterisk() { - return _getAsterisk( - _class.reference.pointer, _id_getAsterisk as jni$_.JMethodIDPtr) - .char; + return _getAsterisk(_class.reference.pointer, _id_getAsterisk.pointer).char; } static final _id_getName = _class.staticMethodId( @@ -653,8 +395,8 @@ class Example extends jni$_.JObject { /// from: `static public java.lang.String getName()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? getName() { - return _getName(_class.reference.pointer, _id_getName as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getName(_class.reference.pointer, _id_getName.pointer) + .object(); } static final _id_getNestedInstance = _class.staticMethodId( @@ -677,9 +419,9 @@ class Example extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.simple_package.Example$Nested getNestedInstance()` /// The returned object must be released after use, by calling the [release] method. static Example$Nested? getNestedInstance() { - return _getNestedInstance(_class.reference.pointer, - _id_getNestedInstance as jni$_.JMethodIDPtr) - .object(const $Example$Nested$NullableType$()); + return _getNestedInstance( + _class.reference.pointer, _id_getNestedInstance.pointer) + .object(); } static final _id_setAmount = _class.staticMethodId( @@ -700,8 +442,7 @@ class Example extends jni$_.JObject { static void setAmount( int i, ) { - _setAmount(_class.reference.pointer, _id_setAmount as jni$_.JMethodIDPtr, i) - .check(); + _setAmount(_class.reference.pointer, _id_setAmount.pointer, i).check(); } static final _id_setName = _class.staticMethodId( @@ -725,8 +466,7 @@ class Example extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - _setName(_class.reference.pointer, _id_setName as jni$_.JMethodIDPtr, - _$string.pointer) + _setName(_class.reference.pointer, _id_setName.pointer, _$string.pointer) .check(); } @@ -751,8 +491,8 @@ class Example extends jni$_.JObject { Example$Nested? nested, ) { final _$nested = nested?.reference ?? jni$_.jNullReference; - _setNestedInstance(_class.reference.pointer, - _id_setNestedInstance as jni$_.JMethodIDPtr, _$nested.pointer) + _setNestedInstance(_class.reference.pointer, _id_setNestedInstance.pointer, + _$nested.pointer) .check(); } @@ -784,8 +524,7 @@ class Example extends jni$_.JObject { int i2, int i3, ) { - return _max4(_class.reference.pointer, _id_max4 as jni$_.JMethodIDPtr, i, - i1, i2, i3) + return _max4(_class.reference.pointer, _id_max4.pointer, i, i1, i2, i3) .integer; } @@ -825,107 +564,345 @@ class Example extends jni$_.JObject { int i6, int i7, ) { - return _max8(_class.reference.pointer, _id_max8 as jni$_.JMethodIDPtr, i, - i1, i2, i3, i4, i5, i6, i7) + return _max8(_class.reference.pointer, _id_max8.pointer, i, i1, i2, i3, i4, + i5, i6, i7) .integer; } - static final _id_getNumber = _class.instanceMethodId( - r'getNumber', - r'()I', + static final _id_new$ = _class.constructorId( + r'()V', ); - static final _getNumber = jni$_.ProtectedJniExtensions.lookup< + static final _new$ = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_CallIntMethod') + )>>('globalEnv_NewObject') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `public int getNumber()` - int getNumber() { - return _getNumber(reference.pointer, _id_getNumber as jni$_.JMethodIDPtr) - .integer; + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory Example() { + return _new$(_class.reference.pointer, _id_new$.pointer).object(); } - static final _id_setNumber = _class.instanceMethodId( - r'setNumber', + static final _id_new$1 = _class.constructorId( r'(I)V', ); - static final _setNumber = jni$_.ProtectedJniExtensions.lookup< + static final _new$1 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_NewObject') .asFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - /// from: `public void setNumber(int i)` - void setNumber( + /// from: `public void (int i)` + /// The returned object must be released after use, by calling the [release] method. + factory Example.new$1( int i, ) { - _setNumber(reference.pointer, _id_setNumber as jni$_.JMethodIDPtr, i) - .check(); + return _new$1(_class.reference.pointer, _id_new$1.pointer, i) + .object(); } - static final _id_getIsUp = _class.instanceMethodId( - r'getIsUp', - r'()Z', + static final _id_new$2 = _class.constructorId( + r'(IZ)V', ); - static final _getIsUp = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallBooleanMethod') + static final _new$2 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>)>>( + 'globalEnv_NewObject') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.Pointer, jni$_.JMethodIDPtr, int, int)>(); - /// from: `public boolean getIsUp()` - core$_.bool getIsUp() { - return _getIsUp(reference.pointer, _id_getIsUp as jni$_.JMethodIDPtr) - .boolean; + /// from: `public void (int i, boolean z)` + /// The returned object must be released after use, by calling the [release] method. + factory Example.new$2( + int i, + core$_.bool z, + ) { + return _new$2(_class.reference.pointer, _id_new$2.pointer, i, z ? 1 : 0) + .object(); } - static final _id_setUp = _class.instanceMethodId( - r'setUp', - r'(Z)V', + static final _id_new$3 = _class.constructorId( + r'(IZLjava/lang/String;)V', ); - static final _setUp = jni$_.ProtectedJniExtensions.lookup< + static final _new$3 = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< - jni$_.JThrowablePtr Function( + jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + jni$_.VarArgs< + ( + jni$_.Int32, + jni$_.Int32, + jni$_.Pointer + )>)>>('globalEnv_NewObject') .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, int, jni$_.Pointer)>(); - /// from: `public void setUp(boolean z)` - void setUp( + /// from: `public void (int i, boolean z, java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + factory Example.new$3( + int i, core$_.bool z, + jni$_.JString? string, ) { - _setUp(reference.pointer, _id_setUp as jni$_.JMethodIDPtr, z ? 1 : 0) - .check(); + final _$string = string?.reference ?? jni$_.jNullReference; + return _new$3(_class.reference.pointer, _id_new$3.pointer, i, z ? 1 : 0, + _$string.pointer) + .object(); } - static final _id_getCodename = _class.instanceMethodId( - r'getCodename', - r'()Ljava/lang/String;', - ); + static final _id_new$4 = _class.constructorId( + r'(IIIIIIII)V', + ); + + static final _new$4 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32, + jni$_.Int32 + )>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, int, int, int, int, int, int, int, int)>(); + + /// from: `public void (int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7)` + /// The returned object must be released after use, by calling the [release] method. + factory Example.new$4( + int i, + int i1, + int i2, + int i3, + int i4, + int i5, + int i6, + int i7, + ) { + return _new$4(_class.reference.pointer, _id_new$4.pointer, i, i1, i2, i3, + i4, i5, i6, i7) + .object(); + } + + static final _id_addInts = _class.staticMethodId( + r'addInts', + r'(II)I', + ); + + static final _addInts = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>)>>( + 'globalEnv_CallStaticIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int, int)>(); + + /// from: `static public int addInts(int i, int i1)` + static int addInts( + int i, + int i1, + ) { + return _addInts(_class.reference.pointer, _id_addInts.pointer, i, i1) + .integer; + } + + static final _id_getArr = _class.staticMethodId( + r'getArr', + r'()[I', + ); + + static final _getArr = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public int[] getArr()` + /// The returned object must be released after use, by calling the [release] method. + static jni$_.JIntArray? getArr() { + return _getArr(_class.reference.pointer, _id_getArr.pointer) + .object(); + } + + static final _id_addAll = _class.staticMethodId( + r'addAll', + r'([I)I', + ); + + static final _addAll = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallStaticIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `static public int addAll(int[] is)` + static int addAll( + jni$_.JIntArray? is$, + ) { + final _$is$ = is$?.reference ?? jni$_.jNullReference; + return _addAll(_class.reference.pointer, _id_addAll.pointer, _$is$.pointer) + .integer; + } + + static final _id_throwException = _class.staticMethodId( + r'throwException', + r'()V', + ); + + static final _throwException = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public void throwException()` + static void throwException() { + _throwException(_class.reference.pointer, _id_throwException.pointer) + .check(); + } +} + +extension Example$$Methods on Example { + static final _id_getNumber = Example._class.instanceMethodId( + r'getNumber', + r'()I', + ); + + static final _getNumber = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public int getNumber()` + int getNumber() { + return _getNumber(reference.pointer, _id_getNumber.pointer).integer; + } + + static final _id_setNumber = Example._class.instanceMethodId( + r'setNumber', + r'(I)V', + ); + + static final _setNumber = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void setNumber(int i)` + void setNumber( + int i, + ) { + _setNumber(reference.pointer, _id_setNumber.pointer, i).check(); + } + + static final _id_getIsUp = Example._class.instanceMethodId( + r'getIsUp', + r'()Z', + ); + + static final _getIsUp = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallBooleanMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public boolean getIsUp()` + core$_.bool getIsUp() { + return _getIsUp(reference.pointer, _id_getIsUp.pointer).boolean; + } + + static final _id_setUp = Example._class.instanceMethodId( + r'setUp', + r'(Z)V', + ); + + static final _setUp = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public void setUp(boolean z)` + void setUp( + core$_.bool z, + ) { + _setUp(reference.pointer, _id_setUp.pointer, z ? 1 : 0).check(); + } + + static final _id_getCodename = Example._class.instanceMethodId( + r'getCodename', + r'()Ljava/lang/String;', + ); static final _getCodename = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< @@ -942,12 +919,11 @@ class Example extends jni$_.JObject { /// from: `public java.lang.String getCodename()` /// The returned object must be released after use, by calling the [release] method. jni$_.JString? getCodename() { - return _getCodename( - reference.pointer, _id_getCodename as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + return _getCodename(reference.pointer, _id_getCodename.pointer) + .object(); } - static final _id_setCodename = _class.instanceMethodId( + static final _id_setCodename = Example._class.instanceMethodId( r'setCodename', r'(Ljava/lang/String;)V', ); @@ -968,12 +944,11 @@ class Example extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - _setCodename(reference.pointer, _id_setCodename as jni$_.JMethodIDPtr, - _$string.pointer) + _setCodename(reference.pointer, _id_setCodename.pointer, _$string.pointer) .check(); } - static final _id_getRandom = _class.instanceMethodId( + static final _id_getRandom = Example._class.instanceMethodId( r'getRandom', r'()Ljava/util/Random;', ); @@ -993,11 +968,11 @@ class Example extends jni$_.JObject { /// from: `public java.util.Random getRandom()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? getRandom() { - return _getRandom(reference.pointer, _id_getRandom as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _getRandom(reference.pointer, _id_getRandom.pointer) + .object(); } - static final _id_setRandom = _class.instanceMethodId( + static final _id_setRandom = Example._class.instanceMethodId( r'setRandom', r'(Ljava/util/Random;)V', ); @@ -1018,12 +993,11 @@ class Example extends jni$_.JObject { jni$_.JObject? random, ) { final _$random = random?.reference ?? jni$_.jNullReference; - _setRandom(reference.pointer, _id_setRandom as jni$_.JMethodIDPtr, - _$random.pointer) + _setRandom(reference.pointer, _id_setRandom.pointer, _$random.pointer) .check(); } - static final _id_getRandomLong = _class.instanceMethodId( + static final _id_getRandomLong = Example._class.instanceMethodId( r'getRandomLong', r'()J', ); @@ -1042,12 +1016,10 @@ class Example extends jni$_.JObject { /// from: `public long getRandomLong()` int getRandomLong() { - return _getRandomLong( - reference.pointer, _id_getRandomLong as jni$_.JMethodIDPtr) - .long; + return _getRandomLong(reference.pointer, _id_getRandomLong.pointer).long; } - static final _id_add4Longs = _class.instanceMethodId( + static final _id_add4Longs = Example._class.instanceMethodId( r'add4Longs', r'(JJJJ)J', ); @@ -1075,12 +1047,11 @@ class Example extends jni$_.JObject { int j2, int j3, ) { - return _add4Longs(reference.pointer, _id_add4Longs as jni$_.JMethodIDPtr, j, - j1, j2, j3) + return _add4Longs(reference.pointer, _id_add4Longs.pointer, j, j1, j2, j3) .long; } - static final _id_add8Longs = _class.instanceMethodId( + static final _id_add8Longs = Example._class.instanceMethodId( r'add8Longs', r'(JJJJJJJJ)J', ); @@ -1116,12 +1087,12 @@ class Example extends jni$_.JObject { int j6, int j7, ) { - return _add8Longs(reference.pointer, _id_add8Longs as jni$_.JMethodIDPtr, j, - j1, j2, j3, j4, j5, j6, j7) + return _add8Longs(reference.pointer, _id_add8Longs.pointer, j, j1, j2, j3, + j4, j5, j6, j7) .long; } - static final _id_getRandomNumericString = _class.instanceMethodId( + static final _id_getRandomNumericString = Example._class.instanceMethodId( r'getRandomNumericString', r'(Ljava/util/Random;)Ljava/lang/String;', ); @@ -1144,11 +1115,11 @@ class Example extends jni$_.JObject { ) { final _$random = random?.reference ?? jni$_.jNullReference; return _getRandomNumericString(reference.pointer, - _id_getRandomNumericString as jni$_.JMethodIDPtr, _$random.pointer) - .object(const jni$_.$JString$NullableType$()); + _id_getRandomNumericString.pointer, _$random.pointer) + .object(); } - static final _id_finalMethod = _class.instanceMethodId( + static final _id_finalMethod = Example._class.instanceMethodId( r'finalMethod', r'()V', ); @@ -1167,11 +1138,10 @@ class Example extends jni$_.JObject { /// from: `public final void finalMethod()` void finalMethod() { - _finalMethod(reference.pointer, _id_finalMethod as jni$_.JMethodIDPtr) - .check(); + _finalMethod(reference.pointer, _id_finalMethod.pointer).check(); } - static final _id_getList = _class.instanceMethodId( + static final _id_getList = Example._class.instanceMethodId( r'getList', r'()Ljava/util/List;', ); @@ -1191,13 +1161,11 @@ class Example extends jni$_.JObject { /// from: `public java.util.List getList()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList? getList() { - return _getList(reference.pointer, _id_getList as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JList$NullableType$( - jni$_.$JString$NullableType$())); + return _getList(reference.pointer, _id_getList.pointer) + .object?>(); } - static final _id_joinStrings = _class.instanceMethodId( + static final _id_joinStrings = Example._class.instanceMethodId( r'joinStrings', r'(Ljava/util/List;Ljava/lang/String;)Ljava/lang/String;', ); @@ -1227,15 +1195,12 @@ class Example extends jni$_.JObject { ) { final _$list = list?.reference ?? jni$_.jNullReference; final _$string = string?.reference ?? jni$_.jNullReference; - return _joinStrings( - reference.pointer, - _id_joinStrings as jni$_.JMethodIDPtr, - _$list.pointer, - _$string.pointer) - .object(const jni$_.$JString$NullableType$()); + return _joinStrings(reference.pointer, _id_joinStrings.pointer, + _$list.pointer, _$string.pointer) + .object(); } - static final _id_methodWithSeveralParams = _class.instanceMethodId( + static final _id_methodWithSeveralParams = Example._class.instanceMethodId( r'methodWithSeveralParams', r'(CLjava/lang/String;[ILjava/lang/CharSequence;Ljava/util/List;Ljava/util/Map;)V', ); @@ -1272,9 +1237,8 @@ class Example extends jni$_.JObject { jni$_.JIntArray? is$, $T? charSequence, jni$_.JList<$T?>? list, - jni$_.JMap? map, { - required jni$_.JType<$T> T, - }) { + jni$_.JMap? map, + ) { final _$string = string?.reference ?? jni$_.jNullReference; final _$is$ = is$?.reference ?? jni$_.jNullReference; final _$charSequence = charSequence?.reference ?? jni$_.jNullReference; @@ -1282,7 +1246,7 @@ class Example extends jni$_.JObject { final _$map = map?.reference ?? jni$_.jNullReference; _methodWithSeveralParams( reference.pointer, - _id_methodWithSeveralParams as jni$_.JMethodIDPtr, + _id_methodWithSeveralParams.pointer, c, _$string.pointer, _$is$.pointer, @@ -1292,302 +1256,52 @@ class Example extends jni$_.JObject { .check(); } - static final _id_new$ = _class.constructorId( - r'()V', + static final _id_whichExample = Example._class.instanceMethodId( + r'whichExample', + r'()I', ); - static final _new$ = jni$_.ProtectedJniExtensions.lookup< + static final _whichExample = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_NewObject') + )>>('globalEnv_CallIntMethod') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `public void ()` - /// The returned object must be released after use, by calling the [release] method. - factory Example() { - return Example.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + /// from: `public int whichExample()` + int whichExample() { + return _whichExample(reference.pointer, _id_whichExample.pointer).integer; } - static final _id_new$1 = _class.constructorId( - r'(I)V', + static final _id_getSelf = Example._class.instanceMethodId( + r'getSelf', + r'()Lcom/github/dart_lang/jnigen/simple_package/Example;', ); - static final _new$1 = jni$_.ProtectedJniExtensions.lookup< + static final _getSelf = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_NewObject') + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( - jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - /// from: `public void (int i)` - /// The returned object must be released after use, by calling the [release] method. - factory Example.new$1( - int i, - ) { - return Example.fromReference( - _new$1(_class.reference.pointer, _id_new$1 as jni$_.JMethodIDPtr, i) - .reference); - } - - static final _id_new$2 = _class.constructorId( - r'(IZ)V', - ); - - static final _new$2 = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>)>>( - 'globalEnv_NewObject') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, jni$_.JMethodIDPtr, int, int)>(); - - /// from: `public void (int i, boolean z)` - /// The returned object must be released after use, by calling the [release] method. - factory Example.new$2( - int i, - core$_.bool z, - ) { - return Example.fromReference(_new$2(_class.reference.pointer, - _id_new$2 as jni$_.JMethodIDPtr, i, z ? 1 : 0) - .reference); - } - - static final _id_new$3 = _class.constructorId( - r'(IZLjava/lang/String;)V', - ); - - static final _new$3 = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Int32, - jni$_.Int32, - jni$_.Pointer - )>)>>('globalEnv_NewObject') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, int, int, jni$_.Pointer)>(); - - /// from: `public void (int i, boolean z, java.lang.String string)` - /// The returned object must be released after use, by calling the [release] method. - factory Example.new$3( - int i, - core$_.bool z, - jni$_.JString? string, - ) { - final _$string = string?.reference ?? jni$_.jNullReference; - return Example.fromReference(_new$3(_class.reference.pointer, - _id_new$3 as jni$_.JMethodIDPtr, i, z ? 1 : 0, _$string.pointer) - .reference); - } - - static final _id_new$4 = _class.constructorId( - r'(IIIIIIII)V', - ); - - static final _new$4 = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Int32, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32, - jni$_.Int32 - )>)>>('globalEnv_NewObject') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, int, int, int, int, int, int, int, int)>(); - - /// from: `public void (int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7)` - /// The returned object must be released after use, by calling the [release] method. - factory Example.new$4( - int i, - int i1, - int i2, - int i3, - int i4, - int i5, - int i6, - int i7, - ) { - return Example.fromReference(_new$4(_class.reference.pointer, - _id_new$4 as jni$_.JMethodIDPtr, i, i1, i2, i3, i4, i5, i6, i7) - .reference); - } - - static final _id_whichExample = _class.instanceMethodId( - r'whichExample', - r'()I', - ); - - static final _whichExample = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallIntMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public int whichExample()` - int whichExample() { - return _whichExample( - reference.pointer, _id_whichExample as jni$_.JMethodIDPtr) - .integer; - } - - static final _id_addInts = _class.staticMethodId( - r'addInts', - r'(II)I', - ); - - static final _addInts = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Int32, jni$_.Int32)>)>>( - 'globalEnv_CallStaticIntMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, jni$_.JMethodIDPtr, int, int)>(); - - /// from: `static public int addInts(int i, int i1)` - static int addInts( - int i, - int i1, - ) { - return _addInts( - _class.reference.pointer, _id_addInts as jni$_.JMethodIDPtr, i, i1) - .integer; - } - - static final _id_getArr = _class.staticMethodId( - r'getArr', - r'()[I', - ); - - static final _getArr = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallStaticObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `static public int[] getArr()` - /// The returned object must be released after use, by calling the [release] method. - static jni$_.JIntArray? getArr() { - return _getArr(_class.reference.pointer, _id_getArr as jni$_.JMethodIDPtr) - .object(const jni$_.$JIntArray$NullableType$()); - } - - static final _id_addAll = _class.staticMethodId( - r'addAll', - r'([I)I', - ); - - static final _addAll = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallStaticIntMethod') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `static public int addAll(int[] is)` - static int addAll( - jni$_.JIntArray? is$, - ) { - final _$is$ = is$?.reference ?? jni$_.jNullReference; - return _addAll(_class.reference.pointer, _id_addAll as jni$_.JMethodIDPtr, - _$is$.pointer) - .integer; - } - - static final _id_getSelf = _class.instanceMethodId( - r'getSelf', - r'()Lcom/github/dart_lang/jnigen/simple_package/Example;', - ); - - static final _getSelf = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public com.github.dart_lang.jnigen.simple_package.Example getSelf()` + /// from: `public com.github.dart_lang.jnigen.simple_package.Example getSelf()` /// The returned object must be released after use, by calling the [release] method. Example? getSelf() { - return _getSelf(reference.pointer, _id_getSelf as jni$_.JMethodIDPtr) - .object(const $Example$NullableType$()); - } - - static final _id_throwException = _class.staticMethodId( - r'throwException', - r'()V', - ); - - static final _throwException = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallStaticVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `static public void throwException()` - static void throwException() { - _throwException( - _class.reference.pointer, _id_throwException as jni$_.JMethodIDPtr) - .check(); + return _getSelf(reference.pointer, _id_getSelf.pointer).object(); } - static final _id_overloaded = _class.instanceMethodId( + static final _id_overloaded = Example._class.instanceMethodId( r'overloaded', r'()V', ); @@ -1606,11 +1320,10 @@ class Example extends jni$_.JObject { /// from: `public void overloaded()` void overloaded() { - _overloaded(reference.pointer, _id_overloaded as jni$_.JMethodIDPtr) - .check(); + _overloaded(reference.pointer, _id_overloaded.pointer).check(); } - static final _id_overloaded$1 = _class.instanceMethodId( + static final _id_overloaded$1 = Example._class.instanceMethodId( r'overloaded', r'(ILjava/lang/String;)V', ); @@ -1633,12 +1346,12 @@ class Example extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - _overloaded$1(reference.pointer, _id_overloaded$1 as jni$_.JMethodIDPtr, i, - _$string.pointer) + _overloaded$1( + reference.pointer, _id_overloaded$1.pointer, i, _$string.pointer) .check(); } - static final _id_overloaded$2 = _class.instanceMethodId( + static final _id_overloaded$2 = Example._class.instanceMethodId( r'overloaded', r'(I)V', ); @@ -1657,11 +1370,10 @@ class Example extends jni$_.JObject { void overloaded$2( int i, ) { - _overloaded$2(reference.pointer, _id_overloaded$2 as jni$_.JMethodIDPtr, i) - .check(); + _overloaded$2(reference.pointer, _id_overloaded$2.pointer, i).check(); } - static final _id_overloaded$3 = _class.instanceMethodId( + static final _id_overloaded$3 = Example._class.instanceMethodId( r'overloaded', r'(Ljava/util/List;Ljava/lang/String;)V', ); @@ -1690,12 +1402,12 @@ class Example extends jni$_.JObject { ) { final _$list = list?.reference ?? jni$_.jNullReference; final _$string = string?.reference ?? jni$_.jNullReference; - _overloaded$3(reference.pointer, _id_overloaded$3 as jni$_.JMethodIDPtr, - _$list.pointer, _$string.pointer) + _overloaded$3(reference.pointer, _id_overloaded$3.pointer, _$list.pointer, + _$string.pointer) .check(); } - static final _id_overloaded$4 = _class.instanceMethodId( + static final _id_overloaded$4 = Example._class.instanceMethodId( r'overloaded', r'(Ljava/util/List;)V', ); @@ -1716,12 +1428,11 @@ class Example extends jni$_.JObject { jni$_.JList? list, ) { final _$list = list?.reference ?? jni$_.jNullReference; - _overloaded$4(reference.pointer, _id_overloaded$4 as jni$_.JMethodIDPtr, - _$list.pointer) + _overloaded$4(reference.pointer, _id_overloaded$4.pointer, _$list.pointer) .check(); } - static final _id_bool = _class.instanceMethodId( + static final _id_bool = Example._class.instanceMethodId( r'bool', r'(Z)Z', ); @@ -1741,11 +1452,10 @@ class Example extends jni$_.JObject { core$_.bool bool( core$_.bool z, ) { - return _bool(reference.pointer, _id_bool as jni$_.JMethodIDPtr, z ? 1 : 0) - .boolean; + return _bool(reference.pointer, _id_bool.pointer, z ? 1 : 0).boolean; } - static final _id_num = _class.instanceMethodId( + static final _id_num = Example._class.instanceMethodId( r'num', r'(D)D', ); @@ -1765,46 +1475,7 @@ class Example extends jni$_.JObject { double num( double d, ) { - return _num(reference.pointer, _id_num as jni$_.JMethodIDPtr, d) - .doubleFloat; - } -} - -final class $Example$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Example$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Example;'; - - @jni$_.internal - @core$_.override - Example? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Example.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$NullableType$) && - other is $Example$NullableType$; + return _num(reference.pointer, _id_num.pointer, d).doubleFloat; } } @@ -1816,52 +1487,75 @@ final class $Example$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Example;'; +} - @jni$_.internal - @core$_.override - Example fromReference(jni$_.JReference reference) => Example.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Example$NullableType$(); +/// from: `com.github.dart_lang.jnigen.simple_package.Exceptions$MyException` +extension type Exceptions$MyException._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/simple_package/Exceptions$MyException'); - @jni$_.internal - @core$_.override - final superCount = 1; + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $Exceptions$MyException$Type$(); + static final _id_new$ = _class.constructorId( + r'(Ljava/lang/String;I)V', + ); - @core$_.override - int get hashCode => ($Example$Type$).hashCode; + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_ + .VarArgs<(jni$_.Pointer, jni$_.Int32)>)>>( + 'globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer, int)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$Type$) && other is $Example$Type$; + /// from: `public void (java.lang.String string, int i)` + /// The returned object must be released after use, by calling the [release] method. + factory Exceptions$MyException( + jni$_.JString? string, + int i, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _new$( + _class.reference.pointer, _id_new$.pointer, _$string.pointer, i) + .object(); } } -/// from: `com.github.dart_lang.jnigen.simple_package.Exceptions` -class Exceptions extends jni$_.JObject { +extension Exceptions$MyException$$Methods on Exceptions$MyException { + static final _id_errorCode = Exceptions$MyException._class.instanceFieldId( + r'errorCode', + r'I', + ); + + /// from: `public int errorCode` + int get errorCode => _id_errorCode.getNullable(this, jni$_.jint.type) as int; + + /// from: `public int errorCode` + set errorCode(int value) => _id_errorCode.set(this, jni$_.jint.type, value); +} + +final class $Exceptions$MyException$Type$ + extends jni$_.JType { @jni$_.internal - @core$_.override - final jni$_.JType $type; + const $Exceptions$MyException$Type$(); @jni$_.internal - Exceptions.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/simple_package/Exceptions$MyException;'; +} +/// from: `com.github.dart_lang.jnigen.simple_package.Exceptions` +extension type Exceptions._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Exceptions'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Exceptions$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Exceptions$Type$(); static final _id_new$ = _class.constructorId( @@ -1883,9 +1577,8 @@ class Exceptions extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Exceptions() { - return Exceptions.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_new$1 = _class.constructorId( @@ -1907,9 +1600,8 @@ class Exceptions extends jni$_.JObject { factory Exceptions.new$1( double f, ) { - return Exceptions.fromReference( - _new$1(_class.reference.pointer, _id_new$1 as jni$_.JMethodIDPtr, f) - .reference); + return _new$1(_class.reference.pointer, _id_new$1.pointer, f) + .object(); } static final _id_new$2 = _class.constructorId( @@ -1944,9 +1636,9 @@ class Exceptions extends jni$_.JObject { int i4, int i5, ) { - return Exceptions.fromReference(_new$2(_class.reference.pointer, - _id_new$2 as jni$_.JMethodIDPtr, i, i1, i2, i3, i4, i5) - .reference); + return _new$2( + _class.reference.pointer, _id_new$2.pointer, i, i1, i2, i3, i4, i5) + .object(); } static final _id_staticObjectMethod = _class.staticMethodId( @@ -1969,9 +1661,9 @@ class Exceptions extends jni$_.JObject { /// from: `static public java.lang.Object staticObjectMethod()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JObject? staticObjectMethod() { - return _staticObjectMethod(_class.reference.pointer, - _id_staticObjectMethod as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _staticObjectMethod( + _class.reference.pointer, _id_staticObjectMethod.pointer) + .object(); } static final _id_staticIntMethod = _class.staticMethodId( @@ -1994,7 +1686,7 @@ class Exceptions extends jni$_.JObject { /// from: `static public int staticIntMethod()` static int staticIntMethod() { return _staticIntMethod( - _class.reference.pointer, _id_staticIntMethod as jni$_.JMethodIDPtr) + _class.reference.pointer, _id_staticIntMethod.pointer) .integer; } @@ -2018,11 +1710,9 @@ class Exceptions extends jni$_.JObject { /// from: `static public java.lang.Object[] staticObjectArrayMethod()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? staticObjectArrayMethod() { - return _staticObjectArrayMethod(_class.reference.pointer, - _id_staticObjectArrayMethod as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - jni$_.$JObject$NullableType$())); + return _staticObjectArrayMethod( + _class.reference.pointer, _id_staticObjectArrayMethod.pointer) + .object?>(); } static final _id_staticIntArrayMethod = _class.staticMethodId( @@ -2045,12 +1735,60 @@ class Exceptions extends jni$_.JObject { /// from: `static public int[] staticIntArrayMethod()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JIntArray? staticIntArrayMethod() { - return _staticIntArrayMethod(_class.reference.pointer, - _id_staticIntArrayMethod as jni$_.JMethodIDPtr) - .object(const jni$_.$JIntArray$NullableType$()); + return _staticIntArrayMethod( + _class.reference.pointer, _id_staticIntArrayMethod.pointer) + .object(); + } + + static final _id_throwLoremIpsum = _class.staticMethodId( + r'throwLoremIpsum', + r'()V', + ); + + static final _throwLoremIpsum = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public void throwLoremIpsum()` + static void throwLoremIpsum() { + _throwLoremIpsum(_class.reference.pointer, _id_throwLoremIpsum.pointer) + .check(); + } + + static final _id_throwMyException = _class.staticMethodId( + r'throwMyException', + r'()V', + ); + + static final _throwMyException = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallStaticVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `static public void throwMyException()` + static void throwMyException() { + _throwMyException(_class.reference.pointer, _id_throwMyException.pointer) + .check(); } +} - static final _id_objectMethod = _class.instanceMethodId( +extension Exceptions$$Methods on Exceptions { + static final _id_objectMethod = Exceptions._class.instanceMethodId( r'objectMethod', r'()Ljava/lang/Object;', ); @@ -2070,12 +1808,11 @@ class Exceptions extends jni$_.JObject { /// from: `public java.lang.Object objectMethod()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? objectMethod() { - return _objectMethod( - reference.pointer, _id_objectMethod as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _objectMethod(reference.pointer, _id_objectMethod.pointer) + .object(); } - static final _id_intMethod = _class.instanceMethodId( + static final _id_intMethod = Exceptions._class.instanceMethodId( r'intMethod', r'()I', ); @@ -2094,11 +1831,10 @@ class Exceptions extends jni$_.JObject { /// from: `public int intMethod()` int intMethod() { - return _intMethod(reference.pointer, _id_intMethod as jni$_.JMethodIDPtr) - .integer; + return _intMethod(reference.pointer, _id_intMethod.pointer).integer; } - static final _id_objectArrayMethod = _class.instanceMethodId( + static final _id_objectArrayMethod = Exceptions._class.instanceMethodId( r'objectArrayMethod', r'()[Ljava/lang/Object;', ); @@ -2118,14 +1854,11 @@ class Exceptions extends jni$_.JObject { /// from: `public java.lang.Object[] objectArrayMethod()` /// The returned object must be released after use, by calling the [release] method. jni$_.JArray? objectArrayMethod() { - return _objectArrayMethod( - reference.pointer, _id_objectArrayMethod as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - jni$_.$JObject$NullableType$())); + return _objectArrayMethod(reference.pointer, _id_objectArrayMethod.pointer) + .object?>(); } - static final _id_intArrayMethod = _class.instanceMethodId( + static final _id_intArrayMethod = Exceptions._class.instanceMethodId( r'intArrayMethod', r'()[I', ); @@ -2145,12 +1878,12 @@ class Exceptions extends jni$_.JObject { /// from: `public int[] intArrayMethod()` /// The returned object must be released after use, by calling the [release] method. jni$_.JIntArray? intArrayMethod() { - return _intArrayMethod( - reference.pointer, _id_intArrayMethod as jni$_.JMethodIDPtr) - .object(const jni$_.$JIntArray$NullableType$()); + return _intArrayMethod(reference.pointer, _id_intArrayMethod.pointer) + .object(); } - static final _id_throwNullPointerException = _class.instanceMethodId( + static final _id_throwNullPointerException = + Exceptions._class.instanceMethodId( r'throwNullPointerException', r'()I', ); @@ -2169,12 +1902,13 @@ class Exceptions extends jni$_.JObject { /// from: `public int throwNullPointerException()` int throwNullPointerException() { - return _throwNullPointerException(reference.pointer, - _id_throwNullPointerException as jni$_.JMethodIDPtr) + return _throwNullPointerException( + reference.pointer, _id_throwNullPointerException.pointer) .integer; } - static final _id_throwFileNotFoundException = _class.instanceMethodId( + static final _id_throwFileNotFoundException = + Exceptions._class.instanceMethodId( r'throwFileNotFoundException', r'()Ljava/io/InputStream;', ); @@ -2195,12 +1929,12 @@ class Exceptions extends jni$_.JObject { /// from: `public java.io.InputStream throwFileNotFoundException()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? throwFileNotFoundException() { - return _throwFileNotFoundException(reference.pointer, - _id_throwFileNotFoundException as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _throwFileNotFoundException( + reference.pointer, _id_throwFileNotFoundException.pointer) + .object(); } - static final _id_throwClassCastException = _class.instanceMethodId( + static final _id_throwClassCastException = Exceptions._class.instanceMethodId( r'throwClassCastException', r'()Ljava/io/FileInputStream;', ); @@ -2220,12 +1954,13 @@ class Exceptions extends jni$_.JObject { /// from: `public java.io.FileInputStream throwClassCastException()` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? throwClassCastException() { - return _throwClassCastException(reference.pointer, - _id_throwClassCastException as jni$_.JMethodIDPtr) - .object(const jni$_.$JObject$NullableType$()); + return _throwClassCastException( + reference.pointer, _id_throwClassCastException.pointer) + .object(); } - static final _id_throwArrayIndexException = _class.instanceMethodId( + static final _id_throwArrayIndexException = + Exceptions._class.instanceMethodId( r'throwArrayIndexException', r'()I', ); @@ -2244,12 +1979,13 @@ class Exceptions extends jni$_.JObject { /// from: `public int throwArrayIndexException()` int throwArrayIndexException() { - return _throwArrayIndexException(reference.pointer, - _id_throwArrayIndexException as jni$_.JMethodIDPtr) + return _throwArrayIndexException( + reference.pointer, _id_throwArrayIndexException.pointer) .integer; } - static final _id_throwArithmeticException = _class.instanceMethodId( + static final _id_throwArithmeticException = + Exceptions._class.instanceMethodId( r'throwArithmeticException', r'()I', ); @@ -2268,72 +2004,10 @@ class Exceptions extends jni$_.JObject { /// from: `public int throwArithmeticException()` int throwArithmeticException() { - return _throwArithmeticException(reference.pointer, - _id_throwArithmeticException as jni$_.JMethodIDPtr) + return _throwArithmeticException( + reference.pointer, _id_throwArithmeticException.pointer) .integer; } - - static final _id_throwLoremIpsum = _class.staticMethodId( - r'throwLoremIpsum', - r'()V', - ); - - static final _throwLoremIpsum = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallStaticVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `static public void throwLoremIpsum()` - static void throwLoremIpsum() { - _throwLoremIpsum( - _class.reference.pointer, _id_throwLoremIpsum as jni$_.JMethodIDPtr) - .check(); - } -} - -final class $Exceptions$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Exceptions$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Exceptions;'; - - @jni$_.internal - @core$_.override - Exceptions? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Exceptions.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Exceptions$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Exceptions$NullableType$) && - other is $Exceptions$NullableType$; - } } final class $Exceptions$Type$ extends jni$_.JType { @@ -2344,69 +2018,15 @@ final class $Exceptions$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Exceptions;'; - - @jni$_.internal - @core$_.override - Exceptions fromReference(jni$_.JReference reference) => - Exceptions.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Exceptions$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Exceptions$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Exceptions$Type$) && - other is $Exceptions$Type$; - } } /// from: `com.github.dart_lang.jnigen.simple_package.Fields$Nested` -class Fields$Nested extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Fields$Nested.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Fields$Nested._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Fields$Nested'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Fields$Nested$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Fields$Nested$Type$(); - static final _id_hundred = _class.instanceFieldId( - r'hundred', - r'J', - ); - - /// from: `public long hundred` - int get hundred => _id_hundred.get(this, const jni$_.jlongType()); - - /// from: `public long hundred` - set hundred(int value) => - _id_hundred.set(this, const jni$_.jlongType(), value); - static final _id_BEST_GOD = _class.staticFieldId( r'BEST_GOD', r'Ljava/lang/String;', @@ -2415,12 +2035,12 @@ class Fields$Nested extends jni$_.JObject { /// from: `static public java.lang.String BEST_GOD` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get BEST_GOD => - _id_BEST_GOD.get(_class, const jni$_.$JString$NullableType$()); + _id_BEST_GOD.getNullable(_class, jni$_.JString.type) as jni$_.JString?; /// from: `static public java.lang.String BEST_GOD` /// The returned object must be released after use, by calling the [release] method. static set BEST_GOD(jni$_.JString? value) => - _id_BEST_GOD.set(_class, const jni$_.$JString$NullableType$(), value); + _id_BEST_GOD.set(_class, jni$_.JString.type, value); static final _id_new$ = _class.constructorId( r'()V', @@ -2441,48 +2061,22 @@ class Fields$Nested extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Fields$Nested() { - return Fields$Nested.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } -final class $Fields$Nested$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Fields$Nested$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Fields$Nested;'; - - @jni$_.internal - @core$_.override - Fields$Nested? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Fields$Nested.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; +extension Fields$Nested$$Methods on Fields$Nested { + static final _id_hundred = Fields$Nested._class.instanceFieldId( + r'hundred', + r'J', + ); - @core$_.override - int get hashCode => ($Fields$Nested$NullableType$).hashCode; + /// from: `public long hundred` + int get hundred => _id_hundred.getNullable(this, jni$_.jlong.type) as int; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Fields$Nested$NullableType$) && - other is $Fields$Nested$NullableType$; - } + /// from: `public long hundred` + set hundred(int value) => _id_hundred.set(this, jni$_.jlong.type, value); } final class $Fields$Nested$Type$ extends jni$_.JType { @@ -2493,54 +2087,13 @@ final class $Fields$Nested$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Fields$Nested;'; - - @jni$_.internal - @core$_.override - Fields$Nested fromReference(jni$_.JReference reference) => - Fields$Nested.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Fields$Nested$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Fields$Nested$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Fields$Nested$Type$) && - other is $Fields$Nested$Type$; - } } /// from: `com.github.dart_lang.jnigen.simple_package.Fields` -class Fields extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Fields.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Fields._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/simple_package/Fields'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Fields$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Fields$Type$(); static final _id_amount = _class.staticFieldId( @@ -2549,11 +2102,12 @@ class Fields extends jni$_.JObject { ); /// from: `static public int amount` - static int get amount => _id_amount.get(_class, const jni$_.jintType()); + static int get amount => + _id_amount.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int amount` static set amount(int value) => - _id_amount.set(_class, const jni$_.jintType(), value); + _id_amount.set(_class, jni$_.jint.type, value); static final _id_pi = _class.staticFieldId( r'pi', @@ -2561,11 +2115,11 @@ class Fields extends jni$_.JObject { ); /// from: `static public double pi` - static double get pi => _id_pi.get(_class, const jni$_.jdoubleType()); + static double get pi => + _id_pi.getNullable(_class, jni$_.jdouble.type) as double; /// from: `static public double pi` - static set pi(double value) => - _id_pi.set(_class, const jni$_.jdoubleType(), value); + static set pi(double value) => _id_pi.set(_class, jni$_.jdouble.type, value); static final _id_asterisk = _class.staticFieldId( r'asterisk', @@ -2573,11 +2127,12 @@ class Fields extends jni$_.JObject { ); /// from: `static public char asterisk` - static int get asterisk => _id_asterisk.get(_class, const jni$_.jcharType()); + static int get asterisk => + _id_asterisk.getNullable(_class, jni$_.jchar.type) as int; /// from: `static public char asterisk` static set asterisk(int value) => - _id_asterisk.set(_class, const jni$_.jcharType(), value); + _id_asterisk.set(_class, jni$_.jchar.type, value); static final _id_name = _class.staticFieldId( r'name', @@ -2587,14 +2142,51 @@ class Fields extends jni$_.JObject { /// from: `static public java.lang.String name` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString? get name => - _id_name.get(_class, const jni$_.$JString$NullableType$()); + _id_name.getNullable(_class, jni$_.JString.type) as jni$_.JString?; /// from: `static public java.lang.String name` /// The returned object must be released after use, by calling the [release] method. static set name(jni$_.JString? value) => - _id_name.set(_class, const jni$_.$JString$NullableType$(), value); + _id_name.set(_class, jni$_.JString.type, value); + + static final _id_euroSymbol = _class.staticFieldId( + r'euroSymbol', + r'C', + ); + + /// from: `static public char euroSymbol` + static int get euroSymbol => + _id_euroSymbol.getNullable(_class, jni$_.jchar.type) as int; + + /// from: `static public char euroSymbol` + static set euroSymbol(int value) => + _id_euroSymbol.set(_class, jni$_.jchar.type, value); - static final _id_i = _class.instanceFieldId( + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory Fields() { + return _new$(_class.reference.pointer, _id_new$.pointer).object(); + } +} + +extension Fields$$Methods on Fields { + static final _id_i = Fields._class.instanceFieldId( r'i', r'Ljava/lang/Integer;', ); @@ -2602,39 +2194,37 @@ class Fields extends jni$_.JObject { /// from: `public java.lang.Integer i` /// The returned object must be released after use, by calling the [release] method. jni$_.JInteger? get i => - _id_i.get(this, const jni$_.$JInteger$NullableType$()); + _id_i.getNullable(this, jni$_.JInteger.type) as jni$_.JInteger?; /// from: `public java.lang.Integer i` /// The returned object must be released after use, by calling the [release] method. - set i(jni$_.JInteger? value) => - _id_i.set(this, const jni$_.$JInteger$NullableType$(), value); + set i(jni$_.JInteger? value) => _id_i.set(this, jni$_.JInteger.type, value); - static final _id_trillion = _class.instanceFieldId( + static final _id_trillion = Fields._class.instanceFieldId( r'trillion', r'J', ); /// from: `public long trillion` - int get trillion => _id_trillion.get(this, const jni$_.jlongType()); + int get trillion => _id_trillion.getNullable(this, jni$_.jlong.type) as int; /// from: `public long trillion` - set trillion(int value) => - _id_trillion.set(this, const jni$_.jlongType(), value); + set trillion(int value) => _id_trillion.set(this, jni$_.jlong.type, value); - static final _id_isAchillesDead = _class.instanceFieldId( + static final _id_isAchillesDead = Fields._class.instanceFieldId( r'isAchillesDead', r'Z', ); /// from: `public boolean isAchillesDead` core$_.bool get isAchillesDead => - _id_isAchillesDead.get(this, const jni$_.jbooleanType()); + _id_isAchillesDead.getNullable(this, jni$_.jboolean.type) as core$_.bool; /// from: `public boolean isAchillesDead` set isAchillesDead(core$_.bool value) => - _id_isAchillesDead.set(this, const jni$_.jbooleanType(), value); + _id_isAchillesDead.set(this, jni$_.jboolean.type, value); - static final _id_bestFighterInGreece = _class.instanceFieldId( + static final _id_bestFighterInGreece = Fields._class.instanceFieldId( r'bestFighterInGreece', r'Ljava/lang/String;', ); @@ -2642,14 +2232,15 @@ class Fields extends jni$_.JObject { /// from: `public java.lang.String bestFighterInGreece` /// The returned object must be released after use, by calling the [release] method. jni$_.JString? get bestFighterInGreece => - _id_bestFighterInGreece.get(this, const jni$_.$JString$NullableType$()); + _id_bestFighterInGreece.getNullable(this, jni$_.JString.type) + as jni$_.JString?; /// from: `public java.lang.String bestFighterInGreece` /// The returned object must be released after use, by calling the [release] method. - set bestFighterInGreece(jni$_.JString? value) => _id_bestFighterInGreece.set( - this, const jni$_.$JString$NullableType$(), value); + set bestFighterInGreece(jni$_.JString? value) => + _id_bestFighterInGreece.set(this, jni$_.JString.type, value); - static final _id_random = _class.instanceFieldId( + static final _id_random = Fields._class.instanceFieldId( r'random', r'Ljava/util/Random;', ); @@ -2657,142 +2248,29 @@ class Fields extends jni$_.JObject { /// from: `public java.util.Random random` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? get random => - _id_random.get(this, const jni$_.$JObject$NullableType$()); + _id_random.getNullable(this, jni$_.JObject.type) as jni$_.JObject?; /// from: `public java.util.Random random` /// The returned object must be released after use, by calling the [release] method. set random(jni$_.JObject? value) => - _id_random.set(this, const jni$_.$JObject$NullableType$(), value); + _id_random.set(this, jni$_.JObject.type, value); +} - static final _id_euroSymbol = _class.staticFieldId( - r'euroSymbol', - r'C', - ); - - /// from: `static public char euroSymbol` - static int get euroSymbol => - _id_euroSymbol.get(_class, const jni$_.jcharType()); - - /// from: `static public char euroSymbol` - static set euroSymbol(int value) => - _id_euroSymbol.set(_class, const jni$_.jcharType(), value); - - static final _id_new$ = _class.constructorId( - r'()V', - ); - - static final _new$ = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_NewObject') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public void ()` - /// The returned object must be released after use, by calling the [release] method. - factory Fields() { - return Fields.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $Fields$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Fields$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/simple_package/Fields;'; - - @jni$_.internal - @core$_.override - Fields? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Fields.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Fields$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Fields$NullableType$) && - other is $Fields$NullableType$; - } -} - -final class $Fields$Type$ extends jni$_.JType { - @jni$_.internal - const $Fields$Type$(); +final class $Fields$Type$ extends jni$_.JType { + @jni$_.internal + const $Fields$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/simple_package/Fields;'; - - @jni$_.internal - @core$_.override - Fields fromReference(jni$_.JReference reference) => Fields.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Fields$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Fields$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Fields$Type$) && other is $Fields$Type$; - } } /// from: `com.github.dart_lang.jnigen.pkg2.C2` -class C2 extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - C2.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type C2._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/pkg2/C2'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $C2$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $C2$Type$(); static final _id_CONSTANT = _class.staticFieldId( @@ -2801,11 +2279,12 @@ class C2 extends jni$_.JObject { ); /// from: `static public int CONSTANT` - static int get CONSTANT => _id_CONSTANT.get(_class, const jni$_.jintType()); + static int get CONSTANT => + _id_CONSTANT.getNullable(_class, jni$_.jint.type) as int; /// from: `static public int CONSTANT` static set CONSTANT(int value) => - _id_CONSTANT.set(_class, const jni$_.jintType(), value); + _id_CONSTANT.set(_class, jni$_.jint.type, value); static final _id_new$ = _class.constructorId( r'()V', @@ -2826,46 +2305,7 @@ class C2 extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory C2() { - return C2.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $C2$NullableType$ extends jni$_.JType { - @jni$_.internal - const $C2$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/pkg2/C2;'; - - @jni$_.internal - @core$_.override - C2? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : C2.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($C2$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($C2$NullableType$) && - other is $C2$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer).object(); } } @@ -2876,52 +2316,13 @@ final class $C2$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/pkg2/C2;'; - - @jni$_.internal - @core$_.override - C2 fromReference(jni$_.JReference reference) => C2.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $C2$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($C2$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($C2$Type$) && other is $C2$Type$; - } } /// from: `com.github.dart_lang.jnigen.pkg2.Example` -class Example$1 extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Example$1.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Example$1._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/pkg2/Example'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Example$1$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Example$1$Type$(); static final _id_new$ = _class.constructorId( @@ -2943,12 +2344,13 @@ class Example$1 extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory Example$1() { - return Example$1.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } +} - static final _id_whichExample = _class.instanceMethodId( +extension Example$1$$Methods on Example$1 { + static final _id_whichExample = Example$1._class.instanceMethodId( r'whichExample', r'()I', ); @@ -2967,46 +2369,7 @@ class Example$1 extends jni$_.JObject { /// from: `public int whichExample()` int whichExample() { - return _whichExample( - reference.pointer, _id_whichExample as jni$_.JMethodIDPtr) - .integer; - } -} - -final class $Example$1$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Example$1$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/pkg2/Example;'; - - @jni$_.internal - @core$_.override - Example$1? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Example$1.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$1$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$1$NullableType$) && - other is $Example$1$NullableType$; + return _whichExample(reference.pointer, _id_whichExample.pointer).integer; } } @@ -3017,88 +2380,15 @@ final class $Example$1$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/pkg2/Example;'; - - @jni$_.internal - @core$_.override - Example$1 fromReference(jni$_.JReference reference) => - Example$1.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Example$1$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Example$1$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Example$1$Type$) && other is $Example$1$Type$; - } } /// from: `com.github.dart_lang.jnigen.enums.Colors$RGB` -class Colors$RGB extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Colors$RGB.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Colors$RGB._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/enums/Colors$RGB'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $Colors$RGB$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Colors$RGB$Type$(); - static final _id_red = _class.instanceFieldId( - r'red', - r'I', - ); - - /// from: `public int red` - int get red => _id_red.get(this, const jni$_.jintType()); - - /// from: `public int red` - set red(int value) => _id_red.set(this, const jni$_.jintType(), value); - - static final _id_green = _class.instanceFieldId( - r'green', - r'I', - ); - - /// from: `public int green` - int get green => _id_green.get(this, const jni$_.jintType()); - - /// from: `public int green` - set green(int value) => _id_green.set(this, const jni$_.jintType(), value); - - static final _id_blue = _class.instanceFieldId( - r'blue', - r'I', - ); - - /// from: `public int blue` - int get blue => _id_blue.get(this, const jni$_.jintType()); - - /// from: `public int blue` - set blue(int value) => _id_blue.set(this, const jni$_.jintType(), value); - static final _id_new$ = _class.constructorId( r'(III)V', ); @@ -3121,12 +2411,46 @@ class Colors$RGB extends jni$_.JObject { int i1, int i2, ) { - return Colors$RGB.fromReference(_new$( - _class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, i, i1, i2) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, i, i1, i2) + .object(); } +} + +extension Colors$RGB$$Methods on Colors$RGB { + static final _id_red = Colors$RGB._class.instanceFieldId( + r'red', + r'I', + ); + + /// from: `public int red` + int get red => _id_red.getNullable(this, jni$_.jint.type) as int; + + /// from: `public int red` + set red(int value) => _id_red.set(this, jni$_.jint.type, value); + + static final _id_green = Colors$RGB._class.instanceFieldId( + r'green', + r'I', + ); + + /// from: `public int green` + int get green => _id_green.getNullable(this, jni$_.jint.type) as int; + + /// from: `public int green` + set green(int value) => _id_green.set(this, jni$_.jint.type, value); + + static final _id_blue = Colors$RGB._class.instanceFieldId( + r'blue', + r'I', + ); + + /// from: `public int blue` + int get blue => _id_blue.getNullable(this, jni$_.jint.type) as int; + + /// from: `public int blue` + set blue(int value) => _id_blue.set(this, jni$_.jint.type, value); - static final _id_equals = _class.instanceMethodId( + static final _id_equals = Colors$RGB._class.instanceMethodId( r'equals', r'(Ljava/lang/Object;)Z', ); @@ -3147,12 +2471,11 @@ class Colors$RGB extends jni$_.JObject { jni$_.JObject? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _equals(reference.pointer, _id_equals as jni$_.JMethodIDPtr, - _$object.pointer) + return _equals(reference.pointer, _id_equals.pointer, _$object.pointer) .boolean; } - static final _id_hashCode$1 = _class.instanceMethodId( + static final _id_hashCode$1 = Colors$RGB._class.instanceMethodId( r'hashCode', r'()I', ); @@ -3171,122 +2494,43 @@ class Colors$RGB extends jni$_.JObject { /// from: `public int hashCode()` int hashCode$1() { - return _hashCode$1(reference.pointer, _id_hashCode$1 as jni$_.JMethodIDPtr) - .integer; + return _hashCode$1(reference.pointer, _id_hashCode$1.pointer).integer; } } -final class $Colors$RGB$NullableType$ extends jni$_.JType { +final class $Colors$RGB$Type$ extends jni$_.JType { @jni$_.internal - const $Colors$RGB$NullableType$(); + const $Colors$RGB$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/enums/Colors$RGB;'; +} - @jni$_.internal - @core$_.override - Colors$RGB? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Colors$RGB.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); +/// from: `com.github.dart_lang.jnigen.enums.Colors` +extension type Colors._(jni$_.JObject _$this) implements jni$_.JObject { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/enums/Colors'); - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Colors$Type$(); + static final _id_red = _class.staticFieldId( + r'red', + r'Lcom/github/dart_lang/jnigen/enums/Colors;', + ); - @jni$_.internal - @core$_.override - final superCount = 1; + /// from: `static public final com.github.dart_lang.jnigen.enums.Colors red` + /// The returned object must be released after use, by calling the [release] method. + static Colors get red => _id_red.get(_class, Colors.type) as Colors; - @core$_.override - int get hashCode => ($Colors$RGB$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Colors$RGB$NullableType$) && - other is $Colors$RGB$NullableType$; - } -} - -final class $Colors$RGB$Type$ extends jni$_.JType { - @jni$_.internal - const $Colors$RGB$Type$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/enums/Colors$RGB;'; - - @jni$_.internal - @core$_.override - Colors$RGB fromReference(jni$_.JReference reference) => - Colors$RGB.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $Colors$RGB$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Colors$RGB$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Colors$RGB$Type$) && - other is $Colors$RGB$Type$; - } -} - -/// from: `com.github.dart_lang.jnigen.enums.Colors` -class Colors extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Colors.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - - static final _class = - jni$_.JClass.forName(r'com/github/dart_lang/jnigen/enums/Colors'); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Colors$NullableType$(); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType type = $Colors$Type$(); - static final _id_red = _class.staticFieldId( - r'red', - r'Lcom/github/dart_lang/jnigen/enums/Colors;', - ); - - /// from: `static public final com.github.dart_lang.jnigen.enums.Colors red` - /// The returned object must be released after use, by calling the [release] method. - static Colors get red => _id_red.get(_class, const $Colors$Type$()); - - static final _id_green = _class.staticFieldId( - r'green', - r'Lcom/github/dart_lang/jnigen/enums/Colors;', - ); + static final _id_green = _class.staticFieldId( + r'green', + r'Lcom/github/dart_lang/jnigen/enums/Colors;', + ); /// from: `static public final com.github.dart_lang.jnigen.enums.Colors green` /// The returned object must be released after use, by calling the [release] method. - static Colors get green => _id_green.get(_class, const $Colors$Type$()); + static Colors get green => _id_green.get(_class, Colors.type) as Colors; static final _id_blue = _class.staticFieldId( r'blue', @@ -3295,15 +2539,7 @@ class Colors extends jni$_.JObject { /// from: `static public final com.github.dart_lang.jnigen.enums.Colors blue` /// The returned object must be released after use, by calling the [release] method. - static Colors get blue => _id_blue.get(_class, const $Colors$Type$()); - - static final _id_code = _class.instanceFieldId( - r'code', - r'I', - ); - - /// from: `public final int code` - int get code => _id_code.get(this, const jni$_.jintType()); + static Colors get blue => _id_blue.get(_class, Colors.type) as Colors; static final _id_values = _class.staticMethodId( r'values', @@ -3325,10 +2561,8 @@ class Colors extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.enums.Colors[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $Colors$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -3353,12 +2587,22 @@ class Colors extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$string.pointer) - .object(const $Colors$NullableType$()); + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$string.pointer) + .object(); } +} + +extension Colors$$Methods on Colors { + static final _id_code = Colors._class.instanceFieldId( + r'code', + r'I', + ); - static final _id_toRGB = _class.instanceMethodId( + /// from: `public final int code` + int get code => _id_code.getNullable(this, jni$_.jint.type) as int; + + static final _id_toRGB = Colors._class.instanceMethodId( r'toRGB', r'()Lcom/github/dart_lang/jnigen/enums/Colors$RGB;', ); @@ -3378,45 +2622,7 @@ class Colors extends jni$_.JObject { /// from: `public com.github.dart_lang.jnigen.enums.Colors$RGB toRGB()` /// The returned object must be released after use, by calling the [release] method. Colors$RGB? toRGB() { - return _toRGB(reference.pointer, _id_toRGB as jni$_.JMethodIDPtr) - .object(const $Colors$RGB$NullableType$()); - } -} - -final class $Colors$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Colors$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/enums/Colors;'; - - @jni$_.internal - @core$_.override - Colors? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Colors.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Colors$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Colors$NullableType$) && - other is $Colors$NullableType$; + return _toRGB(reference.pointer, _id_toRGB.pointer).object(); } } @@ -3427,81 +2633,17 @@ final class $Colors$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/enums/Colors;'; - - @jni$_.internal - @core$_.override - Colors fromReference(jni$_.JReference reference) => Colors.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Colors$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Colors$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Colors$Type$) && other is $Colors$Type$; - } } /// from: `com.github.dart_lang.jnigen.generics.GenericTypeParams` -class GenericTypeParams<$S extends jni$_.JObject?, $K extends jni$_.JObject?> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - GenericTypeParams.fromReference( - this.S, - this.K, - jni$_.JReference reference, - ) : $type = type<$S, $K>(S, K), - super.fromReference(reference); - +extension type GenericTypeParams<$S extends jni$_.JObject?, + $K extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/generics/GenericTypeParams'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$S extends jni$_.JObject?, $K extends jni$_.JObject?>( - jni$_.JType<$S> S, - jni$_.JType<$K> K, - ) { - return $GenericTypeParams$NullableType$<$S, $K>( - S, - K, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$S extends jni$_.JObject?, $K extends jni$_.JObject?>( - jni$_.JType<$S> S, - jni$_.JType<$K> K, - ) { - return $GenericTypeParams$Type$<$S, $K>( - S, - K, - ); - } - + static const jni$_.JType type = $GenericTypeParams$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -3520,228 +2662,140 @@ class GenericTypeParams<$S extends jni$_.JObject?, $K extends jni$_.JObject?> /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory GenericTypeParams({ - required jni$_.JType<$S> S, - required jni$_.JType<$K> K, - }) { - return GenericTypeParams<$S, $K>.fromReference( - S, - K, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + factory GenericTypeParams() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } } -final class $GenericTypeParams$NullableType$<$S extends jni$_.JObject?, - $K extends jni$_.JObject?> extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$S> S; - +final class $GenericTypeParams$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - const $GenericTypeParams$NullableType$( - this.S, - this.K, - ); + const $GenericTypeParams$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/GenericTypeParams;'; - - @jni$_.internal - @core$_.override - GenericTypeParams<$S, $K>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : GenericTypeParams<$S, $K>.fromReference( - S, - K, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GenericTypeParams$NullableType$, S, K); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GenericTypeParams$NullableType$<$S, $K>) && - other is $GenericTypeParams$NullableType$<$S, $K> && - S == other.S && - K == other.K; - } } -final class $GenericTypeParams$Type$<$S extends jni$_.JObject?, - $K extends jni$_.JObject?> extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$K> K; +/// from: `com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child` +extension type GrandParent$Parent$Child<$T extends jni$_.JObject?, + $S extends jni$_.JObject?, $U extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child'); - @jni$_.internal - const $GenericTypeParams$Type$( - this.S, - this.K, + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $GrandParent$Parent$Child$Type$(); + static final _id_new$ = _class.constructorId( + r'(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/lang/Object;)V', ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GenericTypeParams;'; - - @jni$_.internal - @core$_.override - GenericTypeParams<$S, $K> fromReference(jni$_.JReference reference) => - GenericTypeParams<$S, $K>.fromReference( - S, - K, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GenericTypeParams$NullableType$<$S, $K>(S, K); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GenericTypeParams$Type$, S, K); + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs< + ( + jni$_.Pointer, + jni$_.Pointer + )>)>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.Pointer, + jni$_.Pointer)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GenericTypeParams$Type$<$S, $K>) && - other is $GenericTypeParams$Type$<$S, $K> && - S == other.S && - K == other.K; + /// from: `public void (com.github.dart_lang.jnigen.generics.GrandParent$Parent $outerClass, U object)` + /// The returned object must be released after use, by calling the [release] method. + factory GrandParent$Parent$Child( + GrandParent$Parent<$T?, $S?> $outerClass, + $U? object, + ) { + final _$$outerClass = $outerClass.reference; + final _$object = object?.reference ?? jni$_.jNullReference; + return _new$(_class.reference.pointer, _id_new$.pointer, + _$$outerClass.pointer, _$object.pointer) + .object>(); } } -/// from: `com.github.dart_lang.jnigen.generics.GrandParent$Parent$Child` -class GrandParent$Parent$Child< +extension GrandParent$Parent$Child$$Methods< $T extends jni$_.JObject?, $S extends jni$_.JObject?, - $U extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - GrandParent$Parent$Child.fromReference( - this.T, - this.S, - this.U, - jni$_.JReference reference, - ) : $type = type<$T, $S, $U>(T, S, U), - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/generics/GrandParent$Parent$Child'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType< - $T extends jni$_.JObject?, - $S extends jni$_.JObject?, - $U extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$S> S, - jni$_.JType<$U> U, - ) { - return $GrandParent$Parent$Child$NullableType$<$T, $S, $U>( - T, - S, - U, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type< - $T extends jni$_.JObject?, - $S extends jni$_.JObject?, - $U extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$S> S, - jni$_.JType<$U> U, - ) { - return $GrandParent$Parent$Child$Type$<$T, $S, $U>( - T, - S, - U, - ); - } - - static final _id_grandParentValue = _class.instanceFieldId( + $U extends jni$_.JObject?> on GrandParent$Parent$Child<$T, $S, $U> { + static final _id_grandParentValue = + GrandParent$Parent$Child._class.instanceFieldId( r'grandParentValue', r'Ljava/lang/Object;', ); /// from: `public T grandParentValue` /// The returned object must be released after use, by calling the [release] method. - $T? get grandParentValue => _id_grandParentValue.get(this, T.nullableType); + $T? get grandParentValue => + _id_grandParentValue.getNullable(this, jni$_.JObject.type) as $T?; /// from: `public T grandParentValue` /// The returned object must be released after use, by calling the [release] method. set grandParentValue($T? value) => - _id_grandParentValue.set(this, T.nullableType, value); + _id_grandParentValue.set(this, jni$_.JObject.type, value); - static final _id_parentValue = _class.instanceFieldId( + static final _id_parentValue = + GrandParent$Parent$Child._class.instanceFieldId( r'parentValue', r'Ljava/lang/Object;', ); /// from: `public S parentValue` /// The returned object must be released after use, by calling the [release] method. - $S? get parentValue => _id_parentValue.get(this, S.nullableType); + $S? get parentValue => + _id_parentValue.getNullable(this, jni$_.JObject.type) as $S?; /// from: `public S parentValue` /// The returned object must be released after use, by calling the [release] method. set parentValue($S? value) => - _id_parentValue.set(this, S.nullableType, value); + _id_parentValue.set(this, jni$_.JObject.type, value); - static final _id_value = _class.instanceFieldId( + static final _id_value = GrandParent$Parent$Child._class.instanceFieldId( r'value', r'Ljava/lang/Object;', ); /// from: `public U value` /// The returned object must be released after use, by calling the [release] method. - $U? get value => _id_value.get(this, U.nullableType); + $U? get value => _id_value.getNullable(this, jni$_.JObject.type) as $U?; /// from: `public U value` /// The returned object must be released after use, by calling the [release] method. - set value($U? value) => _id_value.set(this, U.nullableType, value); + set value($U? value) => _id_value.set(this, jni$_.JObject.type, value); +} + +final class $GrandParent$Parent$Child$Type$ + extends jni$_.JType { + @jni$_.internal + const $GrandParent$Parent$Child$Type$(); + + @jni$_.internal + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent$Child;'; +} + +/// from: `com.github.dart_lang.jnigen.generics.GrandParent$Parent` +extension type GrandParent$Parent<$T extends jni$_.JObject?, + $S extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/generics/GrandParent$Parent'); + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $GrandParent$Parent$Type$(); static final _id_new$ = _class.constructorId( - r'(Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;Ljava/lang/Object;)V', + r'(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/Object;)V', ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< @@ -3761,237 +2815,73 @@ class GrandParent$Parent$Child< jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void (com.github.dart_lang.jnigen.generics.GrandParent$Parent $outerClass, U object)` + /// from: `public void (com.github.dart_lang.jnigen.generics.GrandParent $outerClass, S object)` /// The returned object must be released after use, by calling the [release] method. - factory GrandParent$Parent$Child( - GrandParent$Parent<$T?, $S?> $outerClass, - $U? object, { - jni$_.JType<$T>? T, - jni$_.JType<$S>? S, - required jni$_.JType<$U> U, - }) { - T ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type - as $GrandParent$Parent$Type$) - .T, - ]) as jni$_.JType<$T>; - S ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type - as $GrandParent$Parent$Type$) - .S, - ]) as jni$_.JType<$S>; + factory GrandParent$Parent( + GrandParent<$T?> $outerClass, + $S? object, + ) { final _$$outerClass = $outerClass.reference; final _$object = object?.reference ?? jni$_.jNullReference; - return GrandParent$Parent$Child<$T, $S, $U>.fromReference( - T, - S, - U, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$$outerClass.pointer, _$object.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, + _$$outerClass.pointer, _$object.pointer) + .object>(); } } -final class $GrandParent$Parent$Child$NullableType$<$T extends jni$_.JObject?, - $S extends jni$_.JObject?, $U extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; +extension GrandParent$Parent$$Methods<$T extends jni$_.JObject?, + $S extends jni$_.JObject?> on GrandParent$Parent<$T, $S> { + static final _id_parentValue = GrandParent$Parent._class.instanceFieldId( + r'parentValue', + r'Ljava/lang/Object;', + ); - @jni$_.internal - final jni$_.JType<$S> S; + /// from: `public T parentValue` + /// The returned object must be released after use, by calling the [release] method. + $T? get parentValue => + _id_parentValue.getNullable(this, jni$_.JObject.type) as $T?; - @jni$_.internal - final jni$_.JType<$U> U; + /// from: `public T parentValue` + /// The returned object must be released after use, by calling the [release] method. + set parentValue($T? value) => + _id_parentValue.set(this, jni$_.JObject.type, value); - @jni$_.internal - const $GrandParent$Parent$Child$NullableType$( - this.T, - this.S, - this.U, + static final _id_value = GrandParent$Parent._class.instanceFieldId( + r'value', + r'Ljava/lang/Object;', ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent$Child;'; - - @jni$_.internal - @core$_.override - GrandParent$Parent$Child<$T, $S, $U>? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : GrandParent$Parent$Child<$T, $S, $U>.fromReference( - T, - S, - U, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - Object.hash($GrandParent$Parent$Child$NullableType$, T, S, U); + /// from: `public S value` + /// The returned object must be released after use, by calling the [release] method. + $S? get value => _id_value.getNullable(this, jni$_.JObject.type) as $S?; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($GrandParent$Parent$Child$NullableType$<$T, $S, $U>) && - other is $GrandParent$Parent$Child$NullableType$<$T, $S, $U> && - T == other.T && - S == other.S && - U == other.U; - } + /// from: `public S value` + /// The returned object must be released after use, by calling the [release] method. + set value($S? value) => _id_value.set(this, jni$_.JObject.type, value); } -final class $GrandParent$Parent$Child$Type$<$T extends jni$_.JObject?, - $S extends jni$_.JObject?, $U extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - +final class $GrandParent$Parent$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - const $GrandParent$Parent$Child$Type$( - this.T, - this.S, - this.U, - ); + const $GrandParent$Parent$Type$(); @jni$_.internal @core$_.override String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent$Child;'; - - @jni$_.internal - @core$_.override - GrandParent$Parent$Child<$T, $S, $U> fromReference( - jni$_.JReference reference) => - GrandParent$Parent$Child<$T, $S, $U>.fromReference( - T, - S, - U, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GrandParent$Parent$Child$NullableType$<$T, $S, $U>(T, S, U); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$Parent$Child$Type$, T, S, U); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$Parent$Child$Type$<$T, $S, $U>) && - other is $GrandParent$Parent$Child$Type$<$T, $S, $U> && - T == other.T && - S == other.S && - U == other.U; - } + r'Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;'; } -/// from: `com.github.dart_lang.jnigen.generics.GrandParent$Parent` -class GrandParent$Parent<$T extends jni$_.JObject?, $S extends jni$_.JObject?> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - GrandParent$Parent.fromReference( - this.T, - this.S, - jni$_.JReference reference, - ) : $type = type<$T, $S>(T, S), - super.fromReference(reference); - +/// from: `com.github.dart_lang.jnigen.generics.GrandParent$StaticParent$Child` +extension type GrandParent$StaticParent$Child<$S extends jni$_.JObject?, + $U extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/generics/GrandParent$Parent'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$T extends jni$_.JObject?, $S extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$S> S, - ) { - return $GrandParent$Parent$NullableType$<$T, $S>( - T, - S, - ); - } + r'com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child'); /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$T extends jni$_.JObject?, $S extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$S> S, - ) { - return $GrandParent$Parent$Type$<$T, $S>( - T, - S, - ); - } - - static final _id_parentValue = _class.instanceFieldId( - r'parentValue', - r'Ljava/lang/Object;', - ); - - /// from: `public T parentValue` - /// The returned object must be released after use, by calling the [release] method. - $T? get parentValue => _id_parentValue.get(this, T.nullableType); - - /// from: `public T parentValue` - /// The returned object must be released after use, by calling the [release] method. - set parentValue($T? value) => - _id_parentValue.set(this, T.nullableType, value); - - static final _id_value = _class.instanceFieldId( - r'value', - r'Ljava/lang/Object;', - ); - - /// from: `public S value` - /// The returned object must be released after use, by calling the [release] method. - $S? get value => _id_value.get(this, S.nullableType); - - /// from: `public S value` - /// The returned object must be released after use, by calling the [release] method. - set value($S? value) => _id_value.set(this, S.nullableType, value); - + static const jni$_.JType type = + $GrandParent$StaticParent$Child$Type$(); static final _id_new$ = _class.constructorId( - r'(Lcom/github/dart_lang/jnigen/generics/GrandParent;Ljava/lang/Object;)V', + r'(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/lang/Object;Ljava/lang/Object;)V', ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< @@ -4001,6 +2891,7 @@ class GrandParent$Parent<$T extends jni$_.JObject?, $S extends jni$_.JObject?> jni$_.JMethodIDPtr, jni$_.VarArgs< ( + jni$_.Pointer, jni$_.Pointer, jni$_.Pointer )>)>>('globalEnv_NewObject') @@ -4009,596 +2900,139 @@ class GrandParent$Parent<$T extends jni$_.JObject?, $S extends jni$_.JObject?> jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer, + jni$_.Pointer, jni$_.Pointer)>(); - /// from: `public void (com.github.dart_lang.jnigen.generics.GrandParent $outerClass, S object)` + /// from: `public void (com.github.dart_lang.jnigen.generics.GrandParent$StaticParent $outerClass, S object, U object1)` /// The returned object must be released after use, by calling the [release] method. - factory GrandParent$Parent( - GrandParent<$T?> $outerClass, - $S? object, { - jni$_.JType<$T>? T, - required jni$_.JType<$S> S, - }) { - T ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $GrandParent$Type$).T, - ]) as jni$_.JType<$T>; + factory GrandParent$StaticParent$Child( + GrandParent$StaticParent<$S?> $outerClass, + $S? object, + $U? object1, + ) { final _$$outerClass = $outerClass.reference; final _$object = object?.reference ?? jni$_.jNullReference; - return GrandParent$Parent<$T, $S>.fromReference( - T, - S, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$$outerClass.pointer, _$object.pointer) - .reference); - } -} - -final class $GrandParent$Parent$NullableType$<$T extends jni$_.JObject?, - $S extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - const $GrandParent$Parent$NullableType$( - this.T, - this.S, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;'; - - @jni$_.internal - @core$_.override - GrandParent$Parent<$T, $S>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : GrandParent$Parent<$T, $S>.fromReference( - T, - S, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$Parent$NullableType$, T, S); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$Parent$NullableType$<$T, $S>) && - other is $GrandParent$Parent$NullableType$<$T, $S> && - T == other.T && - S == other.S; - } -} - -final class $GrandParent$Parent$Type$<$T extends jni$_.JObject?, - $S extends jni$_.JObject?> extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - const $GrandParent$Parent$Type$( - this.T, - this.S, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;'; - - @jni$_.internal - @core$_.override - GrandParent$Parent<$T, $S> fromReference(jni$_.JReference reference) => - GrandParent$Parent<$T, $S>.fromReference( - T, - S, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GrandParent$Parent$NullableType$<$T, $S>(T, S); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$Parent$Type$, T, S); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$Parent$Type$<$T, $S>) && - other is $GrandParent$Parent$Type$<$T, $S> && - T == other.T && - S == other.S; + final _$object1 = object1?.reference ?? jni$_.jNullReference; + return _new$(_class.reference.pointer, _id_new$.pointer, + _$$outerClass.pointer, _$object.pointer, _$object1.pointer) + .object>(); } } -/// from: `com.github.dart_lang.jnigen.generics.GrandParent$StaticParent$Child` -class GrandParent$StaticParent$Child<$S extends jni$_.JObject?, - $U extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - GrandParent$StaticParent$Child.fromReference( - this.S, - this.U, - jni$_.JReference reference, - ) : $type = type<$S, $U>(S, U), - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$S extends jni$_.JObject?, $U extends jni$_.JObject?>( - jni$_.JType<$S> S, - jni$_.JType<$U> U, - ) { - return $GrandParent$StaticParent$Child$NullableType$<$S, $U>( - S, - U, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$S extends jni$_.JObject?, $U extends jni$_.JObject?>( - jni$_.JType<$S> S, - jni$_.JType<$U> U, - ) { - return $GrandParent$StaticParent$Child$Type$<$S, $U>( - S, - U, - ); - } - - static final _id_parentValue = _class.instanceFieldId( +extension GrandParent$StaticParent$Child$$Methods<$S extends jni$_.JObject?, + $U extends jni$_.JObject?> on GrandParent$StaticParent$Child<$S, $U> { + static final _id_parentValue = + GrandParent$StaticParent$Child._class.instanceFieldId( r'parentValue', r'Ljava/lang/Object;', ); /// from: `public S parentValue` /// The returned object must be released after use, by calling the [release] method. - $S? get parentValue => _id_parentValue.get(this, S.nullableType); + $S? get parentValue => + _id_parentValue.getNullable(this, jni$_.JObject.type) as $S?; /// from: `public S parentValue` /// The returned object must be released after use, by calling the [release] method. set parentValue($S? value) => - _id_parentValue.set(this, S.nullableType, value); + _id_parentValue.set(this, jni$_.JObject.type, value); - static final _id_value = _class.instanceFieldId( + static final _id_value = + GrandParent$StaticParent$Child._class.instanceFieldId( r'value', r'Ljava/lang/Object;', ); /// from: `public U value` /// The returned object must be released after use, by calling the [release] method. - $U? get value => _id_value.get(this, U.nullableType); + $U? get value => _id_value.getNullable(this, jni$_.JObject.type) as $U?; /// from: `public U value` /// The returned object must be released after use, by calling the [release] method. - set value($U? value) => _id_value.set(this, U.nullableType, value); + set value($U? value) => _id_value.set(this, jni$_.JObject.type, value); +} + +final class $GrandParent$StaticParent$Child$Type$ + extends jni$_.JType { + @jni$_.internal + const $GrandParent$StaticParent$Child$Type$(); + + @jni$_.internal + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child;'; +} + +/// from: `com.github.dart_lang.jnigen.generics.GrandParent$StaticParent` +extension type GrandParent$StaticParent<$S extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/generics/GrandParent$StaticParent'); + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $GrandParent$StaticParent$Type$(); static final _id_new$ = _class.constructorId( - r'(Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;Ljava/lang/Object;Ljava/lang/Object;)V', + r'(Ljava/lang/Object;)V', ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs< - ( - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer - )>)>>('globalEnv_NewObject') + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_NewObject') .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.Pointer, - jni$_.Pointer, - jni$_.Pointer)>(); + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public void (com.github.dart_lang.jnigen.generics.GrandParent$StaticParent $outerClass, S object, U object1)` + /// from: `public void (S object)` /// The returned object must be released after use, by calling the [release] method. - factory GrandParent$StaticParent$Child( - GrandParent$StaticParent<$S?> $outerClass, + factory GrandParent$StaticParent( $S? object, - $U? object1, { - jni$_.JType<$S>? S, - required jni$_.JType<$U> U, - }) { - S ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $GrandParent$StaticParent$Type$).S, - ]) as jni$_.JType<$S>; - final _$$outerClass = $outerClass.reference; + ) { final _$object = object?.reference ?? jni$_.jNullReference; - final _$object1 = object1?.reference ?? jni$_.jNullReference; - return GrandParent$StaticParent$Child<$S, $U>.fromReference( - S, - U, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$$outerClass.pointer, _$object.pointer, _$object1.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, _$object.pointer) + .object>(); } } -final class $GrandParent$StaticParent$Child$NullableType$< - $S extends jni$_.JObject?, $U extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - const $GrandParent$StaticParent$Child$NullableType$( - this.S, - this.U, +extension GrandParent$StaticParent$$Methods<$S extends jni$_.JObject?> + on GrandParent$StaticParent<$S> { + static final _id_value = GrandParent$StaticParent._class.instanceFieldId( + r'value', + r'Ljava/lang/Object;', ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child;'; + /// from: `public S value` + /// The returned object must be released after use, by calling the [release] method. + $S? get value => _id_value.getNullable(this, jni$_.JObject.type) as $S?; - @jni$_.internal - @core$_.override - GrandParent$StaticParent$Child<$S, $U>? fromReference( - jni$_.JReference reference) => - reference.isNull - ? null - : GrandParent$StaticParent$Child<$S, $U>.fromReference( - S, - U, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + /// from: `public S value` + /// The returned object must be released after use, by calling the [release] method. + set value($S? value) => _id_value.set(this, jni$_.JObject.type, value); +} +final class $GrandParent$StaticParent$Type$ + extends jni$_.JType { @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; + const $GrandParent$StaticParent$Type$(); @jni$_.internal @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => - Object.hash($GrandParent$StaticParent$Child$NullableType$, S, U); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($GrandParent$StaticParent$Child$NullableType$<$S, $U>) && - other is $GrandParent$StaticParent$Child$NullableType$<$S, $U> && - S == other.S && - U == other.U; - } -} - -final class $GrandParent$StaticParent$Child$Type$<$S extends jni$_.JObject?, - $U extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - const $GrandParent$StaticParent$Child$Type$( - this.S, - this.U, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent$Child;'; - - @jni$_.internal - @core$_.override - GrandParent$StaticParent$Child<$S, $U> fromReference( - jni$_.JReference reference) => - GrandParent$StaticParent$Child<$S, $U>.fromReference( - S, - U, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GrandParent$StaticParent$Child$NullableType$<$S, $U>(S, U); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$StaticParent$Child$Type$, S, U); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($GrandParent$StaticParent$Child$Type$<$S, $U>) && - other is $GrandParent$StaticParent$Child$Type$<$S, $U> && - S == other.S && - U == other.U; - } -} - -/// from: `com.github.dart_lang.jnigen.generics.GrandParent$StaticParent` -class GrandParent$StaticParent<$S extends jni$_.JObject?> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - GrandParent$StaticParent.fromReference( - this.S, - jni$_.JReference reference, - ) : $type = type<$S>(S), - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/generics/GrandParent$StaticParent'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$S extends jni$_.JObject?>( - jni$_.JType<$S> S, - ) { - return $GrandParent$StaticParent$NullableType$<$S>( - S, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$S extends jni$_.JObject?>( - jni$_.JType<$S> S, - ) { - return $GrandParent$StaticParent$Type$<$S>( - S, - ); - } - - static final _id_value = _class.instanceFieldId( - r'value', - r'Ljava/lang/Object;', - ); - - /// from: `public S value` - /// The returned object must be released after use, by calling the [release] method. - $S? get value => _id_value.get(this, S.nullableType); - - /// from: `public S value` - /// The returned object must be released after use, by calling the [release] method. - set value($S? value) => _id_value.set(this, S.nullableType, value); - - static final _id_new$ = _class.constructorId( - r'(Ljava/lang/Object;)V', - ); - - static final _new$ = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_NewObject') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public void (S object)` - /// The returned object must be released after use, by calling the [release] method. - factory GrandParent$StaticParent( - $S? object, { - required jni$_.JType<$S> S, - }) { - final _$object = object?.reference ?? jni$_.jNullReference; - return GrandParent$StaticParent<$S>.fromReference( - S, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$object.pointer) - .reference); - } -} - -final class $GrandParent$StaticParent$NullableType$<$S extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - const $GrandParent$StaticParent$NullableType$( - this.S, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;'; - - @jni$_.internal - @core$_.override - GrandParent$StaticParent<$S>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : GrandParent$StaticParent<$S>.fromReference( - S, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$StaticParent$NullableType$, S); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$StaticParent$NullableType$<$S>) && - other is $GrandParent$StaticParent$NullableType$<$S> && - S == other.S; - } -} - -final class $GrandParent$StaticParent$Type$<$S extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$S> S; - - @jni$_.internal - const $GrandParent$StaticParent$Type$( - this.S, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;'; - - @jni$_.internal - @core$_.override - GrandParent$StaticParent<$S> fromReference(jni$_.JReference reference) => - GrandParent$StaticParent<$S>.fromReference( - S, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GrandParent$StaticParent$NullableType$<$S>(S); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$StaticParent$Type$, S); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$StaticParent$Type$<$S>) && - other is $GrandParent$StaticParent$Type$<$S> && - S == other.S; - } + String get signature => + r'Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;'; } /// from: `com.github.dart_lang.jnigen.generics.GrandParent` -class GrandParent<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - GrandParent.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type GrandParent<$T extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/generics/GrandParent'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $GrandParent$NullableType$<$T>( - T, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $GrandParent$Type$<$T>( - T, - ); - } - - static final _id_value = _class.instanceFieldId( - r'value', - r'Ljava/lang/Object;', - ); - - /// from: `public T value` - /// The returned object must be released after use, by calling the [release] method. - $T? get value => _id_value.get(this, T.nullableType); - - /// from: `public T value` - /// The returned object must be released after use, by calling the [release] method. - set value($T? value) => _id_value.set(this, T.nullableType, value); - + static const jni$_.JType type = $GrandParent$Type$(); static final _id_new$ = _class.constructorId( r'(Ljava/lang/Object;)V', ); @@ -4617,132 +3051,134 @@ class GrandParent<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public void (T object)` /// The returned object must be released after use, by calling the [release] method. factory GrandParent( - $T? object, { - required jni$_.JType<$T> T, - }) { + $T? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return GrandParent<$T>.fromReference( - T, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$object.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, _$object.pointer) + .object>(); } - static final _id_stringParent = _class.instanceMethodId( - r'stringParent', - r'()Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;', + static final _id_stringStaticParent = _class.staticMethodId( + r'stringStaticParent', + r'()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;', ); - static final _stringParent = jni$_.ProtectedJniExtensions.lookup< + static final _stringStaticParent = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + )>>('globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `public com.github.dart_lang.jnigen.generics.GrandParent$Parent stringParent()` + /// from: `static public com.github.dart_lang.jnigen.generics.GrandParent$StaticParent stringStaticParent()` /// The returned object must be released after use, by calling the [release] method. - GrandParent$Parent<$T?, jni$_.JString?>? stringParent() { - return _stringParent( - reference.pointer, _id_stringParent as jni$_.JMethodIDPtr) - .object?>( - $GrandParent$Parent$NullableType$<$T?, jni$_.JString?>( - T.nullableType, const jni$_.$JString$NullableType$())); + static GrandParent$StaticParent? stringStaticParent() { + return _stringStaticParent( + _class.reference.pointer, _id_stringStaticParent.pointer) + .object?>(); } - static final _id_varParent = _class.instanceMethodId( - r'varParent', - r'(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;', + static final _id_varStaticParent = _class.staticMethodId( + r'varStaticParent', + r'(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;', ); - static final _varParent = jni$_.ProtectedJniExtensions.lookup< + static final _varStaticParent = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallObjectMethod') + 'globalEnv_CallStaticObjectMethod') .asFunction< jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `public com.github.dart_lang.jnigen.generics.GrandParent$Parent varParent(S object)` + /// from: `static public com.github.dart_lang.jnigen.generics.GrandParent$StaticParent varStaticParent(S object)` /// The returned object must be released after use, by calling the [release] method. - GrandParent$Parent<$T?, $S?>? varParent<$S extends jni$_.JObject?>( - $S? object, { - required jni$_.JType<$S> S, - }) { + static GrandParent$StaticParent<$S?>? + varStaticParent<$S extends jni$_.JObject?>( + $S? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _varParent(reference.pointer, _id_varParent as jni$_.JMethodIDPtr, - _$object.pointer) - .object?>( - $GrandParent$Parent$NullableType$<$T?, $S?>( - T.nullableType, S.nullableType)); + return _varStaticParent(_class.reference.pointer, + _id_varStaticParent.pointer, _$object.pointer) + .object?>(); } +} - static final _id_stringStaticParent = _class.staticMethodId( - r'stringStaticParent', - r'()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;', +extension GrandParent$$Methods<$T extends jni$_.JObject?> on GrandParent<$T> { + static final _id_value = GrandParent._class.instanceFieldId( + r'value', + r'Ljava/lang/Object;', ); - static final _stringStaticParent = jni$_.ProtectedJniExtensions.lookup< + /// from: `public T value` + /// The returned object must be released after use, by calling the [release] method. + $T? get value => _id_value.getNullable(this, jni$_.JObject.type) as $T?; + + /// from: `public T value` + /// The returned object must be released after use, by calling the [release] method. + set value($T? value) => _id_value.set(this, jni$_.JObject.type, value); + + static final _id_stringParent = GrandParent._class.instanceMethodId( + r'stringParent', + r'()Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;', + ); + + static final _stringParent = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_CallStaticObjectMethod') + )>>('globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `static public com.github.dart_lang.jnigen.generics.GrandParent$StaticParent stringStaticParent()` + /// from: `public com.github.dart_lang.jnigen.generics.GrandParent$Parent stringParent()` /// The returned object must be released after use, by calling the [release] method. - static GrandParent$StaticParent? stringStaticParent() { - return _stringStaticParent(_class.reference.pointer, - _id_stringStaticParent as jni$_.JMethodIDPtr) - .object?>( - const $GrandParent$StaticParent$NullableType$( - jni$_.$JString$NullableType$())); + GrandParent$Parent<$T?, jni$_.JString?>? stringParent() { + return _stringParent(reference.pointer, _id_stringParent.pointer) + .object?>(); } - static final _id_varStaticParent = _class.staticMethodId( - r'varStaticParent', - r'(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;', + static final _id_varParent = GrandParent._class.instanceMethodId( + r'varParent', + r'(Ljava/lang/Object;)Lcom/github/dart_lang/jnigen/generics/GrandParent$Parent;', ); - static final _varStaticParent = jni$_.ProtectedJniExtensions.lookup< + static final _varParent = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallStaticObjectMethod') + 'globalEnv_CallObjectMethod') .asFunction< jni$_.JniResult Function(jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.Pointer)>(); - /// from: `static public com.github.dart_lang.jnigen.generics.GrandParent$StaticParent varStaticParent(S object)` + /// from: `public com.github.dart_lang.jnigen.generics.GrandParent$Parent varParent(S object)` /// The returned object must be released after use, by calling the [release] method. - static GrandParent$StaticParent<$S?>? - varStaticParent<$S extends jni$_.JObject?>( - $S? object, { - required jni$_.JType<$S> S, - }) { + GrandParent$Parent<$T?, $S?>? varParent<$S extends jni$_.JObject?>( + $S? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _varStaticParent(_class.reference.pointer, - _id_varStaticParent as jni$_.JMethodIDPtr, _$object.pointer) - .object?>( - $GrandParent$StaticParent$NullableType$<$S?>(S.nullableType)); + return _varParent( + reference.pointer, _id_varParent.pointer, _$object.pointer) + .object?>(); } - static final _id_staticParentWithSameType = _class.instanceMethodId( + static final _id_staticParentWithSameType = + GrandParent._class.instanceMethodId( r'staticParentWithSameType', r'()Lcom/github/dart_lang/jnigen/generics/GrandParent$StaticParent;', ); @@ -4762,180 +3198,33 @@ class GrandParent<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public com.github.dart_lang.jnigen.generics.GrandParent$StaticParent staticParentWithSameType()` /// The returned object must be released after use, by calling the [release] method. GrandParent$StaticParent<$T?>? staticParentWithSameType() { - return _staticParentWithSameType(reference.pointer, - _id_staticParentWithSameType as jni$_.JMethodIDPtr) - .object?>( - $GrandParent$StaticParent$NullableType$<$T?>(T.nullableType)); + return _staticParentWithSameType( + reference.pointer, _id_staticParentWithSameType.pointer) + .object?>(); } } -final class $GrandParent$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { +final class $GrandParent$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $GrandParent$NullableType$( - this.T, - ); + const $GrandParent$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/GrandParent;'; +} - @jni$_.internal - @core$_.override - GrandParent<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : GrandParent<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); +/// from: `com.github.dart_lang.jnigen.generics.MyMap$MyEntry` +extension type MyMap$MyEntry<$K extends jni$_.JObject?, + $V extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/generics/MyMap$MyEntry'); - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$NullableType$<$T>) && - other is $GrandParent$NullableType$<$T> && - T == other.T; - } -} - -final class $GrandParent$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $GrandParent$Type$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/generics/GrandParent;'; - - @jni$_.internal - @core$_.override - GrandParent<$T> fromReference(jni$_.JReference reference) => - GrandParent<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GrandParent$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GrandParent$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GrandParent$Type$<$T>) && - other is $GrandParent$Type$<$T> && - T == other.T; - } -} - -/// from: `com.github.dart_lang.jnigen.generics.MyMap$MyEntry` -class MyMap$MyEntry<$K extends jni$_.JObject?, $V extends jni$_.JObject?> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - MyMap$MyEntry.fromReference( - this.K, - this.V, - jni$_.JReference reference, - ) : $type = type<$K, $V>(K, V), - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/generics/MyMap$MyEntry'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - jni$_.JType<$K> K, - jni$_.JType<$V> V, - ) { - return $MyMap$MyEntry$NullableType$<$K, $V>( - K, - V, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - jni$_.JType<$K> K, - jni$_.JType<$V> V, - ) { - return $MyMap$MyEntry$Type$<$K, $V>( - K, - V, - ); - } - - static final _id_key = _class.instanceFieldId( - r'key', - r'Ljava/lang/Object;', - ); - - /// from: `public K key` - /// The returned object must be released after use, by calling the [release] method. - $K? get key => _id_key.get(this, K.nullableType); - - /// from: `public K key` - /// The returned object must be released after use, by calling the [release] method. - set key($K? value) => _id_key.set(this, K.nullableType, value); - - static final _id_value = _class.instanceFieldId( - r'value', - r'Ljava/lang/Object;', - ); - - /// from: `public V value` - /// The returned object must be released after use, by calling the [release] method. - $V? get value => _id_value.get(this, V.nullableType); - - /// from: `public V value` - /// The returned object must be released after use, by calling the [release] method. - set value($V? value) => _id_value.set(this, V.nullableType, value); - - static final _id_new$ = _class.constructorId( - r'(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/Object;Ljava/lang/Object;)V', - ); + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $MyMap$MyEntry$Type$(); + static final _id_new$ = _class.constructorId( + r'(Lcom/github/dart_lang/jnigen/generics/MyMap;Ljava/lang/Object;Ljava/lang/Object;)V', + ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< @@ -4961,181 +3250,64 @@ class MyMap$MyEntry<$K extends jni$_.JObject?, $V extends jni$_.JObject?> factory MyMap$MyEntry( MyMap<$K?, $V?> $outerClass, $K? object, - $V? object1, { - jni$_.JType<$K>? K, - jni$_.JType<$V>? V, - }) { - K ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $MyMap$Type$).K, - ]) as jni$_.JType<$K>; - V ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $MyMap$Type$).V, - ]) as jni$_.JType<$V>; + $V? object1, + ) { final _$$outerClass = $outerClass.reference; final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return MyMap$MyEntry<$K, $V>.fromReference( - K, - V, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$$outerClass.pointer, _$object.pointer, _$object1.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, + _$$outerClass.pointer, _$object.pointer, _$object1.pointer) + .object>(); } } -final class $MyMap$MyEntry$NullableType$<$K extends jni$_.JObject?, - $V extends jni$_.JObject?> extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $MyMap$MyEntry$NullableType$( - this.K, - this.V, +extension MyMap$MyEntry$$Methods<$K extends jni$_.JObject?, + $V extends jni$_.JObject?> on MyMap$MyEntry<$K, $V> { + static final _id_key = MyMap$MyEntry._class.instanceFieldId( + r'key', + r'Ljava/lang/Object;', ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/MyMap$MyEntry;'; - - @jni$_.internal - @core$_.override - MyMap$MyEntry<$K, $V>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : MyMap$MyEntry<$K, $V>.fromReference( - K, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + /// from: `public K key` + /// The returned object must be released after use, by calling the [release] method. + $K? get key => _id_key.getNullable(this, jni$_.JObject.type) as $K?; - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; + /// from: `public K key` + /// The returned object must be released after use, by calling the [release] method. + set key($K? value) => _id_key.set(this, jni$_.JObject.type, value); - @jni$_.internal - @core$_.override - final superCount = 1; + static final _id_value = MyMap$MyEntry._class.instanceFieldId( + r'value', + r'Ljava/lang/Object;', + ); - @core$_.override - int get hashCode => Object.hash($MyMap$MyEntry$NullableType$, K, V); + /// from: `public V value` + /// The returned object must be released after use, by calling the [release] method. + $V? get value => _id_value.getNullable(this, jni$_.JObject.type) as $V?; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyMap$MyEntry$NullableType$<$K, $V>) && - other is $MyMap$MyEntry$NullableType$<$K, $V> && - K == other.K && - V == other.V; - } + /// from: `public V value` + /// The returned object must be released after use, by calling the [release] method. + set value($V? value) => _id_value.set(this, jni$_.JObject.type, value); } -final class $MyMap$MyEntry$Type$<$K extends jni$_.JObject?, - $V extends jni$_.JObject?> extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$K> K; - +final class $MyMap$MyEntry$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $MyMap$MyEntry$Type$( - this.K, - this.V, - ); + const $MyMap$MyEntry$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/MyMap$MyEntry;'; - - @jni$_.internal - @core$_.override - MyMap$MyEntry<$K, $V> fromReference(jni$_.JReference reference) => - MyMap$MyEntry<$K, $V>.fromReference( - K, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $MyMap$MyEntry$NullableType$<$K, $V>(K, V); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyMap$MyEntry$Type$, K, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyMap$MyEntry$Type$<$K, $V>) && - other is $MyMap$MyEntry$Type$<$K, $V> && - K == other.K && - V == other.V; - } } /// from: `com.github.dart_lang.jnigen.generics.MyMap` -class MyMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> - extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - MyMap.fromReference( - this.K, - this.V, - jni$_.JReference reference, - ) : $type = type<$K, $V>(K, V), - super.fromReference(reference); - +extension type MyMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/generics/MyMap'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - jni$_.JType<$K> K, - jni$_.JType<$V> V, - ) { - return $MyMap$NullableType$<$K, $V>( - K, - V, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> - type<$K extends jni$_.JObject?, $V extends jni$_.JObject?>( - jni$_.JType<$K> K, - jni$_.JType<$V> V, - ) { - return $MyMap$Type$<$K, $V>( - K, - V, - ); - } - + static const jni$_.JType type = $MyMap$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -5154,18 +3326,15 @@ class MyMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory MyMap({ - required jni$_.JType<$K> K, - required jni$_.JType<$V> V, - }) { - return MyMap<$K, $V>.fromReference( - K, - V, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + factory MyMap() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } +} - static final _id_get = _class.instanceMethodId( +extension MyMap$$Methods<$K extends jni$_.JObject?, $V extends jni$_.JObject?> + on MyMap<$K, $V> { + static final _id_get = MyMap._class.instanceMethodId( r'get', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -5187,12 +3356,11 @@ class MyMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> $K? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _get( - reference.pointer, _id_get as jni$_.JMethodIDPtr, _$object.pointer) - .object<$V?>(V.nullableType); + return _get(reference.pointer, _id_get.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_put = _class.instanceMethodId( + static final _id_put = MyMap._class.instanceMethodId( r'put', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -5222,12 +3390,12 @@ class MyMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _put(reference.pointer, _id_put as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer) - .object<$V?>(V.nullableType); + return _put(reference.pointer, _id_put.pointer, _$object.pointer, + _$object1.pointer) + .object<$V?>(); } - static final _id_entryStack = _class.instanceMethodId( + static final _id_entryStack = MyMap._class.instanceMethodId( r'entryStack', r'()Lcom/github/dart_lang/jnigen/generics/MyStack;', ); @@ -5247,153 +3415,28 @@ class MyMap<$K extends jni$_.JObject?, $V extends jni$_.JObject?> /// from: `public com.github.dart_lang.jnigen.generics.MyStack> entryStack()` /// The returned object must be released after use, by calling the [release] method. MyStack?>? entryStack() { - return _entryStack(reference.pointer, _id_entryStack as jni$_.JMethodIDPtr) - .object?>?>( - $MyStack$NullableType$?>( - $MyMap$MyEntry$NullableType$<$K?, $V?>( - K.nullableType, V.nullableType))); - } -} - -final class $MyMap$NullableType$<$K extends jni$_.JObject?, - $V extends jni$_.JObject?> extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $MyMap$NullableType$( - this.K, - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/generics/MyMap;'; - - @jni$_.internal - @core$_.override - MyMap<$K, $V>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : MyMap<$K, $V>.fromReference( - K, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyMap$NullableType$, K, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyMap$NullableType$<$K, $V>) && - other is $MyMap$NullableType$<$K, $V> && - K == other.K && - V == other.V; + return _entryStack(reference.pointer, _id_entryStack.pointer) + .object?>?>(); } } -final class $MyMap$Type$<$K extends jni$_.JObject?, $V extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - final jni$_.JType<$V> V; - +final class $MyMap$Type$ extends jni$_.JType { @jni$_.internal - const $MyMap$Type$( - this.K, - this.V, - ); + const $MyMap$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/MyMap;'; - - @jni$_.internal - @core$_.override - MyMap<$K, $V> fromReference(jni$_.JReference reference) => - MyMap<$K, $V>.fromReference( - K, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $MyMap$NullableType$<$K, $V>(K, V); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyMap$Type$, K, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyMap$Type$<$K, $V>) && - other is $MyMap$Type$<$K, $V> && - K == other.K && - V == other.V; - } } /// from: `com.github.dart_lang.jnigen.generics.MyStack` -class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - MyStack.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type MyStack<$T extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/generics/MyStack'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $MyStack$NullableType$<$T>( - T, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $MyStack$Type$<$T>( - T, - ); - } - + static const jni$_.JType type = $MyStack$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -5412,13 +3455,9 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory MyStack({ - required jni$_.JType<$T> T, - }) { - return MyStack<$T>.fromReference( - T, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + factory MyStack() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } static final _id_fromArray = _class.staticMethodId( @@ -5440,13 +3479,12 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.generics.MyStack fromArray(T[] objects)` /// The returned object must be released after use, by calling the [release] method. static MyStack<$T?>? fromArray<$T extends jni$_.JObject?>( - jni$_.JArray<$T?>? objects, { - required jni$_.JType<$T> T, - }) { + jni$_.JArray<$T?>? objects, + ) { final _$objects = objects?.reference ?? jni$_.jNullReference; - return _fromArray(_class.reference.pointer, - _id_fromArray as jni$_.JMethodIDPtr, _$objects.pointer) - .object?>($MyStack$NullableType$<$T?>(T.nullableType)); + return _fromArray( + _class.reference.pointer, _id_fromArray.pointer, _$objects.pointer) + .object?>(); } static final _id_fromArrayOfArrayOfGrandParents = _class.staticMethodId( @@ -5470,15 +3508,12 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// The returned object must be released after use, by calling the [release] method. static MyStack<$S?>? fromArrayOfArrayOfGrandParents<$S extends jni$_.JObject?>( - jni$_.JArray?>?>? grandParents, { - required jni$_.JType<$S> S, - }) { + jni$_.JArray?>?>? grandParents, + ) { final _$grandParents = grandParents?.reference ?? jni$_.jNullReference; - return _fromArrayOfArrayOfGrandParents( - _class.reference.pointer, - _id_fromArrayOfArrayOfGrandParents as jni$_.JMethodIDPtr, - _$grandParents.pointer) - .object?>($MyStack$NullableType$<$S?>(S.nullableType)); + return _fromArrayOfArrayOfGrandParents(_class.reference.pointer, + _id_fromArrayOfArrayOfGrandParents.pointer, _$grandParents.pointer) + .object?>(); } static final _id_of = _class.staticMethodId( @@ -5500,11 +3535,9 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.generics.MyStack of()` /// The returned object must be released after use, by calling the [release] method. - static MyStack<$T?>? of<$T extends jni$_.JObject?>({ - required jni$_.JType<$T> T, - }) { - return _of(_class.reference.pointer, _id_of as jni$_.JMethodIDPtr) - .object?>($MyStack$NullableType$<$T?>(T.nullableType)); + static MyStack<$T?>? of<$T extends jni$_.JObject?>() { + return _of(_class.reference.pointer, _id_of.pointer) + .object?>(); } static final _id_of$1 = _class.staticMethodId( @@ -5526,13 +3559,11 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.generics.MyStack of(T object)` /// The returned object must be released after use, by calling the [release] method. static MyStack<$T?>? of$1<$T extends jni$_.JObject?>( - $T? object, { - required jni$_.JType<$T> T, - }) { + $T? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _of$1(_class.reference.pointer, _id_of$1 as jni$_.JMethodIDPtr, - _$object.pointer) - .object?>($MyStack$NullableType$<$T?>(T.nullableType)); + return _of$1(_class.reference.pointer, _id_of$1.pointer, _$object.pointer) + .object?>(); } static final _id_of$2 = _class.staticMethodId( @@ -5561,17 +3592,18 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// The returned object must be released after use, by calling the [release] method. static MyStack<$T?>? of$2<$T extends jni$_.JObject?>( $T? object, - $T? object1, { - required jni$_.JType<$T> T, - }) { + $T? object1, + ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _of$2(_class.reference.pointer, _id_of$2 as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer) - .object?>($MyStack$NullableType$<$T?>(T.nullableType)); + return _of$2(_class.reference.pointer, _id_of$2.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); } +} - static final _id_push = _class.instanceMethodId( +extension MyStack$$Methods<$T extends jni$_.JObject?> on MyStack<$T> { + static final _id_push = MyStack._class.instanceMethodId( r'push', r'(Ljava/lang/Object;)V', ); @@ -5592,11 +3624,10 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - _push(reference.pointer, _id_push as jni$_.JMethodIDPtr, _$object.pointer) - .check(); + _push(reference.pointer, _id_push.pointer, _$object.pointer).check(); } - static final _id_pop = _class.instanceMethodId( + static final _id_pop = MyStack._class.instanceMethodId( r'pop', r'()Ljava/lang/Object;', ); @@ -5616,11 +3647,10 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public T pop()` /// The returned object must be released after use, by calling the [release] method. $T? pop() { - return _pop(reference.pointer, _id_pop as jni$_.JMethodIDPtr) - .object<$T?>(T.nullableType); + return _pop(reference.pointer, _id_pop.pointer).object<$T?>(); } - static final _id_size = _class.instanceMethodId( + static final _id_size = MyStack._class.instanceMethodId( r'size', r'()I', ); @@ -5639,141 +3669,29 @@ class MyStack<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public int size()` int size() { - return _size(reference.pointer, _id_size as jni$_.JMethodIDPtr).integer; + return _size(reference.pointer, _id_size.pointer).integer; } } -final class $MyStack$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { +final class $MyStack$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $MyStack$NullableType$( - this.T, - ); + const $MyStack$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/MyStack;'; - - @jni$_.internal - @core$_.override - MyStack<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : MyStack<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyStack$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyStack$NullableType$<$T>) && - other is $MyStack$NullableType$<$T> && - T == other.T; - } } -final class $MyStack$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; +/// from: `com.github.dart_lang.jnigen.generics.StringKeyedMap` +extension type StringKeyedMap<$V extends jni$_.JObject?>._(jni$_.JObject _$this) + implements MyMap { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/generics/StringKeyedMap'); - @jni$_.internal - const $MyStack$Type$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/generics/MyStack;'; - - @jni$_.internal - @core$_.override - MyStack<$T> fromReference(jni$_.JReference reference) => - MyStack<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => $MyStack$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyStack$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyStack$Type$<$T>) && - other is $MyStack$Type$<$T> && - T == other.T; - } -} - -/// from: `com.github.dart_lang.jnigen.generics.StringKeyedMap` -class StringKeyedMap<$V extends jni$_.JObject?> - extends MyMap { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - StringKeyedMap.fromReference( - this.V, - jni$_.JReference reference, - ) : $type = type<$V>(V), - super.fromReference( - const jni$_.$JString$NullableType$(), V.nullableType, reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/generics/StringKeyedMap'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$V extends jni$_.JObject?>( - jni$_.JType<$V> V, - ) { - return $StringKeyedMap$NullableType$<$V>( - V, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$V extends jni$_.JObject?>( - jni$_.JType<$V> V, - ) { - return $StringKeyedMap$Type$<$V>( - V, - ); - } - - static final _id_new$ = _class.constructorId( - r'()V', + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $StringKeyedMap$Type$(); + static final _id_new$ = _class.constructorId( + r'()V', ); static final _new$ = jni$_.ProtectedJniExtensions.lookup< @@ -5790,130 +3708,28 @@ class StringKeyedMap<$V extends jni$_.JObject?> /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory StringKeyedMap({ - required jni$_.JType<$V> V, - }) { - return StringKeyedMap<$V>.fromReference( - V, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $StringKeyedMap$NullableType$<$V extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $StringKeyedMap$NullableType$( - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/StringKeyedMap;'; - - @jni$_.internal - @core$_.override - StringKeyedMap<$V>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : StringKeyedMap<$V>.fromReference( - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => $MyMap$NullableType$( - const jni$_.$JString$NullableType$(), V.nullableType); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => Object.hash($StringKeyedMap$NullableType$, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringKeyedMap$NullableType$<$V>) && - other is $StringKeyedMap$NullableType$<$V> && - V == other.V; + factory StringKeyedMap() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } } -final class $StringKeyedMap$Type$<$V extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$V> V; - +final class $StringKeyedMap$Type$ extends jni$_.JType { @jni$_.internal - const $StringKeyedMap$Type$( - this.V, - ); + const $StringKeyedMap$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/StringKeyedMap;'; - - @jni$_.internal - @core$_.override - StringKeyedMap<$V> fromReference(jni$_.JReference reference) => - StringKeyedMap<$V>.fromReference( - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => $MyMap$NullableType$( - const jni$_.$JString$NullableType$(), V.nullableType); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $StringKeyedMap$NullableType$<$V>(V); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => Object.hash($StringKeyedMap$Type$, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringKeyedMap$Type$<$V>) && - other is $StringKeyedMap$Type$<$V> && - V == other.V; - } } /// from: `com.github.dart_lang.jnigen.generics.StringMap` -class StringMap extends StringKeyedMap { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - StringMap.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(const jni$_.$JString$NullableType$(), reference); - +extension type StringMap._(jni$_.JObject _$this) + implements StringKeyedMap { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/generics/StringMap'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $StringMap$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $StringMap$Type$(); static final _id_new$ = _class.constructorId( @@ -5935,48 +3751,8 @@ class StringMap extends StringKeyedMap { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory StringMap() { - return StringMap.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $StringMap$NullableType$ extends jni$_.JType { - @jni$_.internal - const $StringMap$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/generics/StringMap;'; - - @jni$_.internal - @core$_.override - StringMap? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : StringMap.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $StringKeyedMap$NullableType$( - jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 3; - - @core$_.override - int get hashCode => ($StringMap$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringMap$NullableType$) && - other is $StringMap$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -5987,55 +3763,14 @@ final class $StringMap$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/StringMap;'; - - @jni$_.internal - @core$_.override - StringMap fromReference(jni$_.JReference reference) => - StringMap.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $StringKeyedMap$NullableType$( - jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $StringMap$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 3; - - @core$_.override - int get hashCode => ($StringMap$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringMap$Type$) && other is $StringMap$Type$; - } } /// from: `com.github.dart_lang.jnigen.generics.StringStack` -class StringStack extends MyStack { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - StringStack.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(const jni$_.$JString$NullableType$(), reference); - +extension type StringStack._(jni$_.JObject _$this) + implements MyStack { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/generics/StringStack'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $StringStack$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $StringStack$Type$(); static final _id_new$ = _class.constructorId( @@ -6057,47 +3792,8 @@ class StringStack extends MyStack { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory StringStack() { - return StringStack.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $StringStack$NullableType$ extends jni$_.JType { - @jni$_.internal - const $StringStack$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/generics/StringStack;'; - - @jni$_.internal - @core$_.override - StringStack? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : StringStack.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const $MyStack$NullableType$( - jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($StringStack$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringStack$NullableType$) && - other is $StringStack$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -6108,77 +3804,16 @@ final class $StringStack$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/StringStack;'; - - @jni$_.internal - @core$_.override - StringStack fromReference(jni$_.JReference reference) => - StringStack.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const $MyStack$NullableType$( - jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $StringStack$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($StringStack$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringStack$Type$) && - other is $StringStack$Type$; - } } /// from: `com.github.dart_lang.jnigen.generics.StringValuedMap` -class StringValuedMap<$K extends jni$_.JObject?> - extends MyMap<$K?, jni$_.JString?> { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - StringValuedMap.fromReference( - this.K, - jni$_.JReference reference, - ) : $type = type<$K>(K), - super.fromReference( - K.nullableType, const jni$_.$JString$NullableType$(), reference); - +extension type StringValuedMap<$K extends jni$_.JObject?>._( + jni$_.JObject _$this) implements MyMap<$K?, jni$_.JString?> { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/generics/StringValuedMap'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$K extends jni$_.JObject?>( - jni$_.JType<$K> K, - ) { - return $StringValuedMap$NullableType$<$K>( - K, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$K extends jni$_.JObject?>( - jni$_.JType<$K> K, - ) { - return $StringValuedMap$Type$<$K>( - K, - ); - } - + static const jni$_.JType type = $StringValuedMap$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -6197,150 +3832,175 @@ class StringValuedMap<$K extends jni$_.JObject?> /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory StringValuedMap({ - required jni$_.JType<$K> K, - }) { - return StringValuedMap<$K>.fromReference( - K, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $StringValuedMap$NullableType$<$K extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$K> K; - - @jni$_.internal - const $StringValuedMap$NullableType$( - this.K, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/generics/StringValuedMap;'; - - @jni$_.internal - @core$_.override - StringValuedMap<$K>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : StringValuedMap<$K>.fromReference( - K, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => $MyMap$NullableType$<$K?, jni$_.JString?>( - K.nullableType, const jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => Object.hash($StringValuedMap$NullableType$, K); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringValuedMap$NullableType$<$K>) && - other is $StringValuedMap$NullableType$<$K> && - K == other.K; + factory StringValuedMap() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } } -final class $StringValuedMap$Type$<$K extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$K> K; - +final class $StringValuedMap$Type$ extends jni$_.JType { @jni$_.internal - const $StringValuedMap$Type$( - this.K, - ); + const $StringValuedMap$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/generics/StringValuedMap;'; - - @jni$_.internal - @core$_.override - StringValuedMap<$K> fromReference(jni$_.JReference reference) => - StringValuedMap<$K>.fromReference( - K, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => $MyMap$NullableType$<$K?, jni$_.JString?>( - K.nullableType, const jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $StringValuedMap$NullableType$<$K>(K); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => Object.hash($StringValuedMap$Type$, K); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringValuedMap$Type$<$K>) && - other is $StringValuedMap$Type$<$K> && - K == other.K; - } } /// from: `com.github.dart_lang.jnigen.interfaces.GenericInterface` -class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - GenericInterface.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type GenericInterface<$T extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/GenericInterface'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $GenericInterface$NullableType$<$T>( - T, + static const jni$_.JType type = $GenericInterface$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), ); } - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'genericArrayOf(Ljava/lang/Object;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.genericArrayOf( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'arrayOf(Ljava/lang/Object;)[Ljava/lang/Object;') { + final $r = _$impls[$p]!.arrayOf( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'mapOf(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { + final $r = _$impls[$p]!.mapOf( + ($a![0] as jni$_.JObject?), + ($a![1] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'firstOfGenericArray([Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.firstOfGenericArray( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'firstOfArray([Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.firstOfArray( + ($a![0] as jni$_.JArray?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'firstKeyOf(Ljava/util/Map;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.firstKeyOf( + ($a![0] as jni$_.JMap?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'firstValueOf(Ljava/util/Map;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.firstValueOf( + ($a![0] as jni$_.JMap?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$T extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $GenericInterface<$T> $impl, ) { - return $GenericInterface$Type$<$T>( - T, + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.interfaces.GenericInterface', + $p, + _$invokePointer, + [], ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory GenericInterface.implement( + $GenericInterface<$T> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); } +} - static final _id_genericArrayOf = _class.instanceMethodId( +extension GenericInterface$$Methods<$T extends jni$_.JObject?> + on GenericInterface<$T> { + static final _id_genericArrayOf = GenericInterface._class.instanceMethodId( r'genericArrayOf', r'(Ljava/lang/Object;)[Ljava/lang/Object;', ); @@ -6359,17 +4019,15 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public abstract U[] genericArrayOf(U object)` /// The returned object must be released after use, by calling the [release] method. jni$_.JArray<$U?>? genericArrayOf<$U extends jni$_.JObject?>( - $U? object, { - required jni$_.JType<$U> U, - }) { + $U? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _genericArrayOf(reference.pointer, - _id_genericArrayOf as jni$_.JMethodIDPtr, _$object.pointer) - .object?>( - jni$_.$JArray$NullableType$<$U?>(U.nullableType)); + return _genericArrayOf( + reference.pointer, _id_genericArrayOf.pointer, _$object.pointer) + .object?>(); } - static final _id_arrayOf = _class.instanceMethodId( + static final _id_arrayOf = GenericInterface._class.instanceMethodId( r'arrayOf', r'(Ljava/lang/Object;)[Ljava/lang/Object;', ); @@ -6391,13 +4049,11 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _arrayOf(reference.pointer, _id_arrayOf as jni$_.JMethodIDPtr, - _$object.pointer) - .object?>( - jni$_.$JArray$NullableType$<$T?>(T.nullableType)); + return _arrayOf(reference.pointer, _id_arrayOf.pointer, _$object.pointer) + .object?>(); } - static final _id_mapOf = _class.instanceMethodId( + static final _id_mapOf = GenericInterface._class.instanceMethodId( r'mapOf', r'(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;', ); @@ -6423,18 +4079,17 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { /// The returned object must be released after use, by calling the [release] method. jni$_.JMap<$T?, $U?>? mapOf<$U extends jni$_.JObject?>( $T? object, - $U? object1, { - required jni$_.JType<$U> U, - }) { + $U? object1, + ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1?.reference ?? jni$_.jNullReference; - return _mapOf(reference.pointer, _id_mapOf as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer) - .object?>(jni$_.$JMap$NullableType$<$T?, $U?>( - T.nullableType, U.nullableType)); + return _mapOf(reference.pointer, _id_mapOf.pointer, _$object.pointer, + _$object1.pointer) + .object?>(); } - static final _id_firstOfGenericArray = _class.instanceMethodId( + static final _id_firstOfGenericArray = + GenericInterface._class.instanceMethodId( r'firstOfGenericArray', r'([Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6453,16 +4108,15 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public abstract U firstOfGenericArray(U[] objects)` /// The returned object must be released after use, by calling the [release] method. $U? firstOfGenericArray<$U extends jni$_.JObject?>( - jni$_.JArray<$U?>? objects, { - required jni$_.JType<$U> U, - }) { + jni$_.JArray<$U?>? objects, + ) { final _$objects = objects?.reference ?? jni$_.jNullReference; return _firstOfGenericArray(reference.pointer, - _id_firstOfGenericArray as jni$_.JMethodIDPtr, _$objects.pointer) - .object<$U?>(U.nullableType); + _id_firstOfGenericArray.pointer, _$objects.pointer) + .object<$U?>(); } - static final _id_firstOfArray = _class.instanceMethodId( + static final _id_firstOfArray = GenericInterface._class.instanceMethodId( r'firstOfArray', r'([Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -6484,12 +4138,12 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { jni$_.JArray<$T?>? objects, ) { final _$objects = objects?.reference ?? jni$_.jNullReference; - return _firstOfArray(reference.pointer, - _id_firstOfArray as jni$_.JMethodIDPtr, _$objects.pointer) - .object<$T?>(T.nullableType); + return _firstOfArray( + reference.pointer, _id_firstOfArray.pointer, _$objects.pointer) + .object<$T?>(); } - static final _id_firstKeyOf = _class.instanceMethodId( + static final _id_firstKeyOf = GenericInterface._class.instanceMethodId( r'firstKeyOf', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -6508,16 +4162,14 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public abstract T firstKeyOf(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $T? firstKeyOf<$U extends jni$_.JObject?>( - jni$_.JMap<$T?, $U?>? map, { - required jni$_.JType<$U> U, - }) { + jni$_.JMap<$T?, $U?>? map, + ) { final _$map = map?.reference ?? jni$_.jNullReference; - return _firstKeyOf(reference.pointer, _id_firstKeyOf as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$T?>(T.nullableType); + return _firstKeyOf(reference.pointer, _id_firstKeyOf.pointer, _$map.pointer) + .object<$T?>(); } - static final _id_firstValueOf = _class.instanceMethodId( + static final _id_firstValueOf = GenericInterface._class.instanceMethodId( r'firstValueOf', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -6536,17 +4188,133 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public abstract U firstValueOf(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $U? firstValueOf<$U extends jni$_.JObject?>( - jni$_.JMap<$T?, $U?>? map, { - required jni$_.JType<$U> U, - }) { + jni$_.JMap<$T?, $U?>? map, + ) { final _$map = map?.reference ?? jni$_.jNullReference; - return _firstValueOf(reference.pointer, - _id_firstValueOf as jni$_.JMethodIDPtr, _$map.pointer) - .object<$U?>(U.nullableType); + return _firstValueOf( + reference.pointer, _id_firstValueOf.pointer, _$map.pointer) + .object<$U?>(); + } +} + +abstract base mixin class $GenericInterface<$T extends jni$_.JObject?> { + factory $GenericInterface({ + required jni$_.JArray? Function(jni$_.JObject? object) + genericArrayOf, + required jni$_.JArray? Function($T? object) arrayOf, + required jni$_.JMap? Function( + $T? object, jni$_.JObject? object1) + mapOf, + required jni$_.JObject? Function(jni$_.JArray? objects) + firstOfGenericArray, + required $T? Function(jni$_.JArray? objects) firstOfArray, + required $T? Function(jni$_.JMap? map) + firstKeyOf, + required jni$_.JObject? Function( + jni$_.JMap? map) + firstValueOf, + }) = _$GenericInterface<$T>; + + jni$_.JArray? genericArrayOf(jni$_.JObject? object); + jni$_.JArray? arrayOf($T? object); + jni$_.JMap? mapOf( + $T? object, jni$_.JObject? object1); + jni$_.JObject? firstOfGenericArray(jni$_.JArray? objects); + $T? firstOfArray(jni$_.JArray? objects); + $T? firstKeyOf(jni$_.JMap? map); + jni$_.JObject? firstValueOf(jni$_.JMap? map); +} + +final class _$GenericInterface<$T extends jni$_.JObject?> + with $GenericInterface<$T> { + _$GenericInterface({ + required jni$_.JArray? Function(jni$_.JObject? object) + genericArrayOf, + required jni$_.JArray? Function($T? object) arrayOf, + required jni$_.JMap? Function( + $T? object, jni$_.JObject? object1) + mapOf, + required jni$_.JObject? Function(jni$_.JArray? objects) + firstOfGenericArray, + required $T? Function(jni$_.JArray? objects) firstOfArray, + required $T? Function(jni$_.JMap? map) + firstKeyOf, + required jni$_.JObject? Function( + jni$_.JMap? map) + firstValueOf, + }) : _genericArrayOf = genericArrayOf, + _arrayOf = arrayOf, + _mapOf = mapOf, + _firstOfGenericArray = firstOfGenericArray, + _firstOfArray = firstOfArray, + _firstKeyOf = firstKeyOf, + _firstValueOf = firstValueOf; + + final jni$_.JArray? Function(jni$_.JObject? object) + _genericArrayOf; + final jni$_.JArray? Function($T? object) _arrayOf; + final jni$_.JMap? Function( + $T? object, jni$_.JObject? object1) _mapOf; + final jni$_.JObject? Function(jni$_.JArray? objects) + _firstOfGenericArray; + final $T? Function(jni$_.JArray? objects) _firstOfArray; + final $T? Function(jni$_.JMap? map) + _firstKeyOf; + final jni$_.JObject? Function(jni$_.JMap? map) + _firstValueOf; + + jni$_.JArray? genericArrayOf(jni$_.JObject? object) { + return _genericArrayOf(object); + } + + jni$_.JArray? arrayOf($T? object) { + return _arrayOf(object); + } + + jni$_.JMap? mapOf( + $T? object, jni$_.JObject? object1) { + return _mapOf(object, object1); + } + + jni$_.JObject? firstOfGenericArray(jni$_.JArray? objects) { + return _firstOfGenericArray(objects); + } + + $T? firstOfArray(jni$_.JArray? objects) { + return _firstOfArray(objects); + } + + $T? firstKeyOf(jni$_.JMap? map) { + return _firstKeyOf(map); + } + + jni$_.JObject? firstValueOf(jni$_.JMap? map) { + return _firstValueOf(map); } +} + +final class $GenericInterface$Type$ extends jni$_.JType { + @jni$_.internal + const $GenericInterface$Type$(); + + @jni$_.internal + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/interfaces/GenericInterface;'; +} + +/// from: `com.github.dart_lang.jnigen.interfaces.InheritedFromMyInterface` +extension type InheritedFromMyInterface._(jni$_.JObject _$this) + implements jni$_.JObject, MyInterface { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/interfaces/InheritedFromMyInterface'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $InheritedFromMyInterface$Type$(); /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; + static final core$_.Map _$impls = {}; static jni$_.JObjectPtr _$invoke( int port, jni$_.JObjectPtr descriptor, @@ -6575,56 +4343,15 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { try { final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; - if ($d == r'genericArrayOf(Ljava/lang/Object;)[Ljava/lang/Object;') { - final $r = _$impls[$p]!.genericArrayOf( - $a![0]?.as(const jni$_.$JObject$Type$(), releaseOriginal: true), + if ($d == r'voidCallback(Ljava/lang/String;)V') { + _$impls[$p]!.voidCallback( + ($a![0] as jni$_.JString?), ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'arrayOf(Ljava/lang/Object;)[Ljava/lang/Object;') { - final $r = _$impls[$p]!.arrayOf( - $a![0]?.as(_$impls[$p]!.T, releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'mapOf(Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;') { - final $r = _$impls[$p]!.mapOf( - $a![0]?.as(_$impls[$p]!.T, releaseOriginal: true), - $a![1]?.as(const jni$_.$JObject$Type$(), releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'firstOfGenericArray([Ljava/lang/Object;)Ljava/lang/Object;') { - final $r = _$impls[$p]!.firstOfGenericArray( - $a![0]?.as( - const jni$_.$JArray$Type$( - jni$_.$JObject$NullableType$()), - releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; + return jni$_.nullptr; } - if ($d == r'firstOfArray([Ljava/lang/Object;)Ljava/lang/Object;') { - final $r = _$impls[$p]!.firstOfArray( - $a![0]?.as( - const jni$_.$JArray$Type$( - jni$_.$JObject$NullableType$()), - releaseOriginal: true), + if ($d == r'stringCallback(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.stringCallback( + ($a![0] as jni$_.JString?), ); return ($r as jni$_.JObject?) ?.as(const jni$_.$JObject$Type$()) @@ -6632,13 +4359,9 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { .toPointer() ?? jni$_.nullptr; } - if ($d == r'firstKeyOf(Ljava/util/Map;)Ljava/lang/Object;') { - final $r = _$impls[$p]!.firstKeyOf( - $a![0]?.as( - const jni$_.$JMap$Type$( - jni$_.$JObject$NullableType$(), - jni$_.$JObject$NullableType$()), - releaseOriginal: true), + if ($d == r'varCallback(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.varCallback( + ($a![0] as jni$_.JString?), ); return ($r as jni$_.JObject?) ?.as(const jni$_.$JObject$Type$()) @@ -6646,19 +4369,14 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { .toPointer() ?? jni$_.nullptr; } - if ($d == r'firstValueOf(Ljava/util/Map;)Ljava/lang/Object;') { - final $r = _$impls[$p]!.firstValueOf( - $a![0]?.as( - const jni$_.$JMap$Type$( - jni$_.$JObject$NullableType$(), - jni$_.$JObject$NullableType$()), - releaseOriginal: true), + if ($d == r'manyPrimitives(IZCD)J') { + final $r = _$impls[$p]!.manyPrimitives( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![1] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + ($a![2] as jni$_.JCharacter).charValue(releaseOriginal: true), + ($a![3] as jni$_.JDouble).doubleValue(releaseOriginal: true), ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; + return jni$_.JLong($r).reference.toPointer(); } } catch (e) { return jni$_.ProtectedJniExtensions.newDartException(e); @@ -6666,9 +4384,9 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { return jni$_.nullptr; } - static void implementIn<$T extends jni$_.JObject?>( + static void implementIn( jni$_.JImplementer implementer, - $GenericInterface<$T> $impl, + $InheritedFromMyInterface $impl, ) { late final jni$_.RawReceivePort $p; $p = jni$_.RawReceivePort(($m) { @@ -6682,246 +4400,29 @@ class GenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { jni$_.ProtectedJniExtensions.returnResult($i.result, $r); }); implementer.add( - r'com.github.dart_lang.jnigen.interfaces.GenericInterface', + r'com.github.dart_lang.jnigen.interfaces.InheritedFromMyInterface', $p, _$invokePointer, - [], + [ + if ($impl.voidCallback$async) r'voidCallback(Ljava/lang/String;)V', + ], ); final $a = $p.sendPort.nativePort; _$impls[$a] = $impl; } - factory GenericInterface.implement( - $GenericInterface<$T> $impl, + factory InheritedFromMyInterface.implement( + $InheritedFromMyInterface $impl, ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return GenericInterface<$T>.fromReference( - $impl.T, - $i.implementReference(), - ); - } -} - -abstract base mixin class $GenericInterface<$T extends jni$_.JObject?> { - factory $GenericInterface({ - required jni$_.JType<$T> T, - required jni$_.JArray? Function(jni$_.JObject? object) - genericArrayOf, - required jni$_.JArray? Function($T? object) arrayOf, - required jni$_.JMap? Function( - $T? object, jni$_.JObject? object1) - mapOf, - required jni$_.JObject? Function(jni$_.JArray? objects) - firstOfGenericArray, - required $T? Function(jni$_.JArray? objects) firstOfArray, - required $T? Function(jni$_.JMap? map) - firstKeyOf, - required jni$_.JObject? Function( - jni$_.JMap? map) - firstValueOf, - }) = _$GenericInterface<$T>; - - jni$_.JType<$T> get T; - - jni$_.JArray? genericArrayOf(jni$_.JObject? object); - jni$_.JArray? arrayOf($T? object); - jni$_.JMap? mapOf( - $T? object, jni$_.JObject? object1); - jni$_.JObject? firstOfGenericArray(jni$_.JArray? objects); - $T? firstOfArray(jni$_.JArray? objects); - $T? firstKeyOf(jni$_.JMap? map); - jni$_.JObject? firstValueOf(jni$_.JMap? map); -} - -final class _$GenericInterface<$T extends jni$_.JObject?> - with $GenericInterface<$T> { - _$GenericInterface({ - required this.T, - required jni$_.JArray? Function(jni$_.JObject? object) - genericArrayOf, - required jni$_.JArray? Function($T? object) arrayOf, - required jni$_.JMap? Function( - $T? object, jni$_.JObject? object1) - mapOf, - required jni$_.JObject? Function(jni$_.JArray? objects) - firstOfGenericArray, - required $T? Function(jni$_.JArray? objects) firstOfArray, - required $T? Function(jni$_.JMap? map) - firstKeyOf, - required jni$_.JObject? Function( - jni$_.JMap? map) - firstValueOf, - }) : _genericArrayOf = genericArrayOf, - _arrayOf = arrayOf, - _mapOf = mapOf, - _firstOfGenericArray = firstOfGenericArray, - _firstOfArray = firstOfArray, - _firstKeyOf = firstKeyOf, - _firstValueOf = firstValueOf; - - @core$_.override - final jni$_.JType<$T> T; - - final jni$_.JArray? Function(jni$_.JObject? object) - _genericArrayOf; - final jni$_.JArray? Function($T? object) _arrayOf; - final jni$_.JMap? Function( - $T? object, jni$_.JObject? object1) _mapOf; - final jni$_.JObject? Function(jni$_.JArray? objects) - _firstOfGenericArray; - final $T? Function(jni$_.JArray? objects) _firstOfArray; - final $T? Function(jni$_.JMap? map) - _firstKeyOf; - final jni$_.JObject? Function(jni$_.JMap? map) - _firstValueOf; - - jni$_.JArray? genericArrayOf(jni$_.JObject? object) { - return _genericArrayOf(object); - } - - jni$_.JArray? arrayOf($T? object) { - return _arrayOf(object); - } - - jni$_.JMap? mapOf( - $T? object, jni$_.JObject? object1) { - return _mapOf(object, object1); - } - - jni$_.JObject? firstOfGenericArray(jni$_.JArray? objects) { - return _firstOfGenericArray(objects); - } - - $T? firstOfArray(jni$_.JArray? objects) { - return _firstOfArray(objects); - } - - $T? firstKeyOf(jni$_.JMap? map) { - return _firstKeyOf(map); - } - - jni$_.JObject? firstValueOf(jni$_.JMap? map) { - return _firstValueOf(map); - } -} - -final class $GenericInterface$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $GenericInterface$NullableType$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/GenericInterface;'; - - @jni$_.internal - @core$_.override - GenericInterface<$T>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : GenericInterface<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GenericInterface$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GenericInterface$NullableType$<$T>) && - other is $GenericInterface$NullableType$<$T> && - T == other.T; - } -} - -final class $GenericInterface$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $GenericInterface$Type$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/GenericInterface;'; - - @jni$_.internal - @core$_.override - GenericInterface<$T> fromReference(jni$_.JReference reference) => - GenericInterface<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GenericInterface$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($GenericInterface$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GenericInterface$Type$<$T>) && - other is $GenericInterface$Type$<$T> && - T == other.T; + return $i.implement(); } } -/// from: `com.github.dart_lang.jnigen.interfaces.InheritedFromMyInterface` -class InheritedFromMyInterface extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - InheritedFromMyInterface.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/interfaces/InheritedFromMyInterface'); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $InheritedFromMyInterface$NullableType$(); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType type = - $InheritedFromMyInterface$Type$(); - static final _id_voidCallback = _class.instanceMethodId( +extension InheritedFromMyInterface$$Methods on InheritedFromMyInterface { + static final _id_voidCallback = + InheritedFromMyInterface._class.instanceMethodId( r'voidCallback', r'(Ljava/lang/String;)V', ); @@ -6942,12 +4443,12 @@ class InheritedFromMyInterface extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - _voidCallback(reference.pointer, _id_voidCallback as jni$_.JMethodIDPtr, - _$string.pointer) + _voidCallback(reference.pointer, _id_voidCallback.pointer, _$string.pointer) .check(); } - static final _id_stringCallback = _class.instanceMethodId( + static final _id_stringCallback = + InheritedFromMyInterface._class.instanceMethodId( r'stringCallback', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -6969,12 +4470,13 @@ class InheritedFromMyInterface extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _stringCallback(reference.pointer, - _id_stringCallback as jni$_.JMethodIDPtr, _$string.pointer) - .object(const jni$_.$JString$NullableType$()); + return _stringCallback( + reference.pointer, _id_stringCallback.pointer, _$string.pointer) + .object(); } - static final _id_varCallback = _class.instanceMethodId( + static final _id_varCallback = + InheritedFromMyInterface._class.instanceMethodId( r'varCallback', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -6996,12 +4498,13 @@ class InheritedFromMyInterface extends jni$_.JObject { jni$_.JString? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _varCallback(reference.pointer, - _id_varCallback as jni$_.JMethodIDPtr, _$object.pointer) - .object(const jni$_.$JString$NullableType$()); + return _varCallback( + reference.pointer, _id_varCallback.pointer, _$object.pointer) + .object(); } - static final _id_manyPrimitives = _class.instanceMethodId( + static final _id_manyPrimitives = + InheritedFromMyInterface._class.instanceMethodId( r'manyPrimitives', r'(IZCD)J', ); @@ -7029,136 +4532,20 @@ class InheritedFromMyInterface extends jni$_.JObject { int c, double d, ) { - return _manyPrimitives(reference.pointer, - _id_manyPrimitives as jni$_.JMethodIDPtr, i, z ? 1 : 0, c, d) + return _manyPrimitives( + reference.pointer, _id_manyPrimitives.pointer, i, z ? 1 : 0, c, d) .long; } +} - /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; - static jni$_.JObjectPtr _$invoke( - int port, - jni$_.JObjectPtr descriptor, - jni$_.JObjectPtr args, - ) { - return _$invokeMethod( - port, - jni$_.MethodInvocation.fromAddresses( - 0, - descriptor.address, - args.address, - ), - ); - } - - static final jni$_.Pointer< - jni$_.NativeFunction< - jni$_.JObjectPtr Function( - jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> - _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); - - static jni$_.Pointer _$invokeMethod( - int $p, - jni$_.MethodInvocation $i, - ) { - try { - final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); - final $a = $i.args; - if ($d == r'voidCallback(Ljava/lang/String;)V') { - _$impls[$p]!.voidCallback( - $a![0]?.as(const jni$_.$JString$Type$(), releaseOriginal: true), - ); - return jni$_.nullptr; - } - if ($d == r'stringCallback(Ljava/lang/String;)Ljava/lang/String;') { - final $r = _$impls[$p]!.stringCallback( - $a![0]?.as(const jni$_.$JString$Type$(), releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'varCallback(Ljava/lang/String;)Ljava/lang/String;') { - final $r = _$impls[$p]!.varCallback( - $a![0]?.as(const jni$_.$JString$Type$(), releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'manyPrimitives(IZCD)J') { - final $r = _$impls[$p]!.manyPrimitives( - $a![0]! - .as(const jni$_.$JInteger$Type$(), releaseOriginal: true) - .intValue(releaseOriginal: true), - $a![1]! - .as(const jni$_.$JBoolean$Type$(), releaseOriginal: true) - .booleanValue(releaseOriginal: true), - $a![2]! - .as(const jni$_.$JCharacter$Type$(), releaseOriginal: true) - .charValue(releaseOriginal: true), - $a![3]! - .as(const jni$_.$JDouble$Type$(), releaseOriginal: true) - .doubleValue(releaseOriginal: true), - ); - return jni$_.JLong($r).reference.toPointer(); - } - } catch (e) { - return jni$_.ProtectedJniExtensions.newDartException(e); - } - return jni$_.nullptr; - } - - static void implementIn( - jni$_.JImplementer implementer, - $InheritedFromMyInterface $impl, - ) { - late final jni$_.RawReceivePort $p; - $p = jni$_.RawReceivePort(($m) { - if ($m == null) { - _$impls.remove($p.sendPort.nativePort); - $p.close(); - return; - } - final $i = jni$_.MethodInvocation.fromMessage($m); - final $r = _$invokeMethod($p.sendPort.nativePort, $i); - jni$_.ProtectedJniExtensions.returnResult($i.result, $r); - }); - implementer.add( - r'com.github.dart_lang.jnigen.interfaces.InheritedFromMyInterface', - $p, - _$invokePointer, - [ - if ($impl.voidCallback$async) r'voidCallback(Ljava/lang/String;)V', - ], - ); - final $a = $p.sendPort.nativePort; - _$impls[$a] = $impl; - } - - factory InheritedFromMyInterface.implement( - $InheritedFromMyInterface $impl, - ) { - final $i = jni$_.JImplementer(); - implementIn($i, $impl); - return InheritedFromMyInterface.fromReference( - $i.implementReference(), - ); - } -} - -abstract base mixin class $InheritedFromMyInterface { - factory $InheritedFromMyInterface({ - required void Function(jni$_.JString? string) voidCallback, - core$_.bool voidCallback$async, - required jni$_.JString? Function(jni$_.JString? string) stringCallback, - required jni$_.JString? Function(jni$_.JString? object) varCallback, - required int Function(int i, core$_.bool z, int c, double d) manyPrimitives, - }) = _$InheritedFromMyInterface; +abstract base mixin class $InheritedFromMyInterface { + factory $InheritedFromMyInterface({ + required void Function(jni$_.JString? string) voidCallback, + core$_.bool voidCallback$async, + required jni$_.JString? Function(jni$_.JString? string) stringCallback, + required jni$_.JString? Function(jni$_.JString? object) varCallback, + required int Function(int i, core$_.bool z, int c, double d) manyPrimitives, + }) = _$InheritedFromMyInterface; void voidCallback(jni$_.JString? string); core$_.bool get voidCallback$async => false; @@ -7202,46 +4589,6 @@ final class _$InheritedFromMyInterface with $InheritedFromMyInterface { } } -final class $InheritedFromMyInterface$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $InheritedFromMyInterface$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/InheritedFromMyInterface;'; - - @jni$_.internal - @core$_.override - InheritedFromMyInterface? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : InheritedFromMyInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($InheritedFromMyInterface$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($InheritedFromMyInterface$NullableType$) && - other is $InheritedFromMyInterface$NullableType$; - } -} - final class $InheritedFromMyInterface$Type$ extends jni$_.JType { @jni$_.internal @@ -7251,79 +4598,17 @@ final class $InheritedFromMyInterface$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/InheritedFromMyInterface;'; - - @jni$_.internal - @core$_.override - InheritedFromMyInterface fromReference(jni$_.JReference reference) => - InheritedFromMyInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $InheritedFromMyInterface$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($InheritedFromMyInterface$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($InheritedFromMyInterface$Type$) && - other is $InheritedFromMyInterface$Type$; - } } /// from: `com.github.dart_lang.jnigen.interfaces.InheritedFromMyRunnable` -class InheritedFromMyRunnable extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - InheritedFromMyRunnable.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type InheritedFromMyRunnable._(jni$_.JObject _$this) + implements jni$_.JObject, MyRunnable { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/InheritedFromMyRunnable'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $InheritedFromMyRunnable$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $InheritedFromMyRunnable$Type$(); - static final _id_run = _class.instanceMethodId( - r'run', - r'()V', - ); - - static final _run = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public abstract void run()` - void run() { - _run(reference.pointer, _id_run as jni$_.JMethodIDPtr).check(); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -7397,9 +4682,31 @@ class InheritedFromMyRunnable extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return InheritedFromMyRunnable.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension InheritedFromMyRunnable$$Methods on InheritedFromMyRunnable { + static final _id_run = InheritedFromMyRunnable._class.instanceMethodId( + r'run', + r'()V', + ); + + static final _run = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void run()` + void run() { + _run(reference.pointer, _id_run.pointer).check(); } } @@ -7427,46 +4734,6 @@ final class _$InheritedFromMyRunnable with $InheritedFromMyRunnable { } } -final class $InheritedFromMyRunnable$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $InheritedFromMyRunnable$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/InheritedFromMyRunnable;'; - - @jni$_.internal - @core$_.override - InheritedFromMyRunnable? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : InheritedFromMyRunnable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($InheritedFromMyRunnable$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($InheritedFromMyRunnable$NullableType$) && - other is $InheritedFromMyRunnable$NullableType$; - } -} - final class $InheritedFromMyRunnable$Type$ extends jni$_.JType { @jni$_.internal @@ -7476,82 +4743,135 @@ final class $InheritedFromMyRunnable$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/InheritedFromMyRunnable;'; - - @jni$_.internal - @core$_.override - InheritedFromMyRunnable fromReference(jni$_.JReference reference) => - InheritedFromMyRunnable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $InheritedFromMyRunnable$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($InheritedFromMyRunnable$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($InheritedFromMyRunnable$Type$) && - other is $InheritedFromMyRunnable$Type$; - } } /// from: `com.github.dart_lang.jnigen.interfaces.MyInterface` -class MyInterface<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - MyInterface.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type MyInterface<$T extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/MyInterface'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $MyInterface$NullableType$<$T>( - T, - ); - } + static const jni$_.JType type = $MyInterface$Type$(); - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, ) { - return $MyInterface$Type$<$T>( - T, + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), ); } - static final _id_voidCallback = _class.instanceMethodId( - r'voidCallback', - r'(Ljava/lang/String;)V', - ); + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); - static final _voidCallback = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'voidCallback(Ljava/lang/String;)V') { + _$impls[$p]!.voidCallback( + ($a![0] as jni$_.JString?), + ); + return jni$_.nullptr; + } + if ($d == r'stringCallback(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.stringCallback( + ($a![0] as jni$_.JString?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'varCallback(Ljava/lang/Object;)Ljava/lang/Object;') { + final $r = _$impls[$p]!.varCallback( + ($a![0] as jni$_.JObject?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'manyPrimitives(IZCD)J') { + final $r = _$impls[$p]!.manyPrimitives( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ($a![1] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + ($a![2] as jni$_.JCharacter).charValue(releaseOriginal: true), + ($a![3] as jni$_.JDouble).doubleValue(releaseOriginal: true), + ); + return jni$_.JLong($r).reference.toPointer(); + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$T extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $MyInterface<$T> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.interfaces.MyInterface', + $p, + _$invokePointer, + [ + if ($impl.voidCallback$async) r'voidCallback(Ljava/lang/String;)V', + ], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory MyInterface.implement( + $MyInterface<$T> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } + static core$_.Map get $impls => _$impls; +} + +extension MyInterface$$Methods<$T extends jni$_.JObject?> on MyInterface<$T> { + static final _id_voidCallback = MyInterface._class.instanceMethodId( + r'voidCallback', + r'(Ljava/lang/String;)V', + ); + + static final _voidCallback = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, jni$_.JMethodIDPtr, jni$_.VarArgs<(jni$_.Pointer,)>)>>( 'globalEnv_CallVoidMethod') @@ -7564,12 +4884,11 @@ class MyInterface<$T extends jni$_.JObject?> extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - _voidCallback(reference.pointer, _id_voidCallback as jni$_.JMethodIDPtr, - _$string.pointer) + _voidCallback(reference.pointer, _id_voidCallback.pointer, _$string.pointer) .check(); } - static final _id_stringCallback = _class.instanceMethodId( + static final _id_stringCallback = MyInterface._class.instanceMethodId( r'stringCallback', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -7591,12 +4910,12 @@ class MyInterface<$T extends jni$_.JObject?> extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _stringCallback(reference.pointer, - _id_stringCallback as jni$_.JMethodIDPtr, _$string.pointer) - .object(const jni$_.$JString$NullableType$()); + return _stringCallback( + reference.pointer, _id_stringCallback.pointer, _$string.pointer) + .object(); } - static final _id_varCallback = _class.instanceMethodId( + static final _id_varCallback = MyInterface._class.instanceMethodId( r'varCallback', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -7618,12 +4937,12 @@ class MyInterface<$T extends jni$_.JObject?> extends jni$_.JObject { $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _varCallback(reference.pointer, - _id_varCallback as jni$_.JMethodIDPtr, _$object.pointer) - .object<$T?>(T.nullableType); + return _varCallback( + reference.pointer, _id_varCallback.pointer, _$object.pointer) + .object<$T?>(); } - static final _id_manyPrimitives = _class.instanceMethodId( + static final _id_manyPrimitives = MyInterface._class.instanceMethodId( r'manyPrimitives', r'(IZCD)J', ); @@ -7651,133 +4970,14 @@ class MyInterface<$T extends jni$_.JObject?> extends jni$_.JObject { int c, double d, ) { - return _manyPrimitives(reference.pointer, - _id_manyPrimitives as jni$_.JMethodIDPtr, i, z ? 1 : 0, c, d) + return _manyPrimitives( + reference.pointer, _id_manyPrimitives.pointer, i, z ? 1 : 0, c, d) .long; } - - /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; - static jni$_.JObjectPtr _$invoke( - int port, - jni$_.JObjectPtr descriptor, - jni$_.JObjectPtr args, - ) { - return _$invokeMethod( - port, - jni$_.MethodInvocation.fromAddresses( - 0, - descriptor.address, - args.address, - ), - ); - } - - static final jni$_.Pointer< - jni$_.NativeFunction< - jni$_.JObjectPtr Function( - jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> - _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); - - static jni$_.Pointer _$invokeMethod( - int $p, - jni$_.MethodInvocation $i, - ) { - try { - final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); - final $a = $i.args; - if ($d == r'voidCallback(Ljava/lang/String;)V') { - _$impls[$p]!.voidCallback( - $a![0]?.as(const jni$_.$JString$Type$(), releaseOriginal: true), - ); - return jni$_.nullptr; - } - if ($d == r'stringCallback(Ljava/lang/String;)Ljava/lang/String;') { - final $r = _$impls[$p]!.stringCallback( - $a![0]?.as(const jni$_.$JString$Type$(), releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'varCallback(Ljava/lang/Object;)Ljava/lang/Object;') { - final $r = _$impls[$p]!.varCallback( - $a![0]?.as(_$impls[$p]!.T, releaseOriginal: true), - ); - return ($r as jni$_.JObject?) - ?.as(const jni$_.$JObject$Type$()) - .reference - .toPointer() ?? - jni$_.nullptr; - } - if ($d == r'manyPrimitives(IZCD)J') { - final $r = _$impls[$p]!.manyPrimitives( - $a![0]! - .as(const jni$_.$JInteger$Type$(), releaseOriginal: true) - .intValue(releaseOriginal: true), - $a![1]! - .as(const jni$_.$JBoolean$Type$(), releaseOriginal: true) - .booleanValue(releaseOriginal: true), - $a![2]! - .as(const jni$_.$JCharacter$Type$(), releaseOriginal: true) - .charValue(releaseOriginal: true), - $a![3]! - .as(const jni$_.$JDouble$Type$(), releaseOriginal: true) - .doubleValue(releaseOriginal: true), - ); - return jni$_.JLong($r).reference.toPointer(); - } - } catch (e) { - return jni$_.ProtectedJniExtensions.newDartException(e); - } - return jni$_.nullptr; - } - - static void implementIn<$T extends jni$_.JObject?>( - jni$_.JImplementer implementer, - $MyInterface<$T> $impl, - ) { - late final jni$_.RawReceivePort $p; - $p = jni$_.RawReceivePort(($m) { - if ($m == null) { - _$impls.remove($p.sendPort.nativePort); - $p.close(); - return; - } - final $i = jni$_.MethodInvocation.fromMessage($m); - final $r = _$invokeMethod($p.sendPort.nativePort, $i); - jni$_.ProtectedJniExtensions.returnResult($i.result, $r); - }); - implementer.add( - r'com.github.dart_lang.jnigen.interfaces.MyInterface', - $p, - _$invokePointer, - [ - if ($impl.voidCallback$async) r'voidCallback(Ljava/lang/String;)V', - ], - ); - final $a = $p.sendPort.nativePort; - _$impls[$a] = $impl; - } - - factory MyInterface.implement( - $MyInterface<$T> $impl, - ) { - final $i = jni$_.JImplementer(); - implementIn($i, $impl); - return MyInterface<$T>.fromReference( - $impl.T, - $i.implementReference(), - ); - } - static core$_.Map get $impls => _$impls; } abstract base mixin class $MyInterface<$T extends jni$_.JObject?> { factory $MyInterface({ - required jni$_.JType<$T> T, required void Function(jni$_.JString? string) voidCallback, core$_.bool voidCallback$async, required jni$_.JString? Function(jni$_.JString? string) stringCallback, @@ -7785,8 +4985,6 @@ abstract base mixin class $MyInterface<$T extends jni$_.JObject?> { required int Function(int i, core$_.bool z, int c, double d) manyPrimitives, }) = _$MyInterface<$T>; - jni$_.JType<$T> get T; - void voidCallback(jni$_.JString? string); core$_.bool get voidCallback$async => false; jni$_.JString? stringCallback(jni$_.JString? string); @@ -7796,7 +4994,6 @@ abstract base mixin class $MyInterface<$T extends jni$_.JObject?> { final class _$MyInterface<$T extends jni$_.JObject?> with $MyInterface<$T> { _$MyInterface({ - required this.T, required void Function(jni$_.JString? string) voidCallback, this.voidCallback$async = false, required jni$_.JString? Function(jni$_.JString? string) stringCallback, @@ -7807,9 +5004,6 @@ final class _$MyInterface<$T extends jni$_.JObject?> with $MyInterface<$T> { _varCallback = varCallback, _manyPrimitives = manyPrimitives; - @core$_.override - final jni$_.JType<$T> T; - final void Function(jni$_.JString? string) _voidCallback; final core$_.bool voidCallback$async; final jni$_.JString? Function(jni$_.JString? string) _stringCallback; @@ -7833,117 +5027,22 @@ final class _$MyInterface<$T extends jni$_.JObject?> with $MyInterface<$T> { } } -final class $MyInterface$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $MyInterface$NullableType$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/MyInterface;'; - - @jni$_.internal - @core$_.override - MyInterface<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : MyInterface<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyInterface$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyInterface$NullableType$<$T>) && - other is $MyInterface$NullableType$<$T> && - T == other.T; - } -} - -final class $MyInterface$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - +final class $MyInterface$Type$ extends jni$_.JType { @jni$_.internal - const $MyInterface$Type$( - this.T, - ); + const $MyInterface$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/MyInterface;'; - - @jni$_.internal - @core$_.override - MyInterface<$T> fromReference(jni$_.JReference reference) => - MyInterface<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $MyInterface$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($MyInterface$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyInterface$Type$<$T>) && - other is $MyInterface$Type$<$T> && - T == other.T; - } } /// from: `com.github.dart_lang.jnigen.interfaces.MyInterfaceConsumer` -class MyInterfaceConsumer extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - MyInterfaceConsumer.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type MyInterfaceConsumer._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $MyInterfaceConsumer$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $MyInterfaceConsumer$Type$(); @@ -7966,9 +5065,8 @@ class MyInterfaceConsumer extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory MyInterfaceConsumer() { - return MyInterfaceConsumer.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_consumeOnAnotherThread = _class.staticMethodId( @@ -8011,15 +5109,14 @@ class MyInterfaceConsumer extends jni$_.JObject { core$_.bool z, int c, double d, - $T? object, { - required jni$_.JType<$T> T, - }) { + $T? object, + ) { final _$myInterface = myInterface?.reference ?? jni$_.jNullReference; final _$string = string?.reference ?? jni$_.jNullReference; final _$object = object?.reference ?? jni$_.jNullReference; _consumeOnAnotherThread( _class.reference.pointer, - _id_consumeOnAnotherThread as jni$_.JMethodIDPtr, + _id_consumeOnAnotherThread.pointer, _$myInterface.pointer, _$string.pointer, i, @@ -8070,15 +5167,14 @@ class MyInterfaceConsumer extends jni$_.JObject { core$_.bool z, int c, double d, - $T? object, { - required jni$_.JType<$T> T, - }) { + $T? object, + ) { final _$myInterface = myInterface?.reference ?? jni$_.jNullReference; final _$string = string?.reference ?? jni$_.jNullReference; final _$object = object?.reference ?? jni$_.jNullReference; _consumeOnSameThread( _class.reference.pointer, - _id_consumeOnSameThread as jni$_.JMethodIDPtr, + _id_consumeOnSameThread.pointer, _$myInterface.pointer, _$string.pointer, i, @@ -8090,127 +5186,24 @@ class MyInterfaceConsumer extends jni$_.JObject { } } -final class $MyInterfaceConsumer$NullableType$ - extends jni$_.JType { +final class $MyInterfaceConsumer$Type$ + extends jni$_.JType { @jni$_.internal - const $MyInterfaceConsumer$NullableType$(); + const $MyInterfaceConsumer$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer;'; - - @jni$_.internal - @core$_.override - MyInterfaceConsumer? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : MyInterfaceConsumer.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyInterfaceConsumer$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyInterfaceConsumer$NullableType$) && - other is $MyInterfaceConsumer$NullableType$; - } -} - -final class $MyInterfaceConsumer$Type$ - extends jni$_.JType { - @jni$_.internal - const $MyInterfaceConsumer$Type$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/MyInterfaceConsumer;'; - - @jni$_.internal - @core$_.override - MyInterfaceConsumer fromReference(jni$_.JReference reference) => - MyInterfaceConsumer.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $MyInterfaceConsumer$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyInterfaceConsumer$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyInterfaceConsumer$Type$) && - other is $MyInterfaceConsumer$Type$; - } -} +} /// from: `com.github.dart_lang.jnigen.interfaces.MyRunnable` -class MyRunnable extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - MyRunnable.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type MyRunnable._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/MyRunnable'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $MyRunnable$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $MyRunnable$Type$(); - static final _id_run = _class.instanceMethodId( - r'run', - r'()V', - ); - - static final _run = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public abstract void run()` - void run() { - _run(reference.pointer, _id_run as jni$_.JMethodIDPtr).check(); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -8284,13 +5277,35 @@ class MyRunnable extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return MyRunnable.fromReference( - $i.implementReference(), - ); + return $i.implement(); } static core$_.Map get $impls => _$impls; } +extension MyRunnable$$Methods on MyRunnable { + static final _id_run = MyRunnable._class.instanceMethodId( + r'run', + r'()V', + ); + + static final _run = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract void run()` + void run() { + _run(reference.pointer, _id_run.pointer).check(); + } +} + abstract base mixin class $MyRunnable { factory $MyRunnable({ required void Function() run, @@ -8315,44 +5330,6 @@ final class _$MyRunnable with $MyRunnable { } } -final class $MyRunnable$NullableType$ extends jni$_.JType { - @jni$_.internal - const $MyRunnable$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;'; - - @jni$_.internal - @core$_.override - MyRunnable? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : MyRunnable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyRunnable$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyRunnable$NullableType$) && - other is $MyRunnable$NullableType$; - } -} - final class $MyRunnable$Type$ extends jni$_.JType { @jni$_.internal const $MyRunnable$Type$(); @@ -8361,72 +5338,16 @@ final class $MyRunnable$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;'; - - @jni$_.internal - @core$_.override - MyRunnable fromReference(jni$_.JReference reference) => - MyRunnable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $MyRunnable$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyRunnable$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyRunnable$Type$) && - other is $MyRunnable$Type$; - } } /// from: `com.github.dart_lang.jnigen.interfaces.MyRunnableRunner` -class MyRunnableRunner extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - MyRunnableRunner.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type MyRunnableRunner._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/MyRunnableRunner'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $MyRunnableRunner$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $MyRunnableRunner$Type$(); - static final _id_error = _class.instanceFieldId( - r'error', - r'Ljava/lang/Throwable;', - ); - - /// from: `public java.lang.Throwable error` - /// The returned object must be released after use, by calling the [release] method. - jni$_.JObject? get error => - _id_error.get(this, const jni$_.$JObject$NullableType$()); - - /// from: `public java.lang.Throwable error` - /// The returned object must be released after use, by calling the [release] method. - set error(jni$_.JObject? value) => - _id_error.set(this, const jni$_.$JObject$NullableType$(), value); - static final _id_new$ = _class.constructorId( r'(Lcom/github/dart_lang/jnigen/interfaces/MyRunnable;)V', ); @@ -8448,12 +5369,29 @@ class MyRunnableRunner extends jni$_.JObject { MyRunnable? myRunnable, ) { final _$myRunnable = myRunnable?.reference ?? jni$_.jNullReference; - return MyRunnableRunner.fromReference(_new$(_class.reference.pointer, - _id_new$ as jni$_.JMethodIDPtr, _$myRunnable.pointer) - .reference); + return _new$( + _class.reference.pointer, _id_new$.pointer, _$myRunnable.pointer) + .object(); } +} + +extension MyRunnableRunner$$Methods on MyRunnableRunner { + static final _id_error = MyRunnableRunner._class.instanceFieldId( + r'error', + r'Ljava/lang/Throwable;', + ); + + /// from: `public java.lang.Throwable error` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JObject? get error => + _id_error.getNullable(this, jni$_.JObject.type) as jni$_.JObject?; + + /// from: `public java.lang.Throwable error` + /// The returned object must be released after use, by calling the [release] method. + set error(jni$_.JObject? value) => + _id_error.set(this, jni$_.JObject.type, value); - static final _id_runOnSameThread = _class.instanceMethodId( + static final _id_runOnSameThread = MyRunnableRunner._class.instanceMethodId( r'runOnSameThread', r'()V', ); @@ -8472,12 +5410,11 @@ class MyRunnableRunner extends jni$_.JObject { /// from: `public void runOnSameThread()` void runOnSameThread() { - _runOnSameThread( - reference.pointer, _id_runOnSameThread as jni$_.JMethodIDPtr) - .check(); + _runOnSameThread(reference.pointer, _id_runOnSameThread.pointer).check(); } - static final _id_runOnAnotherThread = _class.instanceMethodId( + static final _id_runOnAnotherThread = + MyRunnableRunner._class.instanceMethodId( r'runOnAnotherThread', r'()V', ); @@ -8496,12 +5433,12 @@ class MyRunnableRunner extends jni$_.JObject { /// from: `public void runOnAnotherThread()` void runOnAnotherThread() { - _runOnAnotherThread( - reference.pointer, _id_runOnAnotherThread as jni$_.JMethodIDPtr) + _runOnAnotherThread(reference.pointer, _id_runOnAnotherThread.pointer) .check(); } - static final _id_runOnAnotherThreadAndJoin = _class.instanceMethodId( + static final _id_runOnAnotherThreadAndJoin = + MyRunnableRunner._class.instanceMethodId( r'runOnAnotherThreadAndJoin', r'()V', ); @@ -8520,52 +5457,12 @@ class MyRunnableRunner extends jni$_.JObject { /// from: `public void runOnAnotherThreadAndJoin()` void runOnAnotherThreadAndJoin() { - _runOnAnotherThreadAndJoin(reference.pointer, - _id_runOnAnotherThreadAndJoin as jni$_.JMethodIDPtr) + _runOnAnotherThreadAndJoin( + reference.pointer, _id_runOnAnotherThreadAndJoin.pointer) .check(); } } -final class $MyRunnableRunner$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $MyRunnableRunner$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/MyRunnableRunner;'; - - @jni$_.internal - @core$_.override - MyRunnableRunner? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : MyRunnableRunner.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyRunnableRunner$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyRunnableRunner$NullableType$) && - other is $MyRunnableRunner$NullableType$; - } -} - final class $MyRunnableRunner$Type$ extends jni$_.JType { @jni$_.internal const $MyRunnableRunner$Type$(); @@ -8574,55 +5471,14 @@ final class $MyRunnableRunner$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/MyRunnableRunner;'; - - @jni$_.internal - @core$_.override - MyRunnableRunner fromReference(jni$_.JReference reference) => - MyRunnableRunner.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $MyRunnableRunner$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyRunnableRunner$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyRunnableRunner$Type$) && - other is $MyRunnableRunner$Type$; - } } /// from: `com.github.dart_lang.jnigen.interfaces.StringConversionException` -class StringConversionException extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - StringConversionException.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type StringConversionException._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/StringConversionException'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $StringConversionException$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $StringConversionException$Type$(); @@ -8647,51 +5503,8 @@ class StringConversionException extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return StringConversionException.fromReference(_new$( - _class.reference.pointer, - _id_new$ as jni$_.JMethodIDPtr, - _$string.pointer) - .reference); - } -} - -final class $StringConversionException$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $StringConversionException$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/StringConversionException;'; - - @jni$_.internal - @core$_.override - StringConversionException? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : StringConversionException.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($StringConversionException$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringConversionException$NullableType$) && - other is $StringConversionException$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer, _$string.pointer) + .object(); } } @@ -8704,82 +5517,16 @@ final class $StringConversionException$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/StringConversionException;'; - - @jni$_.internal - @core$_.override - StringConversionException fromReference(jni$_.JReference reference) => - StringConversionException.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $StringConversionException$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($StringConversionException$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringConversionException$Type$) && - other is $StringConversionException$Type$; - } } /// from: `com.github.dart_lang.jnigen.interfaces.StringConverter` -class StringConverter extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - StringConverter.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type StringConverter._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/StringConverter'); /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $StringConverter$NullableType$(); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType type = $StringConverter$Type$(); - static final _id_parseToInt = _class.instanceMethodId( - r'parseToInt', - r'(Ljava/lang/String;)I', - ); - - static final _parseToInt = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallIntMethod') - .asFunction< - jni$_.JniResult Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public abstract int parseToInt(java.lang.String string)` - int parseToInt( - jni$_.JString? string, - ) { - final _$string = string?.reference ?? jni$_.jNullReference; - return _parseToInt(reference.pointer, _id_parseToInt as jni$_.JMethodIDPtr, - _$string.pointer) - .integer; - } + static const jni$_.JType type = $StringConverter$Type$(); /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -8813,7 +5560,7 @@ class StringConverter extends jni$_.JObject { final $a = $i.args; if ($d == r'parseToInt(Ljava/lang/String;)I') { final $r = _$impls[$p]!.parseToInt( - $a![0]?.as(const jni$_.$JString$Type$(), releaseOriginal: true), + ($a![0] as jni$_.JString?), ); return jni$_.JInteger($r).reference.toPointer(); } @@ -8853,9 +5600,35 @@ class StringConverter extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return StringConverter.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension StringConverter$$Methods on StringConverter { + static final _id_parseToInt = StringConverter._class.instanceMethodId( + r'parseToInt', + r'(Ljava/lang/String;)I', + ); + + static final _parseToInt = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract int parseToInt(java.lang.String string)` + int parseToInt( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _parseToInt( + reference.pointer, _id_parseToInt.pointer, _$string.pointer) + .integer; } } @@ -8879,45 +5652,6 @@ final class _$StringConverter with $StringConverter { } } -final class $StringConverter$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $StringConverter$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/StringConverter;'; - - @jni$_.internal - @core$_.override - StringConverter? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : StringConverter.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($StringConverter$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringConverter$NullableType$) && - other is $StringConverter$NullableType$; - } -} - final class $StringConverter$Type$ extends jni$_.JType { @jni$_.internal const $StringConverter$Type$(); @@ -8926,55 +5660,14 @@ final class $StringConverter$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/StringConverter;'; - - @jni$_.internal - @core$_.override - StringConverter fromReference(jni$_.JReference reference) => - StringConverter.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $StringConverter$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($StringConverter$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringConverter$Type$) && - other is $StringConverter$Type$; - } } /// from: `com.github.dart_lang.jnigen.interfaces.StringConverterConsumer` -class StringConverterConsumer extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - StringConverterConsumer.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type StringConverterConsumer._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/interfaces/StringConverterConsumer'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $StringConverterConsumer$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $StringConverterConsumer$Type$(); @@ -8997,9 +5690,8 @@ class StringConverterConsumer extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory StringConverterConsumer() { - return StringConverterConsumer.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } static final _id_consumeOnSameThread = _class.staticMethodId( @@ -9035,10 +5727,10 @@ class StringConverterConsumer extends jni$_.JObject { final _$string = string?.reference ?? jni$_.jNullReference; return _consumeOnSameThread( _class.reference.pointer, - _id_consumeOnSameThread as jni$_.JMethodIDPtr, + _id_consumeOnSameThread.pointer, _$stringConverter.pointer, _$string.pointer) - .object(const jni$_.$JInteger$NullableType$()); + .object(); } static final _id_consumeOnAnotherThread = _class.staticMethodId( @@ -9074,129 +5766,177 @@ class StringConverterConsumer extends jni$_.JObject { final _$string = string?.reference ?? jni$_.jNullReference; return _consumeOnAnotherThread( _class.reference.pointer, - _id_consumeOnAnotherThread as jni$_.JMethodIDPtr, + _id_consumeOnAnotherThread.pointer, _$stringConverter.pointer, _$string.pointer) - .object(const jni$_.$JObject$NullableType$()); + .object(); } } -final class $StringConverterConsumer$NullableType$ - extends jni$_.JType { +final class $StringConverterConsumer$Type$ + extends jni$_.JType { @jni$_.internal - const $StringConverterConsumer$NullableType$(); + const $StringConverterConsumer$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/interfaces/StringConverterConsumer;'; +} - @jni$_.internal - @core$_.override - StringConverterConsumer? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : StringConverterConsumer.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); +/// from: `com.github.dart_lang.jnigen.inheritance.Animal` +extension type Animal._(jni$_.JObject _$this) implements jni$_.JObject { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/inheritance/Animal'); - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Animal$Type$(); - @jni$_.internal - @core$_.override - final superCount = 1; + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } - @core$_.override - int get hashCode => ($StringConverterConsumer$NullableType$).hashCode; + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringConverterConsumer$NullableType$) && - other is $StringConverterConsumer$NullableType$; + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'eat(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.eat( + ($a![0] as jni$_.JString), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn( + jni$_.JImplementer implementer, + $Animal $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.inheritance.Animal', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory Animal.implement( + $Animal $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement(); } } -final class $StringConverterConsumer$Type$ - extends jni$_.JType { - @jni$_.internal - const $StringConverterConsumer$Type$(); +extension Animal$$Methods on Animal { + static final _id_eat = Animal._class.instanceMethodId( + r'eat', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/interfaces/StringConverterConsumer;'; + static final _eat = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - @jni$_.internal - @core$_.override - StringConverterConsumer fromReference(jni$_.JReference reference) => - StringConverterConsumer.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + /// from: `public abstract java.lang.String eat(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString eat( + jni$_.JString string, + ) { + final _$string = string.reference; + return _eat(reference.pointer, _id_eat.pointer, _$string.pointer) + .object(); + } +} - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $StringConverterConsumer$NullableType$(); +abstract base mixin class $Animal { + factory $Animal({ + required jni$_.JString Function(jni$_.JString string) eat, + }) = _$Animal; - @jni$_.internal - @core$_.override - final superCount = 1; + jni$_.JString eat(jni$_.JString string); +} - @core$_.override - int get hashCode => ($StringConverterConsumer$Type$).hashCode; +final class _$Animal with $Animal { + _$Animal({ + required jni$_.JString Function(jni$_.JString string) eat, + }) : _eat = eat; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($StringConverterConsumer$Type$) && - other is $StringConverterConsumer$Type$; + final jni$_.JString Function(jni$_.JString string) _eat; + + jni$_.JString eat(jni$_.JString string) { + return _eat(string); } } -/// from: `com.github.dart_lang.jnigen.inheritance.BaseClass` -class BaseClass<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - +final class $Animal$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$T> T; + const $Animal$Type$(); @jni$_.internal - BaseClass.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); + @core$_.override + String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/Animal;'; +} +/// from: `com.github.dart_lang.jnigen.inheritance.BaseClass` +extension type BaseClass<$T extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/inheritance/BaseClass'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $BaseClass$NullableType$<$T>( - T, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $BaseClass$Type$<$T>( - T, - ); - } - + static const jni$_.JType type = $BaseClass$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -9215,172 +5955,944 @@ class BaseClass<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory BaseClass({ - required jni$_.JType<$T> T, - }) { - return BaseClass<$T>.fromReference( - T, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + factory BaseClass() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } } -final class $BaseClass$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; +extension BaseClass$$Methods<$T extends jni$_.JObject?> on BaseClass<$T> { + static final _id_someMethod = BaseClass._class.instanceMethodId( + r'someMethod', + r'(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;', + ); + + static final _someMethod = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public T someMethod(T charSequence)` + /// The returned object must be released after use, by calling the [release] method. + $T? someMethod( + $T? charSequence, + ) { + final _$charSequence = charSequence?.reference ?? jni$_.jNullReference; + return _someMethod( + reference.pointer, _id_someMethod.pointer, _$charSequence.pointer) + .object<$T?>(); + } +} +final class $BaseClass$Type$ extends jni$_.JType { @jni$_.internal - const $BaseClass$NullableType$( - this.T, - ); + const $BaseClass$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/BaseClass;'; +} - @jni$_.internal +/// from: `com.github.dart_lang.jnigen.inheritance.BaseGenericInterface` +extension type BaseGenericInterface<$T extends jni$_.JObject?>._( + jni$_.JObject _$this) implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/inheritance/BaseGenericInterface'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = + $BaseGenericInterface$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'foo()Ljava/lang/Object;') { + final $r = _$impls[$p]!.foo(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn<$T extends jni$_.JObject?>( + jni$_.JImplementer implementer, + $BaseGenericInterface<$T> $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.inheritance.BaseGenericInterface', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory BaseGenericInterface.implement( + $BaseGenericInterface<$T> $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement>(); + } +} + +extension BaseGenericInterface$$Methods<$T extends jni$_.JObject?> + on BaseGenericInterface<$T> { + static final _id_foo = BaseGenericInterface._class.instanceMethodId( + r'foo', + r'()Ljava/lang/Object;', + ); + + static final _foo = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract T foo()` + /// The returned object must be released after use, by calling the [release] method. + $T? foo() { + return _foo(reference.pointer, _id_foo.pointer).object<$T?>(); + } +} + +abstract base mixin class $BaseGenericInterface<$T extends jni$_.JObject?> { + factory $BaseGenericInterface({ + required $T? Function() foo, + }) = _$BaseGenericInterface<$T>; + + $T? foo(); +} + +final class _$BaseGenericInterface<$T extends jni$_.JObject?> + with $BaseGenericInterface<$T> { + _$BaseGenericInterface({ + required $T? Function() foo, + }) : _foo = foo; + + final $T? Function() _foo; + + $T? foo() { + return _foo(); + } +} + +final class $BaseGenericInterface$Type$ + extends jni$_.JType { + @jni$_.internal + const $BaseGenericInterface$Type$(); + + @jni$_.internal @core$_.override - BaseClass<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : BaseClass<$T>.fromReference( - T, - reference, + String get signature => + r'Lcom/github/dart_lang/jnigen/inheritance/BaseGenericInterface;'; +} + +/// from: `com.github.dart_lang.jnigen.inheritance.BaseInterface` +extension type BaseInterface._(jni$_.JObject _$this) implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/inheritance/BaseInterface'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $BaseInterface$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'foo()Ljava/lang/String;') { + final $r = _$impls[$p]!.foo(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'someMethod(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.someMethod( + ($a![0] as jni$_.JString?), ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn( + jni$_.JImplementer implementer, + $BaseInterface $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.inheritance.BaseInterface', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory BaseInterface.implement( + $BaseInterface $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement(); + } +} + +extension BaseInterface$$Methods on BaseInterface { + static final _id_foo = BaseInterface._class.instanceMethodId( + r'foo', + r'()Ljava/lang/String;', + ); + + static final _foo = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.lang.String foo()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? foo() { + return _foo(reference.pointer, _id_foo.pointer).object(); + } + + static final _id_someMethod = BaseInterface._class.instanceMethodId( + r'someMethod', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _someMethod = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.String someMethod(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? someMethod( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _someMethod( + reference.pointer, _id_someMethod.pointer, _$string.pointer) + .object(); + } +} + +abstract base mixin class $BaseInterface { + factory $BaseInterface({ + required jni$_.JString? Function() foo, + required jni$_.JString? Function(jni$_.JString? string) someMethod, + }) = _$BaseInterface; + + jni$_.JString? foo(); + jni$_.JString? someMethod(jni$_.JString? string); +} + +final class _$BaseInterface with $BaseInterface { + _$BaseInterface({ + required jni$_.JString? Function() foo, + required jni$_.JString? Function(jni$_.JString? string) someMethod, + }) : _foo = foo, + _someMethod = someMethod; + + final jni$_.JString? Function() _foo; + final jni$_.JString? Function(jni$_.JString? string) _someMethod; + + jni$_.JString? foo() { + return _foo(); + } + + jni$_.JString? someMethod(jni$_.JString? string) { + return _someMethod(string); + } +} + +final class $BaseInterface$Type$ extends jni$_.JType { + @jni$_.internal + const $BaseInterface$Type$(); + + @jni$_.internal + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/inheritance/BaseInterface;'; +} + +/// from: `com.github.dart_lang.jnigen.inheritance.Child` +extension type Child._(jni$_.JObject _$this) + implements BaseClass, BaseInterface { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/inheritance/Child'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Child$Type$(); + static final _id_new$ = _class.constructorId( + r'()V', + ); + + static final _new$ = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_NewObject') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public void ()` + /// The returned object must be released after use, by calling the [release] method. + factory Child() { + return _new$(_class.reference.pointer, _id_new$.pointer).object(); + } +} + +extension Child$$Methods on Child { + static final _id_foo = Child._class.instanceMethodId( + r'foo', + r'()Ljava/lang/String;', + ); + + static final _foo = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public java.lang.String foo()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? foo() { + return _foo(reference.pointer, _id_foo.pointer).object(); + } + + static final _id_someMethod$1 = Child._class.instanceMethodId( + r'someMethod', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _someMethod$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.String someMethod(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? someMethod$1( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _someMethod$1( + reference.pointer, _id_someMethod$1.pointer, _$string.pointer) + .object(); + } +} + +final class $Child$Type$ extends jni$_.JType { + @jni$_.internal + const $Child$Type$(); + @jni$_.internal @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/Child;'; +} + +/// from: `com.github.dart_lang.jnigen.inheritance.DerivedInterface` +extension type DerivedInterface._(jni$_.JObject _$this) + implements + jni$_.JObject, + BaseGenericInterface, + BaseInterface { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/inheritance/DerivedInterface'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $DerivedInterface$Type$(); + + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } + + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'foo()Ljava/lang/String;') { + final $r = _$impls[$p]!.foo(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'someMethod(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.someMethod( + ($a![0] as jni$_.JString?), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn( + jni$_.JImplementer implementer, + $DerivedInterface $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.inheritance.DerivedInterface', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; + factory DerivedInterface.implement( + $DerivedInterface $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement(); + } +} - @jni$_.internal - @core$_.override - final superCount = 1; +extension DerivedInterface$$Methods on DerivedInterface { + static final _id_foo = DerivedInterface._class.instanceMethodId( + r'foo', + r'()Ljava/lang/String;', + ); - @core$_.override - int get hashCode => Object.hash($BaseClass$NullableType$, T); + static final _foo = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($BaseClass$NullableType$<$T>) && - other is $BaseClass$NullableType$<$T> && - T == other.T; + /// from: `public abstract java.lang.String foo()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? foo() { + return _foo(reference.pointer, _id_foo.pointer).object(); + } + + static final _id_someMethod = DerivedInterface._class.instanceMethodId( + r'someMethod', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _someMethod = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.String someMethod(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? someMethod( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _someMethod( + reference.pointer, _id_someMethod.pointer, _$string.pointer) + .object(); } } -final class $BaseClass$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; +abstract base mixin class $DerivedInterface { + factory $DerivedInterface({ + required jni$_.JString? Function() foo, + required jni$_.JString? Function(jni$_.JString? string) someMethod, + }) = _$DerivedInterface; + + jni$_.JString? foo(); + jni$_.JString? someMethod(jni$_.JString? string); +} + +final class _$DerivedInterface with $DerivedInterface { + _$DerivedInterface({ + required jni$_.JString? Function() foo, + required jni$_.JString? Function(jni$_.JString? string) someMethod, + }) : _foo = foo, + _someMethod = someMethod; + + final jni$_.JString? Function() _foo; + final jni$_.JString? Function(jni$_.JString? string) _someMethod; + + jni$_.JString? foo() { + return _foo(); + } + jni$_.JString? someMethod(jni$_.JString? string) { + return _someMethod(string); + } +} + +final class $DerivedInterface$Type$ extends jni$_.JType { @jni$_.internal - const $BaseClass$Type$( - this.T, - ); + const $DerivedInterface$Type$(); @jni$_.internal @core$_.override String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/BaseClass;'; + r'Lcom/github/dart_lang/jnigen/inheritance/DerivedInterface;'; +} - @jni$_.internal - @core$_.override - BaseClass<$T> fromReference(jni$_.JReference reference) => - BaseClass<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); +/// from: `com.github.dart_lang.jnigen.inheritance.Dog` +extension type Dog._(jni$_.JObject _$this) + implements jni$_.JObject, Mammal, FourLegged { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/inheritance/Dog'); - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $BaseClass$NullableType$<$T>(T); + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Dog$Type$(); - @jni$_.internal - @core$_.override - final superCount = 1; + /// Maps a specific port to the implemented interface. + static final core$_.Map _$impls = {}; + static jni$_.JObjectPtr _$invoke( + int port, + jni$_.JObjectPtr descriptor, + jni$_.JObjectPtr args, + ) { + return _$invokeMethod( + port, + jni$_.MethodInvocation.fromAddresses( + 0, + descriptor.address, + args.address, + ), + ); + } - @core$_.override - int get hashCode => Object.hash($BaseClass$Type$, T); + static final jni$_.Pointer< + jni$_.NativeFunction< + jni$_.JObjectPtr Function( + jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)>> + _$invokePointer = jni$_.Pointer.fromFunction(_$invoke); + + static jni$_.Pointer _$invokeMethod( + int $p, + jni$_.MethodInvocation $i, + ) { + try { + final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); + final $a = $i.args; + if ($d == r'bark()Ljava/lang/String;') { + final $r = _$impls[$p]!.bark(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'giveBirth(Z)Ljava/lang/String;') { + final $r = _$impls[$p]!.giveBirth( + ($a![0] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'eat(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.eat( + ($a![0] as jni$_.JString), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'walk(I)I') { + final $r = _$impls[$p]!.walk( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ); + return jni$_.JInteger($r).reference.toPointer(); + } + } catch (e) { + return jni$_.ProtectedJniExtensions.newDartException(e); + } + return jni$_.nullptr; + } + + static void implementIn( + jni$_.JImplementer implementer, + $Dog $impl, + ) { + late final jni$_.RawReceivePort $p; + $p = jni$_.RawReceivePort(($m) { + if ($m == null) { + _$impls.remove($p.sendPort.nativePort); + $p.close(); + return; + } + final $i = jni$_.MethodInvocation.fromMessage($m); + final $r = _$invokeMethod($p.sendPort.nativePort, $i); + jni$_.ProtectedJniExtensions.returnResult($i.result, $r); + }); + implementer.add( + r'com.github.dart_lang.jnigen.inheritance.Dog', + $p, + _$invokePointer, + [], + ); + final $a = $p.sendPort.nativePort; + _$impls[$a] = $impl; + } + + factory Dog.implement( + $Dog $impl, + ) { + final $i = jni$_.JImplementer(); + implementIn($i, $impl); + return $i.implement(); + } +} + +extension Dog$$Methods on Dog { + static final _id_bark = Dog._class.instanceMethodId( + r'bark', + r'()Ljava/lang/String;', + ); + + static final _bark = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract java.lang.String bark()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString bark() { + return _bark(reference.pointer, _id_bark.pointer).object(); + } + + static final _id_giveBirth = Dog._class.instanceMethodId( + r'giveBirth', + r'(Z)Ljava/lang/String;', + ); + + static final _giveBirth = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); + + /// from: `public abstract java.lang.String giveBirth(boolean z)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? giveBirth( + core$_.bool z, + ) { + return _giveBirth(reference.pointer, _id_giveBirth.pointer, z ? 1 : 0) + .object(); + } + + static final _id_eat = Dog._class.instanceMethodId( + r'eat', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); + + static final _eat = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract java.lang.String eat(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString eat( + jni$_.JString string, + ) { + final _$string = string.reference; + return _eat(reference.pointer, _id_eat.pointer, _$string.pointer) + .object(); + } + + static final _id_walk = Dog._class.instanceMethodId( + r'walk', + r'(I)I', + ); + + static final _walk = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($BaseClass$Type$<$T>) && - other is $BaseClass$Type$<$T> && - T == other.T; + /// from: `public abstract int walk(int i)` + int walk( + int i, + ) { + return _walk(reference.pointer, _id_walk.pointer, i).integer; } } -/// from: `com.github.dart_lang.jnigen.inheritance.BaseGenericInterface` -class BaseGenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; +abstract base mixin class $Dog { + factory $Dog({ + required jni$_.JString Function() bark, + required jni$_.JString? Function(core$_.bool z) giveBirth, + required jni$_.JString Function(jni$_.JString string) eat, + required int Function(int i) walk, + }) = _$Dog; - @jni$_.internal - final jni$_.JType<$T> T; + jni$_.JString bark(); + jni$_.JString? giveBirth(core$_.bool z); + jni$_.JString eat(jni$_.JString string); + int walk(int i); +} - @jni$_.internal - BaseGenericInterface.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); +final class _$Dog with $Dog { + _$Dog({ + required jni$_.JString Function() bark, + required jni$_.JString? Function(core$_.bool z) giveBirth, + required jni$_.JString Function(jni$_.JString string) eat, + required int Function(int i) walk, + }) : _bark = bark, + _giveBirth = giveBirth, + _eat = eat, + _walk = walk; - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/inheritance/BaseGenericInterface'); + final jni$_.JString Function() _bark; + final jni$_.JString? Function(core$_.bool z) _giveBirth; + final jni$_.JString Function(jni$_.JString string) _eat; + final int Function(int i) _walk; - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $BaseGenericInterface$NullableType$<$T>( - T, - ); + jni$_.JString bark() { + return _bark(); } - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $BaseGenericInterface$Type$<$T>( - T, - ); + jni$_.JString? giveBirth(core$_.bool z) { + return _giveBirth(z); } - static final _id_foo = _class.instanceMethodId( - r'foo', - r'()Ljava/lang/Object;', - ); - - static final _foo = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); + jni$_.JString eat(jni$_.JString string) { + return _eat(string); + } - /// from: `public abstract T foo()` - /// The returned object must be released after use, by calling the [release] method. - $T? foo() { - return _foo(reference.pointer, _id_foo as jni$_.JMethodIDPtr) - .object<$T?>(T.nullableType); + int walk(int i) { + return _walk(i); } +} + +final class $Dog$Type$ extends jni$_.JType { + @jni$_.internal + const $Dog$Type$(); + + @jni$_.internal + @core$_.override + String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/Dog;'; +} + +/// from: `com.github.dart_lang.jnigen.inheritance.FourLegged` +extension type FourLegged._(jni$_.JObject _$this) + implements jni$_.JObject, Animal { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/inheritance/FourLegged'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $FourLegged$Type$(); /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; + static final core$_.Map _$impls = {}; static jni$_.JObjectPtr _$invoke( int port, jni$_.JObjectPtr descriptor, @@ -9409,8 +6921,16 @@ class BaseGenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { try { final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; - if ($d == r'foo()Ljava/lang/Object;') { - final $r = _$impls[$p]!.foo(); + if ($d == r'walk(I)I') { + final $r = _$impls[$p]!.walk( + ($a![0] as jni$_.JInteger).intValue(releaseOriginal: true), + ); + return jni$_.JInteger($r).reference.toPointer(); + } + if ($d == r'eat(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.eat( + ($a![0] as jni$_.JString), + ); return ($r as jni$_.JObject?) ?.as(const jni$_.$JObject$Type$()) .reference @@ -9423,9 +6943,9 @@ class BaseGenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { return jni$_.nullptr; } - static void implementIn<$T extends jni$_.JObject?>( + static void implementIn( jni$_.JImplementer implementer, - $BaseGenericInterface<$T> $impl, + $FourLegged $impl, ) { late final jni$_.RawReceivePort $p; $p = jni$_.RawReceivePort(($m) { @@ -9439,7 +6959,7 @@ class BaseGenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { jni$_.ProtectedJniExtensions.returnResult($i.result, $r); }); implementer.add( - r'com.github.dart_lang.jnigen.inheritance.BaseGenericInterface', + r'com.github.dart_lang.jnigen.inheritance.FourLegged', $p, _$invokePointer, [], @@ -9448,186 +6968,114 @@ class BaseGenericInterface<$T extends jni$_.JObject?> extends jni$_.JObject { _$impls[$a] = $impl; } - factory BaseGenericInterface.implement( - $BaseGenericInterface<$T> $impl, + factory FourLegged.implement( + $FourLegged $impl, ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return BaseGenericInterface<$T>.fromReference( - $impl.T, - $i.implementReference(), - ); + return $i.implement(); } } -abstract base mixin class $BaseGenericInterface<$T extends jni$_.JObject?> { - factory $BaseGenericInterface({ - required jni$_.JType<$T> T, - required $T? Function() foo, - }) = _$BaseGenericInterface<$T>; - - jni$_.JType<$T> get T; +extension FourLegged$$Methods on FourLegged { + static final _id_walk = FourLegged._class.instanceMethodId( + r'walk', + r'(I)I', + ); - $T? foo(); -} + static final _walk = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); -final class _$BaseGenericInterface<$T extends jni$_.JObject?> - with $BaseGenericInterface<$T> { - _$BaseGenericInterface({ - required this.T, - required $T? Function() foo, - }) : _foo = foo; + /// from: `public abstract int walk(int i)` + int walk( + int i, + ) { + return _walk(reference.pointer, _id_walk.pointer, i).integer; + } - @core$_.override - final jni$_.JType<$T> T; + static final _id_eat = FourLegged._class.instanceMethodId( + r'eat', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); - final $T? Function() _foo; + static final _eat = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - $T? foo() { - return _foo(); + /// from: `public abstract java.lang.String eat(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString eat( + jni$_.JString string, + ) { + final _$string = string.reference; + return _eat(reference.pointer, _id_eat.pointer, _$string.pointer) + .object(); } } -final class $BaseGenericInterface$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $BaseGenericInterface$NullableType$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/BaseGenericInterface;'; +abstract base mixin class $FourLegged { + factory $FourLegged({ + required int Function(int i) walk, + required jni$_.JString Function(jni$_.JString string) eat, + }) = _$FourLegged; - @jni$_.internal - @core$_.override - BaseGenericInterface<$T>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : BaseGenericInterface<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + int walk(int i); + jni$_.JString eat(jni$_.JString string); +} - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; +final class _$FourLegged with $FourLegged { + _$FourLegged({ + required int Function(int i) walk, + required jni$_.JString Function(jni$_.JString string) eat, + }) : _walk = walk, + _eat = eat; - @jni$_.internal - @core$_.override - final superCount = 1; + final int Function(int i) _walk; + final jni$_.JString Function(jni$_.JString string) _eat; - @core$_.override - int get hashCode => Object.hash($BaseGenericInterface$NullableType$, T); + int walk(int i) { + return _walk(i); + } - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($BaseGenericInterface$NullableType$<$T>) && - other is $BaseGenericInterface$NullableType$<$T> && - T == other.T; + jni$_.JString eat(jni$_.JString string) { + return _eat(string); } } -final class $BaseGenericInterface$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { +final class $FourLegged$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $BaseGenericInterface$Type$( - this.T, - ); + const $FourLegged$Type$(); @jni$_.internal @core$_.override String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/BaseGenericInterface;'; - - @jni$_.internal - @core$_.override - BaseGenericInterface<$T> fromReference(jni$_.JReference reference) => - BaseGenericInterface<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $BaseGenericInterface$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($BaseGenericInterface$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($BaseGenericInterface$Type$<$T>) && - other is $BaseGenericInterface$Type$<$T> && - T == other.T; - } + r'Lcom/github/dart_lang/jnigen/inheritance/FourLegged;'; } -/// from: `com.github.dart_lang.jnigen.inheritance.BaseInterface` -class BaseInterface extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - BaseInterface.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/inheritance/BaseInterface'); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $BaseInterface$NullableType$(); +/// from: `com.github.dart_lang.jnigen.inheritance.Furry` +extension type Furry._(jni$_.JObject _$this) implements jni$_.JObject, Mammal { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/inheritance/Furry'); /// The type which includes information such as the signature of this class. - static const jni$_.JType type = $BaseInterface$Type$(); - static final _id_foo = _class.instanceMethodId( - r'foo', - r'()Ljava/lang/String;', - ); - - static final _foo = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public abstract java.lang.String foo()` - /// The returned object must be released after use, by calling the [release] method. - jni$_.JString? foo() { - return _foo(reference.pointer, _id_foo as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); - } + static const jni$_.JType type = $Furry$Type$(); /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; + static final core$_.Map _$impls = {}; static jni$_.JObjectPtr _$invoke( int port, jni$_.JObjectPtr descriptor, @@ -9656,8 +7104,28 @@ class BaseInterface extends jni$_.JObject { try { final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; - if ($d == r'foo()Ljava/lang/String;') { - final $r = _$impls[$p]!.foo(); + if ($d == r'groom()Ljava/lang/String;') { + final $r = _$impls[$p]!.groom(); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'giveBirth(Z)Ljava/lang/String;') { + final $r = _$impls[$p]!.giveBirth( + ($a![0] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'eat(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.eat( + ($a![0] as jni$_.JString), + ); return ($r as jni$_.JObject?) ?.as(const jni$_.$JObject$Type$()) .reference @@ -9672,7 +7140,7 @@ class BaseInterface extends jni$_.JObject { static void implementIn( jni$_.JImplementer implementer, - $BaseInterface $impl, + $Furry $impl, ) { late final jni$_.RawReceivePort $p; $p = jni$_.RawReceivePort(($m) { @@ -9686,7 +7154,7 @@ class BaseInterface extends jni$_.JObject { jni$_.ProtectedJniExtensions.returnResult($i.result, $r); }); implementer.add( - r'com.github.dart_lang.jnigen.inheritance.BaseInterface', + r'com.github.dart_lang.jnigen.inheritance.Furry', $p, _$invokePointer, [], @@ -9695,160 +7163,191 @@ class BaseInterface extends jni$_.JObject { _$impls[$a] = $impl; } - factory BaseInterface.implement( - $BaseInterface $impl, + factory Furry.implement( + $Furry $impl, ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return BaseInterface.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } -abstract base mixin class $BaseInterface { - factory $BaseInterface({ - required jni$_.JString? Function() foo, - }) = _$BaseInterface; - - jni$_.JString? foo(); -} - -final class _$BaseInterface with $BaseInterface { - _$BaseInterface({ - required jni$_.JString? Function() foo, - }) : _foo = foo; +extension Furry$$Methods on Furry { + static final _id_groom = Furry._class.instanceMethodId( + r'groom', + r'()Ljava/lang/String;', + ); - final jni$_.JString? Function() _foo; + static final _groom = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - jni$_.JString? foo() { - return _foo(); + /// from: `public abstract java.lang.String groom()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString groom() { + return _groom(reference.pointer, _id_groom.pointer).object(); } -} - -final class $BaseInterface$NullableType$ extends jni$_.JType { - @jni$_.internal - const $BaseInterface$NullableType$(); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/BaseInterface;'; + static final _id_giveBirth = Furry._class.instanceMethodId( + r'giveBirth', + r'(Z)Ljava/lang/String;', + ); - @jni$_.internal - @core$_.override - BaseInterface? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : BaseInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + static final _giveBirth = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; + /// from: `public abstract java.lang.String giveBirth(boolean z)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? giveBirth( + core$_.bool z, + ) { + return _giveBirth(reference.pointer, _id_giveBirth.pointer, z ? 1 : 0) + .object(); + } - @jni$_.internal - @core$_.override - final superCount = 1; + static final _id_eat = Furry._class.instanceMethodId( + r'eat', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); - @core$_.override - int get hashCode => ($BaseInterface$NullableType$).hashCode; + static final _eat = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($BaseInterface$NullableType$) && - other is $BaseInterface$NullableType$; + /// from: `public abstract java.lang.String eat(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString eat( + jni$_.JString string, + ) { + final _$string = string.reference; + return _eat(reference.pointer, _id_eat.pointer, _$string.pointer) + .object(); } } -final class $BaseInterface$Type$ extends jni$_.JType { - @jni$_.internal - const $BaseInterface$Type$(); +abstract base mixin class $Furry { + factory $Furry({ + required jni$_.JString Function() groom, + required jni$_.JString? Function(core$_.bool z) giveBirth, + required jni$_.JString Function(jni$_.JString string) eat, + }) = _$Furry; - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/BaseInterface;'; + jni$_.JString groom(); + jni$_.JString? giveBirth(core$_.bool z); + jni$_.JString eat(jni$_.JString string); +} - @jni$_.internal - @core$_.override - BaseInterface fromReference(jni$_.JReference reference) => - BaseInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); +final class _$Furry with $Furry { + _$Furry({ + required jni$_.JString Function() groom, + required jni$_.JString? Function(core$_.bool z) giveBirth, + required jni$_.JString Function(jni$_.JString string) eat, + }) : _groom = groom, + _giveBirth = giveBirth, + _eat = eat; - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $BaseInterface$NullableType$(); + final jni$_.JString Function() _groom; + final jni$_.JString? Function(core$_.bool z) _giveBirth; + final jni$_.JString Function(jni$_.JString string) _eat; - @jni$_.internal - @core$_.override - final superCount = 1; + jni$_.JString groom() { + return _groom(); + } - @core$_.override - int get hashCode => ($BaseInterface$Type$).hashCode; + jni$_.JString? giveBirth(core$_.bool z) { + return _giveBirth(z); + } - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($BaseInterface$Type$) && - other is $BaseInterface$Type$; + jni$_.JString eat(jni$_.JString string) { + return _eat(string); } } -/// from: `com.github.dart_lang.jnigen.inheritance.DerivedInterface` -class DerivedInterface extends jni$_.JObject { +final class $Furry$Type$ extends jni$_.JType { @jni$_.internal - @core$_.override - final jni$_.JType $type; + const $Furry$Type$(); @jni$_.internal - DerivedInterface.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); + @core$_.override + String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/Furry;'; +} +/// from: `com.github.dart_lang.jnigen.inheritance.GenericDerivedClass` +extension type GenericDerivedClass<$T extends jni$_.JObject?>._( + jni$_.JObject _$this) implements BaseClass<$T?> { static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/inheritance/DerivedInterface'); - - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $DerivedInterface$NullableType$(); + r'com/github/dart_lang/jnigen/inheritance/GenericDerivedClass'); /// The type which includes information such as the signature of this class. - static const jni$_.JType type = $DerivedInterface$Type$(); - static final _id_foo = _class.instanceMethodId( - r'foo', - r'()Ljava/lang/String;', + static const jni$_.JType type = + $GenericDerivedClass$Type$(); + static final _id_new$ = _class.constructorId( + r'()V', ); - static final _foo = jni$_.ProtectedJniExtensions.lookup< + static final _new$ = jni$_.ProtectedJniExtensions.lookup< jni$_.NativeFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') + )>>('globalEnv_NewObject') .asFunction< jni$_.JniResult Function( jni$_.Pointer, jni$_.JMethodIDPtr, )>(); - /// from: `public abstract java.lang.String foo()` + /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - jni$_.JString? foo() { - return _foo(reference.pointer, _id_foo as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$NullableType$()); + factory GenericDerivedClass() { + return _new$(_class.reference.pointer, _id_new$.pointer) + .object>(); } +} + +final class $GenericDerivedClass$Type$ + extends jni$_.JType { + @jni$_.internal + const $GenericDerivedClass$Type$(); + + @jni$_.internal + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/inheritance/GenericDerivedClass;'; +} + +/// from: `com.github.dart_lang.jnigen.inheritance.Mammal` +extension type Mammal._(jni$_.JObject _$this) implements jni$_.JObject, Animal { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/inheritance/Mammal'); + + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Mammal$Type$(); /// Maps a specific port to the implemented interface. - static final core$_.Map _$impls = {}; + static final core$_.Map _$impls = {}; static jni$_.JObjectPtr _$invoke( int port, jni$_.JObjectPtr descriptor, @@ -9877,8 +7376,20 @@ class DerivedInterface extends jni$_.JObject { try { final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; - if ($d == r'foo()Ljava/lang/String;') { - final $r = _$impls[$p]!.foo(); + if ($d == r'giveBirth(Z)Ljava/lang/String;') { + final $r = _$impls[$p]!.giveBirth( + ($a![0] as jni$_.JBoolean).booleanValue(releaseOriginal: true), + ); + return ($r as jni$_.JObject?) + ?.as(const jni$_.$JObject$Type$()) + .reference + .toPointer() ?? + jni$_.nullptr; + } + if ($d == r'eat(Ljava/lang/String;)Ljava/lang/String;') { + final $r = _$impls[$p]!.eat( + ($a![0] as jni$_.JString), + ); return ($r as jni$_.JObject?) ?.as(const jni$_.$JObject$Type$()) .reference @@ -9893,7 +7404,7 @@ class DerivedInterface extends jni$_.JObject { static void implementIn( jni$_.JImplementer implementer, - $DerivedInterface $impl, + $Mammal $impl, ) { late final jni$_.RawReceivePort $p; $p = jni$_.RawReceivePort(($m) { @@ -9907,7 +7418,7 @@ class DerivedInterface extends jni$_.JObject { jni$_.ProtectedJniExtensions.returnResult($i.result, $r); }); implementer.add( - r'com.github.dart_lang.jnigen.inheritance.DerivedInterface', + r'com.github.dart_lang.jnigen.inheritance.Mammal', $p, _$invokePointer, [], @@ -9916,153 +7427,113 @@ class DerivedInterface extends jni$_.JObject { _$impls[$a] = $impl; } - factory DerivedInterface.implement( - $DerivedInterface $impl, + factory Mammal.implement( + $Mammal $impl, ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return DerivedInterface.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } -abstract base mixin class $DerivedInterface { - factory $DerivedInterface({ - required jni$_.JString? Function() foo, - }) = _$DerivedInterface; - - jni$_.JString? foo(); -} - -final class _$DerivedInterface with $DerivedInterface { - _$DerivedInterface({ - required jni$_.JString? Function() foo, - }) : _foo = foo; +extension Mammal$$Methods on Mammal { + static final _id_giveBirth = Mammal._class.instanceMethodId( + r'giveBirth', + r'(Z)Ljava/lang/String;', + ); - final jni$_.JString? Function() _foo; + static final _giveBirth = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - jni$_.JString? foo() { - return _foo(); + /// from: `public abstract java.lang.String giveBirth(boolean z)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? giveBirth( + core$_.bool z, + ) { + return _giveBirth(reference.pointer, _id_giveBirth.pointer, z ? 1 : 0) + .object(); } -} - -final class $DerivedInterface$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $DerivedInterface$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/DerivedInterface;'; - - @jni$_.internal - @core$_.override - DerivedInterface? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : DerivedInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; + static final _id_eat = Mammal._class.instanceMethodId( + r'eat', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); - @core$_.override - int get hashCode => ($DerivedInterface$NullableType$).hashCode; + static final _eat = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($DerivedInterface$NullableType$) && - other is $DerivedInterface$NullableType$; + /// from: `public abstract java.lang.String eat(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString eat( + jni$_.JString string, + ) { + final _$string = string.reference; + return _eat(reference.pointer, _id_eat.pointer, _$string.pointer) + .object(); } } -final class $DerivedInterface$Type$ extends jni$_.JType { - @jni$_.internal - const $DerivedInterface$Type$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/DerivedInterface;'; +abstract base mixin class $Mammal { + factory $Mammal({ + required jni$_.JString? Function(core$_.bool z) giveBirth, + required jni$_.JString Function(jni$_.JString string) eat, + }) = _$Mammal; - @jni$_.internal - @core$_.override - DerivedInterface fromReference(jni$_.JReference reference) => - DerivedInterface.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); + jni$_.JString? giveBirth(core$_.bool z); + jni$_.JString eat(jni$_.JString string); +} - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $DerivedInterface$NullableType$(); +final class _$Mammal with $Mammal { + _$Mammal({ + required jni$_.JString? Function(core$_.bool z) giveBirth, + required jni$_.JString Function(jni$_.JString string) eat, + }) : _giveBirth = giveBirth, + _eat = eat; - @jni$_.internal - @core$_.override - final superCount = 1; + final jni$_.JString? Function(core$_.bool z) _giveBirth; + final jni$_.JString Function(jni$_.JString string) _eat; - @core$_.override - int get hashCode => ($DerivedInterface$Type$).hashCode; + jni$_.JString? giveBirth(core$_.bool z) { + return _giveBirth(z); + } - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($DerivedInterface$Type$) && - other is $DerivedInterface$Type$; + jni$_.JString eat(jni$_.JString string) { + return _eat(string); } } -/// from: `com.github.dart_lang.jnigen.inheritance.GenericDerivedClass` -class GenericDerivedClass<$T extends jni$_.JObject?> extends BaseClass<$T?> { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - +final class $Mammal$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$T> T; + const $Mammal$Type$(); @jni$_.internal - GenericDerivedClass.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(T.nullableType, reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/inheritance/GenericDerivedClass'); + @core$_.override + String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/Mammal;'; +} - /// The type which includes information such as the signature of this class. - static jni$_.JType?> - nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $GenericDerivedClass$NullableType$<$T>( - T, - ); - } +/// from: `com.github.dart_lang.jnigen.inheritance.ShibaInu` +extension type ShibaInu._(jni$_.JObject _$this) + implements jni$_.JObject, Dog, Furry { + static final _class = + jni$_.JClass.forName(r'com/github/dart_lang/jnigen/inheritance/ShibaInu'); /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $GenericDerivedClass$Type$<$T>( - T, - ); - } - + static const jni$_.JType type = $ShibaInu$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -10081,128 +7552,146 @@ class GenericDerivedClass<$T extends jni$_.JObject?> extends BaseClass<$T?> { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory GenericDerivedClass({ - required jni$_.JType<$T> T, - }) { - return GenericDerivedClass<$T>.fromReference( - T, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + factory ShibaInu() { + return _new$(_class.reference.pointer, _id_new$.pointer).object(); } } -final class $GenericDerivedClass$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; +extension ShibaInu$$Methods on ShibaInu { + static final _id_eat = ShibaInu._class.instanceMethodId( + r'eat', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); - @jni$_.internal - const $GenericDerivedClass$NullableType$( - this.T, + static final _eat = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public java.lang.String eat(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString eat( + jni$_.JString string, + ) { + final _$string = string.reference; + return _eat(reference.pointer, _id_eat.pointer, _$string.pointer) + .object(); + } + + static final _id_giveBirth = ShibaInu._class.instanceMethodId( + r'giveBirth', + r'(Z)Ljava/lang/String;', ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/GenericDerivedClass;'; + static final _giveBirth = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - @jni$_.internal - @core$_.override - GenericDerivedClass<$T>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : GenericDerivedClass<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => $BaseClass$NullableType$<$T?>(T.nullableType); + /// from: `public java.lang.String giveBirth(boolean z)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? giveBirth( + core$_.bool z, + ) { + return _giveBirth(reference.pointer, _id_giveBirth.pointer, z ? 1 : 0) + .object(); + } - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; + static final _id_walk = ShibaInu._class.instanceMethodId( + r'walk', + r'(I)I', + ); - @jni$_.internal - @core$_.override - final superCount = 2; + static final _walk = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Int32,)>)>>('globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, jni$_.JMethodIDPtr, int)>(); - @core$_.override - int get hashCode => Object.hash($GenericDerivedClass$NullableType$, T); + /// from: `public int walk(int i)` + int walk( + int i, + ) { + return _walk(reference.pointer, _id_walk.pointer, i).integer; + } + + static final _id_bark = ShibaInu._class.instanceMethodId( + r'bark', + r'()Ljava/lang/String;', + ); + + static final _bark = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GenericDerivedClass$NullableType$<$T>) && - other is $GenericDerivedClass$NullableType$<$T> && - T == other.T; + /// from: `public java.lang.String bark()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString bark() { + return _bark(reference.pointer, _id_bark.pointer).object(); } -} - -final class $GenericDerivedClass$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - @jni$_.internal - const $GenericDerivedClass$Type$( - this.T, + static final _id_groom = ShibaInu._class.instanceMethodId( + r'groom', + r'()Ljava/lang/String;', ); - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/GenericDerivedClass;'; + static final _groom = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); - @jni$_.internal - @core$_.override - GenericDerivedClass<$T> fromReference(jni$_.JReference reference) => - GenericDerivedClass<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => $BaseClass$NullableType$<$T?>(T.nullableType); + /// from: `public java.lang.String groom()` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString groom() { + return _groom(reference.pointer, _id_groom.pointer).object(); + } +} +final class $ShibaInu$Type$ extends jni$_.JType { @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $GenericDerivedClass$NullableType$<$T>(T); + const $ShibaInu$Type$(); @jni$_.internal @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => Object.hash($GenericDerivedClass$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($GenericDerivedClass$Type$<$T>) && - other is $GenericDerivedClass$Type$<$T> && - T == other.T; - } + String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/ShibaInu;'; } /// from: `com.github.dart_lang.jnigen.inheritance.SpecificDerivedClass` -class SpecificDerivedClass extends BaseClass { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - SpecificDerivedClass.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(const jni$_.$JString$NullableType$(), reference); - +extension type SpecificDerivedClass._(jni$_.JObject _$this) + implements BaseClass { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $SpecificDerivedClass$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $SpecificDerivedClass$Type$(); @@ -10225,50 +7714,37 @@ class SpecificDerivedClass extends BaseClass { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory SpecificDerivedClass() { - return SpecificDerivedClass.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } -final class $SpecificDerivedClass$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $SpecificDerivedClass$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/inheritance/SpecificDerivedClass;'; - - @jni$_.internal - @core$_.override - SpecificDerivedClass? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : SpecificDerivedClass.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const $BaseClass$NullableType$( - jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; +extension SpecificDerivedClass$$Methods on SpecificDerivedClass { + static final _id_someMethod$1 = SpecificDerivedClass._class.instanceMethodId( + r'someMethod', + r'(Ljava/lang/String;)Ljava/lang/String;', + ); - @core$_.override - int get hashCode => ($SpecificDerivedClass$NullableType$).hashCode; + static final _someMethod$1 = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SpecificDerivedClass$NullableType$) && - other is $SpecificDerivedClass$NullableType$; + /// from: `public java.lang.String someMethod(java.lang.String string)` + /// The returned object must be released after use, by calling the [release] method. + jni$_.JString? someMethod$1( + jni$_.JString? string, + ) { + final _$string = string?.reference ?? jni$_.jNullReference; + return _someMethod$1( + reference.pointer, _id_someMethod$1.pointer, _$string.pointer) + .object(); } } @@ -10281,133 +7757,20 @@ final class $SpecificDerivedClass$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/inheritance/SpecificDerivedClass;'; - - @jni$_.internal - @core$_.override - SpecificDerivedClass fromReference(jni$_.JReference reference) => - SpecificDerivedClass.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const $BaseClass$NullableType$( - jni$_.$JString$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $SpecificDerivedClass$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($SpecificDerivedClass$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($SpecificDerivedClass$Type$) && - other is $SpecificDerivedClass$Type$; - } } /// from: `com.github.dart_lang.jnigen.annotations.Annotated$Nested` -class Annotated$Nested<$T extends jni$_.JObject?, $U extends jni$_.JObject, - $W extends jni$_.JObject, $V extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$W> W; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - Annotated$Nested.fromReference( - this.T, - this.U, - this.W, - this.V, - jni$_.JReference reference, - ) : $type = type<$T, $U, $W, $V>(T, U, W, V), - super.fromReference(reference); - +extension type Annotated$Nested< + $T extends jni$_.JObject?, + $U extends jni$_.JObject, + $W extends jni$_.JObject, + $V extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/annotations/Annotated$Nested'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject, - $V extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - jni$_.JType<$W> W, - jni$_.JType<$V> V, - ) { - return $Annotated$Nested$NullableType$<$T, $U, $W, $V>( - T, - U, - W, - V, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject, - $V extends jni$_.JObject?>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - jni$_.JType<$W> W, - jni$_.JType<$V> V, - ) { - return $Annotated$Nested$Type$<$T, $U, $W, $V>( - T, - U, - W, - V, - ); - } - - static final _id_v = _class.instanceFieldId( - r'v', - r'Ljava/lang/Object;', - ); - - /// from: `public V v` - /// The returned object must be released after use, by calling the [release] method. - $V? get v => _id_v.get(this, V.nullableType); - - /// from: `public V v` - /// The returned object must be released after use, by calling the [release] method. - set v($V? value) => _id_v.set(this, V.nullableType, value); - - static final _id_u = _class.instanceFieldId( - r'u', - r'Ljava/lang/Object;', - ); - - /// from: `public U u` - /// The returned object must be released after use, by calling the [release] method. - $U get u => _id_u.get(this, U); - - /// from: `public U u` - /// The returned object must be released after use, by calling the [release] method. - set u($U value) => _id_u.set(this, U, value); - + static const jni$_.JType type = $Annotated$Nested$Type$(); static final _id_new$ = _class.constructorId( r'(Lcom/github/dart_lang/jnigen/annotations/Annotated;Ljava/lang/Object;)V', ); @@ -10433,275 +7796,66 @@ class Annotated$Nested<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// The returned object must be released after use, by calling the [release] method. factory Annotated$Nested( Annotated<$T?, $U, $W> $outerClass, - $V? object, { - jni$_.JType<$T>? T, - jni$_.JType<$U>? U, - jni$_.JType<$W>? W, - required jni$_.JType<$V> V, - }) { - T ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $Annotated$Type$) - .T, - ]) as jni$_.JType<$T>; - U ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $Annotated$Type$) - .U, - ]) as jni$_.JType<$U>; - W ??= jni$_.lowestCommonSuperType([ - ($outerClass.$type as $Annotated$Type$) - .W, - ]) as jni$_.JType<$W>; + $V? object, + ) { final _$$outerClass = $outerClass.reference; final _$object = object?.reference ?? jni$_.jNullReference; - return Annotated$Nested<$T, $U, $W, $V>.fromReference( - T, - U, - W, - V, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$$outerClass.pointer, _$object.pointer) - .reference); - } -} - -final class $Annotated$Nested$NullableType$< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject, - $V extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$W> W; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $Annotated$Nested$NullableType$( - this.T, - this.U, - this.W, - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/annotations/Annotated$Nested;'; - - @jni$_.internal - @core$_.override - Annotated$Nested<$T, $U, $W, $V>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Annotated$Nested<$T, $U, $W, $V>.fromReference( - T, - U, - W, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Annotated$Nested$NullableType$, T, U, W, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == - ($Annotated$Nested$NullableType$<$T, $U, $W, $V>) && - other is $Annotated$Nested$NullableType$<$T, $U, $W, $V> && - T == other.T && - U == other.U && - W == other.W && - V == other.V; - } -} - -final class $Annotated$Nested$Type$< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject, - $V extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$W> W; - - @jni$_.internal - final jni$_.JType<$V> V; - - @jni$_.internal - const $Annotated$Nested$Type$( - this.T, - this.U, - this.W, - this.V, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/annotations/Annotated$Nested;'; - - @jni$_.internal - @core$_.override - Annotated$Nested<$T, $U, $W, $V> fromReference(jni$_.JReference reference) => - Annotated$Nested<$T, $U, $W, $V>.fromReference( - T, - U, - W, - V, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $Annotated$Nested$NullableType$<$T, $U, $W, $V>(T, U, W, V); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Annotated$Nested$Type$, T, U, W, V); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Annotated$Nested$Type$<$T, $U, $W, $V>) && - other is $Annotated$Nested$Type$<$T, $U, $W, $V> && - T == other.T && - U == other.U && - W == other.W && - V == other.V; + return _new$(_class.reference.pointer, _id_new$.pointer, + _$$outerClass.pointer, _$object.pointer) + .object>(); } } -/// from: `com.github.dart_lang.jnigen.annotations.Annotated` -class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, - $W extends jni$_.JObject> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$W> W; - - @jni$_.internal - Annotated.fromReference( - this.T, - this.U, - this.W, - jni$_.JReference reference, - ) : $type = type<$T, $U, $W>(T, U, W), - super.fromReference(reference); - - static final _class = jni$_.JClass.forName( - r'com/github/dart_lang/jnigen/annotations/Annotated'); - - /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - jni$_.JType<$W> W, - ) { - return $Annotated$NullableType$<$T, $U, $W>( - T, - U, - W, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?, - $U extends jni$_.JObject, $W extends jni$_.JObject>( - jni$_.JType<$T> T, - jni$_.JType<$U> U, - jni$_.JType<$W> W, - ) { - return $Annotated$Type$<$T, $U, $W>( - T, - U, - W, - ); - } - - static final _id_t = _class.instanceFieldId( - r't', +extension Annotated$Nested$$Methods< + $T extends jni$_.JObject?, + $U extends jni$_.JObject, + $W extends jni$_.JObject, + $V extends jni$_.JObject?> on Annotated$Nested<$T, $U, $W, $V> { + static final _id_v = Annotated$Nested._class.instanceFieldId( + r'v', r'Ljava/lang/Object;', ); - /// from: `public T t` + /// from: `public V v` /// The returned object must be released after use, by calling the [release] method. - $T? get t => _id_t.get(this, T.nullableType); + $V? get v => _id_v.getNullable(this, jni$_.JObject.type) as $V?; - /// from: `public T t` + /// from: `public V v` /// The returned object must be released after use, by calling the [release] method. - set t($T? value) => _id_t.set(this, T.nullableType, value); + set v($V? value) => _id_v.set(this, jni$_.JObject.type, value); - static final _id_u = _class.instanceFieldId( + static final _id_u = Annotated$Nested._class.instanceFieldId( r'u', r'Ljava/lang/Object;', ); /// from: `public U u` /// The returned object must be released after use, by calling the [release] method. - $U get u => _id_u.get(this, U); + $U get u => _id_u.get(this, jni$_.JObject.type) as $U; /// from: `public U u` /// The returned object must be released after use, by calling the [release] method. - set u($U value) => _id_u.set(this, U, value); + set u($U value) => _id_u.set(this, jni$_.JObject.type, value); +} - static final _id_w = _class.instanceFieldId( - r'w', - r'Ljava/lang/Object;', - ); +final class $Annotated$Nested$Type$ extends jni$_.JType { + @jni$_.internal + const $Annotated$Nested$Type$(); - /// from: `public W w` - /// The returned object must be released after use, by calling the [release] method. - $W get w => _id_w.get(this, W); + @jni$_.internal + @core$_.override + String get signature => + r'Lcom/github/dart_lang/jnigen/annotations/Annotated$Nested;'; +} - /// from: `public W w` - /// The returned object must be released after use, by calling the [release] method. - set w($W value) => _id_w.set(this, W, value); +/// from: `com.github.dart_lang.jnigen.annotations.Annotated` +extension type Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, + $W extends jni$_.JObject>._(jni$_.JObject _$this) implements jni$_.JObject { + static final _class = jni$_.JClass.forName( + r'com/github/dart_lang/jnigen/annotations/Annotated'); + /// The type which includes information such as the signature of this class. + static const jni$_.JType type = $Annotated$Type$(); static final _id_new$ = _class.constructorId( r'(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V', ); @@ -10730,27 +7884,14 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, factory Annotated( $T? object, $U object1, - $W object2, { - required jni$_.JType<$T> T, - jni$_.JType<$U>? U, - jni$_.JType<$W>? W, - }) { - U ??= jni$_.lowestCommonSuperType([ - object1.$type, - ]) as jni$_.JType<$U>; - W ??= jni$_.lowestCommonSuperType([ - object2.$type, - ]) as jni$_.JType<$W>; + $W object2, + ) { final _$object = object?.reference ?? jni$_.jNullReference; final _$object1 = object1.reference; final _$object2 = object2.reference; - return Annotated<$T, $U, $W>.fromReference( - T, - U, - W, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr, - _$object.pointer, _$object1.pointer, _$object2.pointer) - .reference); + return _new$(_class.reference.pointer, _id_new$.pointer, _$object.pointer, + _$object1.pointer, _$object2.pointer) + .object>(); } static final _id_staticHello = _class.staticMethodId( @@ -10773,12 +7914,55 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `static public java.lang.String staticHello()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JString staticHello() { - return _staticHello( - _class.reference.pointer, _id_staticHello as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); + return _staticHello(_class.reference.pointer, _id_staticHello.pointer) + .object(); } +} + +extension Annotated$$Methods< + $T extends jni$_.JObject?, + $U extends jni$_.JObject, + $W extends jni$_.JObject> on Annotated<$T, $U, $W> { + static final _id_t = Annotated._class.instanceFieldId( + r't', + r'Ljava/lang/Object;', + ); + + /// from: `public T t` + /// The returned object must be released after use, by calling the [release] method. + $T? get t => _id_t.getNullable(this, jni$_.JObject.type) as $T?; + + /// from: `public T t` + /// The returned object must be released after use, by calling the [release] method. + set t($T? value) => _id_t.set(this, jni$_.JObject.type, value); + + static final _id_u = Annotated._class.instanceFieldId( + r'u', + r'Ljava/lang/Object;', + ); + + /// from: `public U u` + /// The returned object must be released after use, by calling the [release] method. + $U get u => _id_u.get(this, jni$_.JObject.type) as $U; + + /// from: `public U u` + /// The returned object must be released after use, by calling the [release] method. + set u($U value) => _id_u.set(this, jni$_.JObject.type, value); + + static final _id_w = Annotated._class.instanceFieldId( + r'w', + r'Ljava/lang/Object;', + ); + + /// from: `public W w` + /// The returned object must be released after use, by calling the [release] method. + $W get w => _id_w.get(this, jni$_.JObject.type) as $W; + + /// from: `public W w` + /// The returned object must be released after use, by calling the [release] method. + set w($W value) => _id_w.set(this, jni$_.JObject.type, value); - static final _id_hello = _class.instanceMethodId( + static final _id_hello = Annotated._class.instanceMethodId( r'hello', r'()Ljava/lang/String;', ); @@ -10798,11 +7982,10 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.lang.String hello()` /// The returned object must be released after use, by calling the [release] method. jni$_.JString hello() { - return _hello(reference.pointer, _id_hello as jni$_.JMethodIDPtr) - .object(const jni$_.$JString$Type$()); + return _hello(reference.pointer, _id_hello.pointer).object(); } - static final _id_nullableHello = _class.instanceMethodId( + static final _id_nullableHello = Annotated._class.instanceMethodId( r'nullableHello', r'(Z)Ljava/lang/String;', ); @@ -10822,12 +8005,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JString? nullableHello( core$_.bool z, ) { - return _nullableHello(reference.pointer, - _id_nullableHello as jni$_.JMethodIDPtr, z ? 1 : 0) - .object(const jni$_.$JString$NullableType$()); + return _nullableHello( + reference.pointer, _id_nullableHello.pointer, z ? 1 : 0) + .object(); } - static final _id_echo = _class.instanceMethodId( + static final _id_echo = Annotated._class.instanceMethodId( r'echo', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -10849,12 +8032,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JString string, ) { final _$string = string.reference; - return _echo( - reference.pointer, _id_echo as jni$_.JMethodIDPtr, _$string.pointer) - .object(const jni$_.$JString$Type$()); + return _echo(reference.pointer, _id_echo.pointer, _$string.pointer) + .object(); } - static final _id_nullableEcho = _class.instanceMethodId( + static final _id_nullableEcho = Annotated._class.instanceMethodId( r'nullableEcho', r'(Ljava/lang/String;)Ljava/lang/String;', ); @@ -10876,12 +8058,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _nullableEcho(reference.pointer, - _id_nullableEcho as jni$_.JMethodIDPtr, _$string.pointer) - .object(const jni$_.$JString$NullableType$()); + return _nullableEcho( + reference.pointer, _id_nullableEcho.pointer, _$string.pointer) + .object(); } - static final _id_array = _class.instanceMethodId( + static final _id_array = Annotated._class.instanceMethodId( r'array', r'()[Ljava/lang/String;', ); @@ -10901,12 +8083,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.lang.String[] array()` /// The returned object must be released after use, by calling the [release] method. jni$_.JArray array() { - return _array(reference.pointer, _id_array as jni$_.JMethodIDPtr) - .object>( - const jni$_.$JArray$Type$(jni$_.$JString$Type$())); + return _array(reference.pointer, _id_array.pointer) + .object>(); } - static final _id_arrayOfNullable = _class.instanceMethodId( + static final _id_arrayOfNullable = Annotated._class.instanceMethodId( r'arrayOfNullable', r'()[Ljava/lang/String;', ); @@ -10926,14 +8107,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.lang.String[] arrayOfNullable()` /// The returned object must be released after use, by calling the [release] method. jni$_.JArray arrayOfNullable() { - return _arrayOfNullable( - reference.pointer, _id_arrayOfNullable as jni$_.JMethodIDPtr) - .object>( - const jni$_.$JArray$Type$( - jni$_.$JString$NullableType$())); + return _arrayOfNullable(reference.pointer, _id_arrayOfNullable.pointer) + .object>(); } - static final _id_nullableArray = _class.instanceMethodId( + static final _id_nullableArray = Annotated._class.instanceMethodId( r'nullableArray', r'(Z)[Ljava/lang/String;', ); @@ -10953,14 +8131,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JArray? nullableArray( core$_.bool z, ) { - return _nullableArray(reference.pointer, - _id_nullableArray as jni$_.JMethodIDPtr, z ? 1 : 0) - .object?>( - const jni$_.$JArray$NullableType$( - jni$_.$JString$Type$())); + return _nullableArray( + reference.pointer, _id_nullableArray.pointer, z ? 1 : 0) + .object?>(); } - static final _id_nullableArrayOfNullable = _class.instanceMethodId( + static final _id_nullableArrayOfNullable = Annotated._class.instanceMethodId( r'nullableArrayOfNullable', r'(Z)[Ljava/lang/String;', ); @@ -10980,14 +8156,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JArray? nullableArrayOfNullable( core$_.bool z, ) { - return _nullableArrayOfNullable(reference.pointer, - _id_nullableArrayOfNullable as jni$_.JMethodIDPtr, z ? 1 : 0) - .object?>( - const jni$_.$JArray$NullableType$( - jni$_.$JString$NullableType$())); + return _nullableArrayOfNullable( + reference.pointer, _id_nullableArrayOfNullable.pointer, z ? 1 : 0) + .object?>(); } - static final _id_list = _class.instanceMethodId( + static final _id_list = Annotated._class.instanceMethodId( r'list', r'()Ljava/util/List;', ); @@ -11007,12 +8181,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List list()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList list() { - return _list(reference.pointer, _id_list as jni$_.JMethodIDPtr) - .object>( - const jni$_.$JList$Type$(jni$_.$JString$Type$())); + return _list(reference.pointer, _id_list.pointer) + .object>(); } - static final _id_listOfNullable = _class.instanceMethodId( + static final _id_listOfNullable = Annotated._class.instanceMethodId( r'listOfNullable', r'()Ljava/util/List;', ); @@ -11032,14 +8205,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List listOfNullable()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList listOfNullable() { - return _listOfNullable( - reference.pointer, _id_listOfNullable as jni$_.JMethodIDPtr) - .object>( - const jni$_.$JList$Type$( - jni$_.$JString$NullableType$())); + return _listOfNullable(reference.pointer, _id_listOfNullable.pointer) + .object>(); } - static final _id_nullableList = _class.instanceMethodId( + static final _id_nullableList = Annotated._class.instanceMethodId( r'nullableList', r'(Z)Ljava/util/List;', ); @@ -11059,14 +8229,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JList? nullableList( core$_.bool z, ) { - return _nullableList(reference.pointer, - _id_nullableList as jni$_.JMethodIDPtr, z ? 1 : 0) - .object?>( - const jni$_.$JList$NullableType$( - jni$_.$JString$Type$())); + return _nullableList(reference.pointer, _id_nullableList.pointer, z ? 1 : 0) + .object?>(); } - static final _id_nullableListOfNullable = _class.instanceMethodId( + static final _id_nullableListOfNullable = Annotated._class.instanceMethodId( r'nullableListOfNullable', r'(Z)Ljava/util/List;', ); @@ -11086,14 +8253,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JList? nullableListOfNullable( core$_.bool z, ) { - return _nullableListOfNullable(reference.pointer, - _id_nullableListOfNullable as jni$_.JMethodIDPtr, z ? 1 : 0) - .object?>( - const jni$_.$JList$NullableType$( - jni$_.$JString$NullableType$())); + return _nullableListOfNullable( + reference.pointer, _id_nullableListOfNullable.pointer, z ? 1 : 0) + .object?>(); } - static final _id_classGenericEcho = _class.instanceMethodId( + static final _id_classGenericEcho = Annotated._class.instanceMethodId( r'classGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11111,16 +8276,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T classGenericEcho(T object)` /// The returned object must be released after use, by calling the [release] method. - $T classGenericEcho( - $T object, + $T? classGenericEcho( + $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _classGenericEcho(reference.pointer, - _id_classGenericEcho as jni$_.JMethodIDPtr, _$object.pointer) - .object<$T>(T); + return _classGenericEcho( + reference.pointer, _id_classGenericEcho.pointer, _$object.pointer) + .object<$T?>(); } - static final _id_nullableClassGenericEcho = _class.instanceMethodId( + static final _id_nullableClassGenericEcho = Annotated._class.instanceMethodId( r'nullableClassGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11142,14 +8307,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, $T? object, ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _nullableClassGenericEcho( - reference.pointer, - _id_nullableClassGenericEcho as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$T?>(T.nullableType); + return _nullableClassGenericEcho(reference.pointer, + _id_nullableClassGenericEcho.pointer, _$object.pointer) + .object<$T?>(); } - static final _id_methodGenericEcho = _class.instanceMethodId( + static final _id_methodGenericEcho = Annotated._class.instanceMethodId( r'methodGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11167,17 +8330,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V methodGenericEcho(V object)` /// The returned object must be released after use, by calling the [release] method. - $V methodGenericEcho<$V extends jni$_.JObject?>( - $V object, { - required jni$_.JType<$V> V, - }) { + $V? methodGenericEcho<$V extends jni$_.JObject?>( + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _methodGenericEcho(reference.pointer, - _id_methodGenericEcho as jni$_.JMethodIDPtr, _$object.pointer) - .object<$V>(V); + return _methodGenericEcho( + reference.pointer, _id_methodGenericEcho.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_methodGenericEcho2 = _class.instanceMethodId( + static final _id_methodGenericEcho2 = Annotated._class.instanceMethodId( r'methodGenericEcho2', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11196,19 +8358,15 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V methodGenericEcho2(V object)` /// The returned object must be released after use, by calling the [release] method. $V methodGenericEcho2<$V extends jni$_.JObject>( - $V object, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - object.$type, - ]) as jni$_.JType<$V>; + $V object, + ) { final _$object = object.reference; - return _methodGenericEcho2(reference.pointer, - _id_methodGenericEcho2 as jni$_.JMethodIDPtr, _$object.pointer) - .object<$V>(V); + return _methodGenericEcho2( + reference.pointer, _id_methodGenericEcho2.pointer, _$object.pointer) + .object<$V>(); } - static final _id_methodGenericEcho3 = _class.instanceMethodId( + static final _id_methodGenericEcho3 = Annotated._class.instanceMethodId( r'methodGenericEcho3', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11227,19 +8385,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V methodGenericEcho3(V object)` /// The returned object must be released after use, by calling the [release] method. $V methodGenericEcho3<$V extends jni$_.JObject>( - $V object, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - object.$type, - ]) as jni$_.JType<$V>; + $V object, + ) { final _$object = object.reference; - return _methodGenericEcho3(reference.pointer, - _id_methodGenericEcho3 as jni$_.JMethodIDPtr, _$object.pointer) - .object<$V>(V); + return _methodGenericEcho3( + reference.pointer, _id_methodGenericEcho3.pointer, _$object.pointer) + .object<$V>(); } - static final _id_nullableReturnMethodGenericEcho = _class.instanceMethodId( + static final _id_nullableReturnMethodGenericEcho = + Annotated._class.instanceMethodId( r'nullableReturnMethodGenericEcho', r'(Ljava/lang/Object;Z)Ljava/lang/Object;', ); @@ -11262,20 +8417,20 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V nullableReturnMethodGenericEcho(V object, boolean z)` /// The returned object must be released after use, by calling the [release] method. $V? nullableReturnMethodGenericEcho<$V extends jni$_.JObject?>( - $V object, - core$_.bool z, { - required jni$_.JType<$V> V, - }) { + $V? object, + core$_.bool z, + ) { final _$object = object?.reference ?? jni$_.jNullReference; return _nullableReturnMethodGenericEcho( reference.pointer, - _id_nullableReturnMethodGenericEcho as jni$_.JMethodIDPtr, + _id_nullableReturnMethodGenericEcho.pointer, _$object.pointer, z ? 1 : 0) - .object<$V?>(V.nullableType); + .object<$V?>(); } - static final _id_nullableReturnMethodGenericEcho2 = _class.instanceMethodId( + static final _id_nullableReturnMethodGenericEcho2 = + Annotated._class.instanceMethodId( r'nullableReturnMethodGenericEcho2', r'(Ljava/lang/Object;Z)Ljava/lang/Object;', ); @@ -11299,22 +8454,19 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// The returned object must be released after use, by calling the [release] method. $V? nullableReturnMethodGenericEcho2<$V extends jni$_.JObject>( $V object, - core$_.bool z, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - object.$type, - ]) as jni$_.JType<$V>; + core$_.bool z, + ) { final _$object = object.reference; return _nullableReturnMethodGenericEcho2( reference.pointer, - _id_nullableReturnMethodGenericEcho2 as jni$_.JMethodIDPtr, + _id_nullableReturnMethodGenericEcho2.pointer, _$object.pointer, z ? 1 : 0) - .object<$V?>(V.nullableType); + .object<$V?>(); } - static final _id_nullableMethodGenericEcho = _class.instanceMethodId( + static final _id_nullableMethodGenericEcho = + Annotated._class.instanceMethodId( r'nullableMethodGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11332,19 +8484,17 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V nullableMethodGenericEcho(V object)` /// The returned object must be released after use, by calling the [release] method. - $V nullableMethodGenericEcho<$V extends jni$_.JObject?>( - $V object, { - required jni$_.JType<$V> V, - }) { + $V? nullableMethodGenericEcho<$V extends jni$_.JObject?>( + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _nullableMethodGenericEcho( - reference.pointer, - _id_nullableMethodGenericEcho as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$V>(V); + return _nullableMethodGenericEcho(reference.pointer, + _id_nullableMethodGenericEcho.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_noAnnotationMethodGenericEcho = _class.instanceMethodId( + static final _id_noAnnotationMethodGenericEcho = + Annotated._class.instanceMethodId( r'noAnnotationMethodGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11364,18 +8514,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V noAnnotationMethodGenericEcho(V object)` /// The returned object must be released after use, by calling the [release] method. $V? noAnnotationMethodGenericEcho<$V extends jni$_.JObject?>( - $V? object, { - required jni$_.JType<$V> V, - }) { + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _noAnnotationMethodGenericEcho( - reference.pointer, - _id_noAnnotationMethodGenericEcho as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$V?>(V.nullableType); + return _noAnnotationMethodGenericEcho(reference.pointer, + _id_noAnnotationMethodGenericEcho.pointer, _$object.pointer) + .object<$V?>(); } - static final _id_nullableArgMethodGenericEcho = _class.instanceMethodId( + static final _id_nullableArgMethodGenericEcho = + Annotated._class.instanceMethodId( r'nullableArgMethodGenericEcho', r'(Ljava/lang/Object;)Ljava/lang/Object;', ); @@ -11395,18 +8543,15 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V nullableArgMethodGenericEcho(V object)` /// The returned object must be released after use, by calling the [release] method. $V nullableArgMethodGenericEcho<$V extends jni$_.JObject>( - $V? object, { - required jni$_.JType<$V> V, - }) { + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _nullableArgMethodGenericEcho( - reference.pointer, - _id_nullableArgMethodGenericEcho as jni$_.JMethodIDPtr, - _$object.pointer) - .object<$V>(V); + return _nullableArgMethodGenericEcho(reference.pointer, + _id_nullableArgMethodGenericEcho.pointer, _$object.pointer) + .object<$V>(); } - static final _id_classGenericList = _class.instanceMethodId( + static final _id_classGenericList = Annotated._class.instanceMethodId( r'classGenericList', r'()Ljava/util/List;', ); @@ -11425,13 +8570,13 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List classGenericList()` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$T> classGenericList() { - return _classGenericList( - reference.pointer, _id_classGenericList as jni$_.JMethodIDPtr) - .object>(jni$_.$JList$Type$<$T>(T)); + jni$_.JList<$T?> classGenericList() { + return _classGenericList(reference.pointer, _id_classGenericList.pointer) + .object>(); } - static final _id_classGenericListOfNullable = _class.instanceMethodId( + static final _id_classGenericListOfNullable = + Annotated._class.instanceMethodId( r'classGenericListOfNullable', r'()Ljava/util/List;', ); @@ -11452,12 +8597,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List classGenericListOfNullable()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList<$T?> classGenericListOfNullable() { - return _classGenericListOfNullable(reference.pointer, - _id_classGenericListOfNullable as jni$_.JMethodIDPtr) - .object>(jni$_.$JList$Type$<$T?>(T.nullableType)); + return _classGenericListOfNullable( + reference.pointer, _id_classGenericListOfNullable.pointer) + .object>(); } - static final _id_nullableClassGenericList = _class.instanceMethodId( + static final _id_nullableClassGenericList = Annotated._class.instanceMethodId( r'nullableClassGenericList', r'(Z)Ljava/util/List;', ); @@ -11474,15 +8619,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List nullableClassGenericList(boolean z)` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$T>? nullableClassGenericList( + jni$_.JList<$T?>? nullableClassGenericList( core$_.bool z, ) { - return _nullableClassGenericList(reference.pointer, - _id_nullableClassGenericList as jni$_.JMethodIDPtr, z ? 1 : 0) - .object?>(jni$_.$JList$NullableType$<$T>(T)); + return _nullableClassGenericList( + reference.pointer, _id_nullableClassGenericList.pointer, z ? 1 : 0) + .object?>(); } - static final _id_nullableClassGenericListOfNullable = _class.instanceMethodId( + static final _id_nullableClassGenericListOfNullable = + Annotated._class.instanceMethodId( r'nullableClassGenericListOfNullable', r'(Z)Ljava/util/List;', ); @@ -11502,15 +8648,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JList<$T?>? nullableClassGenericListOfNullable( core$_.bool z, ) { - return _nullableClassGenericListOfNullable( - reference.pointer, - _id_nullableClassGenericListOfNullable as jni$_.JMethodIDPtr, - z ? 1 : 0) - .object?>( - jni$_.$JList$NullableType$<$T?>(T.nullableType)); + return _nullableClassGenericListOfNullable(reference.pointer, + _id_nullableClassGenericListOfNullable.pointer, z ? 1 : 0) + .object?>(); } - static final _id_methodGenericList = _class.instanceMethodId( + static final _id_methodGenericList = Annotated._class.instanceMethodId( r'methodGenericList', r'(Ljava/lang/Object;)Ljava/util/List;', ); @@ -11528,17 +8671,17 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List methodGenericList(V object)` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$V> methodGenericList<$V extends jni$_.JObject?>( - $V object, { - required jni$_.JType<$V> V, - }) { + jni$_.JList<$V?> methodGenericList<$V extends jni$_.JObject?>( + $V? object, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _methodGenericList(reference.pointer, - _id_methodGenericList as jni$_.JMethodIDPtr, _$object.pointer) - .object>(jni$_.$JList$Type$<$V>(V)); + return _methodGenericList( + reference.pointer, _id_methodGenericList.pointer, _$object.pointer) + .object>(); } - static final _id_methodGenericListOfNullable = _class.instanceMethodId( + static final _id_methodGenericListOfNullable = + Annotated._class.instanceMethodId( r'methodGenericListOfNullable', r'()Ljava/util/List;', ); @@ -11558,15 +8701,14 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List methodGenericListOfNullable()` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$V?> methodGenericListOfNullable<$V extends jni$_.JObject?>({ - required jni$_.JType<$V> V, - }) { - return _methodGenericListOfNullable(reference.pointer, - _id_methodGenericListOfNullable as jni$_.JMethodIDPtr) - .object>(jni$_.$JList$Type$<$V?>(V.nullableType)); + jni$_.JList<$V?> methodGenericListOfNullable<$V extends jni$_.JObject?>() { + return _methodGenericListOfNullable( + reference.pointer, _id_methodGenericListOfNullable.pointer) + .object>(); } - static final _id_nullableMethodGenericList = _class.instanceMethodId( + static final _id_nullableMethodGenericList = + Annotated._class.instanceMethodId( r'nullableMethodGenericList', r'(Ljava/lang/Object;Z)Ljava/util/List;', ); @@ -11585,22 +8727,18 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List nullableMethodGenericList(V object, boolean z)` /// The returned object must be released after use, by calling the [release] method. - jni$_.JList<$V>? nullableMethodGenericList<$V extends jni$_.JObject?>( - $V object, - core$_.bool z, { - required jni$_.JType<$V> V, - }) { + jni$_.JList<$V?>? nullableMethodGenericList<$V extends jni$_.JObject?>( + $V? object, + core$_.bool z, + ) { final _$object = object?.reference ?? jni$_.jNullReference; - return _nullableMethodGenericList( - reference.pointer, - _id_nullableMethodGenericList as jni$_.JMethodIDPtr, - _$object.pointer, - z ? 1 : 0) - .object?>(jni$_.$JList$NullableType$<$V>(V)); + return _nullableMethodGenericList(reference.pointer, + _id_nullableMethodGenericList.pointer, _$object.pointer, z ? 1 : 0) + .object?>(); } static final _id_nullableMethodGenericListOfNullable = - _class.instanceMethodId( + Annotated._class.instanceMethodId( r'nullableMethodGenericListOfNullable', r'(Z)Ljava/util/List;', ); @@ -11619,18 +8757,14 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// The returned object must be released after use, by calling the [release] method. jni$_.JList<$V?>? nullableMethodGenericListOfNullable<$V extends jni$_.JObject?>( - core$_.bool z, { - required jni$_.JType<$V> V, - }) { - return _nullableMethodGenericListOfNullable( - reference.pointer, - _id_nullableMethodGenericListOfNullable as jni$_.JMethodIDPtr, - z ? 1 : 0) - .object?>( - jni$_.$JList$NullableType$<$V?>(V.nullableType)); + core$_.bool z, + ) { + return _nullableMethodGenericListOfNullable(reference.pointer, + _id_nullableMethodGenericListOfNullable.pointer, z ? 1 : 0) + .object?>(); } - static final _id_firstOfClassGenericList = _class.instanceMethodId( + static final _id_firstOfClassGenericList = Annotated._class.instanceMethodId( r'firstOfClassGenericList', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11649,15 +8783,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T firstOfClassGenericList(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. $T? firstOfClassGenericList( - jni$_.JList<$T> list, + jni$_.JList<$T?> list, ) { final _$list = list.reference; return _firstOfClassGenericList(reference.pointer, - _id_firstOfClassGenericList as jni$_.JMethodIDPtr, _$list.pointer) - .object<$T?>(T.nullableType); + _id_firstOfClassGenericList.pointer, _$list.pointer) + .object<$T?>(); } - static final _id_firstOfClassGenericNullableList = _class.instanceMethodId( + static final _id_firstOfClassGenericNullableList = + Annotated._class.instanceMethodId( r'firstOfClassGenericNullableList', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11677,17 +8812,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T firstOfClassGenericNullableList(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. $T? firstOfClassGenericNullableList( - jni$_.JList<$T>? list, + jni$_.JList<$T?>? list, ) { final _$list = list?.reference ?? jni$_.jNullReference; - return _firstOfClassGenericNullableList( - reference.pointer, - _id_firstOfClassGenericNullableList as jni$_.JMethodIDPtr, - _$list.pointer) - .object<$T?>(T.nullableType); + return _firstOfClassGenericNullableList(reference.pointer, + _id_firstOfClassGenericNullableList.pointer, _$list.pointer) + .object<$T?>(); } - static final _id_firstOfClassGenericListOfNullable = _class.instanceMethodId( + static final _id_firstOfClassGenericListOfNullable = + Annotated._class.instanceMethodId( r'firstOfClassGenericListOfNullable', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11710,15 +8844,13 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JList<$T?> list, ) { final _$list = list.reference; - return _firstOfClassGenericListOfNullable( - reference.pointer, - _id_firstOfClassGenericListOfNullable as jni$_.JMethodIDPtr, - _$list.pointer) - .object<$T?>(T.nullableType); + return _firstOfClassGenericListOfNullable(reference.pointer, + _id_firstOfClassGenericListOfNullable.pointer, _$list.pointer) + .object<$T?>(); } static final _id_firstOfClassGenericNullableListOfNullable = - _class.instanceMethodId( + Annotated._class.instanceMethodId( r'firstOfClassGenericNullableListOfNullable', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11743,12 +8875,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, final _$list = list?.reference ?? jni$_.jNullReference; return _firstOfClassGenericNullableListOfNullable( reference.pointer, - _id_firstOfClassGenericNullableListOfNullable as jni$_.JMethodIDPtr, + _id_firstOfClassGenericNullableListOfNullable.pointer, _$list.pointer) - .object<$T?>(T.nullableType); + .object<$T?>(); } - static final _id_firstOfMethodGenericList = _class.instanceMethodId( + static final _id_firstOfMethodGenericList = Annotated._class.instanceMethodId( r'firstOfMethodGenericList', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11767,19 +8899,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstOfMethodGenericList(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. $V? firstOfMethodGenericList<$V extends jni$_.JObject?>( - jni$_.JList<$V> list, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (list.$type as jni$_.$JList$Type$).E, - ]) as jni$_.JType<$V>; + jni$_.JList<$V?> list, + ) { final _$list = list.reference; return _firstOfMethodGenericList(reference.pointer, - _id_firstOfMethodGenericList as jni$_.JMethodIDPtr, _$list.pointer) - .object<$V?>(V.nullableType); + _id_firstOfMethodGenericList.pointer, _$list.pointer) + .object<$V?>(); } - static final _id_firstOfMethodGenericNullableList = _class.instanceMethodId( + static final _id_firstOfMethodGenericNullableList = + Annotated._class.instanceMethodId( r'firstOfMethodGenericNullableList', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11799,18 +8928,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstOfMethodGenericNullableList(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. $V? firstOfMethodGenericNullableList<$V extends jni$_.JObject?>( - jni$_.JList<$V>? list, { - required jni$_.JType<$V> V, - }) { + jni$_.JList<$V?>? list, + ) { final _$list = list?.reference ?? jni$_.jNullReference; - return _firstOfMethodGenericNullableList( - reference.pointer, - _id_firstOfMethodGenericNullableList as jni$_.JMethodIDPtr, - _$list.pointer) - .object<$V?>(V.nullableType); + return _firstOfMethodGenericNullableList(reference.pointer, + _id_firstOfMethodGenericNullableList.pointer, _$list.pointer) + .object<$V?>(); } - static final _id_firstOfMethodGenericListOfNullable = _class.instanceMethodId( + static final _id_firstOfMethodGenericListOfNullable = + Annotated._class.instanceMethodId( r'firstOfMethodGenericListOfNullable', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11830,22 +8957,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstOfMethodGenericListOfNullable(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. $V? firstOfMethodGenericListOfNullable<$V extends jni$_.JObject?>( - jni$_.JList<$V?> list, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (list.$type as jni$_.$JList$Type$).E, - ]) as jni$_.JType<$V>; + jni$_.JList<$V?> list, + ) { final _$list = list.reference; - return _firstOfMethodGenericListOfNullable( - reference.pointer, - _id_firstOfMethodGenericListOfNullable as jni$_.JMethodIDPtr, - _$list.pointer) - .object<$V?>(V.nullableType); + return _firstOfMethodGenericListOfNullable(reference.pointer, + _id_firstOfMethodGenericListOfNullable.pointer, _$list.pointer) + .object<$V?>(); } static final _id_firstOfMethodGenericNullableListOfNullable = - _class.instanceMethodId( + Annotated._class.instanceMethodId( r'firstOfMethodGenericNullableListOfNullable', r'(Ljava/util/List;)Ljava/lang/Object;', ); @@ -11865,19 +8986,17 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstOfMethodGenericNullableListOfNullable(java.util.List list)` /// The returned object must be released after use, by calling the [release] method. $V? firstOfMethodGenericNullableListOfNullable<$V extends jni$_.JObject?>( - jni$_.JList<$V?>? list, { - required jni$_.JType<$V> V, - }) { + jni$_.JList<$V?>? list, + ) { final _$list = list?.reference ?? jni$_.jNullReference; return _firstOfMethodGenericNullableListOfNullable( reference.pointer, - _id_firstOfMethodGenericNullableListOfNullable - as jni$_.JMethodIDPtr, + _id_firstOfMethodGenericNullableListOfNullable.pointer, _$list.pointer) - .object<$V?>(V.nullableType); + .object<$V?>(); } - static final _id_firstKeyOfComboMap = _class.instanceMethodId( + static final _id_firstKeyOfComboMap = Annotated._class.instanceMethodId( r'firstKeyOfComboMap', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -11896,19 +9015,15 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T firstKeyOfComboMap(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $T? firstKeyOfComboMap<$V extends jni$_.JObject?>( - jni$_.JMap<$T, $V> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstKeyOfComboMap(reference.pointer, - _id_firstKeyOfComboMap as jni$_.JMethodIDPtr, _$map.pointer) - .object<$T?>(T.nullableType); + return _firstKeyOfComboMap( + reference.pointer, _id_firstKeyOfComboMap.pointer, _$map.pointer) + .object<$T?>(); } - static final _id_firstValueOfComboMap = _class.instanceMethodId( + static final _id_firstValueOfComboMap = Annotated._class.instanceMethodId( r'firstValueOfComboMap', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -11927,19 +9042,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstValueOfComboMap(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $V? firstValueOfComboMap<$V extends jni$_.JObject?>( - jni$_.JMap<$T, $V> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstValueOfComboMap(reference.pointer, - _id_firstValueOfComboMap as jni$_.JMethodIDPtr, _$map.pointer) - .object<$V?>(V.nullableType); + return _firstValueOfComboMap( + reference.pointer, _id_firstValueOfComboMap.pointer, _$map.pointer) + .object<$V?>(); } - static final _id_firstKeyOfComboMapNullableKey = _class.instanceMethodId( + static final _id_firstKeyOfComboMapNullableKey = + Annotated._class.instanceMethodId( r'firstKeyOfComboMapNullableKey', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -11959,21 +9071,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T firstKeyOfComboMapNullableKey(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $T? firstKeyOfComboMapNullableKey<$V extends jni$_.JObject?>( - jni$_.JMap<$T?, $V> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstKeyOfComboMapNullableKey( - reference.pointer, - _id_firstKeyOfComboMapNullableKey as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$T?>(T.nullableType); + return _firstKeyOfComboMapNullableKey(reference.pointer, + _id_firstKeyOfComboMapNullableKey.pointer, _$map.pointer) + .object<$T?>(); } - static final _id_firstValueOfComboMapNullableKey = _class.instanceMethodId( + static final _id_firstValueOfComboMapNullableKey = + Annotated._class.instanceMethodId( r'firstValueOfComboMapNullableKey', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -11993,21 +9100,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstValueOfComboMapNullableKey(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $V? firstValueOfComboMapNullableKey<$V extends jni$_.JObject?>( - jni$_.JMap<$T?, $V> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstValueOfComboMapNullableKey( - reference.pointer, - _id_firstValueOfComboMapNullableKey as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$V?>(V.nullableType); + return _firstValueOfComboMapNullableKey(reference.pointer, + _id_firstValueOfComboMapNullableKey.pointer, _$map.pointer) + .object<$V?>(); } - static final _id_firstKeyOfComboMapNullableValue = _class.instanceMethodId( + static final _id_firstKeyOfComboMapNullableValue = + Annotated._class.instanceMethodId( r'firstKeyOfComboMapNullableValue', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -12027,21 +9129,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T firstKeyOfComboMapNullableValue(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $T? firstKeyOfComboMapNullableValue<$V extends jni$_.JObject?>( - jni$_.JMap<$T, $V?> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstKeyOfComboMapNullableValue( - reference.pointer, - _id_firstKeyOfComboMapNullableValue as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$T?>(T.nullableType); + return _firstKeyOfComboMapNullableValue(reference.pointer, + _id_firstKeyOfComboMapNullableValue.pointer, _$map.pointer) + .object<$T?>(); } - static final _id_firstValueOfComboMapNullableValue = _class.instanceMethodId( + static final _id_firstValueOfComboMapNullableValue = + Annotated._class.instanceMethodId( r'firstValueOfComboMapNullableValue', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -12061,22 +9158,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstValueOfComboMapNullableValue(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $V? firstValueOfComboMapNullableValue<$V extends jni$_.JObject?>( - jni$_.JMap<$T, $V?> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstValueOfComboMapNullableValue( - reference.pointer, - _id_firstValueOfComboMapNullableValue as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$V?>(V.nullableType); + return _firstValueOfComboMapNullableValue(reference.pointer, + _id_firstValueOfComboMapNullableValue.pointer, _$map.pointer) + .object<$V?>(); } static final _id_firstKeyOfComboMapNullableKeyAndValue = - _class.instanceMethodId( + Annotated._class.instanceMethodId( r'firstKeyOfComboMapNullableKeyAndValue', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -12096,22 +9187,16 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public T firstKeyOfComboMapNullableKeyAndValue(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $T? firstKeyOfComboMapNullableKeyAndValue<$V extends jni$_.JObject?>( - jni$_.JMap<$T?, $V?> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstKeyOfComboMapNullableKeyAndValue( - reference.pointer, - _id_firstKeyOfComboMapNullableKeyAndValue as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$T?>(T.nullableType); + return _firstKeyOfComboMapNullableKeyAndValue(reference.pointer, + _id_firstKeyOfComboMapNullableKeyAndValue.pointer, _$map.pointer) + .object<$T?>(); } static final _id_firstValueOfComboMapNullableKeyAndValue = - _class.instanceMethodId( + Annotated._class.instanceMethodId( r'firstValueOfComboMapNullableKeyAndValue', r'(Ljava/util/Map;)Ljava/lang/Object;', ); @@ -12131,21 +9216,15 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public V firstValueOfComboMapNullableKeyAndValue(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. $V? firstValueOfComboMapNullableKeyAndValue<$V extends jni$_.JObject?>( - jni$_.JMap<$T?, $V?> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstValueOfComboMapNullableKeyAndValue( - reference.pointer, - _id_firstValueOfComboMapNullableKeyAndValue as jni$_.JMethodIDPtr, - _$map.pointer) - .object<$V?>(V.nullableType); + return _firstValueOfComboMapNullableKeyAndValue(reference.pointer, + _id_firstValueOfComboMapNullableKeyAndValue.pointer, _$map.pointer) + .object<$V?>(); } - static final _id_firstEntryOfComboMap = _class.instanceMethodId( + static final _id_firstEntryOfComboMap = Annotated._class.instanceMethodId( r'firstEntryOfComboMap', r'(Ljava/util/Map;)Ljava/util/Map$Entry;', ); @@ -12164,19 +9243,15 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.Map$Entry firstEntryOfComboMap(java.util.Map map)` /// The returned object must be released after use, by calling the [release] method. jni$_.JObject? firstEntryOfComboMap<$V extends jni$_.JObject?>( - jni$_.JMap<$T, $V> map, { - jni$_.JType<$V>? V, - }) { - V ??= jni$_.lowestCommonSuperType([ - (map.$type as jni$_.$JMap$Type$).V, - ]) as jni$_.JType<$V>; + jni$_.JMap<$T?, $V?> map, + ) { final _$map = map.reference; - return _firstEntryOfComboMap(reference.pointer, - _id_firstEntryOfComboMap as jni$_.JMethodIDPtr, _$map.pointer) - .object(const jni$_.$JObject$NullableType$()); + return _firstEntryOfComboMap( + reference.pointer, _id_firstEntryOfComboMap.pointer, _$map.pointer) + .object(); } - static final _id_getW = _class.instanceMethodId( + static final _id_getW = Annotated._class.instanceMethodId( r'getW', r'()Ljava/lang/Object;', ); @@ -12196,11 +9271,10 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public W getW()` /// The returned object must be released after use, by calling the [release] method. $W getW() { - return _getW(reference.pointer, _id_getW as jni$_.JMethodIDPtr) - .object<$W>(W); + return _getW(reference.pointer, _id_getW.pointer).object<$W>(); } - static final _id_nullableGetW = _class.instanceMethodId( + static final _id_nullableGetW = Annotated._class.instanceMethodId( r'nullableGetW', r'(Z)Ljava/lang/Object;', ); @@ -12220,12 +9294,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, $W? nullableGetW( core$_.bool z, ) { - return _nullableGetW(reference.pointer, - _id_nullableGetW as jni$_.JMethodIDPtr, z ? 1 : 0) - .object<$W?>(W.nullableType); + return _nullableGetW(reference.pointer, _id_nullableGetW.pointer, z ? 1 : 0) + .object<$W?>(); } - static final _id_list3dOfT = _class.instanceMethodId( + static final _id_list3dOfT = Annotated._class.instanceMethodId( r'list3dOfT', r'()Ljava/util/List;', ); @@ -12245,14 +9318,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List>> list3dOfT()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList>> list3dOfT() { - return _list3dOfT(reference.pointer, _id_list3dOfT as jni$_.JMethodIDPtr) - .object>>>( - jni$_.$JList$Type$>>( - jni$_.$JList$Type$>( - jni$_.$JList$Type$<$T?>(T.nullableType)))); + return _list3dOfT(reference.pointer, _id_list3dOfT.pointer) + .object>>>(); } - static final _id_list3dOfU = _class.instanceMethodId( + static final _id_list3dOfU = Annotated._class.instanceMethodId( r'list3dOfU', r'()Ljava/util/List;', ); @@ -12272,13 +9342,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List>> list3dOfU()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList>> list3dOfU() { - return _list3dOfU(reference.pointer, _id_list3dOfU as jni$_.JMethodIDPtr) - .object>>>( - jni$_.$JList$Type$>>(jni$_ - .$JList$Type$>(jni$_.$JList$Type$<$U>(U)))); + return _list3dOfU(reference.pointer, _id_list3dOfU.pointer) + .object>>>(); } - static final _id_list3dOfW = _class.instanceMethodId( + static final _id_list3dOfW = Annotated._class.instanceMethodId( r'list3dOfW', r'()Ljava/util/List;', ); @@ -12298,13 +9366,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List>> list3dOfW()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList>> list3dOfW() { - return _list3dOfW(reference.pointer, _id_list3dOfW as jni$_.JMethodIDPtr) - .object>>>( - jni$_.$JList$Type$>>(jni$_ - .$JList$Type$>(jni$_.$JList$Type$<$W>(W)))); + return _list3dOfW(reference.pointer, _id_list3dOfW.pointer) + .object>>>(); } - static final _id_list3dOfNullableU = _class.instanceMethodId( + static final _id_list3dOfNullableU = Annotated._class.instanceMethodId( r'list3dOfNullableU', r'(Z)Ljava/util/List;', ); @@ -12324,15 +9390,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JList>> list3dOfNullableU( core$_.bool z, ) { - return _list3dOfNullableU(reference.pointer, - _id_list3dOfNullableU as jni$_.JMethodIDPtr, z ? 1 : 0) - .object>>>( - jni$_.$JList$Type$>>( - jni$_.$JList$Type$>( - jni$_.$JList$Type$<$U?>(U.nullableType)))); + return _list3dOfNullableU( + reference.pointer, _id_list3dOfNullableU.pointer, z ? 1 : 0) + .object>>>(); } - static final _id_list3dOfNullableW = _class.instanceMethodId( + static final _id_list3dOfNullableW = Annotated._class.instanceMethodId( r'list3dOfNullableW', r'(Z)Ljava/util/List;', ); @@ -12352,15 +9415,12 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, jni$_.JList>> list3dOfNullableW( core$_.bool z, ) { - return _list3dOfNullableW(reference.pointer, - _id_list3dOfNullableW as jni$_.JMethodIDPtr, z ? 1 : 0) - .object>>>( - jni$_.$JList$Type$>>( - jni$_.$JList$Type$>( - jni$_.$JList$Type$<$W?>(W.nullableType)))); + return _list3dOfNullableW( + reference.pointer, _id_list3dOfNullableW.pointer, z ? 1 : 0) + .object>>>(); } - static final _id_nested = _class.instanceMethodId( + static final _id_nested = Annotated._class.instanceMethodId( r'nested', r'()Lcom/github/dart_lang/jnigen/annotations/Annotated$Nested;', ); @@ -12380,13 +9440,11 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public com.github.dart_lang.jnigen.annotations.Annotated$Nested nested()` /// The returned object must be released after use, by calling the [release] method. Annotated$Nested<$T?, $U, $W, jni$_.JInteger>? nested() { - return _nested(reference.pointer, _id_nested as jni$_.JMethodIDPtr) - .object?>( - $Annotated$Nested$NullableType$<$T?, $U, $W, jni$_.JInteger>( - T.nullableType, U, W, const jni$_.$JInteger$Type$())); + return _nested(reference.pointer, _id_nested.pointer) + .object?>(); } - static final _id_intList = _class.instanceMethodId( + static final _id_intList = Annotated._class.instanceMethodId( r'intList', r'()Ljava/util/List;', ); @@ -12406,152 +9464,27 @@ class Annotated<$T extends jni$_.JObject?, $U extends jni$_.JObject, /// from: `public java.util.List intList()` /// The returned object must be released after use, by calling the [release] method. jni$_.JList intList() { - return _intList(reference.pointer, _id_intList as jni$_.JMethodIDPtr) - .object>( - const jni$_.$JList$Type$(jni$_.$JInteger$Type$())); - } -} - -final class $Annotated$NullableType$< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject> extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$W> W; - - @jni$_.internal - const $Annotated$NullableType$( - this.T, - this.U, - this.W, - ); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/annotations/Annotated;'; - - @jni$_.internal - @core$_.override - Annotated<$T, $U, $W>? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : Annotated<$T, $U, $W>.fromReference( - T, - U, - W, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Annotated$NullableType$, T, U, W); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Annotated$NullableType$<$T, $U, $W>) && - other is $Annotated$NullableType$<$T, $U, $W> && - T == other.T && - U == other.U && - W == other.W; + return _intList(reference.pointer, _id_intList.pointer) + .object>(); } } -final class $Annotated$Type$< - $T extends jni$_.JObject?, - $U extends jni$_.JObject, - $W extends jni$_.JObject> extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - +final class $Annotated$Type$ extends jni$_.JType { @jni$_.internal - final jni$_.JType<$U> U; - - @jni$_.internal - final jni$_.JType<$W> W; - - @jni$_.internal - const $Annotated$Type$( - this.T, - this.U, - this.W, - ); + const $Annotated$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/annotations/Annotated;'; - - @jni$_.internal - @core$_.override - Annotated<$T, $U, $W> fromReference(jni$_.JReference reference) => - Annotated<$T, $U, $W>.fromReference( - T, - U, - W, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => - $Annotated$NullableType$<$T, $U, $W>(T, U, W); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($Annotated$Type$, T, U, W); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Annotated$Type$<$T, $U, $W>) && - other is $Annotated$Type$<$T, $U, $W> && - T == other.T && - U == other.U && - W == other.W; - } } /// from: `com.github.dart_lang.jnigen.annotations.JsonSerializable$Case` -class JsonSerializable$Case extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonSerializable$Case.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonSerializable$Case._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/annotations/JsonSerializable$Case'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonSerializable$Case$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonSerializable$Case$Type$(); @@ -12563,7 +9496,8 @@ class JsonSerializable$Case extends jni$_.JObject { /// from: `static public final com.github.dart_lang.jnigen.annotations.JsonSerializable$Case SNAKE_CASE` /// The returned object must be released after use, by calling the [release] method. static JsonSerializable$Case get SNAKE_CASE => - _id_SNAKE_CASE.get(_class, const $JsonSerializable$Case$Type$()); + _id_SNAKE_CASE.get(_class, JsonSerializable$Case.type) + as JsonSerializable$Case; static final _id_KEBAB_CASE = _class.staticFieldId( r'KEBAB_CASE', @@ -12573,7 +9507,8 @@ class JsonSerializable$Case extends jni$_.JObject { /// from: `static public final com.github.dart_lang.jnigen.annotations.JsonSerializable$Case KEBAB_CASE` /// The returned object must be released after use, by calling the [release] method. static JsonSerializable$Case get KEBAB_CASE => - _id_KEBAB_CASE.get(_class, const $JsonSerializable$Case$Type$()); + _id_KEBAB_CASE.get(_class, JsonSerializable$Case.type) + as JsonSerializable$Case; static final _id_CAMEL_CASE = _class.staticFieldId( r'CAMEL_CASE', @@ -12583,7 +9518,8 @@ class JsonSerializable$Case extends jni$_.JObject { /// from: `static public final com.github.dart_lang.jnigen.annotations.JsonSerializable$Case CAMEL_CASE` /// The returned object must be released after use, by calling the [release] method. static JsonSerializable$Case get CAMEL_CASE => - _id_CAMEL_CASE.get(_class, const $JsonSerializable$Case$Type$()); + _id_CAMEL_CASE.get(_class, JsonSerializable$Case.type) + as JsonSerializable$Case; static final _id_values = _class.staticMethodId( r'values', @@ -12605,10 +9541,8 @@ class JsonSerializable$Case extends jni$_.JObject { /// from: `static public com.github.dart_lang.jnigen.annotations.JsonSerializable$Case[] values()` /// The returned object must be released after use, by calling the [release] method. static jni$_.JArray? values() { - return _values(_class.reference.pointer, _id_values as jni$_.JMethodIDPtr) - .object?>( - const jni$_.$JArray$NullableType$( - $JsonSerializable$Case$NullableType$())); + return _values(_class.reference.pointer, _id_values.pointer) + .object?>(); } static final _id_valueOf = _class.staticMethodId( @@ -12633,50 +9567,9 @@ class JsonSerializable$Case extends jni$_.JObject { jni$_.JString? string, ) { final _$string = string?.reference ?? jni$_.jNullReference; - return _valueOf(_class.reference.pointer, _id_valueOf as jni$_.JMethodIDPtr, - _$string.pointer) - .object( - const $JsonSerializable$Case$NullableType$()); - } -} - -final class $JsonSerializable$Case$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $JsonSerializable$Case$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;'; - - @jni$_.internal - @core$_.override - JsonSerializable$Case? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : JsonSerializable$Case.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonSerializable$Case$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonSerializable$Case$NullableType$) && - other is $JsonSerializable$Case$NullableType$; + return _valueOf( + _class.reference.pointer, _id_valueOf.pointer, _$string.pointer) + .object(); } } @@ -12689,81 +9582,16 @@ final class $JsonSerializable$Case$Type$ @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;'; - - @jni$_.internal - @core$_.override - JsonSerializable$Case fromReference(jni$_.JReference reference) => - JsonSerializable$Case.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonSerializable$Case$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonSerializable$Case$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonSerializable$Case$Type$) && - other is $JsonSerializable$Case$Type$; - } } /// from: `com.github.dart_lang.jnigen.annotations.JsonSerializable` -class JsonSerializable extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - JsonSerializable.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type JsonSerializable._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/annotations/JsonSerializable'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $JsonSerializable$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $JsonSerializable$Type$(); - static final _id_value = _class.instanceMethodId( - r'value', - r'()Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;', - ); - - static final _value = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>>('globalEnv_CallObjectMethod') - .asFunction< - jni$_.JniResult Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - )>(); - - /// from: `public abstract com.github.dart_lang.jnigen.annotations.JsonSerializable$Case value()` - /// The returned object must be released after use, by calling the [release] method. - JsonSerializable$Case? value() { - return _value(reference.pointer, _id_value as jni$_.JMethodIDPtr) - .object( - const $JsonSerializable$Case$NullableType$()); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -12840,9 +9668,33 @@ class JsonSerializable extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return JsonSerializable.fromReference( - $i.implementReference(), - ); + return $i.implement(); + } +} + +extension JsonSerializable$$Methods on JsonSerializable { + static final _id_value = JsonSerializable._class.instanceMethodId( + r'value', + r'()Lcom/github/dart_lang/jnigen/annotations/JsonSerializable$Case;', + ); + + static final _value = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>>('globalEnv_CallObjectMethod') + .asFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + )>(); + + /// from: `public abstract com.github.dart_lang.jnigen.annotations.JsonSerializable$Case value()` + /// The returned object must be released after use, by calling the [release] method. + JsonSerializable$Case? value() { + return _value(reference.pointer, _id_value.pointer) + .object(); } } @@ -12866,46 +9718,6 @@ final class _$JsonSerializable with $JsonSerializable { } } -final class $JsonSerializable$NullableType$ - extends jni$_.JType { - @jni$_.internal - const $JsonSerializable$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/annotations/JsonSerializable;'; - - @jni$_.internal - @core$_.override - JsonSerializable? fromReference(jni$_.JReference reference) => - reference.isNull - ? null - : JsonSerializable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonSerializable$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonSerializable$NullableType$) && - other is $JsonSerializable$NullableType$; - } -} - final class $JsonSerializable$Type$ extends jni$_.JType { @jni$_.internal const $JsonSerializable$Type$(); @@ -12914,55 +9726,13 @@ final class $JsonSerializable$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/annotations/JsonSerializable;'; - - @jni$_.internal - @core$_.override - JsonSerializable fromReference(jni$_.JReference reference) => - JsonSerializable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $JsonSerializable$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($JsonSerializable$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($JsonSerializable$Type$) && - other is $JsonSerializable$Type$; - } } /// from: `com.github.dart_lang.jnigen.annotations.MyDataClass` -class MyDataClass extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - MyDataClass.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type MyDataClass._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/annotations/MyDataClass'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $MyDataClass$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $MyDataClass$Type$(); static final _id_new$ = _class.constructorId( @@ -12984,47 +9754,8 @@ class MyDataClass extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory MyDataClass() { - return MyDataClass.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $MyDataClass$NullableType$ extends jni$_.JType { - @jni$_.internal - const $MyDataClass$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/annotations/MyDataClass;'; - - @jni$_.internal - @core$_.override - MyDataClass? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : MyDataClass.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyDataClass$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyDataClass$NullableType$) && - other is $MyDataClass$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -13036,54 +9767,13 @@ final class $MyDataClass$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/annotations/MyDataClass;'; - - @jni$_.internal - @core$_.override - MyDataClass fromReference(jni$_.JReference reference) => - MyDataClass.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $MyDataClass$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($MyDataClass$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($MyDataClass$Type$) && - other is $MyDataClass$Type$; - } } /// from: `com.github.dart_lang.jnigen.annotations.NotNull` -class NotNull extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - NotNull.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type NotNull._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/annotations/NotNull'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $NotNull$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $NotNull$Type$(); @@ -13153,9 +9843,7 @@ class NotNull extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return NotNull.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } @@ -13167,43 +9855,6 @@ final class _$NotNull with $NotNull { _$NotNull(); } -final class $NotNull$NullableType$ extends jni$_.JType { - @jni$_.internal - const $NotNull$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/annotations/NotNull;'; - - @jni$_.internal - @core$_.override - NotNull? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : NotNull.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($NotNull$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($NotNull$NullableType$) && - other is $NotNull$NullableType$; - } -} - final class $NotNull$Type$ extends jni$_.JType { @jni$_.internal const $NotNull$Type$(); @@ -13211,51 +9862,13 @@ final class $NotNull$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/annotations/NotNull;'; - - @jni$_.internal - @core$_.override - NotNull fromReference(jni$_.JReference reference) => NotNull.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $NotNull$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($NotNull$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($NotNull$Type$) && other is $NotNull$Type$; - } } /// from: `com.github.dart_lang.jnigen.annotations.Nullable` -class Nullable extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - Nullable.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type Nullable._(jni$_.JObject _$this) implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/annotations/Nullable'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = $Nullable$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $Nullable$Type$(); @@ -13325,9 +9938,7 @@ class Nullable extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return Nullable.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } @@ -13339,43 +9950,6 @@ final class _$Nullable with $Nullable { _$Nullable(); } -final class $Nullable$NullableType$ extends jni$_.JType { - @jni$_.internal - const $Nullable$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/annotations/Nullable;'; - - @jni$_.internal - @core$_.override - Nullable? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : Nullable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Nullable$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Nullable$NullableType$) && - other is $Nullable$NullableType$; - } -} - final class $Nullable$Type$ extends jni$_.JType { @jni$_.internal const $Nullable$Type$(); @@ -13383,78 +9957,16 @@ final class $Nullable$Type$ extends jni$_.JType { @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/annotations/Nullable;'; - - @jni$_.internal - @core$_.override - Nullable fromReference(jni$_.JReference reference) => Nullable.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => const $Nullable$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($Nullable$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($Nullable$Type$) && other is $Nullable$Type$; - } } /// from: `com.github.dart_lang.jnigen.regressions.R2250$Child` -class R2250$Child extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - R2250$Child.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(reference); - +extension type R2250$Child._(jni$_.JObject _$this) + implements jni$_.JObject, R2250 { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/regressions/R2250$Child'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $R2250$Child$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $R2250$Child$Type$(); - static final _id_foo = _class.instanceMethodId( - r'foo', - r'(Ljava/lang/Object;)V', - ); - - static final _foo = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public abstract void foo(java.lang.Object object)` - void foo( - jni$_.JObject? object, - ) { - final _$object = object?.reference ?? jni$_.jNullReference; - _foo(reference.pointer, _id_foo as jni$_.JMethodIDPtr, _$object.pointer) - .check(); - } /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -13486,11 +9998,11 @@ class R2250$Child extends jni$_.JObject { try { final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; - if ($d == r'foo(Ljava/lang/Object;)V') { - _$impls[$p]!.foo( - $a![0]?.as(const jni$_.$JObject$Type$(), releaseOriginal: true), + if ($d == r'foo(Ljava/lang/Object;)I') { + final $r = _$impls[$p]!.foo( + ($a![0] as jni$_.JObject?), ); - return jni$_.nullptr; + return jni$_.JInteger($r).reference.toPointer(); } } catch (e) { return jni$_.ProtectedJniExtensions.newDartException(e); @@ -13517,9 +10029,7 @@ class R2250$Child extends jni$_.JObject { r'com.github.dart_lang.jnigen.regressions.R2250$Child', $p, _$invokePointer, - [ - if ($impl.foo$async) r'foo(Ljava/lang/Object;)V', - ], + [], ); final $a = $p.sendPort.nativePort; _$impls[$a] = $impl; @@ -13530,71 +10040,53 @@ class R2250$Child extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return R2250$Child.fromReference( - $i.implementReference(), - ); + return $i.implement(); } } -abstract base mixin class $R2250$Child { - factory $R2250$Child({ - required void Function(jni$_.JObject? object) foo, - core$_.bool foo$async, - }) = _$R2250$Child; - - void foo(jni$_.JObject? object); - core$_.bool get foo$async => false; -} - -final class _$R2250$Child with $R2250$Child { - _$R2250$Child({ - required void Function(jni$_.JObject? object) foo, - this.foo$async = false, - }) : _foo = foo; +extension R2250$Child$$Methods on R2250$Child { + static final _id_foo = R2250$Child._class.instanceMethodId( + r'foo', + r'(Ljava/lang/Object;)I', + ); - final void Function(jni$_.JObject? object) _foo; - final core$_.bool foo$async; + static final _foo = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); - void foo(jni$_.JObject? object) { - return _foo(object); + /// from: `public abstract int foo(java.lang.Object object)` + int foo( + jni$_.JObject? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _foo(reference.pointer, _id_foo.pointer, _$object.pointer).integer; } } -final class $R2250$Child$NullableType$ extends jni$_.JType { - @jni$_.internal - const $R2250$Child$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/regressions/R2250$Child;'; - - @jni$_.internal - @core$_.override - R2250$Child? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R2250$Child.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); +abstract base mixin class $R2250$Child { + factory $R2250$Child({ + required int Function(jni$_.JObject? object) foo, + }) = _$R2250$Child; - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; + int foo(jni$_.JObject? object); +} - @jni$_.internal - @core$_.override - final superCount = 1; +final class _$R2250$Child with $R2250$Child { + _$R2250$Child({ + required int Function(jni$_.JObject? object) foo, + }) : _foo = foo; - @core$_.override - int get hashCode => ($R2250$Child$NullableType$).hashCode; + final int Function(jni$_.JObject? object) _foo; - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R2250$Child$NullableType$) && - other is $R2250$Child$NullableType$; + int foo(jni$_.JObject? object) { + return _foo(object); } } @@ -13606,97 +10098,16 @@ final class $R2250$Child$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R2250$Child;'; - - @jni$_.internal - @core$_.override - R2250$Child fromReference(jni$_.JReference reference) => - R2250$Child.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $R2250$Child$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => ($R2250$Child$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R2250$Child$Type$) && - other is $R2250$Child$Type$; - } } /// from: `com.github.dart_lang.jnigen.regressions.R2250` -class R2250<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - R2250.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type R2250<$T extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/regressions/R2250'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $R2250$NullableType$<$T>( - T, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $R2250$Type$<$T>( - T, - ); - } - - static final _id_foo = _class.instanceMethodId( - r'foo', - r'(Ljava/lang/Object;)V', - ); - - static final _foo = jni$_.ProtectedJniExtensions.lookup< - jni$_.NativeFunction< - jni$_.JThrowablePtr Function( - jni$_.Pointer, - jni$_.JMethodIDPtr, - jni$_.VarArgs<(jni$_.Pointer,)>)>>( - 'globalEnv_CallVoidMethod') - .asFunction< - jni$_.JThrowablePtr Function(jni$_.Pointer, - jni$_.JMethodIDPtr, jni$_.Pointer)>(); - - /// from: `public abstract void foo(T object)` - void foo( - $T? object, - ) { - final _$object = object?.reference ?? jni$_.jNullReference; - _foo(reference.pointer, _id_foo as jni$_.JMethodIDPtr, _$object.pointer) - .check(); - } + static const jni$_.JType type = $R2250$Type$(); /// Maps a specific port to the implemented interface. static final core$_.Map _$impls = {}; @@ -13728,11 +10139,11 @@ class R2250<$T extends jni$_.JObject?> extends jni$_.JObject { try { final $d = $i.methodDescriptor.toDartString(releaseOriginal: true); final $a = $i.args; - if ($d == r'foo(Ljava/lang/Object;)V') { - _$impls[$p]!.foo( - $a![0]?.as(_$impls[$p]!.T, releaseOriginal: true), + if ($d == r'foo(Ljava/lang/Object;)I') { + final $r = _$impls[$p]!.foo( + ($a![0] as jni$_.JObject?), ); - return jni$_.nullptr; + return jni$_.JInteger($r).reference.toPointer(); } } catch (e) { return jni$_.ProtectedJniExtensions.newDartException(e); @@ -13759,9 +10170,7 @@ class R2250<$T extends jni$_.JObject?> extends jni$_.JObject { r'com.github.dart_lang.jnigen.regressions.R2250', $p, _$invokePointer, - [ - if ($impl.foo$async) r'foo(Ljava/lang/Object;)V', - ], + [], ); final $a = $p.sendPort.nativePort; _$impls[$a] = $impl; @@ -13772,152 +10181,70 @@ class R2250<$T extends jni$_.JObject?> extends jni$_.JObject { ) { final $i = jni$_.JImplementer(); implementIn($i, $impl); - return R2250<$T>.fromReference( - $impl.T, - $i.implementReference(), - ); + return $i.implement>(); + } +} + +extension R2250$$Methods<$T extends jni$_.JObject?> on R2250<$T> { + static final _id_foo = R2250._class.instanceMethodId( + r'foo', + r'(Ljava/lang/Object;)I', + ); + + static final _foo = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JniResult Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallIntMethod') + .asFunction< + jni$_.JniResult Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + /// from: `public abstract int foo(T object)` + int foo( + $T? object, + ) { + final _$object = object?.reference ?? jni$_.jNullReference; + return _foo(reference.pointer, _id_foo.pointer, _$object.pointer).integer; } } abstract base mixin class $R2250<$T extends jni$_.JObject?> { factory $R2250({ - required jni$_.JType<$T> T, - required void Function($T? object) foo, - core$_.bool foo$async, + required int Function($T? object) foo, }) = _$R2250<$T>; - jni$_.JType<$T> get T; - - void foo($T? object); - core$_.bool get foo$async => false; + int foo($T? object); } final class _$R2250<$T extends jni$_.JObject?> with $R2250<$T> { _$R2250({ - required this.T, - required void Function($T? object) foo, - this.foo$async = false, + required int Function($T? object) foo, }) : _foo = foo; - @core$_.override - final jni$_.JType<$T> T; - - final void Function($T? object) _foo; - final core$_.bool foo$async; + final int Function($T? object) _foo; - void foo($T? object) { + int foo($T? object) { return _foo(object); } } -final class $R2250$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $R2250$NullableType$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R2250;'; - - @jni$_.internal - @core$_.override - R2250<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R2250<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($R2250$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R2250$NullableType$<$T>) && - other is $R2250$NullableType$<$T> && - T == other.T; - } -} - -final class $R2250$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - +final class $R2250$Type$ extends jni$_.JType { @jni$_.internal - const $R2250$Type$( - this.T, - ); + const $R2250$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R2250;'; - - @jni$_.internal - @core$_.override - R2250<$T> fromReference(jni$_.JReference reference) => - R2250<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => $R2250$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($R2250$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R2250$Type$<$T>) && - other is $R2250$Type$<$T> && - T == other.T; - } } /// from: `com.github.dart_lang.jnigen.regressions.R693$Child` -class R693$Child extends R693 { - @jni$_.internal - @core$_.override - final jni$_.JType $type; - - @jni$_.internal - R693$Child.fromReference( - jni$_.JReference reference, - ) : $type = type, - super.fromReference(const $R693$Child$NullableType$(), reference); - +extension type R693$Child._(jni$_.JObject _$this) implements R693 { static final _class = jni$_.JClass.forName( r'com/github/dart_lang/jnigen/regressions/R693$Child'); - /// The type which includes information such as the signature of this class. - static const jni$_.JType nullableType = - $R693$Child$NullableType$(); - /// The type which includes information such as the signature of this class. static const jni$_.JType type = $R693$Child$Type$(); static final _id_new$ = _class.constructorId( @@ -13939,48 +10266,8 @@ class R693$Child extends R693 { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. factory R693$Child() { - return R693$Child.fromReference( - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $R693$Child$NullableType$ extends jni$_.JType { - @jni$_.internal - const $R693$Child$NullableType$(); - - @jni$_.internal - @core$_.override - String get signature => - r'Lcom/github/dart_lang/jnigen/regressions/R693$Child;'; - - @jni$_.internal - @core$_.override - R693$Child? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R693$Child.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $R693$NullableType$($R693$Child$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($R693$Child$NullableType$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R693$Child$NullableType$) && - other is $R693$Child$NullableType$; + return _new$(_class.reference.pointer, _id_new$.pointer) + .object(); } } @@ -13992,74 +10279,16 @@ final class $R693$Child$Type$ extends jni$_.JType { @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R693$Child;'; - - @jni$_.internal - @core$_.override - R693$Child fromReference(jni$_.JReference reference) => - R693$Child.fromReference( - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => - const $R693$NullableType$($R693$Child$NullableType$()); - - @jni$_.internal - @core$_.override - jni$_.JType get nullableType => - const $R693$Child$NullableType$(); - - @jni$_.internal - @core$_.override - final superCount = 2; - - @core$_.override - int get hashCode => ($R693$Child$Type$).hashCode; - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R693$Child$Type$) && - other is $R693$Child$Type$; - } } /// from: `com.github.dart_lang.jnigen.regressions.R693` -class R693<$T extends jni$_.JObject?> extends jni$_.JObject { - @jni$_.internal - @core$_.override - final jni$_.JType> $type; - - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - R693.fromReference( - this.T, - jni$_.JReference reference, - ) : $type = type<$T>(T), - super.fromReference(reference); - +extension type R693<$T extends jni$_.JObject?>._(jni$_.JObject _$this) + implements jni$_.JObject { static final _class = jni$_.JClass.forName(r'com/github/dart_lang/jnigen/regressions/R693'); /// The type which includes information such as the signature of this class. - static jni$_.JType?> nullableType<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $R693$NullableType$<$T>( - T, - ); - } - - /// The type which includes information such as the signature of this class. - static jni$_.JType> type<$T extends jni$_.JObject?>( - jni$_.JType<$T> T, - ) { - return $R693$Type$<$T>( - T, - ); - } - + static const jni$_.JType type = $R693$Type$(); static final _id_new$ = _class.constructorId( r'()V', ); @@ -14078,100 +10307,16 @@ class R693<$T extends jni$_.JObject?> extends jni$_.JObject { /// from: `public void ()` /// The returned object must be released after use, by calling the [release] method. - factory R693({ - required jni$_.JType<$T> T, - }) { - return R693<$T>.fromReference( - T, - _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) - .reference); - } -} - -final class $R693$NullableType$<$T extends jni$_.JObject?> - extends jni$_.JType?> { - @jni$_.internal - final jni$_.JType<$T> T; - - @jni$_.internal - const $R693$NullableType$( - this.T, - ); - - @jni$_.internal - @core$_.override - String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R693;'; - - @jni$_.internal - @core$_.override - R693<$T>? fromReference(jni$_.JReference reference) => reference.isNull - ? null - : R693<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => this; - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($R693$NullableType$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R693$NullableType$<$T>) && - other is $R693$NullableType$<$T> && - T == other.T; + factory R693() { + return _new$(_class.reference.pointer, _id_new$.pointer).object>(); } } -final class $R693$Type$<$T extends jni$_.JObject?> - extends jni$_.JType> { - @jni$_.internal - final jni$_.JType<$T> T; - +final class $R693$Type$ extends jni$_.JType { @jni$_.internal - const $R693$Type$( - this.T, - ); + const $R693$Type$(); @jni$_.internal @core$_.override String get signature => r'Lcom/github/dart_lang/jnigen/regressions/R693;'; - - @jni$_.internal - @core$_.override - R693<$T> fromReference(jni$_.JReference reference) => R693<$T>.fromReference( - T, - reference, - ); - @jni$_.internal - @core$_.override - jni$_.JType get superType => const jni$_.$JObject$NullableType$(); - - @jni$_.internal - @core$_.override - jni$_.JType?> get nullableType => $R693$NullableType$<$T>(T); - - @jni$_.internal - @core$_.override - final superCount = 1; - - @core$_.override - int get hashCode => Object.hash($R693$Type$, T); - - @core$_.override - core$_.bool operator ==(Object other) { - return other.runtimeType == ($R693$Type$<$T>) && - other is $R693$Type$<$T> && - T == other.T; - } } diff --git a/pkgs/jnigen/test/simple_package_test/generate.dart b/pkgs/jnigen/test/simple_package_test/generate.dart index 5cfcfe83ba..974b36d706 100644 --- a/pkgs/jnigen/test/simple_package_test/generate.dart +++ b/pkgs/jnigen/test/simple_package_test/generate.dart @@ -40,8 +40,15 @@ final javaFiles = [ join(javaPrefix, 'inheritance', 'BaseClass.java'), join(javaPrefix, 'inheritance', 'BaseInterface.java'), join(javaPrefix, 'inheritance', 'BaseGenericInterface.java'), + join(javaPrefix, 'inheritance', 'Child.java'), join(javaPrefix, 'inheritance', 'DerivedInterface.java'), join(javaPrefix, 'inheritance', 'GenericDerivedClass.java'), + join(javaPrefix, 'inheritance', 'Animal.java'), + join(javaPrefix, 'inheritance', 'Mammal.java'), + join(javaPrefix, 'inheritance', 'FourLegged.java'), + join(javaPrefix, 'inheritance', 'Dog.java'), + join(javaPrefix, 'inheritance', 'Furry.java'), + join(javaPrefix, 'inheritance', 'ShibaInu.java'), join(javaPrefix, 'inheritance', 'SpecificDerivedClass.java'), join(javaPrefix, 'interfaces', 'GenericInterface.java'), join(javaPrefix, 'interfaces', 'InheritedFromMyInterface.java'), diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Animal.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Animal.java new file mode 100644 index 0000000000..6a99998bd5 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Animal.java @@ -0,0 +1,12 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +import com.github.dart_lang.jnigen.annotations.NotNull; + +public interface Animal { + @NotNull + String eat(@NotNull String food); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseClass.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseClass.java index f9157e426d..02aec6b07e 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseClass.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseClass.java @@ -4,4 +4,8 @@ package com.github.dart_lang.jnigen.inheritance; -public class BaseClass {} +public class BaseClass { + public T someMethod(T t) { + return t; + } +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseInterface.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseInterface.java index b035dddb91..3994de5b82 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseInterface.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/BaseInterface.java @@ -2,4 +2,6 @@ public interface BaseInterface { String foo(); + + String someMethod(String s); } diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Child.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Child.java new file mode 100644 index 0000000000..b91ea2037e --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Child.java @@ -0,0 +1,16 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +public class Child extends BaseClass implements BaseInterface { + @Override + public String foo() { + return "foo"; + } + + public String someMethod(String s) { + return s; + } +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Dog.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Dog.java new file mode 100644 index 0000000000..65088582e6 --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Dog.java @@ -0,0 +1,12 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +import com.github.dart_lang.jnigen.annotations.NotNull; + +public interface Dog extends Mammal, FourLegged { + @NotNull + String bark(); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/FourLegged.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/FourLegged.java new file mode 100644 index 0000000000..8f8ee9507e --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/FourLegged.java @@ -0,0 +1,9 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +public interface FourLegged extends Animal { + int walk(int steps); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Furry.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Furry.java new file mode 100644 index 0000000000..ac0a7bdb9f --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Furry.java @@ -0,0 +1,12 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +import com.github.dart_lang.jnigen.annotations.NotNull; + +public interface Furry extends Mammal { + @NotNull + String groom(); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Mammal.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Mammal.java new file mode 100644 index 0000000000..6c93eb946d --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/Mammal.java @@ -0,0 +1,12 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +import com.github.dart_lang.jnigen.annotations.Nullable; + +public interface Mammal extends Animal { + @Nullable + String giveBirth(boolean success); +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/ShibaInu.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/ShibaInu.java new file mode 100644 index 0000000000..06824a3c2a --- /dev/null +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/ShibaInu.java @@ -0,0 +1,39 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +package com.github.dart_lang.jnigen.inheritance; + +import com.github.dart_lang.jnigen.annotations.NotNull; +import com.github.dart_lang.jnigen.annotations.Nullable; + +public class ShibaInu implements Dog, Furry { + @Override + @NotNull + public String eat(@NotNull String food) { + return "Shiba eating " + food; + } + + @Override + @Nullable + public String giveBirth(boolean success) { + return success ? "Baby Shiba" : null; + } + + @Override + public int walk(int steps) { + return steps; + } + + @Override + @NotNull + public String bark() { + return "Woof!"; + } + + @Override + @NotNull + public String groom() { + return "Grooming Shiba"; + } +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass.java index 6c33e8315d..f52e2e3d11 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/inheritance/SpecificDerivedClass.java @@ -4,4 +4,9 @@ package com.github.dart_lang.jnigen.inheritance; -public class SpecificDerivedClass extends BaseClass {} +public class SpecificDerivedClass extends BaseClass { + @Override + public String someMethod(String s) { + return "Hello " + s; + } +} diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/regressions/R2250.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/regressions/R2250.java index fe2f831536..a1047db93a 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/regressions/R2250.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/regressions/R2250.java @@ -6,7 +6,7 @@ // Regression test for https://github.com/dart-lang/native/issues/2250. public interface R2250 { - public void foo(T t); + public int foo(T t); public interface Child extends R2250 {} } diff --git a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Exceptions.java b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Exceptions.java index e0e79b3441..8fac6a742b 100644 --- a/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Exceptions.java +++ b/pkgs/jnigen/test/simple_package_test/java/com/github/dart_lang/jnigen/simple_package/Exceptions.java @@ -79,4 +79,17 @@ public int throwArithmeticException() { public static void throwLoremIpsum() { throw new RuntimeException("Lorem Ipsum"); } + + public static class MyException extends RuntimeException { + public int errorCode; + + public MyException(String message, int errorCode) { + super(message); + this.errorCode = errorCode; + } + } + + public static void throwMyException() { + throw new MyException("My custom exception", 123); + } } diff --git a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart index 1479ccda97..7ba0bb5739 100644 --- a/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart +++ b/pkgs/jnigen/test/simple_package_test/runtime_test_registrant.dart @@ -229,7 +229,7 @@ void registerTests(String groupName, TestRunnerCallback test) { final ex2 = Example(); ex1.setNumber(1); ex2.setNumber(2); - final array = JArray(Example.nullableType, 2); + final array = JArray.withLength(Example.type, 2); array[0] = ex1; array[1] = ex2; expect(array[0]!.getNumber(), 1); @@ -250,7 +250,7 @@ void registerTests(String groupName, TestRunnerCallback test) { group('exception tests', () { void throwsException(void Function() f) { - expect(f, throwsA(isA())); + expect(f, throwsA(isA())); } test('Example throw exception', () { @@ -281,7 +281,7 @@ void registerTests(String groupName, TestRunnerCallback test) { test('Exception contains error message & stack trace', () { try { Exceptions.throwLoremIpsum(); - } on JniException catch (e) { + } on JThrowable catch (e) { expect(e.message, stringContainsInOrder(['Lorem Ipsum'])); expect( e.toString(), @@ -291,6 +291,24 @@ void registerTests(String groupName, TestRunnerCallback test) { } throw AssertionError('No exception was thrown'); }); + + test('Custom exception handling', () { + try { + Exceptions.throwMyException(); + } on JThrowable catch (e) { + switch (e) { + case _ when e.isA(Exceptions$MyException.type): + final myEx = e.as(Exceptions$MyException.type); + expect(myEx.errorCode, 123); + return; + default: + fail('Expected Exceptions\$MyException, but got JThrowable: $e'); + } + } catch (e) { + fail('Expected JThrowable, but got ${e.runtimeType}: $e'); + } + throw AssertionError('No exception was thrown'); + }); }); group('generics', () { @@ -298,10 +316,7 @@ void registerTests(String groupName, TestRunnerCallback test) { using((arena) { final grandParent = GrandParent( 'Hello'.toJString()..releasedBy(arena), - T: JString.type, )..releasedBy(arena); - expect(grandParent, isA>()); - expect(grandParent.$type, isA<$GrandParent$Type$>()); expect( grandParent.value!.toDartString(releaseOriginal: true), 'Hello', @@ -310,38 +325,16 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('MyStack', () { using((arena) { - final stack = MyStack(T: JString.type)..releasedBy(arena); + final stack = MyStack()..releasedBy(arena); stack.push('Hello'.toJString()..releasedBy(arena)); stack.push('World'.toJString()..releasedBy(arena)); expect(stack.pop()!.toDartString(releaseOriginal: true), 'World'); expect(stack.pop()!.toDartString(releaseOriginal: true), 'Hello'); }); }); - test( - 'Different stacks have different types, same stacks have same types', - () { - using((arena) { - final aStringStack = MyStack(T: JString.type)..releasedBy(arena); - final anotherStringStack = MyStack(T: JString.type) - ..releasedBy(arena); - final anObjectStack = MyStack(T: JObject.type)..releasedBy(arena); - expect(aStringStack.$type, anotherStringStack.$type); - expect( - aStringStack.$type.hashCode, - anotherStringStack.$type.hashCode, - ); - expect(aStringStack.$type, isNot(anObjectStack.$type)); - expect( - aStringStack.$type.hashCode, - isNot(anObjectStack.$type.hashCode), - ); - }); - }, - ); test('MyMap', () { using((arena) { - final map = MyMap(K: JString.type, V: Example.type) - ..releasedBy(arena); + final map = MyMap()..releasedBy(arena); final helloExample = Example.new$1(1)..releasedBy(arena); final worldExample = Example.new$1(2)..releasedBy(arena); map.put('Hello'.toJString()..releasedBy(arena), helloExample); @@ -384,7 +377,7 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('StringKeyedMap', () { using((arena) { - final map = StringKeyedMap(V: Example.type)..releasedBy(arena); + final map = StringKeyedMap()..releasedBy(arena); final example = Example()..releasedBy(arena); map.put('Hello'.toJString()..releasedBy(arena), example); expect( @@ -399,7 +392,7 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('StringValuedMap', () { using((arena) { - final map = StringValuedMap(K: Example.type)..releasedBy(arena); + final map = StringValuedMap()..releasedBy(arena); final example = Example()..releasedBy(arena); map.put(example, 'Hello'.toJString()..releasedBy(arena)); expect( @@ -424,22 +417,9 @@ void registerTests(String groupName, TestRunnerCallback test) { }); }); }); - test('superclass count', () { - // ignore: invalid_use_of_internal_member - expect(JObject.type.superCount, 0); - // ignore: invalid_use_of_internal_member - expect(MyMap.type(JObject.type, JObject.type).superCount, 1); - // ignore: invalid_use_of_internal_member - expect(StringKeyedMap.type(JObject.type).superCount, 2); - // ignore: invalid_use_of_internal_member - expect(StringValuedMap.type(JObject.type).superCount, 2); - // ignore: invalid_use_of_internal_member - expect(StringMap.type.superCount, 3); - }); test('nested generics', () { using((arena) { - final grandParent = GrandParent( - T: JString.type, + final grandParent = GrandParent( '!'.toJString()..releasedBy(arena), )..releasedBy(arena); expect(grandParent.value!.toDartString(releaseOriginal: true), '!'); @@ -452,7 +432,6 @@ void registerTests(String groupName, TestRunnerCallback test) { ); final exampleStaticParent = GrandParent.varStaticParent( - S: Example.type, Example()..releasedBy(arena), )! ..releasedBy(arena); @@ -471,7 +450,6 @@ void registerTests(String groupName, TestRunnerCallback test) { expect(strParent.value!.toDartString(releaseOriginal: true), 'Hello'); final exampleParent = grandParent.varParent( - S: Example.type, Example()..releasedBy(arena), )! ..releasedBy(arena); @@ -489,17 +467,14 @@ void registerTests(String groupName, TestRunnerCallback test) { }); test('Constructing non-static nested classes', () { using((arena) { - final grandParent = GrandParent(1.toJInteger(), T: JInteger.type) - ..releasedBy(arena); + final grandParent = GrandParent(1.toJInteger())..releasedBy(arena); final parent = GrandParent$Parent( grandParent, 2.toJInteger(), - S: JInteger.type, )..releasedBy(arena); final child = GrandParent$Parent$Child( parent, 3.toJInteger(), - U: JInteger.type, )..releasedBy(arena); expect(grandParent.value!.intValue(releaseOriginal: true), 1); expect(parent.parentValue!.intValue(releaseOriginal: true), 1); @@ -510,908 +485,927 @@ void registerTests(String groupName, TestRunnerCallback test) { }); }); - group('Generic type inference', () { - test('MyStack.of1', () { - using((arena) { - final emptyStack = MyStack(T: JString.type)..releasedBy(arena); - expect(emptyStack.size(), 0); - final stack = MyStack.of$1( - 'Hello'.toJString()..releasedBy(arena), - T: JString.type, - )! - ..releasedBy(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStack$Type$>()); - expect(stack.pop()!.toDartString(releaseOriginal: true), 'Hello'); - }); - }); - test('MyStack.of 2 strings', () { - using((arena) { - final stack = MyStack.of$2( - 'Hello'.toJString()..releasedBy(arena), - 'World'.toJString()..releasedBy(arena), - T: JString.type, - )! - ..releasedBy(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStack$Type$>()); - expect(stack.pop()!.toDartString(releaseOriginal: true), 'World'); - expect(stack.pop()!.toDartString(releaseOriginal: true), 'Hello'); - }); - }); - test('MyStack.of a string and an array', () { - using((arena) { - final array = JArray.filled(1, 'World'.toJString()..releasedBy(arena)) - ..releasedBy(arena); - final stack = MyStack.of$2( - T: JObject.type, - 'Hello'.toJString()..releasedBy(arena), - array, - )! - ..releasedBy(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStack$Type$>()); - expect( - stack - .pop()! - .as(JArray.type(JString.type), releaseOriginal: true)[0] - .toDartString(releaseOriginal: true), - 'World', + group('interface implementation', () { + for (final (threading, consume) in [ + ('another thread', MyInterfaceConsumer.consumeOnAnotherThread), + ('the same thread', MyInterfaceConsumer.consumeOnSameThread), + ]) { + test('MyInterface.implement on $threading', () async { + final voidCallbackResult = Completer(); + final varCallbackResult = Completer(); + final manyPrimitivesResult = Completer(); + // We can use this trick to access self, instead of generating a + // `thiz` or `self` argument for each one of the callbacks. + late final MyInterface myInterface; + myInterface = MyInterface.implement( + $MyInterface( + voidCallback: voidCallbackResult.complete, + stringCallback: (s) { + return (s!.toDartString(releaseOriginal: true) * 2).toJString(); + }, + varCallback: (JInteger? t) { + final result = + (t!.intValue(releaseOriginal: true) * 2).toJInteger(); + varCallbackResult.complete(result); + return result; + }, + manyPrimitives: (a, b, c, d) { + if (b) { + final result = a + c + d.toInt(); + manyPrimitivesResult.complete(result); + return result; + } else { + // Call self, add to [a] when [b] is false and change b to + // true. + return myInterface.manyPrimitives(a + 1, true, c, d); + } + }, + ), ); - expect( - stack - .pop()! - .as(JString.type, releaseOriginal: true) - .toDartString(releaseOriginal: true), - 'Hello', + // [stringCallback] is going to be called first using [s]. + // The result of it is going to be used as the argument for + // [voidCallback]. + // The other two methods will be called individually using the passed + // arguments afterwards. + consume( + myInterface, + // For stringCallback: + 'hello'.toJString(), + // For manyPrimitives: + -1, + false, + 3, + 3.14, + // For varCallback + 7.toJInteger(), ); + final voidCallback = await voidCallbackResult.future; + expect( + voidCallback.toDartString(releaseOriginal: true), 'hellohello'); + + final varCallback = await varCallbackResult.future; + expect(varCallback.intValue(), 14); + + final manyPrimitives = await manyPrimitivesResult.future; + expect(manyPrimitives, -1 + 3 + 3.14.toInt() + 1); + + // Running garbage collection does not work on Android. Skipping this + // test on Android. + // Currently we have one implementation of the interface. + expect(MyInterface.$impls, hasLength(1), skip: Platform.isAndroid); + myInterface.release(); + if (!Platform.isAndroid) { + _runJavaGC(); + await _waitUntil(() => MyInterface.$impls.isEmpty); + expect(MyInterface.$impls, isEmpty); + } }); - }); - test('MyStack.from array of string', () { - using((arena) { - final array = JArray.filled(1, 'Hello'.toJString()..releasedBy(arena)) - ..releasedBy(arena); - final stack = MyStack.fromArray(T: JString.type, array)! - ..releasedBy(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStack$Type$>()); - expect(stack.pop()!.toDartString(releaseOriginal: true), 'Hello'); + test('implementing multiple interfaces', () async { + final implementer = JImplementer(); + MyInterface.implementIn( + implementer, + $MyInterface( + voidCallback: (s) {}, + stringCallback: (s) { + return s; + }, + varCallback: (t) { + return t; + }, + manyPrimitives: (a, b, c, d) => 42, + ), + ); + var runnableRan = false; + MyRunnable.implementIn( + implementer, + $MyRunnable( + run: () { + runnableRan = true; + }, + ), + ); + final runnable = implementer.implement(); + runnable.run(); + expect(runnableRan, isTrue); + final myInterface = runnable.as( + MyInterface.type, + releaseOriginal: true, + ); + expect(myInterface.manyPrimitives(1, true, 3, 4), 42); + + // Running garbage collection does not work on Android. Skipping this + // test on Android. + expect(MyInterface.$impls, hasLength(1), skip: Platform.isAndroid); + expect(MyRunnable.$impls, hasLength(1), skip: Platform.isAndroid); + myInterface.release(); + if (!Platform.isAndroid) { + _runJavaGC(); + await _waitUntil(() => MyInterface.$impls.isEmpty); + // Since the interface is now deleted, the cleaner must signal to + // Dart to clean up. + expect(MyInterface.$impls, isEmpty); + expect(MyRunnable.$impls, isEmpty); + } }); - }); - test('MyStack.fromArrayOfArrayOfGrandParents', () { - using((arena) { - final firstDimention = JArray.filled( - 1, - GrandParent(T: JString.type, 'Hello'.toJString()..releasedBy(arena)) - ..releasedBy(arena), - )..releasedBy(arena); - final twoDimentionalArray = JArray.filled(1, firstDimention) - ..releasedBy(arena); - final stack = MyStack.fromArrayOfArrayOfGrandParents( - S: JString.type, - twoDimentionalArray, - )! - ..releasedBy(arena); - expect(stack, isA>()); - expect(stack.$type, isA<$MyStack$Type$>()); - expect(stack.pop()!.toDartString(releaseOriginal: true), 'Hello'); + test('Reuse implementation for multiple instances', () { + using((arena) { + final hexParser = StringConverter.implement( + DartStringToIntParser(radix: 16), + )..releasedBy(arena); + final decimalParser = StringConverter.implement( + DartStringToIntParser(radix: 10), + )..releasedBy(arena); + final fifteen = StringConverterConsumer.consumeOnSameThread( + hexParser, + 'F'.toJString()..releasedBy(arena), + )!; + expect(fifteen.intValue(releaseOriginal: true), 15); + final fortyTwo = StringConverterConsumer.consumeOnSameThread( + decimalParser, + '42'.toJString()..releasedBy(arena), + )!; + expect(fortyTwo.intValue(releaseOriginal: true), 42); + }); }); - }); - }); - }); - - group('interface implementation', () { - for (final (threading, consume) in [ - ('another thread', MyInterfaceConsumer.consumeOnAnotherThread), - ('the same thread', MyInterfaceConsumer.consumeOnSameThread), - ]) { - test('MyInterface.implement on $threading', () async { - final voidCallbackResult = Completer(); - final varCallbackResult = Completer(); - final manyPrimitivesResult = Completer(); - // We can use this trick to access self, instead of generating a `thiz` - // or `self` argument for each one of the callbacks. - late final MyInterface myInterface; - myInterface = MyInterface.implement( - $MyInterface( - voidCallback: voidCallbackResult.complete, - stringCallback: (s) { - return (s!.toDartString(releaseOriginal: true) * 2).toJString(); - }, - varCallback: (JInteger? t) { - final result = - (t!.intValue(releaseOriginal: true) * 2).toJInteger(); - varCallbackResult.complete(result); - return result; - }, - manyPrimitives: (a, b, c, d) { - if (b) { - final result = a + c + d.toInt(); - manyPrimitivesResult.complete(result); - return result; - } else { - // Call self, add to [a] when [b] is false and change b to true. - return myInterface.manyPrimitives(a + 1, true, c, d); - } - }, - T: JInteger.type, - ), - ); - // [stringCallback] is going to be called first using [s]. - // The result of it is going to be used as the argument for - // [voidCallback]. - // The other two methods will be called individually using the passed - // arguments afterwards. - consume( - T: JInteger.type, - myInterface, - // For stringCallback: - 'hello'.toJString(), - // For manyPrimitives: - -1, - false, - 3, - 3.14, - // For varCallback - 7.toJInteger(), - ); - final voidCallback = await voidCallbackResult.future; - expect(voidCallback.toDartString(releaseOriginal: true), 'hellohello'); - - final varCallback = await varCallbackResult.future; - expect(varCallback.intValue(), 14); - - final manyPrimitives = await manyPrimitivesResult.future; - expect(manyPrimitives, -1 + 3 + 3.14.toInt() + 1); - - // Running garbage collection does not work on Android. Skipping this - // test on Android. - // Currently we have one implementation of the interface. - expect(MyInterface.$impls, hasLength(1), skip: Platform.isAndroid); - myInterface.release(); - if (!Platform.isAndroid) { - _runJavaGC(); - await _waitUntil(() => MyInterface.$impls.isEmpty); - expect(MyInterface.$impls, isEmpty); - } - }); - test('implementing multiple interfaces', () async { - final implementer = JImplementer(); - MyInterface.implementIn( - implementer, - $MyInterface( - T: JString.type, - voidCallback: (s) {}, - stringCallback: (s) { - return s; - }, - varCallback: (t) { - return t; - }, - manyPrimitives: (a, b, c, d) => 42, - ), - ); - var runnableRan = false; - MyRunnable.implementIn( - implementer, - $MyRunnable( - run: () { - runnableRan = true; - }, - ), - ); - final runnable = implementer.implement(MyRunnable.type); - runnable.run(); - expect(runnableRan, isTrue); - final myInterface = runnable.as( - MyInterface.type(JString.type), - releaseOriginal: true, - ); - expect(myInterface.manyPrimitives(1, true, 3, 4), 42); - - // Running garbage collection does not work on Android. Skipping this - // test on Android. - expect(MyInterface.$impls, hasLength(1), skip: Platform.isAndroid); - expect(MyRunnable.$impls, hasLength(1), skip: Platform.isAndroid); - myInterface.release(); - if (!Platform.isAndroid) { - _runJavaGC(); - await _waitUntil(() => MyInterface.$impls.isEmpty); - // Since the interface is now deleted, the cleaner must signal to Dart - // to clean up. - expect(MyInterface.$impls, isEmpty); - expect(MyRunnable.$impls, isEmpty); + for (final style in ['callback', 'implemented class']) { + test('Listener callbacks - $style style', () async { + final completer = Completer(); + + final MyRunnable runnable; + if (style == 'callback') { + runnable = MyRunnable.implement( + $MyRunnable(run: completer.complete, run$async: true), + ); + } else { + runnable = MyRunnable.implement(AsyncRunnable(completer)); + } + final runner = MyRunnableRunner(runnable); + // Normally this would cause a deadlock, but as the callback is a + // listener, it will work. + runner.runOnAnotherThreadAndJoin(); + await completer.future; + // Running garbage collection does not work on Android. Skipping + // this test on Android. + expect(MyRunnable.$impls, hasLength(1), skip: Platform.isAndroid); + runnable.release(); + runner.release(); + if (!Platform.isAndroid) { + _runJavaGC(); + await _waitUntil(() => MyInterface.$impls.isEmpty); + // Since the interface is now deleted, the cleaner must signal to + // Dart to clean up. + expect(MyRunnable.$impls, isEmpty); + } + }); } - }); - test('Reuse implementation for multiple instances', () { - using((arena) { - final hexParser = StringConverter.implement( - DartStringToIntParser(radix: 16), - )..releasedBy(arena); - final decimalParser = StringConverter.implement( - DartStringToIntParser(radix: 10), - )..releasedBy(arena); - final fifteen = StringConverterConsumer.consumeOnSameThread( - hexParser, - 'F'.toJString()..releasedBy(arena), - )!; - expect(fifteen.intValue(releaseOriginal: true), 15); - final fortyTwo = StringConverterConsumer.consumeOnSameThread( - decimalParser, - '42'.toJString()..releasedBy(arena), - )!; - expect(fortyTwo.intValue(releaseOriginal: true), 42); - }); - }); - for (final style in ['callback', 'implemented class']) { - test('Listener callbacks - $style style', () async { - final completer = Completer(); - - final MyRunnable runnable; - if (style == 'callback') { - runnable = MyRunnable.implement( - $MyRunnable(run: completer.complete, run$async: true), - ); - } else { - runnable = MyRunnable.implement(AsyncRunnable(completer)); - } - final runner = MyRunnableRunner(runnable); - // Normally this would cause a deadlock, but as the callback is a - // listener, it will work. - runner.runOnAnotherThreadAndJoin(); - await completer.future; + test('Object methods work', () async { + final runnable = MyRunnable.implement($MyRunnable(run: () {})); + expect(runnable == runnable, true); + expect(runnable != runnable, false); + expect(runnable.hashCode, runnable.hashCode); + expect(runnable.toString(), runnable.toString()); // Running garbage collection does not work on Android. Skipping // this test on Android. expect(MyRunnable.$impls, hasLength(1), skip: Platform.isAndroid); runnable.release(); - runner.release(); if (!Platform.isAndroid) { _runJavaGC(); await _waitUntil(() => MyInterface.$impls.isEmpty); - // Since the interface is now deleted, the cleaner must signal to - // Dart to clean up. expect(MyRunnable.$impls, isEmpty); } }); } - test('Object methods work', () async { - final runnable = MyRunnable.implement($MyRunnable(run: () {})); - expect(runnable == runnable, true); - expect(runnable != runnable, false); - expect(runnable.hashCode, runnable.hashCode); - expect(runnable.toString(), runnable.toString()); - // Running garbage collection does not work on Android. Skipping - // this test on Android. - expect(MyRunnable.$impls, hasLength(1), skip: Platform.isAndroid); - runnable.release(); - if (!Platform.isAndroid) { - _runJavaGC(); - await _waitUntil(() => MyInterface.$impls.isEmpty); - expect(MyRunnable.$impls, isEmpty); - } - }); - } - group('Dart exceptions are handled', () { - for (final exception in [UnimplementedError(), 'Hello!']) { - for (final sameThread in [true, false]) { - test( - 'on ${sameThread ? 'the same thread' : 'another thread'}' - ' throwing $exception', () async { - await using((arena) async { - final runnable = MyRunnable.implement( - $MyRunnable( - run: () { - // ignore: only_throw_errors - throw exception; - }, - ), - )..releasedBy(arena); - final runner = MyRunnableRunner(runnable)..releasedBy(arena); - if (sameThread) { - runner.runOnSameThread(); - } else { - runner.runOnAnotherThread(); - } - while (runner.error == null) { - await Future.delayed(const Duration(milliseconds: 100)); - } - expect( - runner.error!.isInstanceOf( - JClass.forName( - 'java/lang/reflect/UndeclaredThrowableException', + group('Dart exceptions are handled', () { + for (final exception in [UnimplementedError(), 'Hello!']) { + for (final sameThread in [true, false]) { + test( + 'on ${sameThread ? 'the same thread' : 'another thread'}' + ' throwing $exception', () async { + await using((arena) async { + final runnable = MyRunnable.implement( + $MyRunnable( + run: () { + // ignore: only_throw_errors + throw exception; + }, ), - ), - isTrue, - ); - final throwableClass = runner.error!.jClass; - final cause = throwableClass - .instanceMethodId('getCause', '()Ljava/lang/Throwable;') - .call(runner.error!, JObject.type, []); - expect( - cause.isInstanceOf( - JClass.forName( - 'com/github/dart_lang/jni/PortProxyBuilder\$DartException', + )..releasedBy(arena); + final runner = MyRunnableRunner(runnable)..releasedBy(arena); + if (sameThread) { + runner.runOnSameThread(); + } else { + runner.runOnAnotherThread(); + } + while (runner.error == null) { + await Future.delayed(const Duration(milliseconds: 100)); + } + expect( + runner.error!.isInstanceOf( + JClass.forName( + 'java/lang/reflect/UndeclaredThrowableException', + ), ), - ), - isTrue, - ); - expect(cause.toString(), contains(exception.toString())); + isTrue, + ); + final throwableClass = runner.error!.jClass; + final cause = throwableClass + .instanceMethodId('getCause', '()Ljava/lang/Throwable;') + .call(runner.error!, JObject.type, []); + expect( + cause.isInstanceOf( + JClass.forName( + 'com/github/dart_lang/jni/PortProxyBuilder\$DartException', + ), + ), + isTrue, + ); + expect(cause.toString(), contains(exception.toString())); + }); + if (!Platform.isAndroid) { + _runJavaGC(); + } }); - if (!Platform.isAndroid) { - _runJavaGC(); - } - }); + } } - } - }); + }); - group('throw Java exceptions', () { - for (final (threading, consume) in [ - ('another thread', StringConverterConsumer.consumeOnAnotherThread), - ('the same thread', StringConverterConsumer.consumeOnSameThread), - ]) { - test('StringConverter.implement on $threading ', () async { - final stringConverter = StringConverter.implement( - $StringConverter( - parseToInt: (s) { - final value = int.tryParse(s!.toDartString()); - if (value == null) { - // ignore: only_throw_errors - throw StringConversionException( - 'Invalid integer expression: $s'.toJString(), - ); - } + group('throw Java exceptions', () { + for (final (threading, consume) in [ + ('another thread', StringConverterConsumer.consumeOnAnotherThread), + ('the same thread', StringConverterConsumer.consumeOnSameThread), + ]) { + test('StringConverter.implement on $threading ', () async { + final stringConverter = StringConverter.implement( + $StringConverter( + parseToInt: (s) { + final value = int.tryParse(s!.toDartString()); + if (value == null) { + // ignore: only_throw_errors + throw StringConversionException( + 'Invalid integer expression: $s'.toJString(), + ); + } - return value; - }, + return value; + }, + ), + ); + + // Gets the result of a Java Future. + // TODO(#1213): remove this once we support Java futures. + Future<$T> toDartFuture<$T extends JObject>( + JObject future, + JType<$T> T, + ) async { + final receivePort = ReceivePort(); + await Isolate.spawn((sendPort) { + final futureClass = + JClass.forName('java/util/concurrent/Future'); + final getMethod = futureClass.instanceMethodId( + 'get', + '()Ljava/lang/Object;', + ); + final result = getMethod(future, T, []); + // A workaround for `--pause-isolates-on-exit`. Otherwise + // getting test with coverage pauses indefinitely here. + // https://github.com/dart-lang/coverage/issues/472 + Isolate.current.kill(); + sendPort.send(result); + }, receivePort.sendPort); + return (await receivePort.first) as $T; + } + + final sevenHundredBoxed = consume( + stringConverter, + '700'.toJString(), + )!; + final int sevenHundred; + if (sevenHundredBoxed.isA(JInteger.type)) { + sevenHundred = (sevenHundredBoxed as JInteger).intValue(); + } else { + sevenHundred = (await toDartFuture( + sevenHundredBoxed, + JInteger.type, + )) + .intValue(); + } + expect(sevenHundred, 700); + + final fooBoxed = consume(stringConverter, 'foo'.toJString())!; + final int foo; + if (fooBoxed.isA(JInteger.type)) { + foo = (fooBoxed as JInteger).intValue(); + } else { + foo = (await toDartFuture(fooBoxed, JInteger.type)).intValue(); + } + expect(foo, -1); + + stringConverter.release(); + }); + } + }); + test('Generic interface', () { + using((arena) { + final genericInterface = GenericInterface.implement( + $GenericInterface( + arrayOf: (JObject? element) => + JArray.withLength(JString.type, 1)..[0] = element!, + firstKeyOf: (JMap? map) => map!.asDart().keys.first! as JString, + firstValueOf: (JMap? map) => map!.asDart().values.first, + firstOfArray: (JArray? array) => array!.asDart()[0]! as JString, + firstOfGenericArray: (JArray? array) => array!.asDart()[0], + genericArrayOf: (JObject? element) => + JArray.withLength(JObject.type, 1)..[0] = element, + mapOf: (JObject? key, JObject? value) => {key: value}.toJMap(), ), + )..releasedBy(arena); + final stringArray = genericInterface.arrayOf( + 'hello'.toJString()..releasedBy(arena), + )! + ..releasedBy(arena); + expect(stringArray.asDart(), hasLength(1)); + expect(stringArray[0]!.toDartString(releaseOriginal: true), 'hello'); + expect( + genericInterface + .firstOfArray(stringArray)! + .toDartString(releaseOriginal: true), + 'hello', ); - // Gets the result of a Java Future. - // TODO(#1213): remove this once we support Java futures. - Future<$T> toDartFuture<$T extends JObject>( - JObject future, - JType<$T> T, - ) async { - final receivePort = ReceivePort(); - await Isolate.spawn((sendPort) { - final futureClass = JClass.forName('java/util/concurrent/Future'); - final getMethod = futureClass.instanceMethodId( - 'get', - '()Ljava/lang/Object;', - ); - final result = getMethod(future, T, []); - // A workaround for `--pause-isolates-on-exit`. Otherwise getting - // test with coverage pauses indefinitely here. - // https://github.com/dart-lang/coverage/issues/472 - Isolate.current.kill(); - sendPort.send(result); - }, receivePort.sendPort); - return (await receivePort.first) as $T; - } - - final sevenHundredBoxed = consume( - stringConverter, - '700'.toJString(), - )!; - final int sevenHundred; - if (sevenHundredBoxed is JInteger) { - sevenHundred = sevenHundredBoxed.intValue(); - } else { - sevenHundred = (await toDartFuture( - sevenHundredBoxed, - JInteger.type, - )) - .intValue(); - } - expect(sevenHundred, 700); - - final fooBoxed = consume(stringConverter, 'foo'.toJString())!; - final int foo; - if (fooBoxed is JInteger) { - foo = fooBoxed.intValue(); - } else { - foo = (await toDartFuture(fooBoxed, JInteger.type)).intValue(); - } - expect(foo, -1); + final intArray = genericInterface.genericArrayOf( + 42.toJInteger()..releasedBy(arena), + )! + ..releasedBy(arena); + expect( + genericInterface + .firstOfGenericArray(intArray)! + .intValue(releaseOriginal: true), + 42, + ); - stringConverter.release(); + final jmap = genericInterface.mapOf( + 'hello'.toJString()..releasedBy(arena), + 42.toJInteger()..releasedBy(arena), + )! + ..releasedBy(arena); + expect( + jmap.asDart()['hello'.toJString()..releasedBy(arena)]!.intValue( + releaseOriginal: true, + ), + 42, + ); + expect( + genericInterface + .firstKeyOf(jmap)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + genericInterface + .firstValueOf(jmap)! + .intValue(releaseOriginal: true), + 42, + ); }); - } - }); - test('Generic interface', () { - using((arena) { - final genericInterface = GenericInterface.implement( - $GenericInterface( - T: JString.type, - arrayOf: (element) => - JArray(JString.nullableType, 1)..[0] = element!, - firstKeyOf: (map) => map!.keys.first!.as(JString.type), - firstValueOf: (map) => map!.values.first, - firstOfArray: (array) => array![0]!.as(JString.type), - firstOfGenericArray: (array) => array![0], - genericArrayOf: (element) => - JArray(JObject.nullableType, 1)..[0] = element, - mapOf: (key, value) => - JMap.hash(JString.type, JObject.type)..[key!] = value, - ), - )..releasedBy(arena); - final stringArray = genericInterface.arrayOf( - 'hello'.toJString()..releasedBy(arena), - )! - ..releasedBy(arena); - expect(stringArray, hasLength(1)); - expect(stringArray[0]!.toDartString(releaseOriginal: true), 'hello'); - expect( - genericInterface - .firstOfArray(stringArray)! - .toDartString(releaseOriginal: true), - 'hello', - ); - - final intArray = genericInterface.genericArrayOf( - U: JInteger.type, - 42.toJInteger()..releasedBy(arena), - )! - ..releasedBy(arena); - expect( - genericInterface - .firstOfGenericArray(U: JInteger.type, intArray)! - .intValue(releaseOriginal: true), - 42, + }); + test('Superinterface methods are available', () { + final parent = $R2250( + foo: (JString? _) => 42, ); + expect(parent.foo(null), 42); - final jmap = genericInterface.mapOf( - U: JInteger.type, - 'hello'.toJString()..releasedBy(arena), - 42.toJInteger()..releasedBy(arena), - )! - ..releasedBy(arena); - expect( - jmap['hello'.toJString()..releasedBy(arena)]!.intValue( - releaseOriginal: true, - ), - 42, - ); - expect( - genericInterface - .firstKeyOf(U: JInteger.type, jmap)! - .as(JString.type) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - genericInterface - .firstValueOf(U: JInteger.type, jmap)! - .intValue(releaseOriginal: true), - 42, + final child = $R2250$Child( + foo: (JObject? _) => 24, ); + expect(child.foo(null), 24); }); }); - test('Superinterface methods are available', () { - expect( - $R2250.new, - isA< - $R2250<$T> Function<$T extends JObject?>({ - required JType<$T> T, - required void Function($T?) foo, - bool foo$async, - })>(), - ); - expect( - $R2250$Child.new, - isA< - $R2250$Child Function({ - required void Function(JObject?) foo, - bool foo$async, - })>(), - ); - }); - }); - - group('Nullablity annotations', () { - Annotated newTestObject(Arena arena) { - return Annotated( - null, - 'hello'.toJString()..releasedBy(arena), - 'world'.toJString()..releasedBy(arena), - T: JString.nullableType, - )..releasedBy(arena); - } - Annotated newNonNullTestObject(Arena arena) { - return Annotated( - 'hello'.toJString()..releasedBy(arena), - 'hello'.toJString()..releasedBy(arena), - 'world'.toJString()..releasedBy(arena), - T: JString.type, - )..releasedBy(arena); - } + group('Nullablity annotations', () { + Annotated newTestObject(Arena arena) { + return Annotated( + null, + 'hello'.toJString()..releasedBy(arena), + 'world'.toJString()..releasedBy(arena), + )..releasedBy(arena); + } - test('Field access', () { - using((arena) { - final annotated = newTestObject(arena); - expect(annotated.t, isNull); - expect(annotated.u.toDartString(releaseOriginal: true), 'hello'); - expect(annotated.w.toDartString(releaseOriginal: true), 'world'); - }); - }); + Annotated newNonNullTestObject(Arena arena) { + return Annotated( + 'hello'.toJString()..releasedBy(arena), + 'hello'.toJString()..releasedBy(arena), + 'world'.toJString()..releasedBy(arena), + )..releasedBy(arena); + } - test('Field setting', () { - using((arena) { - final annotated = newTestObject(arena); - annotated.t = 'hello'.toJString()..releasedBy(arena); - expect( - annotated.t! - .as(JString.type, releaseOriginal: true) - .toDartString(releaseOriginal: true), - 'hello', - ); + test('Field access', () { + using((arena) { + final annotated = newTestObject(arena); + expect(annotated.t, isNull); + expect(annotated.u.toDartString(releaseOriginal: true), 'hello'); + expect(annotated.w.toDartString(releaseOriginal: true), 'world'); + }); }); - }); - - test('Static methods', () { - expect( - Annotated.staticHello().toDartString(releaseOriginal: true), - 'hello', - ); - }); - test('Methods with no object args', () { - using((arena) { - final annotated = newTestObject(arena); - expect(annotated.hello().toDartString(releaseOriginal: true), 'hello'); - expect(annotated.nullableHello(true), isNull); - expect( - annotated.nullableHello(false)!.toDartString(releaseOriginal: true), - 'hello', - ); + test('Field setting', () { + using((arena) { + final annotated = newTestObject(arena); + annotated.t = 'hello'.toJString()..releasedBy(arena); + expect( + annotated.t! + .as(JString.type, releaseOriginal: true) + .toDartString(releaseOriginal: true), + 'hello', + ); + }); }); - }); - test('Methods returning arrays', () { - using((arena) { - final annotated = newTestObject(arena); - expect( - (annotated.array()..releasedBy(arena))[0].toDartString( - releaseOriginal: true, - ), - 'hello', - ); - expect((annotated.arrayOfNullable()..releasedBy(arena))[0], isNull); - expect(annotated.nullableArray(true), isNull); + test('Static methods', () { expect( - (annotated.nullableArray( - false, - )! - ..releasedBy(arena))[0] - .toDartString(releaseOriginal: true), + Annotated.staticHello().toDartString(releaseOriginal: true), 'hello', ); - expect(annotated.nullableArrayOfNullable(true), isNull); - expect( - (annotated.nullableArrayOfNullable(false)!..releasedBy(arena))[0], - isNull, - ); }); - }); - test('Methods returning lists', () { - using((arena) { - final annotated = newTestObject(arena); - expect( - (annotated.list()..releasedBy(arena))[0].toDartString( - releaseOriginal: true, - ), - 'hello', - ); - expect((annotated.listOfNullable()..releasedBy(arena))[0], isNull); - expect(annotated.nullableList(true), isNull); - expect( - (annotated.nullableList( - false, - )! - ..releasedBy(arena))[0] - .toDartString(releaseOriginal: true), - 'hello', - ); - expect(annotated.nullableListOfNullable(true), isNull); - expect( - (annotated.nullableListOfNullable(false)!..releasedBy(arena))[0], - isNull, - ); + test('Methods with no object args', () { + using((arena) { + final annotated = newTestObject(arena); + expect( + annotated.hello().toDartString(releaseOriginal: true), 'hello'); + expect(annotated.nullableHello(true), isNull); + expect( + annotated.nullableHello(false)!.toDartString(releaseOriginal: true), + 'hello', + ); + }); }); - }); - test('Methods with one object arg', () { - using((arena) { - final annotated = newTestObject(arena); - final object = 'hello'.toJString()..releasedBy(arena); - expect( - annotated.echo(object).toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated.nullableEcho(object)!.toDartString(releaseOriginal: true), - 'hello', - ); - expect(annotated.nullableEcho(null), isNull); + test('Methods returning arrays', () { + using((arena) { + final annotated = newTestObject(arena); + expect( + (annotated.array()..releasedBy(arena))[0].toDartString( + releaseOriginal: true, + ), + 'hello', + ); + expect((annotated.arrayOfNullable()..releasedBy(arena))[0], isNull); + expect(annotated.nullableArray(true), isNull); + expect( + (annotated.nullableArray( + false, + )! + ..releasedBy(arena))[0] + .toDartString(releaseOriginal: true), + 'hello', + ); + expect(annotated.nullableArrayOfNullable(true), isNull); + expect( + (annotated.nullableArrayOfNullable(false)!..releasedBy(arena))[0], + isNull, + ); + }); }); - }); - test('Class generic methods with one object arg', () { - using((arena) { - final annotatedNullableT = newTestObject(arena); - final object = 'hello'.toJString()..releasedBy(arena); - expect( - annotatedNullableT - .classGenericEcho(object)! // Cannot make it non-nullable. - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotatedNullableT - .nullableClassGenericEcho(object)! - .toDartString(releaseOriginal: true), - 'hello', - ); - expect(annotatedNullableT.nullableClassGenericEcho(null), isNull); + test('Methods returning lists', () { + using((arena) { + final annotated = newTestObject(arena); + expect( + (annotated.list()..releasedBy(arena)).asDart()[0].toDartString( + releaseOriginal: true, + ), + 'hello', + ); + expect((annotated.listOfNullable()..releasedBy(arena)).asDart()[0], + isNull); + expect(annotated.nullableList(true), isNull); + expect( + (annotated.nullableList( + false, + )! + ..releasedBy(arena)) + .asDart()[0] + .toDartString(releaseOriginal: true), + 'hello', + ); + expect(annotated.nullableListOfNullable(true), isNull); + expect( + (annotated.nullableListOfNullable(false)!..releasedBy(arena)) + .asDart()[0], + isNull, + ); + }); + }); - final annotatedNonNullableT = newNonNullTestObject(arena); - expect( - annotatedNonNullableT - .classGenericEcho(object) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotatedNonNullableT - .nullableClassGenericEcho(object)! - .toDartString(releaseOriginal: true), - 'hello', - ); - expect(annotatedNonNullableT.nullableClassGenericEcho(null), isNull); + test('Methods with one object arg', () { + using((arena) { + final annotated = newTestObject(arena); + final object = 'hello'.toJString()..releasedBy(arena); + expect( + annotated.echo(object).toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated.nullableEcho(object)!.toDartString(releaseOriginal: true), + 'hello', + ); + expect(annotated.nullableEcho(null), isNull); + }); }); - }); - test('Method generic methods with one object arg', () { - using((arena) { - final annotated = newTestObject(arena); - final object = 'hello'.toJString()..releasedBy(arena); - expect( - annotated - .methodGenericEcho(object, V: JString.nullableType)! - // Cannot make it non-nullable. - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - .methodGenericEcho(object, V: JString.type) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - .methodGenericEcho2(object) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - .methodGenericEcho3(object) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - // Requires `V`. - .nullableReturnMethodGenericEcho(object, false, V: JString.type)! - // Cannot make it non-nullable. - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - // Requires `V`. - .nullableReturnMethodGenericEcho(object, true, V: JString.type), - isNull, - ); - expect( - annotated - // `V` is optional. - .nullableReturnMethodGenericEcho2(object, false)! - // Cannot make it non-nullable. - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - // `V` is optional. - .nullableReturnMethodGenericEcho2(object, true), - isNull, - ); - expect( - annotated.nullableMethodGenericEcho(null, V: JString.nullableType), - isNull, - ); - expect( - annotated - .nullableMethodGenericEcho(object, V: JString.nullableType)! - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - .nullableMethodGenericEcho(object, V: JString.type) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated.noAnnotationMethodGenericEcho( - null, - V: JString.nullableType, - ), - isNull, - ); - expect( - annotated - .noAnnotationMethodGenericEcho(object, V: JString.nullableType)! - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - // With no annotations, specifying a non-nullable type still - // requires `!`. - .noAnnotationMethodGenericEcho(object, V: JString.type)! - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - annotated - .nullableArgMethodGenericEcho(object, V: JString.type) - .toDartString(releaseOriginal: true), - 'hello', - ); - expect( - () => annotated.nullableArgMethodGenericEcho( - null, - V: JString.type, - ), - throwsA(isA()), - ); - expect( - annotated - .nullableArgMethodGenericEcho(object, V: JString.type) - .toDartString(releaseOriginal: true), - 'hello', - ); + test('Class generic methods with one object arg', () { + using((arena) { + final annotatedNullableT = newTestObject(arena); + final object = 'hello'.toJString()..releasedBy(arena); + expect( + annotatedNullableT + .classGenericEcho(object)! // Cannot make it non-nullable. + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotatedNullableT + .nullableClassGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect(annotatedNullableT.nullableClassGenericEcho(null), isNull); + + final annotatedNonNullableT = newNonNullTestObject(arena); + expect( + annotatedNonNullableT + .classGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotatedNonNullableT + .nullableClassGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect(annotatedNonNullableT.nullableClassGenericEcho(null), isNull); + }); }); - }); - test('Class generic list methods', () { - using((arena) { - final annotated = newNonNullTestObject(arena); - expect( - (annotated.classGenericList()..releasedBy(arena)).first.toDartString( - releaseOriginal: true, - ), - 'hello', - ); - expect( - (annotated.classGenericListOfNullable()..releasedBy(arena)).first, - isNull, - ); - expect(annotated.nullableClassGenericList(true), isNull); - expect( - (annotated.nullableClassGenericList( - false, - )! - ..releasedBy(arena)) - .first - .toDartString(releaseOriginal: true), - 'hello', - ); - expect(annotated.nullableClassGenericListOfNullable(true), isNull); - expect( - (annotated.nullableClassGenericListOfNullable( - false, - )! - ..releasedBy(arena)) - .first, - isNull, - ); + test('Method generic methods with one object arg', () { + using((arena) { + final annotated = newTestObject(arena); + final object = 'hello'.toJString()..releasedBy(arena); + expect( + annotated + .methodGenericEcho(object)! + // Cannot make it non-nullable. + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + .methodGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + .methodGenericEcho2(object) + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + .methodGenericEcho3(object) + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + // Requires `V`. + .nullableReturnMethodGenericEcho(object, false)! + // Cannot make it non-nullable. + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + // Requires `V`. + .nullableReturnMethodGenericEcho(object, true), + isNull, + ); + expect( + annotated + // `V` is optional. + .nullableReturnMethodGenericEcho2(object, false)! + // Cannot make it non-nullable. + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + // `V` is optional. + .nullableReturnMethodGenericEcho2(object, true), + isNull, + ); + expect( + annotated.nullableMethodGenericEcho(null), + isNull, + ); + expect( + annotated + .nullableMethodGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + .nullableMethodGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated.noAnnotationMethodGenericEcho(null), + isNull, + ); + expect( + annotated + .noAnnotationMethodGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + // With no annotations, specifying a non-nullable type still + // requires `!`. + .noAnnotationMethodGenericEcho(object)! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + annotated + .nullableArgMethodGenericEcho(object) + .toDartString(releaseOriginal: true), + 'hello', + ); + expect( + () => annotated.nullableArgMethodGenericEcho(null), + throwsA(isA()), + ); + expect( + annotated + .nullableArgMethodGenericEcho(object) + .toDartString(releaseOriginal: true), + 'hello', + ); + }); }); - }); - }); - group('Enums', () { - test('Color', () { - using((arena) { - final red = Colors.red..releasedBy(arena); - final green = Colors.green..releasedBy(arena); - final blue = Colors.blue..releasedBy(arena); - expect(red.code, 0xFF0000); - expect(green.code, 0x00FF00); - expect(blue.code, 0x0000FF); - expect( - red.toRGB()!..releasedBy(arena), - Colors$RGB(255, 0, 0)..releasedBy(arena), - ); - expect( - green.toRGB()!..releasedBy(arena), - Colors$RGB(0, 255, 0)..releasedBy(arena), - ); - expect( - blue.toRGB()!..releasedBy(arena), - Colors$RGB(0, 0, 255)..releasedBy(arena), - ); + test('Class generic list methods', () { + using((arena) { + final annotated = newNonNullTestObject(arena); + expect( + (annotated.classGenericList()..releasedBy(arena)) + .asDart() + .first! + .toDartString( + releaseOriginal: true, + ), + 'hello', + ); + expect( + (annotated.classGenericListOfNullable()..releasedBy(arena)) + .asDart() + .first, + isNull, + ); + expect(annotated.nullableClassGenericList(true), isNull); + expect( + (annotated.nullableClassGenericList( + false, + )! + ..releasedBy(arena)) + .asDart() + .first! + .toDartString(releaseOriginal: true), + 'hello', + ); + expect(annotated.nullableClassGenericListOfNullable(true), isNull); + expect( + (annotated.nullableClassGenericListOfNullable( + false, + )! + ..releasedBy(arena)) + .asDart() + .first, + isNull, + ); + }); }); }); - }); - group('$groupName (load tests)', () { - const k4 = 4 * 1024; // This is a round number, unlike say 4000 - const k256 = 256 * 1024; - test('Create large number of JNI references without deleting', () { - for (var i = 0; i < k4; i++) { - final e = Example.new$1(i); - expect(e.getNumber(), equals(i)); - } - }); - test('Create many JNI refs with scoped deletion', () { - for (var i = 0; i < k256; i++) { + group('Enums', () { + test('Color', () { using((arena) { - final e = Example.new$1(i)..releasedBy(arena); - expect(e.getNumber(), equals(i)); + final red = Colors.red..releasedBy(arena); + final green = Colors.green..releasedBy(arena); + final blue = Colors.blue..releasedBy(arena); + expect(red.code, 0xFF0000); + expect(green.code, 0x00FF00); + expect(blue.code, 0x0000FF); + expect( + red.toRGB()!..releasedBy(arena), + Colors$RGB(255, 0, 0)..releasedBy(arena), + ); + expect( + green.toRGB()!..releasedBy(arena), + Colors$RGB(0, 255, 0)..releasedBy(arena), + ); + expect( + blue.toRGB()!..releasedBy(arena), + Colors$RGB(0, 0, 255)..releasedBy(arena), + ); }); - } + }); }); - test('Create many JNI refs with scoped deletion, in batches', () { - for (var i = 0; i < 256; i++) { + + group('Inheritance', () { + test('methods', () { + using((arena) { + final base = BaseClass()..releasedBy(arena); + final derived = SpecificDerivedClass()..releasedBy(arena); + + expect( + base + .someMethod('Foo'.toJString()..releasedBy(arena)) + ?.toDartString(releaseOriginal: true), + 'Foo'); + expect( + derived + .someMethod('Bar'.toJString()..releasedBy(arena)) + ?.toDartString(releaseOriginal: true), + 'Hello Bar'); + }); + }); + test('Child implements BaseClass and BaseInterface', () { + using((arena) { + final child = Child()..releasedBy(arena); + expect(child.foo()!.toDartString(releaseOriginal: true), 'foo'); + expect( + child + .someMethod$1('bar'.toJString()..releasedBy(arena)) + ?.toDartString(releaseOriginal: true), + 'bar', + ); + + // Verify it can be assigned to BaseInterface. + final BaseInterface interface = child; + expect(interface.foo()!.toDartString(releaseOriginal: true), 'foo'); + + // Verify it can be assigned to BaseClass. + final BaseClass base = child; + expect( + base + .someMethod('baz'.toJString()..releasedBy(arena)) + ?.toDartString(releaseOriginal: true), + 'baz', + ); + }); + }); + test('DerivedInterface implements BaseGenericInterface and BaseInterface', + () { using((arena) { - for (var i = 0; i < 1024; i++) { + final derived = DerivedInterface.implement( + $DerivedInterface( + foo: () => 'derived_foo'.toJString()..releasedBy(arena), + someMethod: (s) => s, + ), + )..releasedBy(arena); + + expect(derived.foo()?.toDartString(releaseOriginal: true), + 'derived_foo'); + + // Verify it can be assigned to BaseGenericInterface. + // Skip this on Android due to + // https://github.com/dart-lang/native/issues/3212 + final BaseGenericInterface baseGeneric = derived; + expect(baseGeneric.foo()?.toDartString(releaseOriginal: true), + 'derived_foo', + skip: Platform.isAndroid); + + // Verify it can be assigned to BaseInterface. + final BaseInterface base = derived; + expect( + base.foo()?.toDartString(releaseOriginal: true), 'derived_foo'); + }); + }); + test('ShibaInu complicated inheritance', () { + using((arena) { + final shiba = ShibaInu()..releasedBy(arena); + expect(shiba.bark().toDartString(releaseOriginal: true), 'Woof!'); + expect(shiba.groom().toDartString(releaseOriginal: true), + 'Grooming Shiba'); + expect( + shiba + .eat('bones'.toJString()..releasedBy(arena)) + .toDartString(releaseOriginal: true), + 'Shiba eating bones'); + expect(shiba.walk(42), 42); + expect(shiba.giveBirth(true)?.toDartString(releaseOriginal: true), + 'Baby Shiba'); + expect(shiba.giveBirth(false), isNull); + + // Test assignments (diamonds) + final Dog dog = shiba; + expect(dog.bark().toDartString(releaseOriginal: true), 'Woof!'); + + final Mammal mammal = dog; + expect(mammal.giveBirth(true)?.toDartString(releaseOriginal: true), + 'Baby Shiba'); + + final FourLegged fourLegged = dog; + expect(fourLegged.walk(10), 10); + + final Animal animalFromMammal = mammal; + expect( + animalFromMammal + .eat('meat'.toJString()..releasedBy(arena)) + .toDartString(releaseOriginal: true), + 'Shiba eating meat'); + + final Animal animalFromFourLegged = fourLegged; + expect( + animalFromFourLegged + .eat('fish'.toJString()..releasedBy(arena)) + .toDartString(releaseOriginal: true), + 'Shiba eating fish'); + + final Furry furry = shiba; + expect(furry.groom().toDartString(releaseOriginal: true), + 'Grooming Shiba'); + }); + }); + }); + + group('$groupName (load tests)', () { + const k4 = 4 * 1024; // This is a round number, unlike say 4000 + const k256 = 256 * 1024; + test('Create large number of JNI references without deleting', () { + for (var i = 0; i < k4; i++) { + final e = Example.new$1(i); + expect(e.getNumber(), equals(i)); + } + }); + test('Create many JNI refs with scoped deletion', () { + for (var i = 0; i < k256; i++) { + using((arena) { final e = Example.new$1(i)..releasedBy(arena); expect(e.getNumber(), equals(i)); + }); + } + }); + test('Create many JNI refs with scoped deletion, in batches', () { + for (var i = 0; i < 256; i++) { + using((arena) { + for (var i = 0; i < 1024; i++) { + final e = Example.new$1(i)..releasedBy(arena); + expect(e.getNumber(), equals(i)); + } + }); + } + }); + test('Create large number of JNI refs with manual delete', () { + for (var i = 0; i < k256; i++) { + final e = Example.new$1(i); + expect(e.getNumber(), equals(i)); + e.release(); + } + }); + test('Method returning primitive type does not create references', () { + using((arena) { + final e = Example.new$1(64)..releasedBy(arena); + for (var i = 0; i < k256; i++) { + expect(e.getNumber(), equals(64)); } }); - } - }); - test('Create large number of JNI refs with manual delete', () { - for (var i = 0; i < k256; i++) { - final e = Example.new$1(i); - expect(e.getNumber(), equals(i)); - e.release(); - } - }); - test('Method returning primitive type does not create references', () { - using((arena) { - final e = Example.new$1(64)..releasedBy(arena); + }); + test('Class references are cached', () { + final asterisk = '*'.codeUnitAt(0); for (var i = 0; i < k256; i++) { - expect(e.getNumber(), equals(64)); + expect(Fields.asterisk, equals(asterisk)); } }); - }); - test('Class references are cached', () { - final asterisk = '*'.codeUnitAt(0); - for (var i = 0; i < k256; i++) { - expect(Fields.asterisk, equals(asterisk)); + void testPassageOfTime(int n) { + test('Refs are not inadvertently deleted after $n seconds', () { + final f = Fields(); + expect(f.trillion, equals(trillion)); + sleep(Duration(seconds: n)); + expect(f.trillion, equals(trillion)); + }); } - }); - void testPassageOfTime(int n) { - test('Refs are not inadvertently deleted after $n seconds', () { - final f = Fields(); - expect(f.trillion, equals(trillion)); - sleep(Duration(seconds: n)); - expect(f.trillion, equals(trillion)); - }); - } - if (!Platform.isAndroid) { - testPassageOfTime(1); - testPassageOfTime(4); - } + if (!Platform.isAndroid) { + testPassageOfTime(1); + testPassageOfTime(4); + } + }); }); } diff --git a/pkgs/jnigen/test/summary_error_message_test.dart b/pkgs/jnigen/test/summary_error_message_test.dart new file mode 100644 index 0000000000..71b0fce889 --- /dev/null +++ b/pkgs/jnigen/test/summary_error_message_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:jnigen/src/summary/summary.dart'; +import 'package:test/test.dart'; + +void main() { + group('getActionableSummaryParseMessage', () { + test('returns actionable message for unsupported classfile version', () { + const stderr = ''' +Exception in thread "main" java.lang.RuntimeException +Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 66 +'''; + + final message = getActionableSummaryParseMessage(stderr); + + expect(message, isNotNull); + expect(message, contains('class file version 66')); + expect(message, contains('JDK version (11 to 17) (see JNIgen README)')); + expect(message, contains('javac --release 17')); + }); + + test('returns null for unrelated stderr', () { + const stderr = 'Not found: [com.github.dart_lang.jnigen.DoesNotExist]'; + + final message = getActionableSummaryParseMessage(stderr); + + expect(message, isNull); + }); + }); +} diff --git a/pkgs/jnigen/test/summary_generation_test.dart b/pkgs/jnigen/test/summary_generation_test.dart index a5a437d9e5..04aabbf909 100644 --- a/pkgs/jnigen/test/summary_generation_test.dart +++ b/pkgs/jnigen/test/summary_generation_test.dart @@ -8,6 +8,7 @@ @Tags(['summarizer_test']) library; +import 'dart:io'; import 'dart:math'; import 'package:jnigen/src/config/config.dart'; @@ -141,6 +142,51 @@ void main() async { testAllCases(classPath: [targetDir.path]); }); + group('Test unsupported class file version errors', () { + final sourceDir = tempDir.createTempSync('unsupported_classfile_source_'); + final classesDir = tempDir.createTempSync('unsupported_classfile_classes_'); + + setUpAll(() async { + final packageDir = Directory(join(sourceDir.path, 'com', 'example')) + ..createSync(recursive: true); + final javaFile = File(join(packageDir.path, 'Hello.java')); + javaFile.writeAsStringSync(''' + package com.example; + public class Hello { + public int value() { return 42; } + } + '''); + await compileJavaFiles(sourceDir, classesDir); + + //in class file encoding the version as 74 so unsupported + //and trigggers for test + final classFile = File( + join(classesDir.path, 'com', 'example', 'Hello.class'), + ); + final classFileBytes = classFile.readAsBytesSync(); + classFileBytes[6] = 0x00; + classFileBytes[7] = 0x4A; + classFile.writeAsBytesSync(classFileBytes, flush: true); + }); + + test('- should provide actionable guidance for unsupported versions', + () async { + final config = getSummaryGenerationConfig(classPath: [classesDir.path]); + config.classes = ['com.example.Hello']; + + try { + await getSummary(config); + } on SummaryParseException catch (e) { + expect(e.message, contains('Java class file version 74')); + expect(e.message, contains('supported JDK version (11 to 17)')); + expect(e.message, contains('javac --release 17')); + expect(e.message, isNot(contains('FormatException'))); + return; + } + throw AssertionError('No exception was caught'); + }); + }); + // Test summary generation from combination of a source and class path group('Test summary generation from combination', () { final targetDir = tempDir.createTempSync('combination_test_'); diff --git a/pkgs/json_syntax_generator/analysis_options.yaml b/pkgs/json_syntax_generator/analysis_options.yaml index c0462a3a77..19ef10adf6 100644 --- a/pkgs/json_syntax_generator/analysis_options.yaml +++ b/pkgs/json_syntax_generator/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -13,7 +11,3 @@ linter: - prefer_expression_function_bodies - prefer_final_in_for_each - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/json_syntax_generator/lib/src/generator/property_generator.dart b/pkgs/json_syntax_generator/lib/src/generator/property_generator.dart index c8c82fc0b2..203e5bdd55 100644 --- a/pkgs/json_syntax_generator/lib/src/generator/property_generator.dart +++ b/pkgs/json_syntax_generator/lib/src/generator/property_generator.dart @@ -429,7 +429,7 @@ set $setterName($dartType value) { $sortOnKey } -List $validateName() => _reader.validateMap<${dartType.valueType}>('$jsonKey', $keyPattern); +List $validateName() => _reader.validateOptionalMap<${dartType.valueType}>('$jsonKey', $keyPattern); '''); } default: diff --git a/pkgs/json_syntax_generator/lib/src/model/dart_type.dart b/pkgs/json_syntax_generator/lib/src/model/dart_type.dart index c7f7834b0e..80a082f003 100644 --- a/pkgs/json_syntax_generator/lib/src/model/dart_type.dart +++ b/pkgs/json_syntax_generator/lib/src/model/dart_type.dart @@ -79,6 +79,16 @@ class IntDartType extends SimpleDartType { int get hashCode => Object.hash(super.hashCode, 'int'); } +class DoubleDartType extends SimpleDartType { + const DoubleDartType({required super.isNullable}) : super(typeName: 'double'); + + @override + bool operator ==(Object other) => super == other && other is DoubleDartType; + + @override + int get hashCode => Object.hash(super.hashCode, 'double'); +} + class BoolDartType extends SimpleDartType { const BoolDartType({required super.isNullable}) : super(typeName: 'bool'); diff --git a/pkgs/json_syntax_generator/lib/src/parser/schema_analyzer.dart b/pkgs/json_syntax_generator/lib/src/parser/schema_analyzer.dart index caeb3951fa..7e9c8c6398 100644 --- a/pkgs/json_syntax_generator/lib/src/parser/schema_analyzer.dart +++ b/pkgs/json_syntax_generator/lib/src/parser/schema_analyzer.dart @@ -311,6 +311,8 @@ class SchemaAnalyzer { dartType = BoolDartType(isNullable: isNullable); case SchemaType.integer: dartType = IntDartType(isNullable: isNullable); + case SchemaType.number: + dartType = DoubleDartType(isNullable: isNullable); case SchemaType.string: if (schemas.generateUri) { dartType = UriDartType(isNullable: isNullable); @@ -339,11 +341,12 @@ class SchemaAnalyzer { isNullable: false, pattern: schemas.patternPropertiesSchemas.keys.firstOrNull, ); - final additionalPropertiesType = additionalPropertiesSchema.type; + final (additionalPropertiesType, additionalNullable) = + additionalPropertiesSchema.typeAndNullable; switch (additionalPropertiesType) { case SchemaType.array: final items = additionalPropertiesSchema.items; - final itemType = items.type; + final (itemType, itemNullable) = items.typeAndNullable; switch (itemType) { case SchemaType.object: _analyzeClass(items); @@ -353,9 +356,9 @@ class SchemaAnalyzer { valueType: ListDartType( itemType: ClassDartType( classInfo: itemClass, - isNullable: false, + isNullable: itemNullable, ), - isNullable: false, + isNullable: additionalNullable, ), isNullable: isNullable, ); @@ -370,15 +373,18 @@ class SchemaAnalyzer { final clazz = _classes[additionalPropertiesSchema.className]!; dartType = MapDartType( keyType: keyDartType, - valueType: ClassDartType(classInfo: clazz, isNullable: false), + valueType: ClassDartType( + classInfo: clazz, + isNullable: additionalNullable, + ), isNullable: isNullable, ); } else { dartType = MapDartType( keyType: keyDartType, - valueType: const MapDartType( - valueType: ObjectDartType(isNullable: true), - isNullable: false, + valueType: MapDartType( + valueType: const ObjectDartType(isNullable: true), + isNullable: additionalNullable, ), isNullable: isNullable, ); @@ -431,13 +437,13 @@ class SchemaAnalyzer { case SchemaType.string: dartType = MapDartType( keyType: keyDartType, - valueType: const StringDartType(isNullable: false), + valueType: StringDartType(isNullable: additionalNullable), isNullable: isNullable, ); case SchemaType.integer: dartType = MapDartType( keyType: keyDartType, - valueType: const IntDartType(isNullable: false), + valueType: IntDartType(isNullable: additionalNullable), isNullable: isNullable, ); default: @@ -608,10 +614,13 @@ extension type JsonSchemas._(List _schemas) { } SchemaType? get type { - if (types.length > 1) { - throw StateError('Multiple types found'); + if (types.length <= 1) { + return types.singleOrNull; + } else if (types.length == 2 && types.contains(SchemaType.nullValue)) { + return types.firstWhere((t) => t != SchemaType.nullValue); + } else { + throw StateError('Multiple types found: $types'); } - return types.singleOrNull; } (SchemaType?, bool) get typeAndNullable { diff --git a/pkgs/json_syntax_generator/pubspec.yaml b/pkgs/json_syntax_generator/pubspec.yaml index 7a9a8effc2..1b5cbc85bf 100644 --- a/pkgs/json_syntax_generator/pubspec.yaml +++ b/pkgs/json_syntax_generator/pubspec.yaml @@ -12,17 +12,14 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: json_schema: ^5.2.0 dev_dependencies: - custom_lint: ^0.7.5 dart_flutter_team_lints: ^3.5.2 native_test_helpers: path: ../native_test_helpers/ path: ^1.9.1 - repo_lint_rules: - path: ../repo_lint_rules/ test: ^1.25.15 diff --git a/pkgs/native_test_helpers/analysis_options.yaml b/pkgs/native_test_helpers/analysis_options.yaml index c0462a3a77..19ef10adf6 100644 --- a/pkgs/native_test_helpers/analysis_options.yaml +++ b/pkgs/native_test_helpers/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -13,7 +11,3 @@ linter: - prefer_expression_function_bodies - prefer_final_in_for_each - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/native_test_helpers/pubspec.yaml b/pkgs/native_test_helpers/pubspec.yaml index fd01a740d1..e7bd25c4ae 100644 --- a/pkgs/native_test_helpers/pubspec.yaml +++ b/pkgs/native_test_helpers/pubspec.yaml @@ -8,7 +8,7 @@ publish_to: none resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: yaml: ^3.1.3 diff --git a/pkgs/native_toolchain_c/CHANGELOG.md b/pkgs/native_toolchain_c/CHANGELOG.md index a320bdc31e..cad4864af0 100644 --- a/pkgs/native_toolchain_c/CHANGELOG.md +++ b/pkgs/native_toolchain_c/CHANGELOG.md @@ -3,9 +3,13 @@ - Fixed resolution of C compiler and tools on macOS when `swiftly` is installed. - Broaden compiler tool discovery on macOS. -## 0.17.5-wip +## 0.17.5 - Search for NDK in `ANDROID_HOME` and `ANDROID_NDK` environment variables. +- On iOS and macOS, use the `-encryptable` linker flag. This resolves an + [issue](https://github.com/dart-lang/native/issues/2973) with app store + rejections. +- Fix unportable link arg when cross-compiling from MacOS. ## 0.17.4 diff --git a/pkgs/native_toolchain_c/analysis_options.yaml b/pkgs/native_toolchain_c/analysis_options.yaml index c0462a3a77..19ef10adf6 100644 --- a/pkgs/native_toolchain_c/analysis_options.yaml +++ b/pkgs/native_toolchain_c/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:dart_flutter_team_lints/analysis_options.yaml analyzer: language: strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 linter: rules: @@ -13,7 +11,3 @@ linter: - prefer_expression_function_bodies - prefer_final_in_for_each - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart index b714d6e255..12ecfd4392 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/cbuilder.dart @@ -11,10 +11,8 @@ import 'package:meta/meta.dart'; import 'build_mode.dart'; import 'ctool.dart'; -import 'language.dart'; import 'linkmode.dart'; import 'logger.dart'; -import 'optimization_level.dart'; import 'output_type.dart'; import 'run_cbuilder.dart'; @@ -74,11 +72,11 @@ class CBuilder extends CTool implements Builder { this.ndebugDefine = true, super.pic = true, super.std, - super.language = Language.c, + super.language = .c, super.cppLinkStdLib, super.linkModePreference, - super.optimizationLevel = OptimizationLevel.o3, - this.buildMode = BuildMode.release, + super.optimizationLevel = .o3, + this.buildMode = .release, }) : super(type: OutputType.library); CBuilder.executable({ @@ -101,10 +99,10 @@ class CBuilder extends CTool implements Builder { this.ndebugDefine = true, bool? pie = false, super.std, - super.language = Language.c, + super.language = .c, super.cppLinkStdLib, - super.optimizationLevel = OptimizationLevel.o3, - this.buildMode = BuildMode.release, + super.optimizationLevel = .o3, + this.buildMode = .release, }) : super( type: OutputType.executable, assetName: null, @@ -196,7 +194,7 @@ class CBuilder extends CTool implements Builder { defines: { ...defines, if (buildModeDefine) buildMode.name.toUpperCase(): null, - if (ndebugDefine && buildMode != BuildMode.debug) 'NDEBUG': null, + if (ndebugDefine && buildMode != .debug) 'NDEBUG': null, }, pic: pic, std: std, diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/clinker.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/clinker.dart index 7c33d8121e..aee323bae7 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/clinker.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/clinker.dart @@ -10,10 +10,8 @@ import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; import 'ctool.dart'; -import 'language.dart'; import 'linker_options.dart'; import 'linkmode.dart'; -import 'optimization_level.dart'; import 'output_type.dart'; import 'run_cbuilder.dart'; @@ -37,10 +35,10 @@ class CLinker extends CTool implements Linker { super.defines = const {}, super.pic = true, super.std, - super.language = Language.c, + super.language = .c, super.cppLinkStdLib, super.linkModePreference, - super.optimizationLevel = OptimizationLevel.o3, + super.optimizationLevel = .o3, }) : super(type: OutputType.library); /// Runs the C Linker with on this C build spec. diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart index a3e1e2d48b..47c26c15e8 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/compiler_resolver.dart @@ -33,8 +33,8 @@ class CompilerResolver { required this.logger, OS? hostOS, // Only visible for testing. Architecture? hostArchitecture, // Only visible for testing. - }) : hostOS = hostOS ?? OS.current, - hostArchitecture = hostArchitecture ?? Architecture.current, + }) : hostOS = hostOS ?? .current, + hostArchitecture = hostArchitecture ?? .current, context = ToolResolvingContext(logger: logger); Future resolveCompiler() async { @@ -65,28 +65,28 @@ class CompilerResolver { final targetArch = codeConfig.targetArchitecture; switch ((hostOS, targetOS, targetArch)) { - case (_, OS.android, _): + case (_, .android, _): yield androidNdkClang; - case (OS.macOS, OS.macOS || OS.iOS, _): + case (.macOS, .macOS || .iOS, _): yield appleClang; yield clang; - case (OS.linux, OS.linux, _) when hostArchitecture == targetArch: + case (.linux, .linux, _) when hostArchitecture == targetArch: yield clang; - case (OS.linux, _, Architecture.arm): + case (.linux, _, .arm): yield armLinuxGnueabihfGcc; - case (OS.linux, _, Architecture.arm64): + case (.linux, _, .arm64): yield aarch64LinuxGnuGcc; - case (OS.linux, _, Architecture.ia32): + case (.linux, _, .ia32): yield i686LinuxGnuGcc; - case (OS.linux, _, Architecture.x64): + case (.linux, _, .x64): yield x86_64LinuxGnuGcc; - case (OS.linux, _, Architecture.riscv64): + case (.linux, _, .riscv64): yield riscv64LinuxGnuGcc; - case (OS.windows, _, Architecture.ia32): + case (.windows, _, .ia32): yield clIA32; - case (OS.windows, _, Architecture.arm64): + case (.windows, _, .arm64): yield clArm64; - case (OS.windows, _, Architecture.x64): + case (.windows, _, .x64): yield cl; } } @@ -143,32 +143,32 @@ class CompilerResolver { // TODO(dacoharkes): Support falling back on other tools. if (targetArchitecture == hostArchitecture && targetOS == hostOS && - hostOS == OS.linux) { + hostOS == .linux) { return llvmAr; } - if (targetOS == OS.macOS || targetOS == OS.iOS) return appleAr; - if (targetOS == OS.android) return androidNdkLlvmAr; - if (hostOS == OS.linux) { + if (targetOS == .macOS || targetOS == .iOS) return appleAr; + if (targetOS == .android) return androidNdkLlvmAr; + if (hostOS == .linux) { switch (targetArchitecture) { - case Architecture.arm: + case .arm: return armLinuxGnueabihfGccAr; - case Architecture.arm64: + case .arm64: return aarch64LinuxGnuGccAr; - case Architecture.ia32: + case .ia32: return i686LinuxGnuGccAr; - case Architecture.x64: + case .x64: return x86_64LinuxGnuGccAr; - case Architecture.riscv64: + case .riscv64: return riscv64LinuxGnuGccAr; } } - if (hostOS == OS.windows) { + if (hostOS == .windows) { switch (targetArchitecture) { - case Architecture.ia32: + case .ia32: return libIA32; - case Architecture.arm64: + case .arm64: return libArm64; - case Architecture.x64: + case .x64: return lib; } } @@ -191,7 +191,7 @@ class CompilerResolver { } Future> resolveEnvironment(ToolInstance compiler) async { - if (codeConfig.targetOS != OS.windows) { + if (codeConfig.targetOS != .windows) { return {}; } diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/ctool.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/ctool.dart index 064ff58469..be186c175f 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/ctool.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/ctool.dart @@ -45,7 +45,7 @@ abstract class CTool { /// The sources will be reported as dependencies of the hook. final List sources; - /// Include directories to pass to the linker. + /// Include directories to pass to the compiler. /// /// Resolved against [LinkInput.packageRoot]. /// @@ -107,7 +107,7 @@ abstract class CTool { @visibleForTesting final Uri? installName; - /// Flags to pass to the linker. + /// Flags to pass to the build tool (compiler or linker). final List flags; /// Definitions of preprocessor macros. diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/linker_options.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/linker_options.dart index ac8f8a450d..a8baccd8c8 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/linker_options.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/linker_options.dart @@ -121,7 +121,7 @@ extension LinkerOptionsExt on LinkerOptions { OS targetOS, ) { switch (targetOS) { - case OS.macOS || OS.iOS: + case .macOS || .iOS: return [ if (!_keepAllSymbols) ...sourceFiles, ..._toLinkerSyntax(tool, [ @@ -137,7 +137,7 @@ extension LinkerOptionsExt on LinkerOptions { ]), ]; - case OS.android || OS.linux: + case .android || .linux: final wholeArchiveSandwich = sourceFiles.any((source) => source.endsWith('.a')) || _keepAllSymbols; @@ -173,8 +173,7 @@ extension LinkerOptionsExt on LinkerOptions { if (_keepAllSymbols) ...sourceFiles.map((e) => '/WHOLEARCHIVE:$e'), ..._linkerFlags, ..._symbols.map( - (symbol) => - '/INCLUDE:${targetArch == Architecture.ia32 ? '_' : ''}$symbol', + (symbol) => '/INCLUDE:${targetArch == .ia32 ? '_' : ''}$symbol', ), if (_linkerScriptMode is ManualLinkerScript) '/DEF:${_linkerScriptMode.script.toFilePath()}' diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/linkmode.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/linkmode.dart index 6dec092dae..57afa128f7 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/linkmode.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/linkmode.dart @@ -5,13 +5,9 @@ import 'package:code_assets/code_assets.dart'; LinkMode getLinkMode(LinkModePreference preference) { - if (preference == LinkModePreference.dynamic || - preference == LinkModePreference.preferDynamic) { + if (preference == .dynamic || preference == .preferDynamic) { return DynamicLoadingBundled(); } - assert( - preference == LinkModePreference.static || - preference == LinkModePreference.preferStatic, - ); + assert(preference == .static || preference == .preferStatic); return StaticLinking(); } diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/logger.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/logger.dart index 666a485063..ea053ef30e 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/logger.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/logger.dart @@ -9,9 +9,9 @@ import 'package:logging/logging.dart'; /// Creates a default logger that logs to stdout and stderr. Logger createDefaultLogger() { final logger = Logger.detached('CBuilder'); - logger.level = Level.INFO; + logger.level = .INFO; logger.onRecord.listen((record) { - if (record.level >= Level.WARNING) { + if (record.level >= .WARNING) { stderr.writeln(record.message); } else { stdout.writeln(record.message); diff --git a/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart b/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart index 1e078bec78..c694ee7cfb 100644 --- a/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart +++ b/pkgs/native_toolchain_c/lib/src/cbuilder/run_cbuilder.dart @@ -71,7 +71,7 @@ class RunCBuilder { this.defines = const {}, this.pic, this.std, - this.language = Language.c, + this.language = .c, this.cppLinkStdLib, required this.optimizationLevel, }) : outDir = input.outputDirectory, @@ -79,7 +79,7 @@ class RunCBuilder { [executable, dynamicLibrary, staticLibrary].whereType().length == 1, ) { - if (codeConfig.targetOS == OS.windows && cppLinkStdLib != null) { + if (codeConfig.targetOS == .windows && cppLinkStdLib != null) { throw ArgumentError.value( cppLinkStdLib, 'cppLinkStdLib', @@ -98,12 +98,12 @@ class RunCBuilder { Future archiver() async => (await _resolver.resolveArchiver()).uri; Future iosSdk(IOSSdk iosSdk, ToolResolvingContext context) async { - if (iosSdk == IOSSdk.iPhoneOS) { + if (iosSdk == .iPhoneOS) { return (await iPhoneOSSdk.defaultResolver!.resolve( context, )).where((i) => i.tool == iPhoneOSSdk).first.uri; } - assert(iosSdk == IOSSdk.iPhoneSimulator); + assert(iosSdk == .iPhoneSimulator); return (await iPhoneSimulatorSdk.defaultResolver!.resolve( context, )).where((i) => i.tool == iPhoneSimulatorSdk).first.uri; @@ -141,7 +141,7 @@ class RunCBuilder { } final IOSSdk? targetIosSdk; - if (codeConfig.targetOS == OS.iOS) { + if (codeConfig.targetOS == .iOS) { targetIosSdk = codeConfig.iOS.targetSdk; } else { targetIosSdk = null; @@ -151,7 +151,7 @@ class RunCBuilder { // invoking clang. Mimic that behavior here. // See https://github.com/dart-lang/native/issues/171. final int? targetAndroidNdkApi; - if (codeConfig.targetOS == OS.android) { + if (codeConfig.targetOS == .android) { final minimumApi = codeConfig.targetArchitecture == Architecture.riscv64 ? 35 : 21; @@ -160,10 +160,10 @@ class RunCBuilder { targetAndroidNdkApi = null; } - final targetIOSVersion = codeConfig.targetOS == OS.iOS + final targetIOSVersion = codeConfig.targetOS == .iOS ? codeConfig.iOS.targetVersion : null; - final targetMacOSVersion = codeConfig.targetOS == OS.macOS + final targetMacOSVersion = codeConfig.targetOS == .macOS ? codeConfig.macOS.targetVersion : null; @@ -231,26 +231,26 @@ class RunCBuilder { executable: toolInstance.uri, environment: environment, arguments: [ - if (codeConfig.targetOS == OS.android) ...[ + if (codeConfig.targetOS == .android) ...[ '--target=' '${androidNdkClangTargetFlags[architecture]!}' '${targetAndroidNdkApi!}', '--sysroot=${androidSysroot(toolInstance).toFilePath()}', ], - if (codeConfig.targetOS == OS.windows) + if (codeConfig.targetOS == .windows) '--target=${clangWindowsTargetFlags[architecture]!}', - if (codeConfig.targetOS == OS.macOS) + if (codeConfig.targetOS == .macOS) '--target=${appleClangMacosTargetFlags[architecture]!}', - if (codeConfig.targetOS == OS.iOS) + if (codeConfig.targetOS == .iOS) '--target=${appleClangIosTargetFlags[architecture]![targetIosSdk]!}', if (targetIOSVersion != null) '-mios-version-min=$targetIOSVersion', if (targetMacOSVersion != null) '-mmacos-version-min=$targetMacOSVersion', - if (codeConfig.targetOS == OS.iOS) ...[ + if (codeConfig.targetOS == .iOS) ...[ '-isysroot', (await iosSdk(targetIosSdk!, context)).toFilePath(), ], - if (codeConfig.targetOS == OS.macOS) ...[ + if (codeConfig.targetOS == .macOS) ...[ '-isysroot', (await macosSdk(context)).toFilePath(), ], @@ -260,7 +260,7 @@ class RunCBuilder { ], if (pic != null) if (toolInstance.tool.isClangLike && - codeConfig.targetOS != OS.windows) ...[ + codeConfig.targetOS != .windows) ...[ if (pic!) ...[ if (dynamicLibrary != null) '-fPIC', // Using PIC for static libraries allows them to be linked into @@ -291,17 +291,18 @@ class RunCBuilder { ], ], if (std != null) '-std=$std', - if (language == Language.cpp) ...[ + if (language == .cpp) ...[ '-x', 'c++', '-l', cppLinkStdLib ?? defaultCppLinkStdLib[codeConfig.targetOS]!, ], - if (optimizationLevel != OptimizationLevel.unspecified) - optimizationLevel.clangFlag(), + if (optimizationLevel != .unspecified) optimizationLevel.clangFlag(), // Support Android 15 page size by default, can be overridden by // passing [flags]. - if (codeConfig.targetOS == OS.android) '-Wl,-z,max-page-size=16384', + if (codeConfig.targetOS == .android) '-Wl,-z,max-page-size=16384', + if (codeConfig.targetOS == .iOS || codeConfig.targetOS == .macOS) + '-Wl,-encryptable', ...flags, for (final MapEntry(key: name, :value) in defines.entries) if (value == null) '-D$name' else '-D$name=$value', @@ -317,7 +318,7 @@ class RunCBuilder { ) else ...sourceFiles, - if (language == Language.objectiveC) ...[ + if (language == .objectiveC) ...[ for (final framework in frameworks) ...['-framework', framework], ], if (executable != null) ...[ @@ -333,11 +334,11 @@ class RunCBuilder { outFile!.toFilePath(), ], if (executable != null || dynamicLibrary != null) ...[ - if (codeConfig.targetOS case OS.android || OS.linux) + if (codeConfig.targetOS case .android || .linux) // During bundling code assets are all placed in the same directory. // Setting this rpath allows the binary to find other code assets // it is linked against. - '-Wl,-rpath=\$ORIGIN', + '-Wl,-rpath,\$ORIGIN', for (final directory in libraryDirectories) '-L${directory.toFilePath()}', for (final library in libraries) '-l$library', @@ -362,10 +363,9 @@ class RunCBuilder { final result = await runProcess( executable: tool.uri, arguments: [ - if (optimizationLevel != OptimizationLevel.unspecified) - optimizationLevel.msvcFlag(), + if (optimizationLevel != .unspecified) optimizationLevel.msvcFlag(), if (std != null) '/std:$std', - if (language == Language.cpp) '/TP', + if (language == .cpp) '/TP', ...flags, for (final MapEntry(key: name, :value) in defines.entries) if (value == null) '/D$name' else '/D$name=$value', diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart index dd093a93bb..41c47f28f1 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart @@ -78,6 +78,15 @@ final Tool lld = Tool( wrappedResolver: clang.defaultResolver!, relativePath: Uri.file(OS.current.executableFileName('ld')), ), + InstallLocationResolver( + toolName: 'LLD', + paths: [ + '/opt/homebrew/opt/lld/bin/ld.lld', + '/opt/homebrew/bin/ld.lld', + '/usr/local/opt/lld/bin/ld.lld', + '/usr/local/bin/ld.lld', + ], + ), PathToolResolver( toolName: 'LLD', executableName: OS.current.executableFileName('ld.lld'), diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/msvc.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/msvc.dart index 4287f5f3dd..8a1d20e2a5 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/msvc.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/msvc.dart @@ -141,8 +141,8 @@ final Tool vsDevCmd = Tool( final Tool cl = _msvcTool( name: 'cl', versionArguments: [], - targetArchitecture: Architecture.x64, - hostArchitecture: Architecture.current, + targetArchitecture: .x64, + hostArchitecture: .current, ); /// The C/C++ Optimizing Compiler main executable. @@ -151,8 +151,8 @@ final Tool cl = _msvcTool( final Tool clIA32 = _msvcTool( name: 'cl', versionArguments: [], - targetArchitecture: Architecture.ia32, - hostArchitecture: Architecture.current, + targetArchitecture: .ia32, + hostArchitecture: .current, ); /// The C/C++ Optimizing Compiler main executable. @@ -161,30 +161,30 @@ final Tool clIA32 = _msvcTool( final Tool clArm64 = _msvcTool( name: 'cl', versionArguments: [], - targetArchitecture: Architecture.arm64, - hostArchitecture: Architecture.current, + targetArchitecture: .arm64, + hostArchitecture: .current, ); final Tool lib = _msvcTool( name: 'lib', - targetArchitecture: Architecture.x64, - hostArchitecture: Architecture.current, + targetArchitecture: .x64, + hostArchitecture: .current, // https://github.com/dart-lang/native/issues/18 resolveVersion: false, ); final Tool libIA32 = _msvcTool( name: 'lib', - targetArchitecture: Architecture.ia32, - hostArchitecture: Architecture.current, + targetArchitecture: .ia32, + hostArchitecture: .current, // https://github.com/dart-lang/native/issues/18 resolveVersion: false, ); final Tool libArm64 = _msvcTool( name: 'lib', - targetArchitecture: Architecture.arm64, - hostArchitecture: Architecture.current, + targetArchitecture: .arm64, + hostArchitecture: .current, // https://github.com/dart-lang/native/issues/18 resolveVersion: false, ); @@ -193,30 +193,30 @@ final Tool msvcLink = _msvcTool( name: 'link', versionArguments: ['/help'], versionExitCode: 1100, - targetArchitecture: Architecture.x64, - hostArchitecture: Architecture.current, + targetArchitecture: .x64, + hostArchitecture: .current, ); final Tool linkIA32 = _msvcTool( name: 'link', versionArguments: ['/help'], versionExitCode: 1100, - targetArchitecture: Architecture.ia32, - hostArchitecture: Architecture.current, + targetArchitecture: .ia32, + hostArchitecture: .current, ); final Tool linkArm64 = _msvcTool( name: 'link', versionArguments: ['/help'], versionExitCode: 1100, - targetArchitecture: Architecture.arm64, - hostArchitecture: Architecture.current, + targetArchitecture: .arm64, + hostArchitecture: .current, ); final Tool dumpbin = _msvcTool( name: 'dumpbin', - targetArchitecture: Architecture.x64, - hostArchitecture: Architecture.current, + targetArchitecture: .x64, + hostArchitecture: .current, ); const _msvcArchNames = { diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 4db8d43b0a..35ba6f6316 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -82,8 +82,7 @@ class PathToolResolver extends ToolResolver { if (process.exitCode == 0) { final file = File(LineSplitter.split(process.stdout).first); final uri = File(await file.resolveSymbolicLinks()).uri; - if (uri.pathSegments.last == 'llvm' || - uri.pathSegments.last == 'swiftly') { + if (uri.pathSegments.last case 'llvm' || 'lld' || 'swiftly') { // https://github.com/dart-lang/native/issues/136 // https://github.com/dart-lang/native/issues/2792 return file.uri; diff --git a/pkgs/native_toolchain_c/lib/src/utils/run_process.dart b/pkgs/native_toolchain_c/lib/src/utils/run_process.dart index 22285b1ae5..7c64f92c96 100644 --- a/pkgs/native_toolchain_c/lib/src/utils/run_process.dart +++ b/pkgs/native_toolchain_c/lib/src/utils/run_process.dart @@ -19,7 +19,7 @@ Future runProcess({ Map? environment, required Logger? logger, bool captureOutput = true, - Level stdoutLogLevel = Level.FINE, + Level stdoutLogLevel = .FINE, int expectedExitCode = 0, bool throwOnUnexpectedExitCode = false, }) async { diff --git a/pkgs/native_toolchain_c/pubspec.yaml b/pkgs/native_toolchain_c/pubspec.yaml index 9c161dceab..1984dd0b30 100644 --- a/pkgs/native_toolchain_c/pubspec.yaml +++ b/pkgs/native_toolchain_c/pubspec.yaml @@ -14,7 +14,7 @@ topics: resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dependencies: code_assets: ^1.0.0 @@ -26,11 +26,8 @@ dependencies: dev_dependencies: collection: ^1.19.1 - custom_lint: ^0.7.5 dart_flutter_team_lints: ^3.5.2 native_test_helpers: path: ../native_test_helpers/ - repo_lint_rules: - path: ../repo_lint_rules/ test: ^1.25.15 test_descriptor: ^2.0.2 diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart index c4713a8cc3..6655eda2c0 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_build_failure_test.dart @@ -50,7 +50,7 @@ void main() { ? MacOSCodeConfig(targetVersion: defaultMacOSVersion) : null, targetArchitecture: Architecture.current, - linkModePreference: LinkModePreference.dynamic, + linkModePreference: .dynamic, cCompiler: cCompiler, ), ); @@ -62,7 +62,7 @@ void main() { sources: [addCUri.toFilePath()], name: name, assetName: name, - buildMode: BuildMode.release, + buildMode: .release, ); expect( () => @@ -94,9 +94,9 @@ void main() { ..config.setupBuild(linkingEnabled: false) ..addExtension( CodeAssetExtension( - targetOS: OS.windows, + targetOS: .windows, targetArchitecture: Architecture.current, - linkModePreference: LinkModePreference.dynamic, + linkModePreference: .dynamic, cCompiler: cCompiler, ), ); @@ -111,7 +111,7 @@ void main() { name: name, assetName: name, includes: [], - buildMode: BuildMode.release, + buildMode: .release, ); await expectLater( cbuilder.run(input: buildInput, output: buildOutput, logger: logger), @@ -121,8 +121,7 @@ void main() { // Note: don't check the entire message as CL output is based on user // locale. final line = logs.firstWhereOrNull( - (log) => - log.level == Level.INFO && log.message.contains('fatal error C1070'), + (log) => log.level == .INFO && log.message.contains('fatal error C1070'), ); expect(line != null, true); }); diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart index 2e098fb16c..27ab425f62 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_android_test.dart @@ -14,48 +14,77 @@ import '../helpers.dart'; const Timeout longTimeout = Timeout(Duration(minutes: 5)); void main() { - const targets = [ - Architecture.arm, - Architecture.arm64, - Architecture.ia32, - Architecture.x64, - Architecture.riscv64, + // These configurations are a selection of combinations of architectures, + // link modes, and optimization levels. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + architecture: Architecture.arm, + apiLevel: flutterAndroidNdkVersionLowestSupported, + linkMode: DynamicLoadingBundled(), + optimizationLevel: OptimizationLevel.o0, + ), + ( + architecture: Architecture.arm64, + apiLevel: flutterAndroidNdkVersionHighestSupported, + linkMode: StaticLinking(), + optimizationLevel: OptimizationLevel.o1, + ), + ( + architecture: Architecture.ia32, + apiLevel: flutterAndroidNdkVersionLowestSupported, + linkMode: StaticLinking(), + optimizationLevel: OptimizationLevel.o2, + ), + ( + architecture: Architecture.x64, + apiLevel: flutterAndroidNdkVersionHighestSupported, + linkMode: DynamicLoadingBundled(), + optimizationLevel: OptimizationLevel.o3, + ), + ( + architecture: Architecture.riscv64, + apiLevel: flutterAndroidNdkVersionLowestSupported, + linkMode: DynamicLoadingBundled(), + optimizationLevel: OptimizationLevel.oS, + ), + ( + architecture: Architecture.arm64, + apiLevel: flutterAndroidNdkVersionLowestSupported, + linkMode: StaticLinking(), + optimizationLevel: OptimizationLevel.unspecified, + ), + ( + architecture: Architecture.arm, + apiLevel: flutterAndroidNdkVersionHighestSupported, + linkMode: DynamicLoadingBundled(), + optimizationLevel: OptimizationLevel.o2, + ), ]; - const optimizationLevels = OptimizationLevel.values; - var selectOptimizationLevel = 0; - - for (final linkMode in [DynamicLoadingBundled(), StaticLinking()]) { - for (final target in targets) { - for (final apiLevel in [ - flutterAndroidNdkVersionLowestSupported, - flutterAndroidNdkVersionHighestSupported, - ]) { - // Cycle through all optimization levels. - final optimizationLevel = optimizationLevels[selectOptimizationLevel]; - selectOptimizationLevel = - (selectOptimizationLevel + 1) % optimizationLevels.length; - test( - 'CBuilder $linkMode library $target minSdkVersion $apiLevel ' - '$optimizationLevel', - timeout: longTimeout, - () async { - final tempUri = await tempDirForTest(); - final libUri = await buildLib( - tempUri, - target, - apiLevel, - linkMode, - optimizationLevel: optimizationLevel, - ); - await expectMachineArchitecture(libUri, target, OS.android); - if (linkMode == DynamicLoadingBundled()) { - await expectPageSize(libUri, 16 * 1024); - } - }, + for (final (:architecture, :apiLevel, :linkMode, :optimizationLevel) + in configurations) { + test( + 'CBuilder $linkMode library $architecture minSdkVersion $apiLevel ' + '$optimizationLevel', + timeout: longTimeout, + () async { + final tempUri = await tempDirForTest(); + final libUri = await buildLib( + tempUri, + architecture, + apiLevel, + linkMode, + optimizationLevel: optimizationLevel, ); - } - } + await expectMachineArchitecture(libUri, architecture, OS.android); + if (linkMode == DynamicLoadingBundled()) { + await expectPageSize(libUri, 16 * 1024); + } + }, + ); } test('CBuilder API levels binary difference', timeout: longTimeout, () async { @@ -124,13 +153,13 @@ Future buildLib( ..config.setupBuild(linkingEnabled: false) ..addExtension( CodeAssetExtension( - targetOS: OS.android, + targetOS: .android, targetArchitecture: targetArchitecture, cCompiler: cCompiler, android: AndroidCodeConfig(targetNdkApi: androidNdkApi), linkModePreference: linkMode == DynamicLoadingBundled() - ? LinkModePreference.dynamic - : LinkModePreference.static, + ? .dynamic + : .static, ), ); @@ -142,7 +171,7 @@ Future buildLib( assetName: name, sources: [addCUri.toFilePath()], flags: flags, - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart index 826c8bb749..4953e1794a 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_ios_test.dart @@ -22,165 +22,192 @@ void main() { return; } - const targets = [Architecture.arm64, Architecture.x64]; - const name = 'add'; - const optimizationLevels = OptimizationLevel.values; - var selectOptimizationLevel = 0; + // These configurations are a selection of combinations of architectures, + // link modes, and optimization levels. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + language: Language.c, + linkMode: DynamicLoadingBundled(), + targetIOSSdk: IOSSdk.iPhoneOS, + target: Architecture.arm64, + hasInstallName: false, + optimizationLevel: OptimizationLevel.o0, + ), + ( + language: Language.objectiveC, + linkMode: StaticLinking(), + targetIOSSdk: IOSSdk.iPhoneSimulator, + target: Architecture.x64, + hasInstallName: false, + optimizationLevel: OptimizationLevel.o1, + ), + ( + language: Language.c, + linkMode: StaticLinking(), + targetIOSSdk: IOSSdk.iPhoneSimulator, + target: Architecture.arm64, + hasInstallName: false, + optimizationLevel: OptimizationLevel.o2, + ), + ( + language: Language.objectiveC, + linkMode: DynamicLoadingBundled(), + targetIOSSdk: IOSSdk.iPhoneOS, + target: Architecture.arm64, + hasInstallName: true, + optimizationLevel: OptimizationLevel.o3, + ), + ( + language: Language.c, + linkMode: DynamicLoadingBundled(), + targetIOSSdk: IOSSdk.iPhoneSimulator, + target: Architecture.x64, + hasInstallName: true, + optimizationLevel: OptimizationLevel.oS, + ), + ( + language: Language.objectiveC, + linkMode: StaticLinking(), + targetIOSSdk: IOSSdk.iPhoneOS, + target: Architecture.arm64, + hasInstallName: false, + optimizationLevel: OptimizationLevel.unspecified, + ), + ]; - for (final language in [Language.c, Language.objectiveC]) { - for (final linkMode in [DynamicLoadingBundled(), StaticLinking()]) { - for (final targetIOSSdk in IOSSdk.values) { - for (final target in targets) { - if (target == Architecture.x64 && targetIOSSdk == IOSSdk.iPhoneOS) { - continue; - } - final libName = OS.iOS.libraryFileName(name, linkMode); - for (final installName in [ - null, - if (linkMode == DynamicLoadingBundled()) - Uri.file('@executable_path/Frameworks/$libName'), - ]) { - // Cycle through all optimization levels. - final optimizationLevel = - optimizationLevels[selectOptimizationLevel]; - selectOptimizationLevel = - (selectOptimizationLevel + 1) % optimizationLevels.length; - test( - 'CBuilder $linkMode $language library $targetIOSSdk $target' - ' ${installName ?? ''} $optimizationLevel' - .trim(), - () async { - final tempUri = await tempDirForTest(); - final tempUri2 = await tempDirForTest(); - final sourceUri = switch (language) { - Language.c => packageUri.resolve( - 'test/cbuilder/testfiles/add/src/add.c', - ), - Language.objectiveC => packageUri.resolve( - 'test/cbuilder/testfiles/add_objective_c/src/add.m', - ), - Language() => throw UnimplementedError(), - }; + for (final ( + :language, + :linkMode, + :targetIOSSdk, + :target, + :hasInstallName, + :optimizationLevel, + ) + in configurations) { + final libName = OS.iOS.libraryFileName(name, linkMode); + final installName = hasInstallName + ? Uri.file('@executable_path/Frameworks/$libName') + : null; + test( + 'CBuilder $linkMode $language library $targetIOSSdk $target' + ' ${installName ?? ''} $optimizationLevel' + .trim(), + () async { + final tempUri = await tempDirForTest(); + final tempUri2 = await tempDirForTest(); + final sourceUri = switch (language) { + .c => packageUri.resolve('test/cbuilder/testfiles/add/src/add.c'), + .objectiveC => packageUri.resolve( + 'test/cbuilder/testfiles/add_objective_c/src/add.m', + ), + Language() => throw UnimplementedError(), + }; - final buildInputBuilder = BuildInputBuilder() - ..setupShared( - packageName: name, - packageRoot: tempUri, - outputFile: tempUri.resolve('output.json'), - outputDirectoryShared: tempUri2, - ) - ..config.setupBuild(linkingEnabled: false) - ..addExtension( - CodeAssetExtension( - targetOS: OS.iOS, - targetArchitecture: target, - linkModePreference: linkMode == DynamicLoadingBundled() - ? LinkModePreference.dynamic - : LinkModePreference.static, - iOS: IOSCodeConfig( - targetSdk: targetIOSSdk, - targetVersion: flutteriOSHighestBestEffort, - ), - cCompiler: cCompiler, - ), - ); + final buildInputBuilder = BuildInputBuilder() + ..setupShared( + packageName: name, + packageRoot: tempUri, + outputFile: tempUri.resolve('output.json'), + outputDirectoryShared: tempUri2, + ) + ..config.setupBuild(linkingEnabled: false) + ..addExtension( + CodeAssetExtension( + targetOS: .iOS, + targetArchitecture: target, + linkModePreference: linkMode == DynamicLoadingBundled() + ? .dynamic + : .static, + iOS: IOSCodeConfig( + targetSdk: targetIOSSdk, + targetVersion: flutteriOSHighestBestEffort, + ), + cCompiler: cCompiler, + ), + ); - final buildInput = buildInputBuilder.build(); - final buildOutput = BuildOutputBuilder(); + final buildInput = buildInputBuilder.build(); + final buildOutput = BuildOutputBuilder(); - final cbuilder = CBuilder.library( - name: name, - assetName: name, - sources: [sourceUri.toFilePath()], - installName: installName, - language: language, - optimizationLevel: optimizationLevel, - buildMode: BuildMode.release, - ); - await cbuilder.run( - input: buildInput, - output: buildOutput, - logger: logger, - ); + final cbuilder = CBuilder.library( + name: name, + assetName: name, + sources: [sourceUri.toFilePath()], + installName: installName, + language: language, + optimizationLevel: optimizationLevel, + buildMode: .release, + ); + await cbuilder.run( + input: buildInput, + output: buildOutput, + logger: logger, + ); - final libUri = buildInput.outputDirectory.resolve(libName); - final objdumpResult = await runProcess( - executable: Uri.file('objdump'), - arguments: ['-t', libUri.path], - logger: logger, - ); - expect(objdumpResult.exitCode, 0); - final machine = objdumpResult.stdout - .split('\n') - .firstWhere((e) => e.contains('file format')); - expect(machine, contains(objdumpFileFormatIOS[target])); + final libUri = buildInput.outputDirectory.resolve(libName); + final objdumpResult = await runProcess( + executable: Uri.file('objdump'), + arguments: ['-t', libUri.path], + logger: logger, + ); + expect(objdumpResult.exitCode, 0); + final machine = objdumpResult.stdout + .split('\n') + .firstWhere((e) => e.contains('file format')); + expect(machine, contains(objdumpFileFormatIOS[target])); - final otoolResult = await runProcess( - executable: Uri.file('otool'), - arguments: ['-l', libUri.path], - logger: logger, - ); - expect(otoolResult.exitCode, 0); - // As of native_assets_cli 0.10.0, the min target OS version is - // always being passed in. - expect( - otoolResult.stdout, - isNot(contains('LC_VERSION_MIN_IPHONEOS')), - ); - expect(otoolResult.stdout, contains('LC_BUILD_VERSION')); - final platform = otoolResult.stdout - .split('\n') - .firstWhere((e) => e.contains('platform')); - if (targetIOSSdk == IOSSdk.iPhoneOS) { - const platformIosDevice = 2; - expect(platform, contains(platformIosDevice.toString())); - } else { - const platformIosSimulator = 7; - expect(platform, contains(platformIosSimulator.toString())); - } + final otoolResult = await runProcess( + executable: Uri.file('otool'), + arguments: ['-l', libUri.path], + logger: logger, + ); + expect(otoolResult.exitCode, 0); + // As of native_assets_cli 0.10.0, the min target OS version is + // always being passed in. + expect(otoolResult.stdout, isNot(contains('LC_VERSION_MIN_IPHONEOS'))); + expect(otoolResult.stdout, contains('LC_BUILD_VERSION')); + final platform = otoolResult.stdout + .split('\n') + .firstWhere((e) => e.contains('platform')); + if (targetIOSSdk == IOSSdk.iPhoneOS) { + const platformIosDevice = 2; + expect(platform, contains(platformIosDevice.toString())); + } else { + const platformIosSimulator = 7; + expect(platform, contains(platformIosSimulator.toString())); + } - if (linkMode == DynamicLoadingBundled()) { - final libInstallName = await runOtoolInstallName( - libUri, - libName, - ); - if (installName == null) { - // If no install path is passed, we have an absolute path. - final tempName = buildInput.outputDirectory.pathSegments - .lastWhere((e) => e != ''); - final pathEnding = Uri.directory( - tempName, - ).resolve(libName).toFilePath(); - expect(Uri.file(libInstallName).isAbsolute, true); - expect(libInstallName, contains(pathEnding)); - final targetInstallName = - '@executable_path/Frameworks/$libName'; - await runProcess( - executable: Uri.file('install_name_tool'), - arguments: [ - '-id', - targetInstallName, - libUri.toFilePath(), - ], - logger: logger, - ); - final libInstallName2 = await runOtoolInstallName( - libUri, - libName, - ); - expect(libInstallName2, targetInstallName); - } else { - expect(libInstallName, installName.toFilePath()); - } - } - }, + if (linkMode == DynamicLoadingBundled()) { + final libInstallName = await runOtoolInstallName(libUri, libName); + if (installName == null) { + // If no install path is passed, we have an absolute path. + final tempName = buildInput.outputDirectory.pathSegments.lastWhere( + (e) => e != '', + ); + final pathEnding = Uri.directory( + tempName, + ).resolve(libName).toFilePath(); + expect(Uri.file(libInstallName).isAbsolute, true); + expect(libInstallName, contains(pathEnding)); + final targetInstallName = '@executable_path/Frameworks/$libName'; + await runProcess( + executable: Uri.file('install_name_tool'), + arguments: ['-id', targetInstallName, libUri.toFilePath()], + logger: logger, ); + final libInstallName2 = await runOtoolInstallName(libUri, libName); + expect(libInstallName2, targetInstallName); + } else { + expect(libInstallName, installName.toFilePath()); } } - } - } + }, + ); } for (final iosVersion in [ @@ -235,11 +262,11 @@ Future buildLib( ..config.setupBuild(linkingEnabled: false) ..addExtension( CodeAssetExtension( - targetOS: OS.iOS, + targetOS: .iOS, targetArchitecture: targetArchitecture, linkModePreference: linkMode == DynamicLoadingBundled() - ? LinkModePreference.dynamic - : LinkModePreference.static, + ? .dynamic + : .static, iOS: IOSCodeConfig( targetSdk: IOSSdk.iPhoneOS, targetVersion: targetIOSVersion, @@ -255,7 +282,7 @@ Future buildLib( name: name, assetName: name, sources: [addCUri.toFilePath()], - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart index 2dc7c9223e..b950356250 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_linux_host_test.dart @@ -20,72 +20,93 @@ void main() { return; } - const targets = [ - Architecture.arm, - Architecture.arm64, - Architecture.ia32, - Architecture.x64, - Architecture.riscv64, + // These configurations are a selection of combinations of architectures, + // link modes, and optimization levels. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + linkMode: DynamicLoadingBundled(), + target: Architecture.arm, + optimizationLevel: OptimizationLevel.o0, + ), + ( + linkMode: StaticLinking(), + target: Architecture.arm64, + optimizationLevel: OptimizationLevel.o1, + ), + ( + linkMode: DynamicLoadingBundled(), + target: Architecture.ia32, + optimizationLevel: OptimizationLevel.o2, + ), + ( + linkMode: StaticLinking(), + target: Architecture.x64, + optimizationLevel: OptimizationLevel.o3, + ), + ( + linkMode: DynamicLoadingBundled(), + target: Architecture.riscv64, + optimizationLevel: OptimizationLevel.oS, + ), + ( + linkMode: StaticLinking(), + target: Architecture.arm, + optimizationLevel: OptimizationLevel.unspecified, + ), ]; - const optimizationLevels = OptimizationLevel.values; - var selectOptimizationLevel = 0; + for (final (:linkMode, :target, :optimizationLevel) in configurations) { + test('CBuilder $linkMode library $target $optimizationLevel', () async { + final tempUri = await tempDirForTest(); + final tempUri2 = await tempDirForTest(); + final addCUri = packageUri.resolve( + 'test/cbuilder/testfiles/add/src/add.c', + ); + const name = 'add'; - for (final linkMode in [DynamicLoadingBundled(), StaticLinking()]) { - for (final target in targets) { - // Cycle through all optimization levels. - final optimizationLevel = optimizationLevels[selectOptimizationLevel]; - selectOptimizationLevel = - (selectOptimizationLevel + 1) % optimizationLevels.length; - test('CBuilder $linkMode library $target $optimizationLevel', () async { - final tempUri = await tempDirForTest(); - final tempUri2 = await tempDirForTest(); - final addCUri = packageUri.resolve( - 'test/cbuilder/testfiles/add/src/add.c', + final buildInputBuilder = BuildInputBuilder() + ..setupShared( + packageName: name, + packageRoot: tempUri, + outputFile: tempUri.resolve('output.json'), + outputDirectoryShared: tempUri2, + ) + ..config.setupBuild(linkingEnabled: false) + ..addExtension( + CodeAssetExtension( + targetOS: .linux, + targetArchitecture: target, + linkModePreference: linkMode == DynamicLoadingBundled() + ? .dynamic + : .static, + cCompiler: cCompiler, + ), ); - const name = 'add'; - final buildInputBuilder = BuildInputBuilder() - ..setupShared( - packageName: name, - packageRoot: tempUri, - outputFile: tempUri.resolve('output.json'), - outputDirectoryShared: tempUri2, - ) - ..config.setupBuild(linkingEnabled: false) - ..addExtension( - CodeAssetExtension( - targetOS: OS.linux, - targetArchitecture: target, - linkModePreference: linkMode == DynamicLoadingBundled() - ? LinkModePreference.dynamic - : LinkModePreference.static, - cCompiler: cCompiler, - ), - ); + final buildInput = buildInputBuilder.build(); + final buildOutput = BuildOutputBuilder(); - final buildInput = buildInputBuilder.build(); - final buildOutput = BuildOutputBuilder(); + final cbuilder = CBuilder.library( + name: name, + assetName: name, + sources: [addCUri.toFilePath()], + optimizationLevel: optimizationLevel, + buildMode: .release, + ); + await cbuilder.run( + input: buildInput, + output: buildOutput, + logger: logger, + ); - final cbuilder = CBuilder.library( - name: name, - assetName: name, - sources: [addCUri.toFilePath()], - optimizationLevel: optimizationLevel, - buildMode: BuildMode.release, - ); - await cbuilder.run( - input: buildInput, - output: buildOutput, - logger: logger, - ); - - final libUri = buildInput.outputDirectory.resolve( - OS.linux.libraryFileName(name, linkMode), - ); - final machine = await readelfMachine(libUri.path); - expect(machine, contains(readElfMachine[target])); - }); - } + final libUri = buildInput.outputDirectory.resolve( + OS.linux.libraryFileName(name, linkMode), + ); + final machine = await readelfMachine(libUri.path); + expect(machine, contains(readElfMachine[target])); + }); } } diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart index 0029b642b4..235b722138 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_cross_macos_host_test.dart @@ -10,106 +10,209 @@ import 'dart:io'; import 'package:code_assets/code_assets.dart'; import 'package:hooks/hooks.dart'; +import 'package:logging/logging.dart'; import 'package:native_toolchain_c/native_toolchain_c.dart'; +import 'package:native_toolchain_c/src/native_toolchain/apple_clang.dart'; +import 'package:native_toolchain_c/src/native_toolchain/clang.dart'; +import 'package:native_toolchain_c/src/tool/tool_resolver.dart'; import 'package:native_toolchain_c/src/utils/run_process.dart'; import 'package:test/test.dart'; import '../helpers.dart'; -void main() { +void main() async { if (!Platform.isMacOS) { // Avoid needing status files on Dart SDK CI. return; } - const targets = [Architecture.arm64, Architecture.x64]; + final context = ToolResolvingContext(logger: Logger.detached('main')); + final lldInstances = await lld.defaultResolver!.resolve(context); + final lldAvailable = lldInstances.isNotEmpty; + final lldPath = lldAvailable ? lldInstances.first.uri.toFilePath() : 'ld.lld'; + + if (!lldAvailable) { + stderr.writeln( + 'ld.lld not found. Linux cross-compilation tests will fail.', + ); + stderr.writeln("Install with 'brew install lld' on macOS."); + } // Dont include 'mach-o' or 'Mach-O', different spelling is used. const objdumpFileFormat = { - Architecture.arm64: 'arm64', - Architecture.x64: '64-bit x86-64', + (OS.macOS, Architecture.arm64): 'arm64', + (OS.macOS, Architecture.x64): '64-bit x86-64', + (OS.linux, Architecture.arm): 'elf32-littlearm', + (OS.linux, Architecture.arm64): 'elf64-littleaarch64', + (OS.linux, Architecture.ia32): 'elf32-i386', + (OS.linux, Architecture.x64): 'elf64-x86-64', + + (OS.linux, Architecture.riscv32): 'elf32-riscv32', + (OS.linux, Architecture.riscv64): 'elf64-riscv64', }; - const optimizationLevels = OptimizationLevel.values; - var selectOptimizationLevel = 0; + // These configurations are a selection of combinations of architectures, + // link modes, and optimization levels. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + language: Language.c, + linkMode: DynamicLoadingBundled(), + os: OS.macOS, + arch: Architecture.arm64, + optimizationLevel: OptimizationLevel.o0, + ), + ( + language: Language.objectiveC, + linkMode: StaticLinking(), + os: OS.macOS, + arch: Architecture.x64, + optimizationLevel: OptimizationLevel.o1, + ), + ( + language: Language.c, + linkMode: StaticLinking(), + os: OS.linux, + arch: Architecture.arm, + optimizationLevel: OptimizationLevel.o2, + ), + ( + language: Language.c, + linkMode: DynamicLoadingBundled(), + os: OS.linux, + arch: Architecture.arm64, + optimizationLevel: OptimizationLevel.o3, + ), + ( + language: Language.c, + linkMode: StaticLinking(), + os: OS.linux, + arch: Architecture.ia32, + optimizationLevel: OptimizationLevel.oS, + ), + ( + language: Language.c, + linkMode: DynamicLoadingBundled(), + os: OS.linux, + arch: Architecture.x64, + optimizationLevel: OptimizationLevel.unspecified, + ), + ( + language: Language.objectiveC, + linkMode: DynamicLoadingBundled(), + os: OS.macOS, + arch: Architecture.arm64, + optimizationLevel: OptimizationLevel.o2, + ), + ( + language: Language.c, + linkMode: StaticLinking(), + os: OS.macOS, + arch: Architecture.x64, + optimizationLevel: OptimizationLevel.o3, + ), + ]; - for (final language in [Language.c, Language.objectiveC]) { - for (final linkMode in [DynamicLoadingBundled(), StaticLinking()]) { - for (final target in targets) { - // Cycle through all optimization levels. - final optimizationLevel = optimizationLevels[selectOptimizationLevel]; - selectOptimizationLevel = - (selectOptimizationLevel + 1) % optimizationLevels.length; - - test( - 'CBuilder $linkMode $language library $target $optimizationLevel', - () async { - final tempUri = await tempDirForTest(); - final tempUri2 = await tempDirForTest(); - final sourceUri = switch (language) { - Language.c => packageUri.resolve( - 'test/cbuilder/testfiles/add/src/add.c', - ), - Language.objectiveC => packageUri.resolve( - 'test/cbuilder/testfiles/add_objective_c/src/add.m', - ), - Language() => throw UnimplementedError(), - }; - const name = 'add'; - - final buildInputBuilder = BuildInputBuilder() - ..setupShared( - packageName: name, - packageRoot: tempUri, - outputFile: tempUri.resolve('output.json'), - outputDirectoryShared: tempUri2, - ) - ..config.setupBuild(linkingEnabled: false) - ..addExtension( - CodeAssetExtension( - targetOS: OS.macOS, - targetArchitecture: target, - linkModePreference: linkMode == DynamicLoadingBundled() - ? LinkModePreference.dynamic - : LinkModePreference.static, - cCompiler: cCompiler, - macOS: MacOSCodeConfig(targetVersion: defaultMacOSVersion), + for (final (:language, :linkMode, :os, :arch, :optimizationLevel) + in configurations) { + test( + 'CBuilder $linkMode $language library $os $arch $optimizationLevel', + () async { + final tempUri = await tempDirForTest(); + final tempUri2 = await tempDirForTest(); + final sourceUri = switch (language) { + .c => packageUri.resolve('test/cbuilder/testfiles/add/src/add.c'), + .objectiveC => packageUri.resolve( + 'test/cbuilder/testfiles/add_objective_c/src/add.m', + ), + Language() => throw UnimplementedError(), + }; + const name = 'add'; + + // When cross-compiling from MacOS, explicitly specify apple clang. + // + // The default tool-finding does not support macos cross compiling + // right now. + var chosenCCompiler = cCompiler; + if (os == .linux) { + // still respect the CI-provided compiler + chosenCCompiler ??= await resolveAppleToolchain(); + } + + final buildInputBuilder = BuildInputBuilder() + ..setupShared( + packageName: name, + packageRoot: tempUri, + outputFile: tempUri.resolve('output.json'), + outputDirectoryShared: tempUri2, + ) + ..config.setupBuild(linkingEnabled: false) + ..addExtension( + CodeAssetExtension( + targetOS: os, + targetArchitecture: arch, + linkModePreference: linkMode == DynamicLoadingBundled() + ? .dynamic + : .static, + cCompiler: chosenCCompiler, + macOS: MacOSCodeConfig(targetVersion: defaultMacOSVersion), + ), + ); + final buildInput = buildInputBuilder.build(); + final buildOutput = BuildOutputBuilder(); + + final cbuilder = CBuilder.library( + name: name, + assetName: name, + sources: [sourceUri.toFilePath()], + language: language, + optimizationLevel: optimizationLevel, + buildMode: .release, + flags: [ + if (os == .linux) + switch (arch) { + .arm => '--target=arm-linux-gnueabihf', + .arm64 => '--target=aarch64-linux-gnu', + .ia32 => '--target=i686-linux-gnu', + .x64 => '--target=x86_64-linux-gnu', + .riscv32 => '--target=riscv32-linux-gnu', + .riscv64 => '--target=riscv64-linux-gnu', + _ => throw UnsupportedError( + 'Unexpected linux architecture: $arch', ), - ); - final buildInput = buildInputBuilder.build(); - final buildOutput = BuildOutputBuilder(); - - final cbuilder = CBuilder.library( - name: name, - assetName: name, - sources: [sourceUri.toFilePath()], - language: language, - optimizationLevel: optimizationLevel, - buildMode: BuildMode.release, - ); - await cbuilder.run( - input: buildInput, - output: buildOutput, - logger: logger, - ); - - final libUri = buildInput.outputDirectory.resolve( - OS.macOS.libraryFileName(name, linkMode), - ); - final result = await runProcess( - executable: Uri.file('objdump'), - arguments: ['-t', libUri.path], - logger: logger, - ); - expect(result.exitCode, 0); - final machine = result.stdout - .split('\n') - .firstWhere((e) => e.contains('file format')); - expect(machine, contains(objdumpFileFormat[target])); - }, + }, + // Only homebrew lld can link for linux, and we don't have a + // sysroot so we can't use stdlibs / C-runtime files. + if (os == .linux) ...[ + '--ld-path=$lldPath', + '-nostartfiles', + '-nostdlib', + ], + ], ); - } - } + await cbuilder.run( + input: buildInput, + output: buildOutput, + logger: logger, + ); + + final libUri = buildInput.outputDirectory.resolve( + os.libraryFileName(name, linkMode), + ); + final result = await runProcess( + executable: Uri.file('objdump'), + arguments: ['-t', libUri.path], + logger: logger, + ); + expect(result.exitCode, 0); + final machine = result.stdout + .split('\n') + .firstWhere((e) => e.contains('file format')); + expect(machine, contains(objdumpFileFormat[(os, arch)])); + }, + ); } const flutterMacOSLowestBestEffort = 12; @@ -167,11 +270,11 @@ Future buildLib( ..config.setupBuild(linkingEnabled: false) ..addExtension( CodeAssetExtension( - targetOS: OS.macOS, + targetOS: .macOS, targetArchitecture: targetArchitecture, linkModePreference: linkMode == DynamicLoadingBundled() - ? LinkModePreference.dynamic - : LinkModePreference.static, + ? .dynamic + : .static, macOS: MacOSCodeConfig(targetVersion: targetMacOSVersion), cCompiler: cCompiler, ), @@ -184,7 +287,7 @@ Future buildLib( name: name, assetName: name, sources: [addCUri.toFilePath()], - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); @@ -193,3 +296,18 @@ Future buildLib( ); return libUri; } + +Future resolveAppleToolchain() async { + // (still respect the CI provided compiler) + final context = ToolResolvingContext(logger: logger); + + final resolvedClang = await appleClang.defaultResolver!.resolve(context); + final resolvedAr = await appleAr.defaultResolver!.resolve(context); + final resolvedLd = await appleLd.defaultResolver!.resolve(context); + + return CCompilerConfig( + compiler: resolvedClang.first.uri, + archiver: resolvedAr.first.uri, + linker: resolvedLd.first.uri, + ); +} diff --git a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart index f2dd2578ad..4e497c9356 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/cbuilder_test.dart @@ -159,7 +159,7 @@ void main() { name: name, assetName: name, pic: pic, - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run( input: buildInput, @@ -272,7 +272,7 @@ void main() { sources: [definesCUri.toFilePath()], forcedIncludes: [forcedIncludeCUri.toFilePath()], flags: [flag], - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); @@ -333,7 +333,7 @@ void main() { assetName: name, includes: [includeDirectoryUri.toFilePath()], sources: [includesCUri.toFilePath()], - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run( input: buildInput, @@ -395,7 +395,7 @@ void main() { name: name, assetName: name, std: std, - buildMode: BuildMode.release, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); @@ -462,8 +462,8 @@ void main() { final cbuilder = CBuilder.executable( name: name, sources: [helloWorldCppUri.toFilePath()], - language: Language.cpp, - buildMode: BuildMode.release, + language: .cpp, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); @@ -522,9 +522,9 @@ void main() { final cbuilder = CBuilder.executable( name: name, sources: [helloWorldCppUri.toFilePath()], - language: Language.cpp, + language: .cpp, cppLinkStdLib: 'stdc++', - buildMode: BuildMode.release, + buildMode: .release, ); if (buildInput.config.code.targetOS == OS.windows) { @@ -609,7 +609,7 @@ void main() { assetName: 'debug', includes: [dynamicallyLinkedSrcUri.toFilePath()], sources: [debugCUri.toFilePath()], - buildMode: BuildMode.release, + buildMode: .release, ); await debugBuilder.run( @@ -741,7 +741,7 @@ Future testDefines({ ); } - if (ndebugDefine && buildMode != BuildMode.debug) { + if (ndebugDefine && buildMode != .debug) { expect(result.stdout, contains('Macro NDEBUG is defined: 1')); } else { expect(result.stdout, contains('Macro NDEBUG is undefined.')); diff --git a/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart b/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart index 1b71a0fa4b..46f03ed280 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/compiler_resolver_test.dart @@ -56,7 +56,7 @@ void main() { ? MacOSCodeConfig(targetVersion: defaultMacOSVersion) : null, targetArchitecture: Architecture.current, - linkModePreference: LinkModePreference.dynamic, + linkModePreference: .dynamic, cCompiler: CCompilerConfig( archiver: ar, compiler: cc, @@ -102,9 +102,9 @@ void main() { ..config.setupBuild(linkingEnabled: false) ..addExtension( CodeAssetExtension( - targetOS: OS.windows, - targetArchitecture: Architecture.arm64, - linkModePreference: LinkModePreference.dynamic, + targetOS: .windows, + targetArchitecture: .arm64, + linkModePreference: .dynamic, cCompiler: cCompiler, ), ); @@ -114,8 +114,8 @@ void main() { final resolver = CompilerResolver( codeConfig: buildInput.config.code, logger: logger, - hostOS: OS.android, // This is never a host. - hostArchitecture: Architecture.arm64, // This is never a host. + hostOS: .android, // This is never a host. + hostArchitecture: .arm64, // This is never a host. ); expect(resolver.resolveCompiler, throwsA(isA())); expect(resolver.resolveArchiver, throwsA(isA())); diff --git a/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart b/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart index 30dee678aa..0af6ca1d3e 100644 --- a/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart +++ b/pkgs/native_toolchain_c/test/cbuilder/objective_c_test.dart @@ -63,8 +63,8 @@ void main() { name: name, assetName: name, sources: [addMUri.toFilePath()], - language: Language.objectiveC, - buildMode: BuildMode.release, + language: .objectiveC, + buildMode: .release, ); await cbuilder.run(input: buildInput, output: buildOutput, logger: logger); diff --git a/pkgs/native_toolchain_c/test/clinker/objects_cross_android_test.dart b/pkgs/native_toolchain_c/test/clinker/objects_cross_android_test.dart index c7974c1bd3..5703c0834c 100644 --- a/pkgs/native_toolchain_c/test/clinker/objects_cross_android_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/objects_cross_android_test.dart @@ -8,16 +8,51 @@ import 'package:test/test.dart'; import '../helpers.dart'; import 'objects_helper.dart'; +const Timeout longTimeout = Timeout(Duration(minutes: 5)); + void main() { const targetOS = OS.android; - final architectures = supportedArchitecturesFor(targetOS); - for (final apiLevel in [ - flutterAndroidNdkVersionLowestSupported, - flutterAndroidNdkVersionHighestSupported, - ]) { - group('Android API$apiLevel:', () { - runObjectsTests(targetOS, architectures, androidTargetNdkApi: apiLevel); + // These configurations are a selection of combinations of architectures + // and API levels. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + architecture: Architecture.arm, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ( + architecture: Architecture.arm64, + apiLevel: flutterAndroidNdkVersionHighestSupported, + ), + ( + architecture: Architecture.ia32, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ( + architecture: Architecture.x64, + apiLevel: flutterAndroidNdkVersionHighestSupported, + ), + ( + architecture: Architecture.riscv64, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ( + architecture: Architecture.arm64, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ]; + + for (final (:architecture, :apiLevel) in configurations) { + group('Android API$apiLevel ($architecture):', () { + runObjectsTests( + targetOS, + [architecture], + androidTargetNdkApi: apiLevel, + timeout: longTimeout, + ); }); } } diff --git a/pkgs/native_toolchain_c/test/clinker/objects_cross_ios_test.dart b/pkgs/native_toolchain_c/test/clinker/objects_cross_ios_test.dart index 0ddf6f6720..f206880c4c 100644 --- a/pkgs/native_toolchain_c/test/clinker/objects_cross_ios_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/objects_cross_ios_test.dart @@ -21,19 +21,28 @@ void main() { const targetOS = OS.iOS; - for (final iOSVersion in [ - flutteriOSHighestBestEffort, - flutteriOSHighestSupported, - ]) { - for (final iOSTargetSdk in IOSSdk.values) { - group('$iOSTargetSdk $iOSVersion:', () { - runObjectsTests( - targetOS, - iOSSupportedArchitecturesFor(iOSTargetSdk), - iOSTargetVersion: iOSVersion, - iOSTargetSdk: iOSTargetSdk, - ); - }); - } + // These configurations are a selection of combinations of architectures + // and iOS versions. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + (iOSTargetSdk: IOSSdk.iPhoneOS, iOSVersion: flutteriOSHighestBestEffort), + ( + iOSTargetSdk: IOSSdk.iPhoneSimulator, + iOSVersion: flutteriOSHighestSupported, + ), + (iOSTargetSdk: IOSSdk.iPhoneOS, iOSVersion: flutteriOSHighestSupported), + ]; + + for (final (:iOSTargetSdk, :iOSVersion) in configurations) { + group('$iOSTargetSdk $iOSVersion:', () { + runObjectsTests( + targetOS, + iOSSupportedArchitecturesFor(iOSTargetSdk), + iOSTargetVersion: iOSVersion, + iOSTargetSdk: iOSTargetSdk, + ); + }); } } diff --git a/pkgs/native_toolchain_c/test/clinker/objects_helper.dart b/pkgs/native_toolchain_c/test/clinker/objects_helper.dart index d25eccb42b..076ac5be00 100644 --- a/pkgs/native_toolchain_c/test/clinker/objects_helper.dart +++ b/pkgs/native_toolchain_c/test/clinker/objects_helper.dart @@ -19,6 +19,7 @@ void runObjectsTests( int? macOSTargetVersion, // Must be specified iff targetOS is OS.macos. int? iOSTargetVersion, // Must be specified iff targetOS is OS.iOS. IOSSdk? iOSTargetSdk, // Must be specified iff targetOS is OS.iOS. + Timeout? timeout, }) { if (targetOS == OS.android) { ArgumentError.checkNotNull(androidTargetNdkApi, 'androidTargetNdkApi'); @@ -34,7 +35,7 @@ void runObjectsTests( const name = 'mylibname'; for (final architecture in architectures) { - test('link two objects for $architecture', () async { + test('link two objects for $architecture', timeout: timeout, () async { final tempUri = await tempDirForTest(); final tempUri2 = await tempDirForTest(); diff --git a/pkgs/native_toolchain_c/test/clinker/treeshake_cross_android_test.dart b/pkgs/native_toolchain_c/test/clinker/treeshake_cross_android_test.dart index ae9b030f6e..51cc6cb1ef 100644 --- a/pkgs/native_toolchain_c/test/clinker/treeshake_cross_android_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/treeshake_cross_android_test.dart @@ -11,18 +11,41 @@ import 'treeshake_helper.dart'; void main() { const targetOS = OS.android; - for (final apiLevel in [ - flutterAndroidNdkVersionLowestSupported, - flutterAndroidNdkVersionHighestSupported, - ]) { - for (final architecture in supportedArchitecturesFor(targetOS)) { - group('Android API$apiLevel ($architecture):', () { - runTreeshakeTests( - targetOS, - architecture, - androidTargetNdkApi: apiLevel, - ); - }); - } + // These configurations are a selection of combinations of architectures + // and API levels. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + architecture: Architecture.arm, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ( + architecture: Architecture.arm64, + apiLevel: flutterAndroidNdkVersionHighestSupported, + ), + ( + architecture: Architecture.ia32, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ( + architecture: Architecture.x64, + apiLevel: flutterAndroidNdkVersionHighestSupported, + ), + ( + architecture: Architecture.riscv64, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ( + architecture: Architecture.arm64, + apiLevel: flutterAndroidNdkVersionLowestSupported, + ), + ]; + + for (final (:architecture, :apiLevel) in configurations) { + group('Android API$apiLevel ($architecture):', () { + runTreeshakeTests(targetOS, architecture, androidTargetNdkApi: apiLevel); + }); } } diff --git a/pkgs/native_toolchain_c/test/clinker/treeshake_cross_ios_test.dart b/pkgs/native_toolchain_c/test/clinker/treeshake_cross_ios_test.dart index e3c1574bdd..6d0928020e 100644 --- a/pkgs/native_toolchain_c/test/clinker/treeshake_cross_ios_test.dart +++ b/pkgs/native_toolchain_c/test/clinker/treeshake_cross_ios_test.dart @@ -21,21 +21,42 @@ void main() { const targetOS = OS.iOS; - for (final iOSVersion in [ - flutteriOSHighestBestEffort, - flutteriOSHighestSupported, - ]) { - for (final iOSTargetSdk in IOSSdk.values) { - for (final architecture in iOSSupportedArchitecturesFor(iOSTargetSdk)) { - group('$iOSTargetSdk $iOSVersion ($architecture):', () { - runTreeshakeTests( - targetOS, - architecture, - iOSTargetVersion: iOSVersion, - iOSTargetSdk: iOSTargetSdk, - ); - }); - } - } + // These configurations are a selection of combinations of architectures + // and iOS versions. + // We don't test the full cartesian product to keep the CI time manageable. + // When adding a new configuration, consider if it tests a new combination + // that is not yet covered by the existing tests. + final configurations = [ + ( + architecture: Architecture.arm64, + iOSTargetSdk: IOSSdk.iPhoneOS, + iOSVersion: flutteriOSHighestBestEffort, + ), + ( + architecture: Architecture.arm64, + iOSTargetSdk: IOSSdk.iPhoneSimulator, + iOSVersion: flutteriOSHighestSupported, + ), + ( + architecture: Architecture.x64, + iOSTargetSdk: IOSSdk.iPhoneSimulator, + iOSVersion: flutteriOSHighestBestEffort, + ), + ( + architecture: Architecture.arm64, + iOSTargetSdk: IOSSdk.iPhoneOS, + iOSVersion: flutteriOSHighestSupported, + ), + ]; + + for (final (:architecture, :iOSTargetSdk, :iOSVersion) in configurations) { + group('$iOSTargetSdk $iOSVersion ($architecture):', () { + runTreeshakeTests( + targetOS, + architecture, + iOSTargetVersion: iOSVersion, + iOSTargetSdk: iOSTargetSdk, + ); + }); } } diff --git a/pkgs/native_toolchain_c/test/helpers.dart b/pkgs/native_toolchain_c/test/helpers.dart index 4485ef5049..8e1dfd4462 100644 --- a/pkgs/native_toolchain_c/test/helpers.dart +++ b/pkgs/native_toolchain_c/test/helpers.dart @@ -206,7 +206,7 @@ Future readelf(String filePath, String flags) async { } List nmParameterFor(OS targetOS) => switch (targetOS) { - OS.macOS || OS.iOS => const [], + .macOS || .iOS => const [], OS() => ['-D'], }; @@ -214,7 +214,7 @@ List nmParameterFor(OS targetOS) => switch (targetOS) { Future readSymbols(CodeAsset asset, OS targetOS) async { final assetUri = asset.file!; switch (targetOS) { - case OS.windows: + case .windows: final result = await _runDumpbin(['/EXPORTS'], asset.file!); if (result == null) { return null; @@ -373,28 +373,20 @@ Future expectMachineArchitecture( } List supportedArchitecturesFor(OS targetOS) => switch (targetOS) { - OS.macOS || OS.iOS => [Architecture.arm64, Architecture.x64], - OS.windows => [ + .macOS || .iOS => [.arm64, .x64], + .windows => [ // TODO(https://github.com/dart-lang/native/issues/170): Support arm64. // Architecture.arm64, - Architecture.ia32, - Architecture.x64, - ], - OS() => [ - Architecture.arm, - Architecture.arm64, - Architecture.ia32, - Architecture.x64, - Architecture.riscv64, + .ia32, + .x64, ], + OS() => [.arm, .arm64, .ia32, .x64, .riscv64], }; List iOSSupportedArchitecturesFor(IOSSdk iosSdk) => switch (iosSdk) { - IOSSdk.iPhoneOS => supportedArchitecturesFor( - OS.iOS, - )..remove(Architecture.x64), - IOSSdk.iPhoneSimulator => supportedArchitecturesFor(OS.iOS), + .iPhoneOS => supportedArchitecturesFor(OS.iOS)..remove(Architecture.x64), + .iPhoneSimulator => supportedArchitecturesFor(OS.iOS), IOSSdk() => throw UnimplementedError(), }; diff --git a/pkgs/objective_c/CHANGELOG.md b/pkgs/objective_c/CHANGELOG.md index 7ebb1a8362..48d7f17353 100644 --- a/pkgs/objective_c/CHANGELOG.md +++ b/pkgs/objective_c/CHANGELOG.md @@ -1,3 +1,25 @@ +## 9.4.0 +- Fix (https://github.com/dart-lang/native/issues/2877) such that all occurances of ObjCObject `isA` now accepts a nullable `ObjCObject?` and returns `false` when input is`null` + +## 9.3.0 +- `autoReleasePool` now returns the value produced by its callback. + +## 9.2.5 +- Fix a [bug](https://github.com/dart-lang/native/issues/3011) by adding + minimum OS version flags to the build script. + +## 9.2.4 + +- Fix a [bug](https://github.com/dart-lang/native/issues/2990) build hook path + issue that could pass percent-encoded cache paths to clang, leading to missing + source file errors. + +## 9.2.3 + +- Fix a [bug](https://github.com/dart-lang/native/issues/2973) where the + objective_c framework was rejected by the Apple app store due to code signing + issues. + ## 9.2.2 - Fix a [bug](https://github.com/dart-lang/http/issues/1861) where the build diff --git a/pkgs/objective_c/example/command_line/pubspec.yaml b/pkgs/objective_c/example/command_line/pubspec.yaml index ff6cf0f7ad..fae3f21a89 100644 --- a/pkgs/objective_c/example/command_line/pubspec.yaml +++ b/pkgs/objective_c/example/command_line/pubspec.yaml @@ -11,5 +11,5 @@ dependencies: path: ../.. dev_dependencies: - lints: ^5.0.0 + lints: ^6.0.0 test: ^1.27.0 diff --git a/pkgs/objective_c/hook/build.dart b/pkgs/objective_c/hook/build.dart index d6d93aeec9..94c2b63313 100644 --- a/pkgs/objective_c/hook/build.dart +++ b/pkgs/objective_c/hook/build.dart @@ -63,15 +63,24 @@ void main(List args) async { // aren't supported on iOS, like mach_vm_region. We don't need them on iOS // anyway since we only run memory tests on mac. if (os == OS.macOS) { - cFiles.addAll(testFiles.map((f) => input.packageRoot.resolve(f).path)); + cFiles.addAll( + testFiles.map((f) => input.packageRoot.resolve(f).toFilePath()), + ); } final sysroot = sdkPath(codeConfig); - final cFlags = ['-isysroot', sysroot, '-target', target]; + final minVersion = minOSVersion(codeConfig); + final cFlags = [ + '-isysroot', + sysroot, + '-target', + target, + minVersion, + ]; final mFlags = [...cFlags, ...objCFlags]; final linkFlags = cFlags; - final builder = await Builder.create(input, input.packageRoot.path); + final builder = await Builder.create(input, input.packageRoot.toFilePath()); final objectFiles = await Future.wait(>[ for (final src in cFiles) builder.buildObject(src, cFlags), @@ -115,7 +124,7 @@ class Builder { Future buildObject(String input, List flags) async { assert(input.startsWith(_rootDir)); final relativeInput = input.substring(_rootDir.length); - final output = '${_tempOutDir.resolve(relativeInput).path}.o'; + final output = '${_tempOutDir.resolve(relativeInput).toFilePath()}.o'; File(output).parent.createSync(recursive: true); await _compile([...flags, '-c', input, '-fpic', '-I', 'src'], output); return output; @@ -127,6 +136,7 @@ class Builder { List flags, ) => _compile([ '-shared', + '-Wl,-encryptable', '-undefined', 'dynamic_lookup', ...flags, @@ -171,6 +181,16 @@ String firstLineOfStdout(String cmd, List args) { .first; } +String minOSVersion(CodeConfig codeConfig) { + if (codeConfig.targetOS == OS.iOS) { + final targetVersion = codeConfig.iOS.targetVersion; + return '-mios-version-min=$targetVersion'; + } + assert(codeConfig.targetOS == OS.macOS); + final targetVersion = codeConfig.macOS.targetVersion; + return '-mmacos-version-min=$targetVersion'; +} + String toTargetTriple(CodeConfig codeConfig) { final architecture = codeConfig.targetArchitecture; if (codeConfig.targetOS == OS.iOS) { diff --git a/pkgs/objective_c/lib/src/autorelease.dart b/pkgs/objective_c/lib/src/autorelease.dart index 56f4d0b728..0182694b1f 100644 --- a/pkgs/objective_c/lib/src/autorelease.dart +++ b/pkgs/objective_c/lib/src/autorelease.dart @@ -35,10 +35,10 @@ import 'runtime_bindings_generated.dart'; /// here (the [Future] it returns will not be awaited). Objective-C autorelease /// pools form a strict stack, and allowing async execution gaps inside the pool /// scope could easily break this nesting, so async functions are not supported. -void autoReleasePool(void Function() function) { +T autoReleasePool(T Function() function) { final pool = autoreleasePoolPush(); try { - function(); + return function(); } finally { autoreleasePoolPop(pool); } diff --git a/pkgs/objective_c/lib/src/c_bindings_generated.dart b/pkgs/objective_c/lib/src/c_bindings_generated.dart index 1e4dabcc13..fcd21d8581 100644 --- a/pkgs/objective_c/lib/src/c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/c_bindings_generated.dart @@ -122,6 +122,38 @@ final class DOBJC_Context extends ffi.Struct { external ffi.Pointer> getCurrentThreadOwnsIsolate; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int version, + required ffi.Pointer Function()>> + newWaiter$1, + required ffi.Pointer< + ffi.NativeFunction)> + > + awaitWaiter$1, + required ffi.Pointer< + ffi.NativeFunction Function()> + > + currentIsolate, + required ffi.Pointer< + ffi.NativeFunction)> + > + enterIsolate, + required ffi.Pointer> exitIsolate, + required ffi.Pointer> + getMainPortId, + required ffi.Pointer> + getCurrentThreadOwnsIsolate, + }) => $allocator() + ..ref.version = version + ..ref.newWaiter$1 = newWaiter$1 + ..ref.awaitWaiter$1 = awaitWaiter$1 + ..ref.currentIsolate = currentIsolate + ..ref.enterIsolate = enterIsolate + ..ref.exitIsolate = exitIsolate + ..ref.getMainPortId = getMainPortId + ..ref.getCurrentThreadOwnsIsolate = getCurrentThreadOwnsIsolate; } typedef Dart_FinalizableHandle = ffi.Pointer; @@ -150,6 +182,28 @@ final class ObjCBlockDesc extends ffi.Struct { dispose_helper; external ffi.Pointer signature; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int reserved, + required int size, + required ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer dst, ffi.Pointer src) + > + > + copy_helper, + required ffi.Pointer< + ffi.NativeFunction src)> + > + dispose_helper, + required ffi.Pointer signature, + }) => $allocator() + ..ref.reserved = reserved + ..ref.size = size + ..ref.copy_helper = copy_helper + ..ref.dispose_helper = dispose_helper + ..ref.signature = signature; } final class ObjCBlockImpl extends ffi.Struct { @@ -169,6 +223,24 @@ final class ObjCBlockImpl extends ffi.Struct { @ffi.Int64() external int dispose_port; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer isa, + required int flags, + required int reserved, + required ffi.Pointer invoke, + required ffi.Pointer descriptor, + required ffi.Pointer target, + required int dispose_port, + }) => $allocator() + ..ref.isa = isa + ..ref.flags = flags + ..ref.reserved = reserved + ..ref.invoke = invoke + ..ref.descriptor = descriptor + ..ref.target = target + ..ref.dispose_port = dispose_port; } final class ObjCObjectImpl extends ffi.Opaque {} diff --git a/pkgs/objective_c/lib/src/ns_array.dart b/pkgs/objective_c/lib/src/ns_array.dart index a37161cd5d..f009147ab1 100644 --- a/pkgs/objective_c/lib/src/ns_array.dart +++ b/pkgs/objective_c/lib/src/ns_array.dart @@ -16,9 +16,6 @@ class _NSArrayAdapter with ListBase { @override int get length => _array.count; - @override - ObjCObject elementAt(int index) => _array.objectAtIndex(index); - @override Iterator get iterator => _NSArrayIterator(this); @@ -61,9 +58,6 @@ class _NSMutableArrayAdapter with ListBase { } } - @override - ObjCObject elementAt(int index) => _array.objectAtIndex(index); - @override Iterator get iterator => _NSArrayIterator(this); diff --git a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart index 37d56e5a33..42598bb0a2 100644 --- a/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/objective_c_bindings_generated.dart @@ -622,6 +622,14 @@ final class AEDesc extends ffi.Struct { external int descriptorType; external ffi.Pointer> dataHandle; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int descriptorType, + required ffi.Pointer> dataHandle, + }) => $allocator() + ..ref.descriptorType = descriptorType + ..ref.dataHandle = dataHandle; } final class CFRunLoop extends ffi.Opaque {} @@ -636,6 +644,14 @@ final class CGPoint extends ffi.Struct { @ffi.Double() external double y; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required double x, + required double y, + }) => $allocator() + ..ref.x = x + ..ref.y = y; } final class CGRect extends ffi.Struct { @@ -650,6 +666,14 @@ final class CGSize extends ffi.Struct { @ffi.Double() external double height; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required double width, + required double height, + }) => $allocator() + ..ref.width = width + ..ref.height = height; } /// Represents a single KVO observation. Each observation creates a new @@ -671,11 +695,13 @@ extension type DOBJCObservation._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [DOBJCObservation]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_DOBJCObservation, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_DOBJCObservation, + ); /// alloc static DOBJCObservation alloc() { @@ -772,11 +798,13 @@ extension type DartInputStreamAdapter._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [DartInputStreamAdapter]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_DOBJCDartInputStreamAdapter, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_DOBJCDartInputStreamAdapter, + ); /// alloc static DartInputStreamAdapter alloc() { @@ -1011,11 +1039,13 @@ extension type DartInputStreamAdapterWeakHolder._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [DartInputStreamAdapterWeakHolder]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_DOBJCDartInputStreamAdapterWeakHolder, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_DOBJCDartInputStreamAdapterWeakHolder, + ); /// alloc static DartInputStreamAdapterWeakHolder alloc() { @@ -1128,11 +1158,13 @@ extension type DartProtocol._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [DartProtocol]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_DOBJCDartProtocol, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_DOBJCDartProtocol, + ); /// alloc static DartProtocol alloc() { @@ -1226,11 +1258,13 @@ extension type DartProtocolBuilder._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [DartProtocolBuilder]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_DOBJCDartProtocolBuilder, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_DOBJCDartProtocolBuilder, + ); /// alloc static DartProtocolBuilder alloc() { @@ -1381,11 +1415,13 @@ extension type NSArray._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSArray]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSArray, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSArray, + ); /// alloc static NSArray alloc() { @@ -1613,11 +1649,13 @@ extension type NSAttributedString._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSAttributedString]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSAttributedString, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSAttributedString, + ); /// alloc static NSAttributedString alloc() { @@ -2096,11 +2134,13 @@ extension type NSAttributedStringMarkdownParsingOptions._( } /// Returns whether [obj] is an instance of [NSAttributedStringMarkdownParsingOptions]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSAttributedStringMarkdownParsingOptions, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSAttributedStringMarkdownParsingOptions, + ); /// alloc static NSAttributedStringMarkdownParsingOptions alloc() { @@ -2337,11 +2377,13 @@ extension type NSBundle._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSBundle]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSBundle, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSBundle, + ); /// URLForResource:withExtension:subdirectory:inBundleWithURL: static NSURL? URLForResource$3( @@ -3220,11 +3262,13 @@ extension type NSCharacterSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSCharacterSet]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSCharacterSet, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSCharacterSet, + ); /// alloc static NSCharacterSet alloc() { @@ -3548,11 +3592,13 @@ extension type NSCoder._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSCoder]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSCoder, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSCoder, + ); /// alloc static NSCoder alloc() { @@ -4037,11 +4083,13 @@ extension type NSData._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSData]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSData, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSData, + ); /// alloc static NSData alloc() { @@ -4548,11 +4596,13 @@ extension type NSDate._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSDate]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSDate, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSDate, + ); /// alloc static NSDate alloc() { @@ -4793,11 +4843,13 @@ extension type NSDictionary._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSDictionary]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSDictionary, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSDictionary, + ); /// alloc static NSDictionary alloc() { @@ -5050,6 +5102,18 @@ final class NSEdgeInsets extends ffi.Struct { @ffi.Double() external double right; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required double top, + required double left, + required double bottom, + required double right, + }) => $allocator() + ..ref.top = top + ..ref.left = left + ..ref.bottom = bottom + ..ref.right = right; } sealed class NSEnumerationOptions { @@ -5075,11 +5139,13 @@ extension type NSEnumerator._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSEnumerator]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSEnumerator, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSEnumerator, + ); /// alloc static NSEnumerator alloc() { @@ -5164,11 +5230,13 @@ extension type NSError._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSError]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSError, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSError, + ); /// alloc static NSError alloc() { @@ -8396,11 +8464,13 @@ extension type NSIndexSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSIndexSet]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSIndexSet, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSIndexSet, + ); /// alloc static NSIndexSet alloc() { @@ -8911,11 +8981,13 @@ extension type NSInputStream._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSInputStream]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSInputStream, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSInputStream, + ); /// alloc static NSInputStream alloc() { @@ -9085,11 +9157,13 @@ extension type NSInvocation._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSInvocation]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSInvocation, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSInvocation, + ); /// alloc static NSInvocation alloc() { @@ -9274,11 +9348,13 @@ extension type NSItemProvider._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSItemProvider]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSItemProvider, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSItemProvider, + ); /// alloc static NSItemProvider alloc() { @@ -10128,11 +10204,13 @@ extension type NSLocale._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSLocale]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSLocale, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSLocale, + ); /// alloc static NSLocale alloc() { @@ -10292,11 +10370,13 @@ extension type NSMethodSignature._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMethodSignature]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMethodSignature, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMethodSignature, + ); /// alloc static NSMethodSignature alloc() { @@ -10423,11 +10503,13 @@ extension type NSMutableArray._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableArray]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableArray, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableArray, + ); /// alloc static NSMutableArray alloc() { @@ -10771,11 +10853,13 @@ extension type NSMutableData._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableData]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableData, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableData, + ); /// alloc static NSMutableData alloc() { @@ -11291,11 +11375,13 @@ extension type NSMutableDictionary._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableDictionary]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableDictionary, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableDictionary, + ); /// alloc static NSMutableDictionary alloc() { @@ -11555,11 +11641,13 @@ extension type NSMutableIndexSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableIndexSet]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableIndexSet, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableIndexSet, + ); /// alloc static NSMutableIndexSet alloc() { @@ -11764,11 +11852,13 @@ extension type NSMutableOrderedSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableOrderedSet]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableOrderedSet, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableOrderedSet, + ); /// alloc static NSMutableOrderedSet alloc() { @@ -12283,11 +12373,13 @@ extension type NSMutableSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableSet]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableSet, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableSet, + ); /// alloc static NSMutableSet alloc() { @@ -12519,11 +12611,13 @@ extension type NSMutableString._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSMutableString]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSMutableString, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSMutableString, + ); /// alloc static NSMutableString alloc() { @@ -13178,11 +13272,13 @@ extension type NSNotification._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSNotification]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSNotification, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSNotification, + ); /// alloc static NSNotification alloc() { @@ -13333,11 +13429,13 @@ extension type NSNull._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSNull]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSNull, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSNull, + ); /// alloc static NSNull alloc() { @@ -13431,11 +13529,13 @@ extension type NSNumber._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSNumber]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSNumber, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSNumber, + ); /// alloc static NSNumber alloc() { @@ -13996,11 +14096,13 @@ extension type NSObject._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSObject]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSObject, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSObject, + ); /// alloc static NSObject alloc() { @@ -15700,11 +15802,13 @@ extension type NSOrderedCollectionChange._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSOrderedCollectionChange]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSOrderedCollectionChange, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSOrderedCollectionChange, + ); /// alloc static NSOrderedCollectionChange alloc() { @@ -15965,11 +16069,13 @@ extension type NSOrderedCollectionDifference._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSOrderedCollectionDifference]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSOrderedCollectionDifference, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSOrderedCollectionDifference, + ); /// alloc static NSOrderedCollectionDifference alloc() { @@ -16260,11 +16366,13 @@ extension type NSOrderedSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSOrderedSet]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSOrderedSet, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSOrderedSet, + ); /// alloc static NSOrderedSet alloc() { @@ -16759,11 +16867,13 @@ extension type NSOutputStream._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSOutputStream]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSOutputStream, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSOutputStream, + ); /// alloc static NSOutputStream alloc() { @@ -16952,11 +17062,13 @@ extension type NSPort._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSPort]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSPort, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSPort, + ); /// alloc static NSPort alloc() { @@ -17329,11 +17441,13 @@ extension type NSPortMessage._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSPortMessage]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSPortMessage, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSPortMessage, + ); /// alloc static NSPortMessage alloc() { @@ -17454,11 +17568,13 @@ extension type NSProgress._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSProgress]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSProgress, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSProgress, + ); /// addSubscriberForFileURL:withPublishingHandler: /// @@ -18305,6 +18421,14 @@ final class NSRange extends ffi.Struct { @ffi.UnsignedLong() external int length; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required int location, + required int length, + }) => $allocator() + ..ref.location = location + ..ref.length = length; } /// NSRunLoop @@ -18325,11 +18449,13 @@ extension type NSRunLoop._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSRunLoop]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSRunLoop, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSRunLoop, + ); /// alloc static NSRunLoop alloc() { @@ -18721,8 +18847,13 @@ extension type NSSet._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSSet]. - static bool isA(objc.ObjCObject obj) => - _objc_msgSend_19nvye5(obj.ref.pointer, _sel_isKindOfClass_, _class_NSSet); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSSet, + ); /// alloc static NSSet alloc() { @@ -18967,11 +19098,13 @@ extension type NSStream._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSStream]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSStream, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSStream, + ); /// alloc static NSStream alloc() { @@ -19366,11 +19499,13 @@ extension type NSString._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSString]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSString, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSString, + ); /// alloc static NSString alloc() { @@ -21231,11 +21366,13 @@ extension type NSTimer._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSTimer]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSTimer, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSTimer, + ); /// alloc static NSTimer alloc() { @@ -21523,8 +21660,13 @@ extension type NSURL._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSURL]. - static bool isA(objc.ObjCObject obj) => - _objc_msgSend_19nvye5(obj.ref.pointer, _sel_isKindOfClass_, _class_NSURL); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURL, + ); /// URLByResolvingAliasFileAtURL:options:error: static NSURL? URLByResolvingAliasFileAtURL( @@ -22567,11 +22709,13 @@ extension type NSURLHandle._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSURLHandle]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSURLHandle, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSURLHandle, + ); /// alloc static NSURLHandle alloc() { @@ -22651,11 +22795,13 @@ extension type NSValue._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [NSValue]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_NSValue, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_NSValue, + ); /// alloc static NSValue alloc() { @@ -29492,387 +29638,6 @@ extension ObjCBlock_ffiVoid_NSURL_bool_NSError$CallExtension ); } -/// Construction methods for `objc.ObjCBlock, ffi.UnsignedLong, ffi.Pointer)>`. -abstract final class ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool { - /// Returns a block that wraps the given raw block pointer. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - fromPointer( - ffi.Pointer pointer, { - bool retain = false, - bool release = false, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >(pointer, retain: retain, release: release); - - /// Creates a block from a C function pointer. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - fromFunctionPointer( - ffi.Pointer< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.UnsignedLong arg1, - ffi.Pointer arg2, - ) - > - > - ptr, - ) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >( - objc.newPointerBlock(_fnPtrCallable, ptr.cast()), - retain: false, - release: true, - ); - - /// Creates a block from a Dart function. - /// - /// This block must be invoked by native code running on the same thread as - /// the isolate that registered it. Invoking the block on the wrong thread - /// will result in a crash. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - fromFunction( - void Function(objc.ObjCObject, int, ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) => - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >( - objc.newClosureBlock( - _closureCallable, - ( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) => fn( - objc.ObjCObject(arg0, retain: true, release: true), - arg1, - arg2, - ), - keepIsolateAlive, - ), - retain: false, - release: true, - ); - - /// Creates a listener block from a Dart function. - /// - /// This is based on FFI's NativeCallable.listener, and has the same - /// capabilities and limitations. This block can be invoked from any thread, - /// but only supports void functions, and is not run synchronously. See - /// NativeCallable.listener for more details. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - listener( - void Function(objc.ObjCObject, int, ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _listenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) => fn(objc.ObjCObject(arg0, retain: false, release: true), arg1, arg2), - keepIsolateAlive, - ); - final wrapper = _1wx624s_wrapListenerBlock_1p9ui4q(raw); - objc.objectRelease(raw.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >(wrapper, retain: false, release: true); - } - - /// Creates a blocking block from a Dart function. - /// - /// This callback can be invoked from any native thread, and will block the - /// caller until the callback is handled by the Dart isolate that created - /// the block. Async functions are not supported. - /// - /// If `keepIsolateAlive` is true, this block will keep this isolate alive - /// until it is garbage collected by both Dart and ObjC. If the owner isolate - /// has shut down, and the block is invoked by native code, it may block - /// indefinitely, or have other undefined behavior. - static objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - blocking( - void Function(objc.ObjCObject, int, ffi.Pointer) fn, { - bool keepIsolateAlive = true, - }) { - final raw = objc.newClosureBlock( - _blockingCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) => fn(objc.ObjCObject(arg0, retain: false, release: true), arg1, arg2), - keepIsolateAlive, - ); - final rawListener = objc.newClosureBlock( - _blockingListenerCallable.nativeFunction.cast(), - ( - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) => fn(objc.ObjCObject(arg0, retain: false, release: true), arg1, arg2), - keepIsolateAlive, - ); - final wrapper = _1wx624s_wrapBlockingBlock_1p9ui4q( - raw, - rawListener, - objc.objCContext, - ); - objc.objectRelease(raw.cast()); - objc.objectRelease(rawListener.cast()); - return objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >(wrapper, retain: false, release: true); - } - - static void _listenerTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2); - objc.objectRelease(block.cast()); - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - _listenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >.listener(_listenerTrampoline) - ..keepIsolateAlive = false; - static void _blockingTrampoline( - ffi.Pointer block, - ffi.Pointer waiter, - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) { - try { - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2); - } catch (e) { - } finally { - objc.signalWaiter(waiter); - objc.objectRelease(block.cast()); - } - } - - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - _blockingCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >.isolateLocal(_blockingTrampoline) - ..keepIsolateAlive = false; - static ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > - _blockingListenerCallable = - ffi.NativeCallable< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >.listener(_blockingTrampoline) - ..keepIsolateAlive = false; - static void _fnPtrTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) => block.ref.target - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer arg0, - ffi.UnsignedLong arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - int, - ffi.Pointer, - ) - >()(arg0, arg1, arg2); - static ffi.Pointer _fnPtrCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >(_fnPtrTrampoline) - .cast(); - static void _closureTrampoline( - ffi.Pointer block, - ffi.Pointer arg0, - int arg1, - ffi.Pointer arg2, - ) => - (objc.getBlockClosure(block) - as void Function( - ffi.Pointer, - int, - ffi.Pointer, - ))(arg0, arg1, arg2); - static ffi.Pointer _closureCallable = - ffi.Pointer.fromFunction< - ffi.Void Function( - ffi.Pointer, - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - >(_closureTrampoline) - .cast(); -} - -/// Call operator for `objc.ObjCBlock, ffi.UnsignedLong, ffi.Pointer)>`. -extension ObjCBlock_ffiVoid_ObjectType_NSUInteger_bool$CallExtension - on - objc.ObjCBlock< - ffi.Void Function( - ffi.Pointer, - ffi.UnsignedLong, - ffi.Pointer, - ) - > { - void call(objc.ObjCObject arg0, int arg1, ffi.Pointer arg2) => ref - .pointer - .ref - .invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.UnsignedLong arg1, - ffi.Pointer arg2, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - int, - ffi.Pointer, - ) - >()(ref.pointer, arg0.ref.pointer, arg1, arg2); -} - /// Construction methods for `objc.ObjCBlock, ffi.Pointer)>`. abstract final class ObjCBlock_ffiVoid_ObjectType_bool { /// Returns a block that wraps the given raw block pointer. @@ -32790,11 +32555,366 @@ extension ObjCBlock_ffiVoid_idNSItemProviderReading_NSError$CallExtension ); } -/// Construction methods for `objc.ObjCBlock?, NSError?)>`. -abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { +/// Construction methods for `objc.ObjCBlock?, NSError?)>`. +abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + >(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + > + fromFunction( + void Function(NSItemProviderWriting?, NSError?) fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.fromPointer( + arg0, + retain: true, + release: true, + ), + arg1.address == 0 + ? null + : NSError.fromPointer(arg1, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + > + listener( + void Function(NSItemProviderWriting?, NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.fromPointer( + arg0, + retain: false, + release: true, + ), + arg1.address == 0 + ? null + : NSError.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _1wx624s_wrapListenerBlock_pfv6jd(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + >(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + > + blocking( + void Function(NSItemProviderWriting?, NSError?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.fromPointer( + arg0, + retain: false, + release: true, + ), + arg1.address == 0 + ? null + : NSError.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => fn( + arg0.address == 0 + ? null + : NSItemProviderWriting.fromPointer( + arg0, + retain: false, + release: true, + ), + arg1.address == 0 + ? null + : NSError.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _1wx624s_wrapBlockingBlock_pfv6jd( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + >(wrapper, retain: false, release: true); + } + + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + objc.objectRelease(block.cast()); + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) { + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} + +/// Call operator for `objc.ObjCBlock?, NSError?)>`. +extension ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError$CallExtension + on + objc.ObjCBlock< + ffi.Void Function(ffi.Pointer?, NSError?) + > { + void call(NSItemProviderWriting? arg0, NSError? arg1) => + ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()( + ref.pointer, + arg0?.ref.pointer ?? ffi.nullptr, + arg1?.ref.pointer ?? ffi.nullptr, + ); +} + +/// Construction methods for `objc.ObjCBlock?, NSError)>`. +abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { /// Returns a block that wraps the given raw block pointer. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) > fromPointer( ffi.Pointer pointer, { @@ -32802,7 +32922,7 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { bool release = false, }) => objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) >(pointer, retain: retain, release: release); /// Creates a block from a C function pointer. @@ -32811,7 +32931,7 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) > fromFunctionPointer( ffi.Pointer< @@ -32825,7 +32945,7 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { ptr, ) => objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) >( objc.newPointerBlock(_fnPtrCallable, ptr.cast()), retain: false, @@ -32841,14 +32961,14 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { /// If `keepIsolateAlive` is true, this block will keep this isolate alive /// until it is garbage collected by both Dart and ObjC. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) > fromFunction( - void Function(NSItemProviderWriting?, NSError?) fn, { + void Function(NSSecureCoding?, NSError) fn, { bool keepIsolateAlive = true, }) => objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) >( objc.newClosureBlock( _closureCallable, @@ -32858,14 +32978,8 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { ) => fn( arg0.address == 0 ? null - : NSItemProviderWriting.fromPointer( - arg0, - retain: true, - release: true, - ), - arg1.address == 0 - ? null - : NSError.fromPointer(arg1, retain: true, release: true), + : NSSecureCoding.fromPointer(arg0, retain: true, release: true), + NSError.fromPointer(arg1, retain: true, release: true), ), keepIsolateAlive, ), @@ -32883,10 +32997,10 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { /// If `keepIsolateAlive` is true, this block will keep this isolate alive /// until it is garbage collected by both Dart and ObjC. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) > listener( - void Function(NSItemProviderWriting?, NSError?) fn, { + void Function(NSSecureCoding?, NSError) fn, { bool keepIsolateAlive = true, }) { final raw = objc.newClosureBlock( @@ -32897,21 +33011,15 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { ) => fn( arg0.address == 0 ? null - : NSItemProviderWriting.fromPointer( - arg0, - retain: false, - release: true, - ), - arg1.address == 0 - ? null - : NSError.fromPointer(arg1, retain: false, release: true), + : NSSecureCoding.fromPointer(arg0, retain: false, release: true), + NSError.fromPointer(arg1, retain: false, release: true), ), keepIsolateAlive, ); final wrapper = _1wx624s_wrapListenerBlock_pfv6jd(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) >(wrapper, retain: false, release: true); } @@ -32926,10 +33034,10 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { /// has shut down, and the block is invoked by native code, it may block /// indefinitely, or have other undefined behavior. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) > blocking( - void Function(NSItemProviderWriting?, NSError?) fn, { + void Function(NSSecureCoding?, NSError) fn, { bool keepIsolateAlive = true, }) { final raw = objc.newClosureBlock( @@ -32940,14 +33048,8 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { ) => fn( arg0.address == 0 ? null - : NSItemProviderWriting.fromPointer( - arg0, - retain: false, - release: true, - ), - arg1.address == 0 - ? null - : NSError.fromPointer(arg1, retain: false, release: true), + : NSSecureCoding.fromPointer(arg0, retain: false, release: true), + NSError.fromPointer(arg1, retain: false, release: true), ), keepIsolateAlive, ); @@ -32959,14 +33061,8 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { ) => fn( arg0.address == 0 ? null - : NSItemProviderWriting.fromPointer( - arg0, - retain: false, - release: true, - ), - arg1.address == 0 - ? null - : NSError.fromPointer(arg1, retain: false, release: true), + : NSSecureCoding.fromPointer(arg0, retain: false, release: true), + NSError.fromPointer(arg1, retain: false, release: true), ), keepIsolateAlive, ); @@ -32978,7 +33074,7 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { objc.objectRelease(raw.cast()); objc.objectRelease(rawListener.cast()); return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) >(wrapper, retain: false, release: true); } @@ -33115,41 +33211,40 @@ abstract final class ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError { .cast(); } -/// Call operator for `objc.ObjCBlock?, NSError?)>`. -extension ObjCBlock_ffiVoid_idNSItemProviderWriting_NSError$CallExtension +/// Call operator for `objc.ObjCBlock?, NSError)>`. +extension ObjCBlock_ffiVoid_idNSSecureCoding_NSError$CallExtension on objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError?) + ffi.Void Function(ffi.Pointer?, NSError) > { - void call(NSItemProviderWriting? arg0, NSError? arg1) => - ref.pointer.ref.invoke - .cast< - ffi.NativeFunction< - ffi.Void Function( - ffi.Pointer block, - ffi.Pointer arg0, - ffi.Pointer arg1, - ) - > - >() - .asFunction< - void Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >()( - ref.pointer, - arg0?.ref.pointer ?? ffi.nullptr, - arg1?.ref.pointer ?? ffi.nullptr, - ); + void call(NSSecureCoding? arg0, NSError arg1) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1.ref.pointer); } -/// Construction methods for `objc.ObjCBlock?, NSError)>`. -abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { +/// Construction methods for `objc.ObjCBlock, ffi.UnsignedLong, ffi.Pointer)>`. +abstract final class ObjCBlock_ffiVoid_objcObjCObjectImpl_ffiUnsignedLong_bool { /// Returns a block that wraps the given raw block pointer. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) > fromPointer( ffi.Pointer pointer, { @@ -33157,7 +33252,11 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { bool release = false, }) => objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) >(pointer, retain: retain, release: release); /// Creates a block from a C function pointer. @@ -33166,21 +33265,30 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { /// the isolate that registered it. Invoking the block on the wrong thread /// will result in a crash. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) > fromFunctionPointer( ffi.Pointer< ffi.NativeFunction< ffi.Void Function( ffi.Pointer arg0, - ffi.Pointer arg1, + ffi.UnsignedLong arg1, + ffi.Pointer arg2, ) > > ptr, ) => objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) >( objc.newPointerBlock(_fnPtrCallable, ptr.cast()), retain: false, @@ -33196,25 +33304,33 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { /// If `keepIsolateAlive` is true, this block will keep this isolate alive /// until it is garbage collected by both Dart and ObjC. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) > fromFunction( - void Function(NSSecureCoding?, NSError) fn, { + void Function(objc.ObjCObject, int, ffi.Pointer) fn, { bool keepIsolateAlive = true, }) => objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) >( objc.newClosureBlock( _closureCallable, ( ffi.Pointer arg0, - ffi.Pointer arg1, + int arg1, + ffi.Pointer arg2, ) => fn( - arg0.address == 0 - ? null - : NSSecureCoding.fromPointer(arg0, retain: true, release: true), - NSError.fromPointer(arg1, retain: true, release: true), + objc.ObjCObject(arg0, retain: true, release: true), + arg1, + arg2, ), keepIsolateAlive, ), @@ -33232,29 +33348,33 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { /// If `keepIsolateAlive` is true, this block will keep this isolate alive /// until it is garbage collected by both Dart and ObjC. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) > listener( - void Function(NSSecureCoding?, NSError) fn, { + void Function(objc.ObjCObject, int, ffi.Pointer) fn, { bool keepIsolateAlive = true, }) { final raw = objc.newClosureBlock( _listenerCallable.nativeFunction.cast(), ( ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSSecureCoding.fromPointer(arg0, retain: false, release: true), - NSError.fromPointer(arg1, retain: false, release: true), - ), + int arg1, + ffi.Pointer arg2, + ) => fn(objc.ObjCObject(arg0, retain: false, release: true), arg1, arg2), keepIsolateAlive, ); - final wrapper = _1wx624s_wrapListenerBlock_pfv6jd(raw); + final wrapper = _1wx624s_wrapListenerBlock_1p9ui4q(raw); objc.objectRelease(raw.cast()); return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) >(wrapper, retain: false, release: true); } @@ -33269,39 +33389,35 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { /// has shut down, and the block is invoked by native code, it may block /// indefinitely, or have other undefined behavior. static objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) > blocking( - void Function(NSSecureCoding?, NSError) fn, { + void Function(objc.ObjCObject, int, ffi.Pointer) fn, { bool keepIsolateAlive = true, }) { final raw = objc.newClosureBlock( _blockingCallable.nativeFunction.cast(), ( ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSSecureCoding.fromPointer(arg0, retain: false, release: true), - NSError.fromPointer(arg1, retain: false, release: true), - ), + int arg1, + ffi.Pointer arg2, + ) => fn(objc.ObjCObject(arg0, retain: false, release: true), arg1, arg2), keepIsolateAlive, ); final rawListener = objc.newClosureBlock( _blockingListenerCallable.nativeFunction.cast(), ( ffi.Pointer arg0, - ffi.Pointer arg1, - ) => fn( - arg0.address == 0 - ? null - : NSSecureCoding.fromPointer(arg0, retain: false, release: true), - NSError.fromPointer(arg1, retain: false, release: true), - ), + int arg1, + ffi.Pointer arg2, + ) => fn(objc.ObjCObject(arg0, retain: false, release: true), arg1, arg2), keepIsolateAlive, ); - final wrapper = _1wx624s_wrapBlockingBlock_pfv6jd( + final wrapper = _1wx624s_wrapBlockingBlock_1p9ui4q( raw, rawListener, objc.objCContext, @@ -33309,20 +33425,26 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { objc.objectRelease(raw.cast()); objc.objectRelease(rawListener.cast()); return objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) >(wrapper, retain: false, release: true); } static void _listenerTrampoline( ffi.Pointer block, ffi.Pointer arg0, - ffi.Pointer arg1, + int arg1, + ffi.Pointer arg2, ) { (objc.getBlockClosure(block) as void Function( ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); + int, + ffi.Pointer, + ))(arg0, arg1, arg2); objc.objectRelease(block.cast()); } @@ -33330,7 +33452,8 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) > _listenerCallable = @@ -33338,7 +33461,8 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) >.listener(_listenerTrampoline) ..keepIsolateAlive = false; @@ -33346,14 +33470,16 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Pointer block, ffi.Pointer waiter, ffi.Pointer arg0, - ffi.Pointer arg1, + int arg1, + ffi.Pointer arg2, ) { try { (objc.getBlockClosure(block) as void Function( ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); + int, + ffi.Pointer, + ))(arg0, arg1, arg2); } catch (e) { } finally { objc.signalWaiter(waiter); @@ -33366,7 +33492,8 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) > _blockingCallable = @@ -33375,7 +33502,8 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) >.isolateLocal(_blockingTrampoline) ..keepIsolateAlive = false; @@ -33384,7 +33512,8 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) > _blockingListenerCallable = @@ -33393,72 +33522,88 @@ abstract final class ObjCBlock_ffiVoid_idNSSecureCoding_NSError { ffi.Pointer, ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) >.listener(_blockingTrampoline) ..keepIsolateAlive = false; static void _fnPtrTrampoline( ffi.Pointer block, ffi.Pointer arg0, - ffi.Pointer arg1, + int arg1, + ffi.Pointer arg2, ) => block.ref.target .cast< ffi.NativeFunction< ffi.Void Function( ffi.Pointer arg0, - ffi.Pointer arg1, + ffi.UnsignedLong arg1, + ffi.Pointer arg2, ) > >() .asFunction< void Function( ffi.Pointer, - ffi.Pointer, + int, + ffi.Pointer, ) - >()(arg0, arg1); + >()(arg0, arg1, arg2); static ffi.Pointer _fnPtrCallable = ffi.Pointer.fromFunction< ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) >(_fnPtrTrampoline) .cast(); static void _closureTrampoline( ffi.Pointer block, ffi.Pointer arg0, - ffi.Pointer arg1, + int arg1, + ffi.Pointer arg2, ) => (objc.getBlockClosure(block) as void Function( ffi.Pointer, - ffi.Pointer, - ))(arg0, arg1); + int, + ffi.Pointer, + ))(arg0, arg1, arg2); static ffi.Pointer _closureCallable = ffi.Pointer.fromFunction< ffi.Void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, ) >(_closureTrampoline) .cast(); } -/// Call operator for `objc.ObjCBlock?, NSError)>`. -extension ObjCBlock_ffiVoid_idNSSecureCoding_NSError$CallExtension +/// Call operator for `objc.ObjCBlock, ffi.UnsignedLong, ffi.Pointer)>`. +extension ObjCBlock_ffiVoid_objcObjCObjectImpl_ffiUnsignedLong_bool$CallExtension on objc.ObjCBlock< - ffi.Void Function(ffi.Pointer?, NSError) + ffi.Void Function( + ffi.Pointer, + ffi.UnsignedLong, + ffi.Pointer, + ) > { - void call(NSSecureCoding? arg0, NSError arg1) => ref.pointer.ref.invoke + void call(objc.ObjCObject arg0, int arg1, ffi.Pointer arg2) => ref + .pointer + .ref + .invoke .cast< ffi.NativeFunction< ffi.Void Function( ffi.Pointer block, ffi.Pointer arg0, - ffi.Pointer arg1, + ffi.UnsignedLong arg1, + ffi.Pointer arg2, ) > >() @@ -33466,9 +33611,10 @@ extension ObjCBlock_ffiVoid_idNSSecureCoding_NSError$CallExtension void Function( ffi.Pointer, ffi.Pointer, - ffi.Pointer, + int, + ffi.Pointer, ) - >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr, arg1.ref.pointer); + >()(ref.pointer, arg0.ref.pointer, arg1, arg2); } /// Construction methods for `objc.ObjCBlock, ffi.UnsignedLong)>`. @@ -35330,11 +35476,13 @@ extension type Protocol._(objc.ObjCObject object$) implements objc.ObjCObject { } /// Returns whether [obj] is an instance of [Protocol]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_Protocol, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_Protocol, + ); } extension Protocol$Methods on Protocol {} diff --git a/pkgs/objective_c/lib/src/runtime_bindings_generated.dart b/pkgs/objective_c/lib/src/runtime_bindings_generated.dart index 67cdf86ebe..0cb438ddb7 100644 --- a/pkgs/objective_c/lib/src/runtime_bindings_generated.dart +++ b/pkgs/objective_c/lib/src/runtime_bindings_generated.dart @@ -176,6 +176,14 @@ final class ObjCMethodDesc extends ffi.Struct { external ffi.Pointer name; external ffi.Pointer types; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer name, + required ffi.Pointer types, + }) => $allocator() + ..ref.name = name + ..ref.types = types; } final class ObjCObjectImpl extends ffi.Opaque {} diff --git a/pkgs/objective_c/pubspec.yaml b/pkgs/objective_c/pubspec.yaml index ff3da09961..b2c36821c3 100644 --- a/pkgs/objective_c/pubspec.yaml +++ b/pkgs/objective_c/pubspec.yaml @@ -4,7 +4,7 @@ name: objective_c description: 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.' -version: 9.2.2 +version: 9.4.0-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/objective_c issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aobjective_c @@ -18,18 +18,18 @@ environment: sdk: '>=3.10.0 <4.0.0' dependencies: - code_assets: ^0.19.0 + code_assets: ^1.0.0 collection: ^1.19.1 ffi: ^2.1.0 - hooks: ^0.20.5 + hooks: ^1.0.0 logging: ^1.3.0 - native_toolchain_c: ^0.17.2 + native_toolchain_c: ^0.17.4 pub_semver: ^2.1.4 dev_dependencies: args: ^2.6.0 dart_flutter_team_lints: ^3.5.2 - ffigen: ^20.1.0 + ffigen: ^20.1.1 native_test_helpers: path: ../native_test_helpers/ path: ^1.9.0 diff --git a/pkgs/objective_c/src/objective_c_bindings_generated.m b/pkgs/objective_c/src/objective_c_bindings_generated.m index 79a58835c7..c3c69aea45 100644 --- a/pkgs/objective_c/src/objective_c_bindings_generated.m +++ b/pkgs/objective_c/src/objective_c_bindings_generated.m @@ -357,42 +357,19 @@ _ListenerTrampoline_9 _1wx624s_wrapBlockingBlock_rnu2c5( }); } -typedef void (^_ListenerTrampoline_10)(id arg0, unsigned long arg1, BOOL * arg2); +typedef void (^_ListenerTrampoline_10)(void * arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_10 _1wx624s_wrapListenerBlock_1p9ui4q(_ListenerTrampoline_10 block) NS_RETURNS_RETAINED { - return ^void(id arg0, unsigned long arg1, BOOL * arg2) { - objc_retainBlock(block); - block((__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); - }; -} - -typedef void (^_BlockingTrampoline_10)(void * waiter, id arg0, unsigned long arg1, BOOL * arg2); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_10 _1wx624s_wrapBlockingBlock_1p9ui4q( - _BlockingTrampoline_10 block, _BlockingTrampoline_10 listenerBlock, - DOBJC_Context* ctx) NS_RETURNS_RETAINED { - BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, unsigned long arg1, BOOL * arg2), { - objc_retainBlock(block); - block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); - }, { - objc_retainBlock(listenerBlock); - listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); - }); -} - -typedef void (^_ListenerTrampoline_11)(void * arg0); -__attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_11 _1wx624s_wrapListenerBlock_ovsamd(_ListenerTrampoline_11 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_10 _1wx624s_wrapListenerBlock_ovsamd(_ListenerTrampoline_10 block) NS_RETURNS_RETAINED { return ^void(void * arg0) { objc_retainBlock(block); block(arg0); }; } -typedef void (^_BlockingTrampoline_11)(void * waiter, void * arg0); +typedef void (^_BlockingTrampoline_10)(void * waiter, void * arg0); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_11 _1wx624s_wrapBlockingBlock_ovsamd( - _BlockingTrampoline_11 block, _BlockingTrampoline_11 listenerBlock, +_ListenerTrampoline_10 _1wx624s_wrapBlockingBlock_ovsamd( + _BlockingTrampoline_10 block, _BlockingTrampoline_10 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0), { objc_retainBlock(block); @@ -409,19 +386,19 @@ void _1wx624s_protocolTrampoline_ovsamd(id target, void * sel) { return ((_ProtocolTrampoline_9)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel); } -typedef void (^_ListenerTrampoline_12)(void * arg0, id arg1); +typedef void (^_ListenerTrampoline_11)(void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_12 _1wx624s_wrapListenerBlock_18v1jvf(_ListenerTrampoline_12 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_11 _1wx624s_wrapListenerBlock_18v1jvf(_ListenerTrampoline_11 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1)); }; } -typedef void (^_BlockingTrampoline_12)(void * waiter, void * arg0, id arg1); +typedef void (^_BlockingTrampoline_11)(void * waiter, void * arg0, id arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_12 _1wx624s_wrapBlockingBlock_18v1jvf( - _BlockingTrampoline_12 block, _BlockingTrampoline_12 listenerBlock, +_ListenerTrampoline_11 _1wx624s_wrapBlockingBlock_18v1jvf( + _BlockingTrampoline_11 block, _BlockingTrampoline_11 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1), { objc_retainBlock(block); @@ -438,19 +415,19 @@ void _1wx624s_protocolTrampoline_18v1jvf(id target, void * sel, id arg1) { return ((_ProtocolTrampoline_10)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1); } -typedef void (^_ListenerTrampoline_13)(void * arg0, struct _NSRange arg1, BOOL * arg2); +typedef void (^_ListenerTrampoline_12)(void * arg0, struct _NSRange arg1, BOOL * arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_13 _1wx624s_wrapListenerBlock_1q8ia8l(_ListenerTrampoline_13 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_12 _1wx624s_wrapListenerBlock_1q8ia8l(_ListenerTrampoline_12 block) NS_RETURNS_RETAINED { return ^void(void * arg0, struct _NSRange arg1, BOOL * arg2) { objc_retainBlock(block); block(arg0, arg1, arg2); }; } -typedef void (^_BlockingTrampoline_13)(void * waiter, void * arg0, struct _NSRange arg1, BOOL * arg2); +typedef void (^_BlockingTrampoline_12)(void * waiter, void * arg0, struct _NSRange arg1, BOOL * arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_13 _1wx624s_wrapBlockingBlock_1q8ia8l( - _BlockingTrampoline_13 block, _BlockingTrampoline_13 listenerBlock, +_ListenerTrampoline_12 _1wx624s_wrapBlockingBlock_1q8ia8l( + _BlockingTrampoline_12 block, _BlockingTrampoline_12 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, struct _NSRange arg1, BOOL * arg2), { objc_retainBlock(block); @@ -461,19 +438,19 @@ _ListenerTrampoline_13 _1wx624s_wrapBlockingBlock_1q8ia8l( }); } -typedef void (^_ListenerTrampoline_14)(void * arg0, id arg1, NSStreamEvent arg2); +typedef void (^_ListenerTrampoline_13)(void * arg0, id arg1, NSStreamEvent arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_14 _1wx624s_wrapListenerBlock_hoampi(_ListenerTrampoline_14 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_13 _1wx624s_wrapListenerBlock_hoampi(_ListenerTrampoline_13 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, NSStreamEvent arg2) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), arg2); }; } -typedef void (^_BlockingTrampoline_14)(void * waiter, void * arg0, id arg1, NSStreamEvent arg2); +typedef void (^_BlockingTrampoline_13)(void * waiter, void * arg0, id arg1, NSStreamEvent arg2); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_14 _1wx624s_wrapBlockingBlock_hoampi( - _BlockingTrampoline_14 block, _BlockingTrampoline_14 listenerBlock, +_ListenerTrampoline_13 _1wx624s_wrapBlockingBlock_hoampi( + _BlockingTrampoline_13 block, _BlockingTrampoline_13 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, NSStreamEvent arg2), { objc_retainBlock(block); @@ -490,19 +467,19 @@ void _1wx624s_protocolTrampoline_hoampi(id target, void * sel, id arg1, NSStrea return ((_ProtocolTrampoline_11)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2); } -typedef void (^_ListenerTrampoline_15)(void * arg0, id arg1, id arg2, id arg3, void * arg4); +typedef void (^_ListenerTrampoline_14)(void * arg0, id arg1, id arg2, id arg3, void * arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_15 _1wx624s_wrapListenerBlock_1sr3ozv(_ListenerTrampoline_15 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_14 _1wx624s_wrapListenerBlock_1sr3ozv(_ListenerTrampoline_14 block) NS_RETURNS_RETAINED { return ^void(void * arg0, id arg1, id arg2, id arg3, void * arg4) { objc_retainBlock(block); block(arg0, (__bridge id)(__bridge_retained void*)(arg1), (__bridge id)(__bridge_retained void*)(arg2), (__bridge id)(__bridge_retained void*)(arg3), arg4); }; } -typedef void (^_BlockingTrampoline_15)(void * waiter, void * arg0, id arg1, id arg2, id arg3, void * arg4); +typedef void (^_BlockingTrampoline_14)(void * waiter, void * arg0, id arg1, id arg2, id arg3, void * arg4); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_15 _1wx624s_wrapBlockingBlock_1sr3ozv( - _BlockingTrampoline_15 block, _BlockingTrampoline_15 listenerBlock, +_ListenerTrampoline_14 _1wx624s_wrapBlockingBlock_1sr3ozv( + _BlockingTrampoline_14 block, _BlockingTrampoline_14 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, id arg1, id arg2, id arg3, void * arg4), { objc_retainBlock(block); @@ -519,19 +496,19 @@ void _1wx624s_protocolTrampoline_1sr3ozv(id target, void * sel, id arg1, id arg return ((_ProtocolTrampoline_12)((id (*)(id, SEL, SEL))objc_msgSend)(target, @selector(getDOBJCDartProtocolMethodForSelector:), sel))(sel, arg1, arg2, arg3, arg4); } -typedef void (^_ListenerTrampoline_16)(void * arg0, unsigned long arg1); +typedef void (^_ListenerTrampoline_15)(void * arg0, unsigned long arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_16 _1wx624s_wrapListenerBlock_zuf90e(_ListenerTrampoline_16 block) NS_RETURNS_RETAINED { +_ListenerTrampoline_15 _1wx624s_wrapListenerBlock_zuf90e(_ListenerTrampoline_15 block) NS_RETURNS_RETAINED { return ^void(void * arg0, unsigned long arg1) { objc_retainBlock(block); block(arg0, arg1); }; } -typedef void (^_BlockingTrampoline_16)(void * waiter, void * arg0, unsigned long arg1); +typedef void (^_BlockingTrampoline_15)(void * waiter, void * arg0, unsigned long arg1); __attribute__((visibility("default"))) __attribute__((used)) -_ListenerTrampoline_16 _1wx624s_wrapBlockingBlock_zuf90e( - _BlockingTrampoline_16 block, _BlockingTrampoline_16 listenerBlock, +_ListenerTrampoline_15 _1wx624s_wrapBlockingBlock_zuf90e( + _BlockingTrampoline_15 block, _BlockingTrampoline_15 listenerBlock, DOBJC_Context* ctx) NS_RETURNS_RETAINED { BLOCKING_BLOCK_IMPL(ctx, ^void(void * arg0, unsigned long arg1), { objc_retainBlock(block); @@ -542,6 +519,29 @@ _ListenerTrampoline_16 _1wx624s_wrapBlockingBlock_zuf90e( }); } +typedef void (^_ListenerTrampoline_16)(id arg0, unsigned long arg1, BOOL * arg2); +__attribute__((visibility("default"))) __attribute__((used)) +_ListenerTrampoline_16 _1wx624s_wrapListenerBlock_1p9ui4q(_ListenerTrampoline_16 block) NS_RETURNS_RETAINED { + return ^void(id arg0, unsigned long arg1, BOOL * arg2) { + objc_retainBlock(block); + block((__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); + }; +} + +typedef void (^_BlockingTrampoline_16)(void * waiter, id arg0, unsigned long arg1, BOOL * arg2); +__attribute__((visibility("default"))) __attribute__((used)) +_ListenerTrampoline_16 _1wx624s_wrapBlockingBlock_1p9ui4q( + _BlockingTrampoline_16 block, _BlockingTrampoline_16 listenerBlock, + DOBJC_Context* ctx) NS_RETURNS_RETAINED { + BLOCKING_BLOCK_IMPL(ctx, ^void(id arg0, unsigned long arg1, BOOL * arg2), { + objc_retainBlock(block); + block(nil, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); + }, { + objc_retainBlock(listenerBlock); + listenerBlock(waiter, (__bridge id)(__bridge_retained void*)(arg0), arg1, arg2); + }); +} + typedef void (^_ListenerTrampoline_17)(unsigned short * arg0, unsigned long arg1); __attribute__((visibility("default"))) __attribute__((used)) _ListenerTrampoline_17 _1wx624s_wrapListenerBlock_vhbh5h(_ListenerTrampoline_17 block) NS_RETURNS_RETAINED { diff --git a/pkgs/objective_c/test/autorelease_test.dart b/pkgs/objective_c/test/autorelease_test.dart index 3a323920c0..12f64ce6e4 100644 --- a/pkgs/objective_c/test/autorelease_test.dart +++ b/pkgs/objective_c/test/autorelease_test.dart @@ -56,5 +56,25 @@ void main() { expect(objectRetainCount(pointer), 0); }); + + test('returns callback value', () async { + late Pointer pointer; + + final returnedPointer = autoReleasePool(() { + final object = NSObject(); + pointer = object.ref.retainAndAutorelease(); + return pointer; + }); + + // Returned value should be exactly what the callback returned + expect(returnedPointer, same(pointer)); + + doGC(); + await Future.delayed(Duration.zero); + doGC(); + + // Object should be released once the pool is popped + expect(objectRetainCount(pointer), 0); + }); }); } diff --git a/pkgs/objective_c/test/hook_build_path_test.dart b/pkgs/objective_c/test/hook_build_path_test.dart new file mode 100644 index 0000000000..ee08fe490f --- /dev/null +++ b/pkgs/objective_c/test/hook_build_path_test.dart @@ -0,0 +1,109 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:code_assets/code_assets.dart'; +import 'package:hooks/hooks.dart'; +import 'package:native_test_helpers/native_test_helpers.dart'; +import 'package:test/test.dart'; + +import '../hook/build.dart' as hook; + +void main() { + test( + 'build hook decodes percent-encoded package root paths', + () async { + final tempDir = await Directory.systemTemp.createTemp( + 'objective_c_hook_path', + ); + addTearDown(() => tempDir.delete(recursive: true)); + + final realPackageRoot = findPackageRoot('objective_c'); + const rootDirName = 'pkg%47root'; + final rootDir = Directory('${tempDir.path}/$rootDirName'); + await rootDir.create(); + final symlinkPath = '${rootDir.path}/objective_c'; + await Link(symlinkPath).create(realPackageRoot.toFilePath()); + final symlinkDir = Directory(symlinkPath); + + final encodedPath = symlinkPath.replaceAll('%', '%25'); + final encodedPackageRoot = Uri.parse( + 'file:///${encodedPath.substring(1)}/', + ); + expect(encodedPackageRoot.toString(), contains('%2547')); + + final compilerLog = tempDir.uri.resolve('compiler_args.txt').toFilePath(); + File(compilerLog).writeAsStringSync(''); + final compilerScript = tempDir.uri.resolve('clang').toFilePath(); + File(compilerScript).writeAsStringSync('''#!/bin/sh +if [ "\$1" = "--version" ]; then + echo "Apple clang version 15.0.0" + exit 0 +fi +log="$compilerLog" +out="" +prev="" +for arg in "\$@"; do + if [ "\$prev" = "-o" ]; then + out="\$arg" + fi + prev="\$arg" + printf '%s\\n' "\$arg" >> "\$log" +done +if [ -n "\$out" ]; then + mkdir -p "\$(dirname "\$out")" + : > "\$out" +fi +exit 0 +'''); + Process.runSync('chmod', ['+x', compilerScript]); + + final outputDirectoryShared = tempDir.uri.resolve('output_shared/'); + await Directory.fromUri(outputDirectoryShared).create(); + final outputFile = tempDir.uri.resolve('output.json'); + + final inputBuilder = BuildInputBuilder() + ..setupShared( + packageRoot: encodedPackageRoot, + packageName: 'objective_c', + outputFile: outputFile, + outputDirectoryShared: outputDirectoryShared, + ) + ..setupBuildInput() + ..config.setupBuild(linkingEnabled: false) + ..addExtension( + CodeAssetExtension( + targetArchitecture: Architecture.current, + targetOS: OS.macOS, + linkModePreference: LinkModePreference.dynamic, + macOS: MacOSCodeConfig(targetVersion: 13), + cCompiler: CCompilerConfig( + compiler: Uri.file(compilerScript), + linker: Uri.file(compilerScript), + archiver: Uri.file(compilerScript), + ), + ), + ); + final input = inputBuilder.build(); + final inputFile = tempDir.uri.resolve('input.json'); + File.fromUri(inputFile).writeAsStringSync(json.encode(input.json)); + + final originalCwd = Directory.current; + Directory.current = symlinkDir; + try { + await (hook.main as dynamic)(['--config=${inputFile.toFilePath()}']); + } finally { + Directory.current = originalCwd; + } + + final logLines = File(compilerLog).readAsLinesSync(); + final decodedUtil = '$symlinkPath/test/util.c'; + expect(logLines, contains(decodedUtil)); + expect(logLines.any((line) => line.contains('%2547')), isFalse); + }, + skip: !Platform.isMacOS ? 'Requires macOS' : null, + ); +} diff --git a/pkgs/pub_formats/analysis_options.yaml b/pkgs/pub_formats/analysis_options.yaml new file mode 100644 index 0000000000..d978f811cc --- /dev/null +++ b/pkgs/pub_formats/analysis_options.yaml @@ -0,0 +1 @@ +include: package:dart_flutter_team_lints/analysis_options.yaml diff --git a/pkgs/pub_formats/pubspec.yaml b/pkgs/pub_formats/pubspec.yaml index f88342d3e0..61ab067657 100644 --- a/pkgs/pub_formats/pubspec.yaml +++ b/pkgs/pub_formats/pubspec.yaml @@ -13,10 +13,11 @@ version: 0.0.1-wip resolution: workspace environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' dev_dependencies: args: ^2.6.0 + dart_flutter_team_lints: ^3.5.2 json_schema: ^5.2.0 # May only be used in tool/ and test/json_schema/. json_syntax_generator: path: ../json_syntax_generator/ diff --git a/pkgs/pub_formats/test/helpers.dart b/pkgs/pub_formats/test/helpers.dart index 40cc192eba..7ef42676f2 100644 --- a/pkgs/pub_formats/test/helpers.dart +++ b/pkgs/pub_formats/test/helpers.dart @@ -19,7 +19,7 @@ Map loadYamlAsJson(String relativePath) { final packageRoot = findPackageRoot('pub_formats'); final pubspecFile = File.fromUri(packageRoot.resolve(relativePath)); final json = convertYamlMapToJsonMap( - loadYaml(pubspecFile.readAsStringSync()), + loadYaml(pubspecFile.readAsStringSync()) as YamlMap, ); return json; } diff --git a/pkgs/pub_formats/test/package_graph_test.dart b/pkgs/pub_formats/test/package_graph_test.dart index c156316137..d4c77c105d 100644 --- a/pkgs/pub_formats/test/package_graph_test.dart +++ b/pkgs/pub_formats/test/package_graph_test.dart @@ -15,7 +15,7 @@ void main() { expect(errors, isEmpty); expect( parsed.roots, - equals(["add_asset_link", "app_with_asset_treeshaking"]), + equals(['add_asset_link', 'app_with_asset_treeshaking']), ); final somePackage = parsed.packages.firstWhere( (e) => e.name == 'code_assets', diff --git a/pkgs/pub_formats/test/pubspec_lock_test.dart b/pkgs/pub_formats/test/pubspec_lock_test.dart index ea3fa63987..552508d7a2 100644 --- a/pkgs/pub_formats/test/pubspec_lock_test.dart +++ b/pkgs/pub_formats/test/pubspec_lock_test.dart @@ -41,8 +41,12 @@ void main() { expect( errorsDescription, equals([ - "Unexpected value 'not a valid name' (String) for 'dart_apitool.description.name'. Expected a String satisfying ^[a-zA-Z_]\\w*\$.", - "Unexpected value 'not a valid sha' (String) for 'dart_apitool.description.sha256'. Expected a String satisfying ^[a-f0-9]{64}\$.", + "Unexpected value 'not a valid name' (String) " + "for 'dart_apitool.description.name'. " + 'Expected a String satisfying ^[a-zA-Z_]\\w*\$.', + "Unexpected value 'not a valid sha' (String) " + "for 'dart_apitool.description.sha256'. " + 'Expected a String satisfying ^[a-f0-9]{64}\$.', ]), ); expect(() => description.sha256, throwsFormatException); diff --git a/pkgs/pub_formats/test/pubspec_test.dart b/pkgs/pub_formats/test/pubspec_test.dart index 9ead18d98d..123ce18787 100644 --- a/pkgs/pub_formats/test/pubspec_test.dart +++ b/pkgs/pub_formats/test/pubspec_test.dart @@ -95,7 +95,8 @@ void main() { expect( syntaxError1.validate(), equals([ - "Unexpected value 'not a map' (String) for 'executables'. Expected a Map?.", + "Unexpected value 'not a map' (String) for 'executables'. " + 'Expected a Map?.', ]), ); expect(() => syntaxError1.executables, throwsFormatException); diff --git a/pkgs/pub_formats/tool/generate.dart b/pkgs/pub_formats/tool/generate.dart index 52152a5510..e1cff2517a 100644 --- a/pkgs/pub_formats/tool/generate.dart +++ b/pkgs/pub_formats/tool/generate.dart @@ -40,10 +40,10 @@ void main(List args) { 'pubspec', ]) { final schemaFile = File.fromUri( - packageRoot.resolve('doc/schema/${name}.schema.json'), + packageRoot.resolve('doc/schema/$name.schema.json'), ); final schemaJson = jsonDecode(schemaFile.readAsStringSync()); - final schema = JsonSchema.create(schemaJson); + final schema = JsonSchema.create(schemaJson as Object); final analyzedSchema = SchemaAnalyzer( schema, diff --git a/pkgs/record_use/CHANGELOG.md b/pkgs/record_use/CHANGELOG.md index a7e1942ff2..a35c54e252 100644 --- a/pkgs/record_use/CHANGELOG.md +++ b/pkgs/record_use/CHANGELOG.md @@ -1,8 +1,15 @@ -## 0.5.0-wip +## 0.6.0-wip -- Made locations optional to accomodate for dart2js compiler not providing - source locations for constant instances. -- Introduce a JSON schema for the json encoding. +- **Breaking Change**: Changed the JSON format and Dart API in various ways. + +## 0.5.0 + +- Complete reimplementation of the package. The Dart API changed completely, the + underlying JSON format changed completely, the internal architecture changed + completely to be based on a JSON schema, the format can now express many more + recordings, the code samples in the doc comments are now tested and up to + date, and many more changes. This is by no means a final version, but will + enable people to play with the current state of the implementation. ## 0.4.2 diff --git a/pkgs/record_use/README.md b/pkgs/record_use/README.md index ce0778cf06..a0008a6da9 100644 --- a/pkgs/record_use/README.md +++ b/pkgs/record_use/README.md @@ -1,117 +1,100 @@ > [!CAUTION] -> This is an experimental package, and it's API can break at any time. Use at -> your own discretion. +> This is an experimental package. Its API and the underlying JSON format +> **will break** as we are actively iterating. Use at your own discretion. +> +> We are continuously changing the implementation, so a released version of the +> package may only work with one or two [dev releases] of the Dart SDK. This +> version will work with the first dev release _after_ `3.12.0-203.0.dev`. This package provides the data classes for the usage recording feature in the Dart SDK. -Dart objects with the `@RecordUse` annotation are being recorded at compile +Dart objects with the `@RecordUse()` annotation are being recorded at compile time, providing the user with information. The information depends on the object being recorded. - If placed on a static method, the annotation means that arguments passed to the method will be recorded, as far as they can be inferred at compile time. -- If placed on a class with a constant constructor, the annotation means that -any constant instance of the class will be recorded. This is particularly useful -when using the class as an annotation. +- If placed on a class, the annotation means that any constant instance of the +class and any constructor invocation will be recorded. + +> [!NOTE] +> The `@RecordUse()` annotation is only allowed on definitions within a package's +> `lib/` directory. This includes definitions that are members of a class, such +> as static methods. ## Example + ```dart -import 'package:meta/meta.dart' show RecordUse; - void main() { - print(SomeClass.stringMetadata(42)); - print(SomeClass.doubleMetadata(42)); - print(SomeClass.intMetadata(42)); - print(SomeClass.boolMetadata(42)); + PirateTranslator.speak('Hello'); + print(const PirateShip('Black Pearl', 50)); } -class SomeClass { - @RecordMetadata('leroyjenkins') +abstract class PirateTranslator { @RecordUse() - static stringMetadata(int i) { - return i + 1; - } - - @RecordMetadata(3.14) - @RecordUse() - static doubleMetadata(int i) { - return i + 1; - } - - @RecordMetadata(42) - @RecordUse() - static intMetadata(int i) { - return i + 1; - } - - @RecordMetadata(true) - @RecordUse() - static boolMetadata(int i) { - return i + 1; - } + static String speak(String english) => 'Ahoy $english'; } @RecordUse() -class RecordMetadata { - final Object metadata; +final class PirateShip { + final String name; + final int cannons; - const RecordMetadata(this.metadata); + const PirateShip(this.name, this.cannons); } - ``` -This code will generate a data file that contains both the `metadata` values of -the `RecordMetadata` instances, as well as the arguments for the different -methods annotated with `@RecordUse()`. +This code will generate a data file that contains both the field values of +the `PirateShip` instances, as well as the arguments for the `speak` +method annotated with `@RecordUse()`. This information can then be accessed in a link hook as follows: + ```dart -import 'dart:convert'; - -import 'package:hooks/hooks.dart'; -import 'package:record_use/record_use_internal.dart'; - -final methodId = Identifier( - uri: 'myfile.dart', - name: 'myMethod', -); - -final classId = Identifier( - uri: 'myfile.dart', - name: 'myClass', -); - -void main(List arguments){ - link(arguments, (config, output) async { - final usesUri = config.recordedUses; - final usesJson = await File,fromUri(usesUri).readAsString(); - final uses = UsageRecord.fromJson(jsonDecode(usesJson)); - - final args = uses.argumentsTo(methodId)); - //[args] is an iterable of arguments, in this case containing "42" - - final fields = uses.instancesOf(classId); - //[fields] is an iterable of the fields of the class, in this case - //containing - // {"arguments": "leroyjenkins"} - // {"arguments": 3.14} - // {"arguments": 42} - // {"arguments": true} - - ... // Do something with the information, such as tree-shaking native assets +void main(List arguments) { + link(arguments, (input, output) async { + final usesUri = input.recordedUsagesFile; + if (usesUri == null) return; + final usesJson = await File.fromUri(usesUri).readAsString(); + final uses = Recordings.fromJson( + jsonDecode(usesJson) as Map, + ); + + final calls = uses.calls[methodId] ?? []; + for (final call in calls) { + switch (call) { + case CallWithArguments( + positionalArguments: [StringConstant(value: final english), ...], + ): + // Shrink a translations file based on all the different translation + // keys. + print('Translating to pirate: $english'); + case _: + print('Cannot determine which translations are used.'); + } + } + + final ships = uses.instances[classId] ?? []; + for (final ship in ships) { + switch (ship) { + case InstanceConstantReference( + instanceConstant: InstanceConstant( + fields: {'name': StringConstant(value: final name)}, + ), + ): + // Include the 3d model for this ship in the application but not + // bundle the other ships. + print('Pirate ship found: $name'); + case _: + print('Cannot determine which ships are used.'); + } + } }); } ``` -## Limitations -As this is designed to work on both web and native platforms, we have to adapt -to the platform pecularities. One of them is that javascript does not support -named arguments, so the dart2js compiler rewrites functions to only accept named -parameters. -While you can use named parameters to record functions, we advise caution as the -retrieval behavior might change once we work around this dart2js limitation and -implement separate positional and named parameters. - ## Contributing Contributions are welcome! Please open an issue or submit a pull request. + +[dev releases]: https://dart.dev/get-dart/archive#dev-channel diff --git a/pkgs/record_use/doc/schema/record_use.schema.json b/pkgs/record_use/doc/schema/record_use.schema.json index 4040ac69f2..0e352cfb52 100644 --- a/pkgs/record_use/doc/schema/record_use.schema.json +++ b/pkgs/record_use/doc/schema/record_use.schema.json @@ -19,15 +19,18 @@ } ] }, - "@": { + "loading_unit_index": { "type": "integer" }, - "loading_unit": { - "type": "string" + "receiver": { + "type": [ + "integer", + "null" + ] } }, "required": [ - "loading_unit", + "loading_unit_index", "type" ], "if": { @@ -48,15 +51,32 @@ "positional": { "type": "array", "items": { - "type": [ - "integer", - "null" - ] + "type": "integer" } } } } }, + "CallRecording": { + "type": "object", + "properties": { + "definition_index": { + "type": "integer" + }, + "uses": { + "type": "array", + "items": { + "$ref": "#/definitions/Call" + }, + "minItems": 1 + } + }, + "required": [ + "definition_index", + "uses" + ], + "additionalProperties": false + }, "Constant": { "type": "object", "properties": { @@ -65,13 +85,19 @@ "anyOf": [ { "enum": [ - "Instance", - "Null", - "String", "bool", + "double", + "enum", + "instance", "int", "list", - "map" + "map", + "non_constant", + "null", + "record", + "string", + "symbol", + "unsupported" ] }, { @@ -88,51 +114,70 @@ "if": { "properties": { "type": { - "const": "Instance" + "const": "bool" } } }, "then": { "properties": { "value": { - "type": "object", - "additionalProperties": true + "type": "boolean" } - } + }, + "required": [ + "value" + ] } }, { "if": { "properties": { "type": { - "const": "Null" + "const": "double" } } }, "then": { - "not": { - "required": [ - "value" - ] - } + "properties": { + "value": { + "$ref": "#/definitions/DoubleConstantValue" + } + }, + "required": [ + "value" + ] } }, { "if": { "properties": { "type": { - "const": "String" + "const": "enum" } } }, "then": { "properties": { - "value": { + "definition_index": { + "type": "integer" + }, + "index": { + "type": "integer" + }, + "name": { "type": "string" + }, + "value": { + "type": "object", + "additionalProperties": { + "type": "integer" + } } }, "required": [ - "value" + "definition_index", + "index", + "name" ] } }, @@ -140,18 +185,22 @@ "if": { "properties": { "type": { - "const": "bool" + "const": "instance" } } }, "then": { "properties": { + "definition_index": { + "type": "integer" + }, "value": { - "type": "boolean" + "type": "object", + "additionalProperties": true } }, "required": [ - "value" + "definition_index" ] } }, @@ -204,83 +253,416 @@ "then": { "properties": { "value": { + "type": "array", + "items": { + "$ref": "#/definitions/MapEntry" + } + } + }, + "required": [ + "value" + ] + } + }, + { + "if": { + "properties": { + "type": { + "const": "non_constant" + } + } + }, + "then": { + "not": { + "required": [ + "value" + ] + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "null" + } + } + }, + "then": { + "not": { + "required": [ + "value" + ] + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "record" + } + } + }, + "then": { + "properties": { + "named": { "type": "object", - "additionalProperties": true + "additionalProperties": { + "type": "integer" + } + }, + "positional": { + "type": "array", + "items": { + "type": "integer" + } + } + } + } + }, + { + "if": { + "properties": { + "type": { + "const": "string" + } + } + }, + "then": { + "properties": { + "value": { + "type": "string" } }, "required": [ "value" ] } + }, + { + "if": { + "properties": { + "type": { + "const": "symbol" + } + } + }, + "then": { + "properties": { + "libraryUri": { + "type": [ + "null", + "string" + ], + "pattern": "^package:" + }, + "name": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + }, + { + "if": { + "properties": { + "type": { + "const": "unsupported" + } + } + }, + "then": { + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ] + } } ] }, - "Identifier": { + "Definition": { "type": "object", "properties": { - "name": { - "type": "string" - }, - "scope": { - "type": "string" + "path": { + "type": "array", + "items": { + "$ref": "#/definitions/Name" + }, + "minItems": 1 }, "uri": { - "type": "string" + "type": "string", + "pattern": "^package:" } }, "required": [ - "name", + "path", "uri" ] }, + "DoubleConstantValue": { + "type": "object", + "properties": { + "type": { + "type": "string", + "anyOf": [ + { + "enum": [ + "negative_infinity", + "not_a_number", + "number", + "positive_infinity" + ] + }, + { + "type": "string" + } + ] + }, + "value": { + "type": "number" + } + }, + "required": [ + "type" + ], + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "number" + } + } + }, + "then": { + "required": [ + "value" + ] + } + } + ] + }, "Instance": { "type": "object", "properties": { - "@": { + "type": { + "type": "string", + "anyOf": [ + { + "enum": [ + "constant", + "creation", + "tearoff" + ] + }, + { + "type": "string" + } + ] + }, + "loading_unit_index": { "type": "integer" + } + }, + "required": [ + "loading_unit_index", + "type" + ], + "allOf": [ + { + "if": { + "properties": { + "type": { + "const": "constant" + } + } + }, + "then": { + "properties": { + "constant_index": { + "type": "integer" + } + }, + "required": [ + "constant_index" + ] + } + }, + { + "if": { + "properties": { + "type": { + "const": "creation" + } + } + }, + "then": { + "properties": { + "definition_index": { + "type": "integer" + }, + "named": { + "type": "object", + "additionalProperties": { + "type": "integer" + } + }, + "positional": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "required": [ + "definition_index" + ] + } }, - "constant_index": { + { + "if": { + "properties": { + "type": { + "const": "tearoff" + } + } + }, + "then": { + "properties": { + "definition_index": { + "type": "integer" + } + }, + "required": [ + "definition_index" + ] + } + } + ] + }, + "InstanceRecording": { + "type": "object", + "properties": { + "definition_index": { "type": "integer" }, - "loading_unit": { + "uses": { + "type": "array", + "items": { + "$ref": "#/definitions/Instance" + }, + "minItems": 1 + } + }, + "required": [ + "definition_index", + "uses" + ], + "additionalProperties": false + }, + "LoadingUnit": { + "type": "object", + "properties": { + "name": { "type": "string" } }, "required": [ - "constant_index", - "loading_unit" + "name" ] }, - "Location": { + "MapEntry": { "type": "object", "properties": { - "column": { + "key": { "type": "integer" }, - "line": { + "value": { "type": "integer" + } + }, + "required": [ + "key", + "value" + ] + }, + "Name": { + "type": "object", + "properties": { + "disambiguators": { + "type": "array", + "items": { + "type": "string", + "anyOf": [ + { + "enum": [ + "instance", + "static" + ] + }, + { + "type": "string" + } + ] + } }, - "uri": { + "kind": { + "type": "string", + "anyOf": [ + { + "enum": [ + "class", + "constructor", + "enum", + "extension", + "extension_type", + "getter", + "method", + "mixin", + "operator", + "setter" + ] + }, + { + "type": "string" + } + ] + }, + "name": { "type": "string" } }, "required": [ - "uri" + "name" ] }, "RecordedUses": { "type": "object", "properties": { + "definitions": { + "type": "array", + "items": { + "$ref": "#/definitions/Definition" + } + }, "constants": { "type": "array", "items": { "$ref": "#/definitions/Constant" } }, - "locations": { + "loading_units": { "type": "array", "items": { - "$ref": "#/definitions/Location" + "$ref": "#/definitions/LoadingUnit" } }, "metadata": { @@ -298,50 +680,31 @@ "version" ] }, - "recordings": { - "type": "array", - "items": { - "$ref": "#/definitions/Recording" - } + "uses": { + "$ref": "#/definitions/Uses" } }, "required": [ "metadata" ] }, - "Recording": { + "Uses": { "type": "object", "properties": { - "calls": { + "instances": { "type": "array", "items": { - "$ref": "#/definitions/Call" + "$ref": "#/definitions/InstanceRecording" } }, - "definition": { - "type": "object", - "properties": { - "identifier": { - "$ref": "#/definitions/Identifier" - }, - "loading_unit": { - "type": "string" - } - }, - "required": [ - "identifier" - ] - }, - "instances": { + "static_calls": { "type": "array", "items": { - "$ref": "#/definitions/Instance" + "$ref": "#/definitions/CallRecording" } } }, - "required": [ - "definition" - ] + "additionalProperties": false } } } diff --git a/pkgs/record_use/doc/use_cases/README.md b/pkgs/record_use/doc/use_cases/README.md new file mode 100644 index 0000000000..bd43bedef8 --- /dev/null +++ b/pkgs/record_use/doc/use_cases/README.md @@ -0,0 +1,19 @@ +# Use cases for `package:record_use` + +This directory contains documents describing various use cases for the +`record_use` package. Each document outlines a specific scenario where the +package can be used to gather information about code for purposes like +tree-shaking, code generation, or analysis. + +## Use Cases + +- [Icon Font Tree-Shaking](./icon_data.md): Reducing the size of icon fonts in + Flutter applications by tree-shaking unused icons. +- [ICU4X Data Tree-Shaking](./icu4x.md): Tree-shaking native code in the `icu4x` + library to reduce binary size. +- [Jaspr Widget Trees](./jaspr.md): Extracting information from Jaspr widget + trees to generate CSS, similar to Tailwind CSS. +- [JNIgen ProGuard Rules](./jnigen.md): Generating ProGuard rules for + Java/Kotlin code used via `jnigen` to enable code shrinking. +- [Message Translation Tree-Shaking](./messages.md): Shrinking translation + files by removing unused messages. diff --git a/pkgs/record_use/doc/use_cases/icon_data.md b/pkgs/record_use/doc/use_cases/icon_data.md new file mode 100644 index 0000000000..94c311c2c6 --- /dev/null +++ b/pkgs/record_use/doc/use_cases/icon_data.md @@ -0,0 +1,75 @@ +# Icon data record_use + +The goal here is to be able to tree-shake icon fonts in Flutter. Currently, this +is a custom-built solution in Flutter. This should be the capability of a +package. + +Dart API and use: + + +```dart +class IconData { + const IconData( + this.codePoint, { + this.fontFamily, + this.fontPackage, + this.matchTextDirection = false, + this.fontFamilyFallback, + }); +} +``` + + +```dart +abstract final class GalleryIcons { + static const IconData tooltip = IconData(0xe900, fontFamily: 'GalleryIcons'); + static const IconData text_fields_alt = IconData(0xe901, fontFamily: 'GalleryIcons'); + // ... +} +``` + +## Information needed for tree-shaking + +Const instances inside Dart code (const instances inside annotations are not +reachable at runtime, and thus can never be used). + +Note that `const` constructors can be called in non-`const` contexts. To +reliably track all uses, we need to record both `const` instances and all calls +to `const` constructors, regardless of whether the call site is `const`. + +* https://github.com/dart-lang/native/issues/2911 + +Moreover, we need the arguments to the const constructor calls and the fields of +the const instances. + +### Static getters won't work. + +Since this API is already in active use, we cannot simply change the API to +static getters, as that would prevent const: + + +```dart +abstract final class GalleryIcons { + static IconData get tooltip => IconData(0xe900, fontFamily: 'GalleryIcons'); + static IconData get text_fields_alt => IconData(0xe901, fontFamily: 'GalleryIcons'); + // ... +} +``` + +An API with static getters (disallowing const instances) would enable two other +possiblities of recording uses. + +1. Record each static getter in `GalleryIcons` individually, no arguments. + (Static calls we are aiming for in v1.0) +2. Record the non-const constructor of `IconData` with the const argument values. + This requires: + + * https://github.com/dart-lang/native/issues/2907 + +Flutter actively makes everything const, so forcing this API to be non-const is +a no-go. + +## Links + +* https://api.flutter.dev/flutter/cupertino/CupertinoIcons-class.html +* https://github.com/flutter/flutter/pull/174860 diff --git a/pkgs/record_use/doc/use_cases/icu4x.md b/pkgs/record_use/doc/use_cases/icu4x.md new file mode 100644 index 0000000000..f019a6e2cd --- /dev/null +++ b/pkgs/record_use/doc/use_cases/icu4x.md @@ -0,0 +1,42 @@ +# Icu4x record_use + +This is a rust library, and the goal is to tree-shake native code if symbols are +not reachable from Dart code to cut down binary size from ~40MB to a couple of +MBs. + +## Information needed for tree-shaking + +The native symbols that are reachable: + + +```dart +@ffi.Native Function(ffi.Size, ffi.Size)>( + symbol: 'diplomat_alloc', + isLeaf: true, +) +external ffi.Pointer _diplomat_alloc(int len, int align); +``` +([[source](https://github.com/unicode-org/icu4x/blob/e5a29a7d591157e8906bbd3f00021f164031f7cd/ffi/dart/lib/src/bindings/lib.g.dart#L237C1-L237C68)) + + +The link hook needs to know `diplomat_alloc` is reachable or not. + +This can be achieved by knowing whether the static function `_diplomat_alloc` is reachable. + +### Mapping Dart identifiers to native identifiers + +The file containing the external static functions is a generated file. + +The link hook could import a generated file that contains the mapping: + + +```dart +const dartStaticCallToNativeSymbol = { + 'diplomat_alloc': '_diplomat_alloc', + // ... +}; +``` + +## Links + +* https://pub.dev/packages/icu4x diff --git a/pkgs/record_use/doc/use_cases/jaspr.md b/pkgs/record_use/doc/use_cases/jaspr.md new file mode 100644 index 0000000000..aa23015188 --- /dev/null +++ b/pkgs/record_use/doc/use_cases/jaspr.md @@ -0,0 +1,81 @@ +# Jaspr Component Trees record_use + +Jaspr is a web framework. The goal is to generate a minimal CSS file containing +only the styles used in a Jaspr application. This is achieved by using +`record_use` to extract information about which components are used and what +styles they apply. This enables a "Tailwind-like" experience where developers +use style utilities and the final CSS is tree-shaken. + +For example, a `Column` component might have styling options passed to its +constructor: + + +```dart +class Column extends Component { + @RecordUse() + const Column({this.spacing = 0, this.crossAxisAlignment = 'start'}); + + @override + Iterable build(BuildContext context) { + // ... + } +} +``` + +When this component is used, we want to record the constructor call, including +the arguments: + + +```dart +class MyComponent extends Component { + @override + Iterable build(BuildContext context) { + return [ + Column(spacing: 42, crossAxisAlignment: 'center'), + ]; + } +} +``` + +A link-time hook can then process all recorded uses of `Column`. From the +`spacing` and `crossAxisAlignment` arguments, it can generate the required CSS +rules and emit them into a single CSS file for the application: + +```css +.column-spacing-42 { + padding: 42px; +} + +.column-cross-axis-center { + align-items: center; +} +``` + +## Information required for CSS generation + +To generate the CSS, the link hook needs to know about all constructor calls to +components that are annotated with `@RecordUse`. + +* **`const` constructor calls**: + These are the most common in component trees. We need to record the static + calls to these `const` constructors and the values of their arguments. + See: https://github.com/dart-lang/native/issues/2911 + +* **`const` instances**: + `const` instances of components are also common. The hook needs to be aware + of these instances and their field values. + (We are _not_ interested in any of these const instances occurring in + annotations, such as https://github.com/dart-lang/native/issues/2719.) + +* **Non-`const` constructor calls**: + Component trees are not always `const`. To ensure all styles are captured, we + also need to record non-`const` constructor calls. + See: https://github.com/dart-lang/native/issues/2907 + +By collecting this information, a tool can build a complete picture of which +styling primitives are used in an application and generate an optimized CSS file. + +## Links + +* https://github.com/schultek/jaspr +* https://github.com/schultek/universal_widgets diff --git a/pkgs/record_use/doc/use_cases/jnigen.md b/pkgs/record_use/doc/use_cases/jnigen.md new file mode 100644 index 0000000000..3df88f19a5 --- /dev/null +++ b/pkgs/record_use/doc/use_cases/jnigen.md @@ -0,0 +1,106 @@ +# JNIgen record_use + +JNIgen generates Dart bindings to Java/Kotlin code. After tree-shaking the generated +Dart code not all Java/Kotlin code is reachable. To tree-shake the unreachable +Java/Kotlin code we want to generate ProGuard rules that list all the +reachable Java/Kotlin classes, methods, and fields. + +## Information needed for tree-shaking + +### 1. Which classes are possibly instantiated. + + +```dart +class PDDocument extends jni$_.JObject { + PDDocument.fromReference( + jni$_.JReference reference, + ); + + factory PDDocument() { + return PDDocument.fromReference( + _new$(_class.reference.pointer, _id_new$ as jni$_.JMethodIDPtr) + .reference); + } + + factory PDDocument.new$1( + jni$_.JObject? memUsageSetting, + ); +} +``` + +This requires tracking non-const (factory) constructor calls. + +* https://github.com/dart-lang/native/issues/2907 + +Because the `JObjects` are wrappers around native pointers, none of the JNIgen +generated classes will ever have const constructors. + +### 2. Which methods, getters and setters are reachable. + + +```dart +class PDDocument extends jni$_.JObject { + void addPage( + jni$_.JObject? page, + ) +} +``` + +This requires tracking instance calls, or generating a static call inside the +instance call. JNIgen already generates a static field (with a static getter) +that could be annotated to record a static call: + + +```dart +class PDDocument extends jni$_.JObject { + static final _addPage = jni$_.ProtectedJniExtensions.lookup< + jni$_.NativeFunction< + jni$_.JThrowablePtr Function( + jni$_.Pointer, + jni$_.JMethodIDPtr, + jni$_.VarArgs<(jni$_.Pointer,)>)>>( + 'globalEnv_CallVoidMethod') + .asFunction< + jni$_.JThrowablePtr Function(jni$_.Pointer, + jni$_.JMethodIDPtr, jni$_.Pointer)>(); + + void addPage( + final _$page = page?.reference ?? jni$_.jNullReference; + _addPage(reference.pointer, _id_addPage as jni$_.JMethodIDPtr, + _$page.pointer) + .check(); + ) +} +``` + +Java fields in JNIgen generated code are Dart getters and setters. + +* https://github.com/dart-lang/native/issues/2906 + +### 3. Mapping Dart identifiers to native identifiers + +For each class-use and method/field-use the link hook in JNIgen needs to know +the original Java/Kotlin unique name. + +Since JNIgen is already a code generator, this can be achieved by generating a +file that maps Dart identifiers to Java identifiers: + + +```dart +const dartToJava = { + DartMethodIdentifer( + importUrl: 'package:foo/foo.dart', + name: 'Bar', + methodName: 'baz', + ) : JavaMethodDefinition( + qualifiedImport: 'org.foo.foo', + name: 'Bar', + methodName: 'baz', + ), + // ... +} +``` + +## Links + +* https://pub.dev/packages/jnigen diff --git a/pkgs/record_use/doc/use_cases/messages.md b/pkgs/record_use/doc/use_cases/messages.md new file mode 100644 index 0000000000..e8838eb6d0 --- /dev/null +++ b/pkgs/record_use/doc/use_cases/messages.md @@ -0,0 +1,58 @@ +# messages record_use + +The goal of this package is to provide translation. The goal of using link hooks +is to be able to shrink the translation files based on use. + + +```dart +class MessageTable { + @RecordUse() + static String lookup(int id, String appId) => // ... + + @RecordUse() + static String evaluate(int id, String appId, List args) => + // ... +} +``` + + +```dart +String translateFoo() => lookup(/*int id of foo*/0, 'baz'); + +String translateBar(String name) => evaluate(/*int id of foo*/0, 'baz', name); +``` + +The calls to the translate methods are almost always generated. Either by a +transformer as a compiler plugin or by an external code generator that generates +the API for the translations. + +If a transformer is used, the pre-transform code looks something like: + + +```dart +class Intl { + static String message(String messageText, + {String? desc = '', + Map? examples, + String? locale, + String? name, + List? args, + String? meaning, + bool? skip}); +} +``` + +An `id` is generated based on the calls to `message` and the message calls are +transformed to the `lookup` and `evaluate` calls. + +This transformation step might not be needed if we can reconstruct the +id-generation in the link hook. + +## Information needed for tree-shaking + +The uses of the static methods, and their const argument values. + +## Links + +* https://pub.dev/packages/intl +* https://pub.dev/packages/messages diff --git a/pkgs/record_use/example/api/usage.dart b/pkgs/record_use/example/api/usage.dart new file mode 100644 index 0000000000..38b1f98663 --- /dev/null +++ b/pkgs/record_use/example/api/usage.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: experimental_member_use, unreachable_from_main + +import 'package:meta/meta.dart' show RecordUse; + +// snippet-start#usage +void main() { + PirateTranslator.speak('Hello'); + print(const PirateShip('Black Pearl', 50)); +} + +// snippet-start#static-call +abstract class PirateTranslator { + @RecordUse() + static String speak(String english) => 'Ahoy $english'; +} +// snippet-end#static-call + +// snippet-start#const-instance +@RecordUse() +final class PirateShip { + final String name; + final int cannons; + + const PirateShip(this.name, this.cannons); +} + +// snippet-end#const-instance +// snippet-end#usage diff --git a/pkgs/record_use/example/api/usage_link.dart b/pkgs/record_use/example/api/usage_link.dart new file mode 100644 index 0000000000..ddda430ddf --- /dev/null +++ b/pkgs/record_use/example/api/usage_link.dart @@ -0,0 +1,87 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: experimental_member_use +// ignore_for_file: depend_on_referenced_packages + +import 'dart:convert'; +import 'dart:io'; + +import 'package:hooks/hooks.dart'; +import 'package:record_use/record_use.dart'; + +final methodId = Definition( + 'package:pirate_speak/pirate_speak.dart', + [ + const Name( + kind: .classKind, + 'PirateTranslator', + ), + Name( + kind: .methodKind, + 'speak', + disambiguators: { + .staticDisambiguator, + }, + ), + ], +); + +const classId = Definition( + 'package:pirate_technology/pirate_technology.dart', + [ + Name( + kind: .classKind, + 'PirateShip', + ), + ], +); + +// snippet-start#link +void main(List arguments) { + link(arguments, (input, output) async { + final usesUri = input.recordedUsagesFile; + if (usesUri == null) return; + final usesJson = await File.fromUri(usesUri).readAsString(); + final uses = Recordings.fromJson( + jsonDecode(usesJson) as Map, + ); + + // snippet-start#static-call + final calls = uses.calls[methodId] ?? []; + for (final call in calls) { + switch (call) { + case CallWithArguments( + positionalArguments: [StringConstant(value: final english), ...], + ): + // Shrink a translations file based on all the different translation + // keys. + print('Translating to pirate: $english'); + case _: + print('Cannot determine which translations are used.'); + } + } + // snippet-end#static-call + + // snippet-start#const-instance + final ships = uses.instances[classId] ?? []; + for (final ship in ships) { + switch (ship) { + case InstanceConstantReference( + instanceConstant: InstanceConstant( + fields: {'name': StringConstant(value: final name)}, + ), + ): + // Include the 3d model for this ship in the application but not + // bundle the other ships. + print('Pirate ship found: $name'); + case _: + print('Cannot determine which ships are used.'); + } + } + // snippet-end#const-instance + }); +} + +// snippet-end#link diff --git a/pkgs/record_use/lib/record_use.dart b/pkgs/record_use/lib/record_use.dart index 0bfb7fa750..7b6196660d 100644 --- a/pkgs/record_use/lib/record_use.dart +++ b/pkgs/record_use/lib/record_use.dart @@ -2,7 +2,129 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export 'src/identifier.dart' show Identifier; +/// @docImport 'src/recordings.dart'; + +/// This package provides the data classes for the usage recording feature in +/// the Dart SDK. +/// +/// Dart objects with the `@RecordUse()` annotation are being recorded at +/// compile time, providing the user with information. The information depends +/// on the object being recorded. +/// +/// The main entrypoint for recorded usages is [Recordings]. +/// +/// - If placed on a static method, the annotation means that arguments passed +/// to the method will be recorded, as far as they can be inferred at compile +/// time. These can be found in [Recordings.calls]. +/// - If placed on a class, the annotation means that any constant instance of +/// the class and any constructor invocation will be recorded. These can be +/// found in [Recordings.instances]. +/// +/// > [!NOTE] +/// > The `@RecordUse()` annotation is only allowed on definitions within a +/// > package's `lib/` directory. This includes definitions that are members of +/// > a class, such as static methods. +/// +/// ## Example +/// +/// +/// ```dart +/// void main() { +/// PirateTranslator.speak('Hello'); +/// print(const PirateShip('Black Pearl', 50)); +/// } +/// +/// abstract class PirateTranslator { +/// @RecordUse() +/// static String speak(String english) => 'Ahoy $english'; +/// } +/// +/// @RecordUse() +/// final class PirateShip { +/// final String name; +/// final int cannons; +/// +/// const PirateShip(this.name, this.cannons); +/// } +/// ``` +/// This code will generate a data file that contains both the field values of +/// the `PirateShip` instances, as well as the arguments for the `speak` +/// method annotated with `@RecordUse()`. +/// +/// This information can then be accessed in a link hook as follows: +/// +/// ```dart +/// void main(List arguments) { +/// link(arguments, (input, output) async { +/// final usesUri = input.recordedUsagesFile; +/// if (usesUri == null) return; +/// final usesJson = await File.fromUri(usesUri).readAsString(); +/// final uses = Recordings.fromJson( +/// jsonDecode(usesJson) as Map, +/// ); +/// +/// final calls = uses.calls[methodId] ?? []; +/// for (final call in calls) { +/// switch (call) { +/// case CallWithArguments( +/// positionalArguments: [StringConstant(value: final english), ...], +/// ): +/// // Shrink a translations file based on all the different translation +/// // keys. +/// print('Translating to pirate: $english'); +/// case _: +/// print('Cannot determine which translations are used.'); +/// } +/// } +/// +/// final ships = uses.instances[classId] ?? []; +/// for (final ship in ships) { +/// switch (ship) { +/// case InstanceConstantReference( +/// instanceConstant: InstanceConstant( +/// fields: {'name': StringConstant(value: final name)}, +/// ), +/// ): +/// // Include the 3d model for this ship in the application but not +/// // bundle the other ships. +/// print('Pirate ship found: $name'); +/// case _: +/// print('Cannot determine which ships are used.'); +/// } +/// } +/// }); +/// } +/// ``` +library; + +export 'src/constant.dart' + show + BoolConstant, + Constant, + DoubleConstant, + EnumConstant, + InstanceConstant, + IntConstant, + ListConstant, + MapConstant, + MaybeConstant, + NonConstant, + NullConstant, + RecordConstant, + StringConstant, + SymbolConstant, + UnsupportedConstant; +export 'src/definition.dart' + show Definition, DefinitionDisambiguator, DefinitionKind, Name; +export 'src/loading_unit.dart' show LoadingUnit; export 'src/metadata.dart' show Metadata; -export 'src/record_use.dart' show ConstantInstance, RecordedUsages; -export 'src/recorded_usage_from_file.dart' show parseFromFile; +export 'src/recordings.dart' show Recordings; +export 'src/reference.dart' + show + CallReference, + CallTearoff, + CallWithArguments, + ConstructorTearoffReference, + InstanceConstantReference, + InstanceCreationReference, + InstanceReference; diff --git a/pkgs/record_use/lib/record_use_internal.dart b/pkgs/record_use/lib/record_use_internal.dart deleted file mode 100644 index 06a086c298..0000000000 --- a/pkgs/record_use/lib/record_use_internal.dart +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -export 'src/constant.dart' - show - BoolConstant, - Constant, - InstanceConstant, - IntConstant, - ListConstant, - MapConstant, - NullConstant, - PrimitiveConstant, - StringConstant; -export 'src/definition.dart' show Definition; -export 'src/identifier.dart' show Identifier; -export 'src/location.dart' show Location; -export 'src/metadata.dart' show Metadata; -export 'src/record_use.dart' show RecordedUsages; -export 'src/recordings.dart' - show FlattenConstantsExtension, MapifyIterableExtension, Recordings; -export 'src/reference.dart' - show CallReference, CallTearOff, CallWithArguments, InstanceReference; -export 'src/version.dart' show version; diff --git a/pkgs/record_use/lib/src/canonicalization_context.dart b/pkgs/record_use/lib/src/canonicalization_context.dart new file mode 100644 index 0000000000..48db29d1da --- /dev/null +++ b/pkgs/record_use/lib/src/canonicalization_context.dart @@ -0,0 +1,51 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'constant.dart'; +import 'definition.dart'; +import 'loading_unit.dart'; + +/// A context used to canonicalize [Definition]s, [LoadingUnit]s, and +/// [MaybeConstant]s. +class CanonicalizationContext { + final Set _definitions = {}; + final Set _loadingUnits = {}; + final Set _constants = {}; + + /// Canonicalizes the given [Definition]. + Definition canonicalizeDefinition(Definition definition) { + final existing = _definitions.lookup(definition); + if (existing != null) return existing; + final canonical = definition.canonicalizeChildren(this); + _definitions.add(canonical); + return canonical; + } + + /// Canonicalizes the given [LoadingUnit]. + LoadingUnit canonicalizeLoadingUnit(LoadingUnit loadingUnit) { + final existing = _loadingUnits.lookup(loadingUnit); + if (existing != null) return existing; + final canonical = loadingUnit.canonicalizeChildren(this); + _loadingUnits.add(canonical); + return canonical; + } + + /// Canonicalizes the given [MaybeConstant]. + MaybeConstant canonicalizeConstant(MaybeConstant constant) { + final existing = _constants.lookup(constant); + if (existing != null) return existing; + final canonical = constant.canonicalizeChildren(this); + _constants.add(canonical); + return canonical; + } + + /// All canonicalized [Definition]s. + Iterable get definitions => _definitions; + + /// All canonicalized [LoadingUnit]s. + Iterable get loadingUnits => _loadingUnits; + + /// All canonicalized [MaybeConstant]s. + Iterable get constants => _constants; +} diff --git a/pkgs/record_use/lib/src/constant.dart b/pkgs/record_use/lib/src/constant.dart index 0f6d2ad24f..a78daa257e 100644 --- a/pkgs/record_use/lib/src/constant.dart +++ b/pkgs/record_use/lib/src/constant.dart @@ -2,214 +2,890 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:math'; + +import 'package:meta/meta.dart'; + +import 'canonicalization_context.dart'; +import 'definition.dart'; import 'helper.dart'; +import 'serialization_context.dart'; import 'syntax.g.dart'; -/// A constant value that can be recorded and serialized. -/// -/// This supports basic constants such as [bool]s or [int]s, as well as -/// [ListConstant], [MapConstant] or [InstanceConstant] for more complex -/// structures. -/// -/// This follows the AST constant concept from the Dart SDK. -sealed class Constant { - /// Creates a [Constant] object. - const Constant(); +/// A value recorded during compilation. +sealed class MaybeConstant { + const MaybeConstant(); - /// Converts this [Constant] object to a JSON representation. + /// The maximum depth of the constant tree. /// - /// [constants] needs to be passed, as the [Constant]s are normalized and - /// stored separately in the JSON. - Map toJson(Map constants) => - _toSyntax(constants).json; - - /// Converts this [Constant] object to a syntax representation. - ConstantSyntax _toSyntax(Map constants); - - /// Converts this [Constant] to the value it represents. - Object? toValue() => switch (this) { - NullConstant() => null, - final PrimitiveConstant p => p.value, - final ListConstant l => l.value.map((c) => c.toValue()).toList(), - final MapConstant m => m.value.map( - (key, value) => MapEntry(key, value.toValue()), - ), - final InstanceConstant i => i.fields.map( - (key, value) => MapEntry(key, value.toValue()), - ), - }; + /// Used for fast-path optimization in `operator ==`. Not included in + /// `hashCode` because it is implicitly covered by the content-based hash. + int get _depth; - /// Creates a [Constant] object from its JSON representation. + /// The total number of nodes in the constant tree. /// - /// [constants] needs to be passed, as the [Constant]s are normalized and - /// stored separately in the JSON. - static Constant fromJson( - Map value, - List constants, - ) => _fromSyntax(ConstantSyntax.fromJson(value), constants); - - /// Creates a [Constant] object from its syntax representation. - static Constant _fromSyntax( + /// Used for fast-path optimization in `operator ==`. Not included in + /// `hashCode` because it is implicitly covered by the content-based hash. + int get _size; + + /// Canonicalizes this [MaybeConstant]. + MaybeConstant _canonicalizeChildren(CanonicalizationContext context); + + /// Returns a new [MaybeConstant] that only contains information allowed + /// by the provided criteria. + /// + /// If [definitionPackageName] is provided, constants that are instances of + /// classes or enums from other packages are replaced with an + /// [UnsupportedConstant]. + MaybeConstant _filter({String? definitionPackageName}); + + /// Compares this [MaybeConstant] with [other] for stable sorting. + int _compareTo(MaybeConstant other) { + if (identical(this, other)) return 0; + // By comparing the depth first, the serialization order of constants + // always has the children serialized before the parents. + var compare = _depth.compareTo(other._depth); + if (compare != 0) return compare; + compare = _orderingTypePriority.compareTo(other._orderingTypePriority); + if (compare != 0) return compare; + compare = _size.compareTo(other._size); + if (compare != 0) return compare; + return _compareToSameType(other); + } + + /// Internal comparison for objects of the same type. + @protected + int _compareToSameType(covariant MaybeConstant other); + + /// A stable priority for this type. + @protected + int get _orderingTypePriority; + + /// Compares this [MaybeConstant] with [other] for semantic equality. + /// + /// If [allowPromotionOfUnsupported] is true, an [UnsupportedConstant] in + /// [other] matches any [Constant] in this. + @visibleForTesting + bool semanticEquals( + MaybeConstant other, { + bool allowPromotionOfUnsupported = false, + }); + + /// Converts this [MaybeConstant] object to a syntax representation. + ConstantSyntax _toSyntax(SerializationContext context); + + /// Creates a [MaybeConstant] object from its syntax representation. + static MaybeConstant _fromSyntax( ConstantSyntax syntax, - List constants, + DeserializationContext context, ) => switch (syntax) { + NonConstantConstantSyntax() => const NonConstant(), NullConstantSyntax() => const NullConstant(), BoolConstantSyntax(:final value) => BoolConstant(value), IntConstantSyntax(:final value) => IntConstant(value), + DoubleConstantSyntax(value: final doubleValue) => DoubleConstant( + switch (doubleValue.type) { + 'number' => doubleValue.asNumberDoubleConstantValue.value!, + 'positive_infinity' => double.infinity, + 'negative_infinity' => double.negativeInfinity, + 'not_a_number' => double.nan, + _ => throw FormatException( + 'Invalid double constant type: ${doubleValue.type}', + ), + }, + ), StringConstantSyntax(:final value) => StringConstant(value), + SymbolConstantSyntax(:final name, :final libraryUri) => SymbolConstant( + name, + libraryUri: libraryUri, + ), ListConstantSyntax(:final value) => ListConstant( - value!.cast().map((i) => constants[i]).toList(), + value!.cast().map((i) { + final constant = context.constants[i]; + if (constant is! Constant) { + throw FormatException( + 'List constant element at index $i is not a constant', + ); + } + return constant; + }).toList(), ), MapConstantSyntax(:final value) => MapConstant( - value.json.map((key, value) => MapEntry(key, constants[value as int])), + value.map( + (e) { + final key = context.constants[e.key]; + if (key is! Constant) { + throw FormatException( + 'Map constant key at index ${e.key} is not a constant', + ); + } + final value = context.constants[e.value]; + if (value is! Constant) { + throw FormatException( + 'Map constant value at index ${e.value} is not a constant', + ); + } + return MapEntry(key, value); + }, + ).toList(), ), - InstanceConstantSyntax(value: final value) => InstanceConstant( - fields: (value?.json ?? {}).map( - (key, value) => MapEntry(key, constants[value as int]), + InstanceConstantSyntax(value: final value, :final definitionIndex) => + InstanceConstant( + definition: context.definitions[definitionIndex], + fields: (value?.json ?? {}).map( + (key, index) { + final constant = context.constants[index as int]; + if (constant is! Constant) { + throw FormatException( + 'Instance constant field $key at index $index is not ' + 'a constant', + ); + } + return MapEntry(key, constant); + }, + ), + ), + EnumConstantSyntax( + value: final value, + :final definitionIndex, + :final index, + :final name, + ) => + EnumConstant( + definition: context.definitions[definitionIndex], + index: index, + name: name, + fields: (value ?? {}).map( + (key, index) { + final constant = context.constants[index]; + if (constant is! Constant) { + throw FormatException( + 'Enum constant field $key at index $index is not ' + 'a constant', + ); + } + return MapEntry(key, constant); + }, + ), ), + RecordConstantSyntax(:final positional, :final named) => RecordConstant( + positional: (positional ?? const []).map((i) { + final constant = context.constants[i]; + if (constant is! Constant) { + throw FormatException( + 'Record constant positional field at index $i is not ' + 'a constant', + ); + } + return constant; + }).toList(), + named: (named ?? const {}).map( + (key, index) { + final constant = context.constants[index]; + if (constant is! Constant) { + throw FormatException( + 'Record constant named field $key at index $index is not ' + 'a constant', + ); + } + return MapEntry(key, constant); + }, + ), + ), + UnsupportedConstantSyntax(:final message) => UnsupportedConstant(message), + _ => throw UnimplementedError( + '"${syntax.type}" is not a supported constant type', ), - _ => throw UnimplementedError('This type is not a supported constant'), }; } -/// Represents the `null` constant value. +/// A value that is not a constant. +final class NonConstant extends MaybeConstant { + const NonConstant(); + + @override + NonConstantConstantSyntax _toSyntax(SerializationContext context) => + NonConstantConstantSyntax(); + + @override + bool operator ==(Object other) => other is NonConstant; + + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + MaybeConstant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + MaybeConstant _filter({String? definitionPackageName}) => this; + + @override + int get hashCode => 0x4e6f6e43; + + @override + int get _orderingTypePriority => 0; + + @override + int _compareToSameType(NonConstant other) => 0; + + @override + String toString() => 'NonConstant()'; + + @override + @visibleForTesting + bool semanticEquals( + MaybeConstant other, { + bool allowPromotionOfUnsupported = false, + }) => other is NonConstant; +} + +/// A constant value that can be recorded and serialized. +/// +/// This follows the AST constant concept from the Dart SDK. +/// +/// This class is intentionally not sealed. Adding new subtypes of [Constant] +/// should not be a breaking change for users of this package. Users should +/// use a wildcard pattern or a default case when switching over [Constant]. +abstract class Constant extends MaybeConstant { + /// Creates a [Constant] object. + const Constant(); + + @override + Constant _canonicalizeChildren(CanonicalizationContext context); + + @override + Constant _filter({String? definitionPackageName}); + + @override + @visibleForTesting + bool semanticEquals( + MaybeConstant other, { + bool allowPromotionOfUnsupported = false, + }) { + if (this == other) return true; + if (allowPromotionOfUnsupported && other is UnsupportedConstant) { + return true; + } + return _semanticEqualsInternal(other, allowPromotionOfUnsupported); + } + + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ); +} + +/// The `null` constant value. final class NullConstant extends Constant { /// Creates a [NullConstant] object. const NullConstant() : super(); @override - NullConstantSyntax _toSyntax(Map constants) => + NullConstantSyntax _toSyntax(SerializationContext context) => NullConstantSyntax(); @override bool operator ==(Object other) => other is NullConstant; @override - int get hashCode => 0; + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + int get hashCode => 0x4e756c6c; + + @override + int get _orderingTypePriority => 2; + + @override + int _compareToSameType(NullConstant other) => 0; + + @override + String toString() => 'NullConstant()'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => other is NullConstant; } -/// Represents a constant value of a primitive type. -sealed class PrimitiveConstant extends Constant { - /// The underlying value of this constant. - final T value; +/// A constant value in Dart but not supported in `package:record_use`. +final class UnsupportedConstant extends Constant { + /// The reason why this constant is unsupported. + final String message; - /// Creates a [PrimitiveConstant] object with the given [value]. - const PrimitiveConstant(this.value); + /// Creates an [UnsupportedConstant] object with the given [message]. + const UnsupportedConstant(this.message); @override - int get hashCode => value.hashCode; + UnsupportedConstantSyntax _toSyntax(SerializationContext context) => + UnsupportedConstantSyntax(message: message); @override - bool operator ==(Object other) { - if (identical(this, other)) return true; + bool operator ==(Object other) => + other is UnsupportedConstant && other.message == message; - return other is PrimitiveConstant && other.value == value; - } + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + int get hashCode => message.hashCode; + + @override + int get _orderingTypePriority => 1; + + @override + int _compareToSameType(UnsupportedConstant other) => + message.compareTo(other.message); + + @override + String toString() => 'UnsupportedConstant($message)'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => other is UnsupportedConstant && other.message == message; } -/// Represents a constant boolean value. -final class BoolConstant extends PrimitiveConstant { +/// A constant boolean value. +final class BoolConstant extends Constant { + /// The underlying value of this constant. + final bool value; + /// Creates a [BoolConstant] object with the given boolean [value]. // ignore: avoid_positional_boolean_parameters - const BoolConstant(super.value); + const BoolConstant(this.value); @override - BoolConstantSyntax _toSyntax(Map constants) => + BoolConstantSyntax _toSyntax(SerializationContext context) => BoolConstantSyntax(value: value); + + @override + int get hashCode => value.hashCode; + + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + bool operator ==(Object other) => + other is BoolConstant && other.value == value; + + @override + int get _orderingTypePriority => 3; + + @override + int _compareToSameType(BoolConstant other) { + if (value == other.value) return 0; + return value ? 1 : -1; + } + + @override + String toString() => 'BoolConstant($value)'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => other is BoolConstant && other.value == value; } -/// Represents a constant integer value. -final class IntConstant extends PrimitiveConstant { +/// A constant integer value. +final class IntConstant extends Constant { + /// The underlying value of this constant. + final int value; + /// Creates an [IntConstant] object with the given integer [value]. - const IntConstant(super.value); + const IntConstant(this.value); @override - IntConstantSyntax _toSyntax(Map constants) => + IntConstantSyntax _toSyntax(SerializationContext context) => IntConstantSyntax(value: value); + + @override + int get hashCode => value.hashCode; + + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + bool operator ==(Object other) => + other is IntConstant && other.value == value; + + @override + int get _orderingTypePriority => 4; + + @override + int _compareToSameType(IntConstant other) => value.compareTo(other.value); + + @override + String toString() => 'IntConstant($value)'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => other is IntConstant && other.value == value; } -/// Represents a constant string value. -final class StringConstant extends PrimitiveConstant { +/// A constant double value. +final class DoubleConstant extends Constant { + /// The underlying value of this constant. + final double value; + + /// Creates a [DoubleConstant] object with the given double [value]. + const DoubleConstant(this.value); + + @override + DoubleConstantSyntax _toSyntax(SerializationContext context) { + final DoubleConstantValueSyntax syntaxValue; + if (value.isNaN) { + syntaxValue = NotANumberDoubleConstantValueSyntax(); + } else if (value == double.infinity) { + syntaxValue = PositiveInfinityDoubleConstantValueSyntax(); + } else if (value == double.negativeInfinity) { + syntaxValue = NegativeInfinityDoubleConstantValueSyntax(); + } else { + syntaxValue = NumberDoubleConstantValueSyntax(value: value); + } + return DoubleConstantSyntax(value: syntaxValue); + } + + @override + int get hashCode => Object.hash(value, value.isNegative); + + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + bool operator ==(Object other) => + other is DoubleConstant && value.compareTo(other.value) == 0; + + @override + int get _orderingTypePriority => 5; + + @override + int _compareToSameType(DoubleConstant other) => value.compareTo(other.value); + + @override + String toString() => 'DoubleConstant($value)'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => other is DoubleConstant && value.compareTo(other.value) == 0; +} + +/// A constant string value. +final class StringConstant extends Constant { + /// The underlying value of this constant. + final String value; + /// Creates a [StringConstant] object with the given string [value]. - const StringConstant(super.value); + const StringConstant(this.value); @override - StringConstantSyntax _toSyntax(Map constants) => + StringConstantSyntax _toSyntax(SerializationContext context) => StringConstantSyntax(value: value); + + @override + int get hashCode => value.hashCode; + + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + bool operator ==(Object other) => + other is StringConstant && other.value == value; + + @override + int get _orderingTypePriority => 6; + + @override + int _compareToSameType(StringConstant other) => value.compareTo(other.value); + + @override + String toString() => 'StringConstant($value)'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => other is StringConstant && other.value == value; } -/// Represents a constant list of [Constant] values. -final class ListConstant extends Constant { +/// A constant symbol value. +final class SymbolConstant extends Constant { + /// The name of the symbol. + final String name; + + /// The library URI if this is a private symbol (starts with '_'). + /// Null for public symbols. + final String? libraryUri; + + /// Creates a [SymbolConstant] object with the given [name] and optional + /// [libraryUri]. + const SymbolConstant(this.name, {this.libraryUri}); + + @override + SymbolConstantSyntax _toSyntax(SerializationContext context) => + SymbolConstantSyntax(name: name, libraryUri: libraryUri); + + @override + int get hashCode => Object.hash(name, libraryUri); + + @override + int get _depth => 1; + + @override + int get _size => 1; + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + Constant _filter({String? definitionPackageName}) => this; + + @override + bool operator ==(Object other) => + other is SymbolConstant && + other.name == name && + other.libraryUri == libraryUri; + + @override + int get _orderingTypePriority => 7; + + @override + int _compareToSameType(SymbolConstant other) { + final nameCompare = name.compareTo(other.name); + if (nameCompare != 0) return nameCompare; + if (libraryUri == null) return other.libraryUri == null ? 0 : -1; + if (other.libraryUri == null) return 1; + return libraryUri!.compareTo(other.libraryUri!); + } + + @override + String toString() { + if (libraryUri == null) { + return '#$name'; + } + return '$libraryUri::#$name'; + } + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) => + other is SymbolConstant && + other.name == name && + other.libraryUri == libraryUri; +} + +/// A constant list of [Constant] values. +final class ListConstant extends Constant { /// The underlying list of constant values. - final List value; + final List value; /// Creates a [ListConstant] object with the given list of [value]s. const ListConstant(this.value); @override - int get hashCode => deepHash(value); + int get hashCode => cacheHashCode(() => deepHash(value)); + + @override + int get _depth => cacheDepth(() { + var depth = 0; + for (final constant in value) { + depth = max(depth, constant._depth); + } + return 1 + depth; + }); + + @override + int get _size => cacheSize(() { + var size = 0; + for (final constant in value) { + size += constant._size; + } + return 1 + size; + }); + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) => + ListConstant([ + for (final c in value) context.canonicalizeConstant(c) as Constant, + ]); + + @override + Constant _filter({String? definitionPackageName}) => ListConstant([ + for (final c in value) + c._filter(definitionPackageName: definitionPackageName), + ]); @override bool operator ==(Object other) { if (identical(this, other)) return true; - return other is ListConstant && deepEquals(other.value, value); + return other is ListConstant && + other._depth == _depth && + other._size == _size && + deepEquals(other.value, value); } @override - ListConstantSyntax _toSyntax(Map constants) => + ListConstantSyntax _toSyntax(SerializationContext context) => ListConstantSyntax( - value: value.map((constant) => constants[constant]).toList(), + value: [for (final constant in value) context.constants[constant]!], ); + + @override + int get _orderingTypePriority => 8; + + @override + int _compareToSameType(ListConstant other) { + final lengthCompare = value.length.compareTo(other.value.length); + if (lengthCompare != 0) return lengthCompare; + for (var i = 0; i < value.length; i++) { + final itemCompare = value[i]._compareTo(other.value[i]); + if (itemCompare != 0) return itemCompare; + } + return 0; + } + + @override + String toString() => 'ListConstant([${value.join(', ')}])'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) { + if (other is! ListConstant) return false; + if (value.length != other.value.length) return false; + for (var i = 0; i < value.length; i++) { + if (!value[i].semanticEquals( + other.value[i], + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + return true; + } } -/// Represents a constant map from string keys to [Constant] values. -final class MapConstant extends Constant { +/// A constant map from [Constant] keys to [Constant] values. +final class MapConstant extends Constant { /// The underlying map of constant values. - final Map value; + final List> entries; - /// Creates a [MapConstant] object with the given map of [value]s. - const MapConstant(this.value); + /// Creates a [MapConstant] object with the given map of entries. + const MapConstant(this.entries); @override - int get hashCode => deepHash(value); + int get hashCode => cacheHashCode( + () => Object.hashAll( + entries.map((e) => Object.hash(e.key, e.value)), + ), + ); + + @override + int get _depth => cacheDepth(() { + var depth = 0; + for (final entry in entries) { + depth = max(depth, max(entry.key._depth, entry.value._depth)); + } + return 1 + depth; + }); + + @override + int get _size => cacheSize(() { + var size = 0; + for (final entry in entries) { + size += entry.key._size + entry.value._size; + } + return 1 + size; + }); + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) { + final canonEntries = [ + for (final e in entries) + MapEntry( + context.canonicalizeConstant(e.key) as Constant, + context.canonicalizeConstant(e.value) as Constant, + ), + ]; + canonEntries.sort((a, b) => a.key._compareTo(b.key)); + return MapConstant(canonEntries); + } + + @override + Constant _filter({String? definitionPackageName}) => MapConstant([ + for (final entry in entries) + MapEntry( + entry.key._filter(definitionPackageName: definitionPackageName), + entry.value._filter(definitionPackageName: definitionPackageName), + ), + ]); @override bool operator ==(Object other) { if (identical(this, other)) return true; - return other is MapConstant && deepEquals(other.value, value); + if (other is! MapConstant) return false; + if (other._depth != _depth || other._size != _size) return false; + if (other.entries.length != entries.length) return false; + for (var i = 0; i < entries.length; i++) { + if (entries[i].key != other.entries[i].key || + entries[i].value != other.entries[i].value) { + return false; + } + } + return true; } @override - MapConstantSyntax _toSyntax(Map constants) => + MapConstantSyntax _toSyntax(SerializationContext context) => MapConstantSyntax( - value: JsonObjectSyntax.fromJson( - value.map((key, constant) => MapEntry(key, constants[constant]!)), - ), + value: [ + for (final entry in entries) + MapEntrySyntax( + key: context.constants[entry.key]!, + value: context.constants[entry.value]!, + ), + ], ); + + @override + int get _orderingTypePriority => 9; + + @override + int _compareToSameType(MapConstant other) { + final lengthCompare = entries.length.compareTo(other.entries.length); + if (lengthCompare != 0) return lengthCompare; + for (var i = 0; i < entries.length; i++) { + final keyCompare = entries[i].key._compareTo(other.entries[i].key); + if (keyCompare != 0) return keyCompare; + final valueCompare = entries[i].value._compareTo(other.entries[i].value); + if (valueCompare != 0) return valueCompare; + } + return 0; + } + + @override + String toString() => + 'MapConstant({${entries.map((e) => '${e.key}: ${e.value}').join(', ')}})'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) { + if (other is! MapConstant) return false; + if (entries.length != other.entries.length) return false; + for (var i = 0; i < entries.length; i++) { + if (!entries[i].key.semanticEquals( + other.entries[i].key, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + ) || + !entries[i].value.semanticEquals( + other.entries[i].value, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + return true; + } } -/// A constant instance of a class with its fields +/// A constant instance of a class with its fields. /// /// Only as far as they can also be represented by constants. This is more or /// less the same as a [MapConstant]. +/// +/// Fields initialized by default constructor values are also included in +/// [fields]. final class InstanceConstant extends Constant { + /// The definition of the class of this instance. + final Definition definition; + /// The fields of this instance, mapped from field name to [Constant] value. final Map fields; - /// Creates an [InstanceConstant] object with the given [fields]. - const InstanceConstant({required this.fields}); + /// Creates an [InstanceConstant] object with the given [definition] and + /// [fields]. + const InstanceConstant({required this.definition, required this.fields}); @override - InstanceConstantSyntax _toSyntax(Map constants) => + InstanceConstantSyntax _toSyntax(SerializationContext context) => InstanceConstantSyntax( + definitionIndex: context.definitions[definition]!, value: fields.isNotEmpty - ? JsonObjectSyntax.fromJson( - fields.map( - (name, constant) => MapEntry(name, constants[constant]!), - ), - ) + ? JsonObjectSyntax.fromJson({ + for (final entry in fields.entries) + entry.key: context.constants[entry.value]!, + }) : null, ); @@ -217,20 +893,471 @@ final class InstanceConstant extends Constant { bool operator ==(Object other) { if (identical(this, other)) return true; - return other is InstanceConstant && deepEquals(other.fields, fields); + return other is InstanceConstant && + other._depth == _depth && + other._size == _size && + other.definition == definition && + deepEquals(other.fields, fields); + } + + @override + int get hashCode => + cacheHashCode(() => Object.hash(definition, deepHash(fields))); + + @override + int get _depth => cacheDepth(() { + var depth = 0; + for (final field in fields.values) { + depth = max(depth, field._depth); + } + return 1 + depth; + }); + + @override + int get _size => cacheSize(() { + var size = 0; + for (final field in fields.values) { + size += field._size; + } + return 1 + size; + }); + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) { + final sortedEntries = fields.entries.toList() + ..sort((a, b) => a.key.compareTo(b.key)); + return InstanceConstant( + definition: context.canonicalizeDefinition(definition), + fields: { + for (final e in sortedEntries) + e.key: context.canonicalizeConstant(e.value) as Constant, + }, + ); + } + + @override + Constant _filter({String? definitionPackageName}) { + if (definitionPackageName != null && + !definition.library.startsWith('package:$definitionPackageName/')) { + return UnsupportedConstant( + 'Instance of $definition from other package is not supported.', + ); + } + return InstanceConstant( + definition: definition, + fields: fields.map( + (key, value) => MapEntry( + key, + value._filter(definitionPackageName: definitionPackageName), + ), + ), + ); } @override - int get hashCode => deepHash(fields); + int get _orderingTypePriority => 12; + + @override + int _compareToSameType(InstanceConstant other) { + final definitionCompare = definition.compareTo(other.definition); + if (definitionCompare != 0) return definitionCompare; + final lengthCompare = fields.length.compareTo(other.fields.length); + if (lengthCompare != 0) return lengthCompare; + final sortedKeys = fields.keys.toList()..sort(); + final otherSortedKeys = other.fields.keys.toList()..sort(); + for (var i = 0; i < sortedKeys.length; i++) { + final keyCompare = sortedKeys[i].compareTo(otherSortedKeys[i]); + if (keyCompare != 0) return keyCompare; + final valueCompare = fields[sortedKeys[i]]!._compareTo( + other.fields[otherSortedKeys[i]]!, + ); + if (valueCompare != 0) return valueCompare; + } + return 0; + } + + @override + String toString() => + 'InstanceConstant($definition, {' + '${fields.entries.map((e) => '${e.key}: ${e.value}').join(', ')}})'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) { + if (other is! InstanceConstant) return false; + // ignore: invalid_use_of_visible_for_testing_member + if (!definition.semanticEquals(other.definition)) return false; + if (fields.length != other.fields.length) return false; + for (final entry in fields.entries) { + final otherField = other.fields[entry.key]; + if (otherField == null || + !entry.value.semanticEquals( + otherField, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + return true; + } } -/// Package private (protected) methods for [Constant]. +/// A constant enum value. +/// +/// Fields initialized by default constructor values (for enhanced enums) are +/// also included in [fields]. +final class EnumConstant extends Constant { + /// The definition of the enum class of this value. + final Definition definition; + + /// The index of the enum member. + final int index; + + /// The name of the enum member. + final String name; + + /// The fields of this instance, mapped from field name to [Constant] value. + /// + /// This includes additional fields from enhanced enums. + final Map fields; + + /// Creates an [EnumConstant] object with the given [definition], [index], + /// [name], and [fields]. + const EnumConstant({ + required this.definition, + required this.index, + required this.name, + this.fields = const {}, + }); + + @override + EnumConstantSyntax _toSyntax(SerializationContext context) => + EnumConstantSyntax( + definitionIndex: context.definitions[definition]!, + index: index, + name: name, + value: fields.isNotEmpty + ? { + for (final entry in fields.entries) + entry.key: context.constants[entry.value]!, + } + : null, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + return other is EnumConstant && + other._depth == _depth && + other._size == _size && + other.definition == definition && + other.index == index && + other.name == name && + deepEquals(other.fields, fields); + } + + @override + int get hashCode => cacheHashCode( + () => Object.hash(definition, index, name, deepHash(fields)), + ); + + @override + int get _depth => cacheDepth(() { + var depth = 0; + for (final field in fields.values) { + depth = max(depth, field._depth); + } + return 1 + depth; + }); + + @override + int get _size => cacheSize(() { + var size = 0; + for (final field in fields.values) { + size += field._size; + } + return 1 + size; + }); + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) { + final sortedEntries = fields.entries.toList() + ..sort((a, b) => a.key.compareTo(b.key)); + return EnumConstant( + definition: context.canonicalizeDefinition(definition), + index: index, + name: name, + fields: { + for (final e in sortedEntries) + e.key: context.canonicalizeConstant(e.value) as Constant, + }, + ); + } + + @override + Constant _filter({String? definitionPackageName}) { + if (definitionPackageName != null && + !definition.library.startsWith('package:$definitionPackageName/')) { + return UnsupportedConstant( + 'Instance of $definition from other package is not supported.', + ); + } + return EnumConstant( + definition: definition, + index: index, + name: name, + fields: fields.map( + (key, value) => MapEntry( + key, + value._filter(definitionPackageName: definitionPackageName), + ), + ), + ); + } + + @override + int get _orderingTypePriority => 11; + + @override + int _compareToSameType(EnumConstant other) { + final definitionCompare = definition.compareTo(other.definition); + if (definitionCompare != 0) return definitionCompare; + final indexCompare = index.compareTo(other.index); + if (indexCompare != 0) return indexCompare; + final lengthCompare = fields.length.compareTo(other.fields.length); + if (lengthCompare != 0) return lengthCompare; + final sortedKeys = fields.keys.toList()..sort(); + final otherSortedKeys = other.fields.keys.toList()..sort(); + for (var i = 0; i < sortedKeys.length; i++) { + final keyCompare = sortedKeys[i].compareTo(otherSortedKeys[i]); + if (keyCompare != 0) return keyCompare; + final valueCompare = fields[sortedKeys[i]]!._compareTo( + other.fields[otherSortedKeys[i]]!, + ); + if (valueCompare != 0) return valueCompare; + } + return 0; + } + + @override + String toString() => + 'EnumConstant($definition, index: $index, name: $name, fields: {' + '${fields.entries.map((e) => '${e.key}: ${e.value}').join(', ')}})'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) { + if (other is! EnumConstant) return false; + // ignore: invalid_use_of_visible_for_testing_member + if (!definition.semanticEquals(other.definition)) return false; + if (index != other.index || name != other.name) return false; + if (fields.length != other.fields.length) return false; + for (final entry in fields.entries) { + final otherField = other.fields[entry.key]; + if (otherField == null || + !entry.value.semanticEquals( + otherField, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + return true; + } +} + +/// A constant record value. +final class RecordConstant extends Constant { + /// The positional fields of this record. + final List positional; + + /// The named fields of this record. + final Map named; + + /// Creates a [RecordConstant] object with the given [positional] and [named] + /// fields. + const RecordConstant({ + this.positional = const [], + this.named = const {}, + }); + + @override + RecordConstantSyntax _toSyntax(SerializationContext context) => + RecordConstantSyntax( + positional: positional.isNotEmpty + ? [for (final c in positional) context.constants[c]!] + : null, + named: named.isNotEmpty + ? { + for (final entry in named.entries) + entry.key: context.constants[entry.value]!, + } + : null, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + return other is RecordConstant && + other._depth == _depth && + other._size == _size && + deepEquals(other.positional, positional) && + deepEquals(other.named, named); + } + + @override + int get hashCode => cacheHashCode( + () => Object.hash(deepHash(positional), deepHash(named)), + ); + + @override + int get _depth => cacheDepth(() { + var depth = 0; + for (final constant in positional) { + depth = max(depth, constant._depth); + } + for (final constant in named.values) { + depth = max(depth, constant._depth); + } + return 1 + depth; + }); + + @override + int get _size => cacheSize(() { + var size = 0; + for (final constant in positional) { + size += constant._size; + } + for (final constant in named.values) { + size += constant._size; + } + return 1 + size; + }); + + @override + Constant _canonicalizeChildren(CanonicalizationContext context) { + final sortedNamedEntries = named.entries.toList() + ..sort((a, b) => a.key.compareTo(b.key)); + return RecordConstant( + positional: [ + for (final c in positional) context.canonicalizeConstant(c) as Constant, + ], + named: { + for (final e in sortedNamedEntries) + e.key: context.canonicalizeConstant(e.value) as Constant, + }, + ); + } + + @override + Constant _filter({String? definitionPackageName}) => RecordConstant( + positional: [ + for (final c in positional) + c._filter(definitionPackageName: definitionPackageName), + ], + named: named.map( + (key, value) => MapEntry( + key, + value._filter(definitionPackageName: definitionPackageName), + ), + ), + ); + + @override + int get _orderingTypePriority => 10; + + @override + int _compareToSameType(RecordConstant other) { + var compare = positional.length.compareTo(other.positional.length); + if (compare != 0) return compare; + compare = named.length.compareTo(other.named.length); + if (compare != 0) return compare; + for (var i = 0; i < positional.length; i++) { + compare = positional[i]._compareTo(other.positional[i]); + if (compare != 0) return compare; + } + final sortedKeys = named.keys.toList()..sort(); + final otherSortedKeys = other.named.keys.toList()..sort(); + for (var i = 0; i < sortedKeys.length; i++) { + compare = sortedKeys[i].compareTo(otherSortedKeys[i]); + if (compare != 0) return compare; + compare = named[sortedKeys[i]]!._compareTo( + other.named[otherSortedKeys[i]]!, + ); + if (compare != 0) return compare; + } + return 0; + } + + @override + String toString() => + 'RecordConstant(' + '${positional.join(', ')}' + '${positional.isNotEmpty && named.isNotEmpty ? ', ' : ''}' + '${named.entries.map((e) => '${e.key}: ${e.value}').join(', ')})'; + + @override + bool _semanticEqualsInternal( + MaybeConstant other, + bool allowPromotionOfUnsupported, + ) { + if (other is! RecordConstant) return false; + if (positional.length != other.positional.length) return false; + if (named.length != other.named.length) return false; + for (var i = 0; i < positional.length; i++) { + if (!positional[i].semanticEquals( + other.positional[i], + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + for (final entry in named.entries) { + final otherField = other.named[entry.key]; + if (otherField == null || + !entry.value.semanticEquals( + otherField, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + return true; + } +} + +/// Package private (protected) methods for [MaybeConstant]. /// /// This avoids bloating the public API and public API docs and prevents /// internal types from leaking from the API. -extension ConstantProtected on Constant { - ConstantSyntax toSyntax(Map constants) => _toSyntax(constants); +extension MaybeConstantProtected on MaybeConstant { + ConstantSyntax toSyntax(SerializationContext context) => _toSyntax(context); + + MaybeConstant canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context); + + MaybeConstant filter({String? definitionPackageName}) => + _filter(definitionPackageName: definitionPackageName); + + int compareTo(MaybeConstant other) => _compareTo(other); + + static MaybeConstant fromSyntax( + ConstantSyntax syntax, + DeserializationContext context, + ) => MaybeConstant._fromSyntax(syntax, context); - static Constant fromSyntax(ConstantSyntax syntax, List constants) => - Constant._fromSyntax(syntax, constants); + @visibleForTesting + bool semanticEquals( + MaybeConstant other, { + bool allowPromotionOfUnsupported = false, + }) => this.semanticEquals( + other, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + ); } diff --git a/pkgs/record_use/lib/src/definition.dart b/pkgs/record_use/lib/src/definition.dart index 025ed45b44..bbf71ec609 100644 --- a/pkgs/record_use/lib/src/definition.dart +++ b/pkgs/record_use/lib/src/definition.dart @@ -4,75 +4,307 @@ import 'package:meta/meta.dart'; -import 'identifier.dart'; +import 'canonicalization_context.dart'; +import 'helper.dart'; import 'syntax.g.dart'; -/// A definition is an [identifier] with its [loadingUnit]. +/// A unique identifier for a code element, such as a class, method, +/// or field, within a Dart program. +/// +/// A [Definition] is used to pinpoint a specific element based on its +/// location and name. +// TODO(https://github.com/dart-lang/native/issues/3062): Make this API more +// kind-centric, after we've added support for kinds and disambiguators in the +// compilers. class Definition { - final Identifier identifier; - final String? loadingUnit; + /// The URI of the library where the element is defined. + /// + /// This must be a `package:` URI, so that it is OS- and user independent. + /// + /// For elements annotated with `@RecordUse`, this URI will always point to a + /// file in the `lib/` directory of a package. + final String library; - const Definition({required this.identifier, this.loadingUnit}); + /// The hierarchical path to the element within the library. + final List path; - factory Definition.fromJson(Map json) => - Definition._fromSyntax(DefinitionSyntax.fromJson(json)); + /// Creates a [Definition] object. + const Definition(this.library, this.path); - factory Definition._fromSyntax(DefinitionSyntax syntax) => Definition( - identifier: IdentifierProtected.fromSyntax(syntax.identifier), - loadingUnit: syntax.loadingUnit, + /// Creates a [Definition] object from its syntax representation. + static Definition _fromSyntax(DefinitionSyntax syntax) => Definition( + syntax.uri, + syntax.definitionPath + .map( + (nameSyntax) => Name( + nameSyntax.name, + kind: nameSyntax.kind != null + ? DefinitionKind._fromName(nameSyntax.kind!) + : null, + disambiguators: + nameSyntax.disambiguators + ?.map(DefinitionDisambiguator._fromName) + .toSet() ?? + {}, + ), + ) + .toList(), ); - Map toJson() => _toSyntax().json; - + /// Converts this [Definition] object to a syntax representation. DefinitionSyntax _toSyntax() => DefinitionSyntax( - identifier: identifier.toSyntax(), - loadingUnit: loadingUnit, + uri: library, + definitionPath: path + .map( + (name) => NameSyntax( + name: name.name, + kind: name.kind?.toString(), + disambiguators: name.disambiguators.isEmpty + ? null + : name.disambiguators.map((d) => d.toString()).toList(), + ), + ) + .toList(), ); + /// Canonicalizes the children of this [Definition]. + Definition _canonicalizeChildren(CanonicalizationContext context) => + Definition( + library, + [for (final name in path) name._canonicalizeChildren(context)], + ); + + /// The parent, if it exists. + Definition? get parent => path.length > 1 + ? Definition(library, path.sublist(0, path.length - 1)) + : null; + @override bool operator ==(Object other) { if (identical(this, other)) return true; - return other is Definition && - other.identifier == identifier && - other.loadingUnit == loadingUnit; + if (other is! Definition) return false; + if (other.library != library) return false; + if (other.path.length != path.length) return false; + for (var i = 0; i < path.length; i++) { + if (other.path[i] != path[i]) return false; + } + return true; } @override - int get hashCode => Object.hash(identifier, loadingUnit); + int get hashCode => + cacheHashCode(() => Object.hash(library, Object.hashAll(path))); - /// Compares this [Definition] with [other] for semantic equality. + // This should align with [toString] ordering. + int _compareTo(Definition other) => toString().compareTo(other.toString()); + + /// Returns a URI representation of this definition. /// - /// The [loadingUnit] can be mapped using [loadingUnitMapping]. - /// If [allowLoadingUnitNull] is true, a null [loadingUnit] is considered - /// equal to any other loading unit. + /// The [library] is the base URI and the [path] is the fragment. + /// [Name]s in the [path] are separated by `::`. + @override + String toString() => '$library#${path.join('::')}'; + + /// Compares this [Definition] with [other] for semantic equality. /// - /// The [uriMapping] is passed on to the comparison of the [identifier]. + /// The [library] can be mapped using [uriMapping] before comparison. @visibleForTesting bool semanticEquals( Definition other, { - bool allowLoadingUnitNull = false, String Function(String)? uriMapping, - String Function(String)? loadingUnitMapping, }) { - final skipLoadingUnitComparison = - allowLoadingUnitNull && - (loadingUnit == null || other.loadingUnit == null); - if (!skipLoadingUnitComparison) { - final mappedLoadingUnit = - loadingUnit == null || loadingUnitMapping == null - ? loadingUnit - : loadingUnitMapping(loadingUnit!); - if (other.loadingUnit != mappedLoadingUnit) { - return false; - } + if (other.path.length != path.length) return false; + for (var i = 0; i < path.length; i++) { + if (other.path[i] != path[i]) return false; } - // ignore: invalid_use_of_visible_for_testing_member - return identifier.semanticEquals( - other.identifier, - uriMapping: uriMapping, + final mappedLibrary = uriMapping == null ? library : uriMapping(library); + return mappedLibrary == other.library; + } +} + +/// A component of a [Definition] path. +class Name { + /// The name of the element itself. + final String name; + + /// The kind of the element. + /// + /// TODO(https://github.com/dart-lang/native/issues/2888): Make this + /// non-nullable. + final DefinitionKind? kind; + + /// Optional disambiguators (e.g. to distinguish between static and instance + /// members in extensions and extension types). + final Set disambiguators; + + const Name( + this.name, { + this.kind, + this.disambiguators = const {}, + }); + + Name _canonicalizeChildren(CanonicalizationContext context) { + if (disambiguators.isEmpty) return this; + return Name( + name, + kind: kind, + disambiguators: Set.from( + disambiguators.toList()..sort((a, b) => a.compareTo(b)), + ), ); } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + if (other is! Name) return false; + if (other.name != name) return false; + if (other.kind != kind) return false; + if (other.disambiguators.length != disambiguators.length) return false; + return disambiguators.every(other.disambiguators.contains); + } + + @override + int get hashCode => cacheHashCode( + () => Object.hash(name, kind, Object.hashAllUnordered(disambiguators)), + ); + + /// Returns a string representation of this name that can be used as a part of + /// a URI fragment. + /// + /// The format is `kind:name@disambiguator1@disambiguator2`. + /// Disambiguators are sorted alphabetically. + @override + String toString() { + final buffer = StringBuffer(); + if (kind != null) { + buffer.write('$kind:'); + } + buffer.write(name); + if (disambiguators.isNotEmpty) { + final sorted = disambiguators.toList()..sort((a, b) => a.compareTo(b)); + for (final disambiguator in sorted) { + buffer.write('@$disambiguator'); + } + } + return buffer.toString(); + } +} + +/// The kind of code element represented by a [Name]. +/// +/// This is not an enum because adding new elements to an enum is a breaking +/// change for switch statements. By using a class with static const instances, +/// we can add new kinds without breaking existing code. +final class DefinitionKind { + final String _name; + const DefinitionKind._(this._name); + + static const classKind = DefinitionKind._('class'); + static const mixinKind = DefinitionKind._('mixin'); + static const enumKind = DefinitionKind._('enum'); + static const extensionKind = DefinitionKind._('extension'); + static const extensionTypeKind = DefinitionKind._('extension_type'); + static const methodKind = DefinitionKind._('method'); + static const getterKind = DefinitionKind._('getter'); + static const setterKind = DefinitionKind._('setter'); + static const operatorKind = DefinitionKind._('operator'); + static const constructorKind = DefinitionKind._('constructor'); + + static const _knownValues = [ + classKind, + mixinKind, + enumKind, + extensionKind, + extensionTypeKind, + methodKind, + getterKind, + setterKind, + operatorKind, + constructorKind, + ]; + + static DefinitionKind _fromName(String name) => _knownValues.firstWhere( + (v) => v._name == name, + orElse: () => DefinitionKind._(name), + ); + + @override + bool operator ==(Object other) => + other is DefinitionKind && other._name == _name; + + @override + int get hashCode => _name.hashCode; + + int _compareTo(DefinitionKind other) => _name.compareTo(other._name); + + @override + String toString() => _name; +} + +/// Package private (protected) methods for [DefinitionKind]. +/// +/// This avoids bloating the public API and public API docs and prevents +/// internal types from leaking from the API. +extension DefinitionKindProtected on DefinitionKind { + int compareTo(DefinitionKind other) => _compareTo(other); +} + +/// Extra metadata to disambiguate between elements that might have the same +/// name and kind. +/// +/// This is not an enum because adding new elements to an enum is a breaking +/// change for switch statements. By using a class with static const instances, +/// we can add new kinds without breaking existing code. +final class DefinitionDisambiguator { + final String _name; + const DefinitionDisambiguator._(this._name); + + /// Applied to members that are static (e.g. a static method in a class). + /// + /// Only applies to [DefinitionKind.methodKind], [DefinitionKind.getterKind], + /// [DefinitionKind.setterKind], and [DefinitionKind.operatorKind]. + static const staticDisambiguator = DefinitionDisambiguator._('static'); + + /// Applied to members that are instance members (e.g. an instance method in a + /// class or extension). + /// + /// Only applies to [DefinitionKind.methodKind], [DefinitionKind.getterKind], + /// [DefinitionKind.setterKind], and [DefinitionKind.operatorKind]. + static const instanceDisambiguator = DefinitionDisambiguator._('instance'); + + static const _knownValues = [ + staticDisambiguator, + instanceDisambiguator, + ]; + + static DefinitionDisambiguator _fromName(String name) => + _knownValues.firstWhere( + (v) => v._name == name, + orElse: () => DefinitionDisambiguator._(name), + ); + + @override + bool operator ==(Object other) => + other is DefinitionDisambiguator && other._name == _name; + + @override + int get hashCode => _name.hashCode; + + int _compareTo(DefinitionDisambiguator other) => _name.compareTo(other._name); + + @override + String toString() => _name; +} + +/// Package private (protected) methods for [DefinitionDisambiguator]. +/// +/// This avoids bloating the public API and public API docs and prevents +/// internal types from leaking from the API. +extension DefinitionDisambiguatorProtected on DefinitionDisambiguator { + int compareTo(DefinitionDisambiguator other) => _compareTo(other); } /// Package private (protected) methods for [Definition]. @@ -82,6 +314,11 @@ class Definition { extension DefinitionProtected on Definition { DefinitionSyntax toSyntax() => _toSyntax(); + Definition canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context); + + int compareTo(Definition other) => _compareTo(other); + static Definition fromSyntax(DefinitionSyntax syntax) => Definition._fromSyntax(syntax); } diff --git a/pkgs/record_use/lib/src/helper.dart b/pkgs/record_use/lib/src/helper.dart index 4141938def..86bce9d204 100644 --- a/pkgs/record_use/lib/src/helper.dart +++ b/pkgs/record_use/lib/src/helper.dart @@ -7,3 +7,19 @@ import 'package:collection/collection.dart'; final deepEquals = const DeepCollectionEquality().equals; final deepHash = const DeepCollectionEquality().hash; + +final _hashCodeCache = Expando(); +final _depthCache = Expando(); +final _sizeCache = Expando(); + +extension HashCodeCaching on Object { + /// Caches the hash code of this object. + int cacheHashCode(int Function() compute) => + _hashCodeCache[this] ??= compute(); + + /// Caches the depth of this object. + int cacheDepth(int Function() compute) => _depthCache[this] ??= compute(); + + /// Caches the size of this object. + int cacheSize(int Function() compute) => _sizeCache[this] ??= compute(); +} diff --git a/pkgs/record_use/lib/src/identifier.dart b/pkgs/record_use/lib/src/identifier.dart deleted file mode 100644 index 6e34dd1dbd..0000000000 --- a/pkgs/record_use/lib/src/identifier.dart +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:meta/meta.dart'; - -import 'syntax.g.dart'; - -/// Represents a unique identifier for a code element, such as a class, method, -/// or field, within a Dart program. -/// -/// An [Identifier] is used to pinpoint a specific element based on its -/// location and name. It consists of: -/// -/// - `importUri`: The URI of the library where the element is defined. -/// - `parent`: The name of the parent element (e.g., the class name for a -/// method or field). This is optional, as not all elements have parents (e.g. -/// top-level functions). -/// - `name`: The name of the element itself. -class Identifier { - /// The URI of the library where the element is defined. - /// - /// This is given in the form of its package import uri, so that it is OS- and - /// user independent. - final String importUri; - - /// The name of the parent element (e.g., the class name for a method or - /// field). This is optional, as not all elements have parents (e.g. top-level - /// functions). - final String? scope; - - /// The name of the element itself. - final String name; - - /// Creates an [Identifier] object. - /// - /// [importUri] is the URI of the library where the element is defined. - /// [scope] is the optional name of the parent element. - /// [name] is the name of the element. - const Identifier({required this.importUri, this.scope, required this.name}); - - /// Creates an [Identifier] object from its JSON representation. - factory Identifier.fromJson(Map json) => - Identifier._fromSyntax(IdentifierSyntax.fromJson(json)); - - /// Creates an [Identifier] object from its syntax representation. - factory Identifier._fromSyntax(IdentifierSyntax syntax) => - Identifier(importUri: syntax.uri, scope: syntax.scope, name: syntax.name); - - /// Converts this [Identifier] object to a JSON representation. - Map toJson() => _toSyntax().json; - - /// Converts this [Identifier] object to a syntax representation. - IdentifierSyntax _toSyntax() => - IdentifierSyntax(uri: importUri, scope: scope, name: name); - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is Identifier && - other.importUri == importUri && - other.scope == scope && - other.name == name; - } - - @override - int get hashCode => Object.hash(importUri, scope, name); - - /// Compares this [Identifier] with [other] for semantic equality. - /// - /// The [importUri] can be mapped using [uriMapping] before comparison. - @visibleForTesting - bool semanticEquals( - Identifier other, { - String Function(String)? uriMapping, - }) { - if (other.scope != scope) return false; - if (other.name != name) return false; - final mappedImportUri = uriMapping == null - ? importUri - : uriMapping(importUri); - return mappedImportUri == other.importUri; - } -} - -/// Package private (protected) methods for [Identifier]. -/// -/// This avoids bloating the public API and public API docs and prevents -/// internal types from leaking from the API. -extension IdentifierProtected on Identifier { - IdentifierSyntax toSyntax() => _toSyntax(); - - static Identifier fromSyntax(IdentifierSyntax syntax) => - Identifier._fromSyntax(syntax); -} diff --git a/pkgs/record_use/lib/src/loading_unit.dart b/pkgs/record_use/lib/src/loading_unit.dart new file mode 100644 index 0000000000..c5da5d9a05 --- /dev/null +++ b/pkgs/record_use/lib/src/loading_unit.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'canonicalization_context.dart'; +import 'definition.dart'; + +/// A loading unit in which a usage of a [Definition] was recorded. +/// +/// A loading unit is a blob in the target format of the compiler that can be +/// loaded separately when an application is loaded. Loading units are either +/// binary blobs containing machine code, web assembly or javascript files. +final class LoadingUnit { + /// The name of the loading unit. + final String name; + + const LoadingUnit(this.name); + + /// Canonicalizes the children of this [LoadingUnit]. + LoadingUnit _canonicalizeChildren(CanonicalizationContext context) => this; + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + + return other is LoadingUnit && other.name == name; + } + + @override + int get hashCode => name.hashCode; + + @override + String toString() => 'LoadingUnit($name)'; +} + +/// Package private (protected) methods for [LoadingUnit]. +/// +/// This avoids bloating the public API and public API docs and prevents +/// internal types from leaking from the API. +extension LoadingUnitProtected on LoadingUnit { + LoadingUnit canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context); +} diff --git a/pkgs/record_use/lib/src/location.dart b/pkgs/record_use/lib/src/location.dart deleted file mode 100644 index b50f17a368..0000000000 --- a/pkgs/record_use/lib/src/location.dart +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:meta/meta.dart'; - -import 'syntax.g.dart'; - -class Location { - final String uri; - final int? line; - final int? column; - - const Location({required this.uri, this.line, this.column}); - - factory Location.fromJson(Map map) => - Location._fromSyntax(LocationSyntax.fromJson(map)); - - factory Location._fromSyntax(LocationSyntax syntax) => - Location(uri: syntax.uri, line: syntax.line, column: syntax.column); - - Map toJson() => _toSyntax().json; - - LocationSyntax _toSyntax() => - LocationSyntax(uri: uri, line: line, column: column); - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is Location && - other.uri == uri && - other.line == line && - other.column == column; - } - - @override - int get hashCode => Object.hash(uri, line, column); - - /// Compares this [Location] with [other] for semantic equality. - /// - /// The [uri] can be mapped using [uriMapping] before comparison. - /// - /// If [allowLocationNull] is true, a null [line] and [column] is considered - /// equal to any other line and column. - @visibleForTesting - bool semanticEquals( - Location other, { - bool allowLocationNull = false, - String Function(String)? uriMapping, - }) { - if (!((line == other.line && column == other.column) || - (allowLocationNull && - (line == null && column == null || - other.line == null && other.column == null)))) { - return false; - } - final mappedUri = uriMapping == null ? uri : uriMapping(uri); - return mappedUri == other.uri; - } -} - -/// Package private (protected) methods for [Location]. -/// -/// This avoids bloating the public API and public API docs and prevents -/// internal types from leaking from the API. -extension LocationProtected on Location { - LocationSyntax toSyntax() => _toSyntax(); - - static Location fromSyntax(LocationSyntax syntax) => - Location._fromSyntax(syntax); -} diff --git a/pkgs/record_use/lib/src/metadata.dart b/pkgs/record_use/lib/src/metadata.dart index 330622b529..f24542cce9 100644 --- a/pkgs/record_use/lib/src/metadata.dart +++ b/pkgs/record_use/lib/src/metadata.dart @@ -6,6 +6,7 @@ import 'package:pub_semver/pub_semver.dart'; import 'helper.dart'; import 'syntax.g.dart'; +import 'version.dart'; /// Metadata attached to a recorded usages file. /// @@ -17,8 +18,23 @@ class Metadata { const Metadata._(this._syntax); - factory Metadata.fromJson(Map json) => - Metadata._(MetadataSyntax.fromJson(json)); + factory Metadata({ + Version? version, + String comment = + 'Recorded usages of objects tagged with a `RecordUse` annotation.', + Map? extension, + }) { + version ??= versionInternal; + final syntax = MetadataSyntax( + comment: comment, + version: version.toString(), + ); + // TODO(https://github.com/dart-lang/native/issues/2984): Nest extension + // fields. + return Metadata._( + MetadataSyntax.fromJson({...syntax.json, ...?extension}), + ); + } /// The underlying data. /// @@ -27,11 +43,20 @@ class Metadata { /// VM. Map get json => _syntax.json; - Map toJson() => _syntax.json; - Version get version => Version.parse(_syntax.version); + String get comment => _syntax.comment; + Map? get extension { + // TODO(https://github.com/dart-lang/native/issues/2984): Nest extension + // fields. + final dummy = MetadataSyntax(comment: comment, version: version.toString()); + return { + for (final entry in _syntax.json.entries) + if (!dummy.json.keys.contains(entry.key)) entry.key: entry.value, + }; + } + @override bool operator ==(covariant Metadata other) { if (identical(this, other)) return true; @@ -40,7 +65,7 @@ class Metadata { } @override - int get hashCode => deepHash(json); + int get hashCode => cacheHashCode(() => deepHash(json)); } /// Package private (protected) methods for [Metadata]. diff --git a/pkgs/record_use/lib/src/record_use.dart b/pkgs/record_use/lib/src/record_use.dart deleted file mode 100644 index b7e1713a0f..0000000000 --- a/pkgs/record_use/lib/src/record_use.dart +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import '../record_use_internal.dart'; - -/// Holds all information recorded during compilation. -/// -/// This can be queried using the methods provided, which each take an -/// [Identifier] which must be annotated with `@RecordUse` from `package:meta`. -extension type RecordedUsages._(Recordings _recordings) { - RecordedUsages.fromJson(Map json) - : this._(Recordings.fromJson(json)); - - /// Show the metadata for this recording of usages. - Metadata get metadata => _recordings.metadata; - - /// Finds all const arguments for calls to the [identifier]. - /// - /// The definition must be annotated with `@RecordUse()`. If there are no - /// calls to the definition, either because it was treeshaken, because it was - /// not annotated, or because it does not exist, returns empty. - /// - /// Returns an empty iterable if the arguments were not collected. - /// - /// Example: - /// ```dart - /// import 'package:meta/meta.dart' show RecordUse; - /// void main() { - /// print(SomeClass.someStaticMethod(42)); - /// } - /// - /// class SomeClass { - /// @RecordUse('id') - /// static someStaticMethod(int i) { - /// return i + 1; - /// } - /// } - /// ``` - /// - /// Would mean that - /// ``` - /// constArgumentsFor( - /// Identifier( - /// importUri: 'path/to/file.dart', - /// scope: 'SomeClass', - /// name: 'someStaticMethod', - /// ), - /// ).first.positional[0] == 42 - /// ``` - Iterable<({Map named, List positional})> - constArgumentsFor(Identifier identifier) => - _recordings.calls[identifier]?.whereType().map( - (call) => ( - named: call.namedArguments.map( - (name, argument) => MapEntry(name, argument?.toValue()), - ), - positional: call.positionalArguments - .map((argument) => argument?.toValue()) - .toList(), - ), - ) ?? - []; - - /// Finds all constant fields of a const instance of the class [identifier]. - /// - /// The definition must be annotated with `@RecordUse()`. If there are - /// no instances of the definition, either because it was treeshaken, because - /// it was not annotated, or because it does not exist, returns empty. - /// - /// Example: - /// ```dart - /// void main() { - /// print(SomeClass.someStaticMethod(42)); - /// } - /// - /// class SomeClass { - /// @AnnotationClass('freddie') - /// static someStaticMethod(int i) { - /// return i + 1; - /// } - /// } - /// - /// @RecordUse() - /// class AnnotationClass { - /// final String s; - /// const AnnotationClass(this.s); - /// } - /// ``` - /// - /// Would mean that - /// ``` - /// constantsOf( - /// Identifier( - /// importUri: 'path/to/file.dart', - /// name: 'AnnotationClass'), - /// ).first['s'] == 'freddie'; - /// ``` - /// - /// What kinds of fields can be recorded depends on the implementation of - /// https://dart-review.googlesource.com/c/sdk/+/369620/13/pkg/vm/lib/transformations/record_use/record_instance.dart - Iterable constantsOf(Identifier identifier) => - _recordings.instances[identifier]?.map( - (reference) => ConstantInstance(reference.instanceConstant.fields), - ) ?? - []; - - /// Checks if any call to [identifier] has non-const arguments, or if any - /// tear-off was recorded. - /// - /// The definition must be annotated with `@RecordUse()`. If there are no - /// calls to the definition, either because it was treeshaken, because it was - /// not annotated, or because it does not exist, returns `false`. - bool hasNonConstArguments(Identifier identifier) => - (_recordings.calls[identifier] ?? []).any( - (element) => switch (element) { - CallTearOff() => true, - final CallWithArguments call => call.positionalArguments.any( - (argument) => argument == null, - ), - }, - ); -} - -extension type ConstantInstance(Map _fields) { - bool hasField(String key) => _fields.containsKey(key); - - Object? operator [](String key) { - if (!hasField(key)) { - throw ArgumentError('No field with name $key found.'); - } - return _fields[key]!.toValue(); - } -} diff --git a/pkgs/record_use/lib/src/recorded_usage_from_file.dart b/pkgs/record_use/lib/src/recorded_usage_from_file.dart deleted file mode 100644 index 96b798b738..0000000000 --- a/pkgs/record_use/lib/src/recorded_usage_from_file.dart +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:convert' show jsonDecode; -import 'dart:io' show File; - -import '../record_use_internal.dart' show RecordedUsages; - -RecordedUsages? parseFromFile(Uri? recordedUsagesFile) { - if (recordedUsagesFile == null) { - return null; - } - final usagesContent = File.fromUri(recordedUsagesFile).readAsStringSync(); - final usagesJson = jsonDecode(usagesContent) as Map; - return RecordedUsages.fromJson(usagesJson); -} diff --git a/pkgs/record_use/lib/src/recordings.dart b/pkgs/record_use/lib/src/recordings.dart index 93c2b2d097..ff34248a95 100644 --- a/pkgs/record_use/lib/src/recordings.dart +++ b/pkgs/record_use/lib/src/recordings.dart @@ -7,60 +7,267 @@ import 'dart:convert'; import 'package:meta/meta.dart'; +import 'canonicalization_context.dart'; import 'constant.dart'; import 'definition.dart'; import 'helper.dart'; -import 'identifier.dart'; -import 'location.dart'; +import 'loading_unit.dart'; import 'metadata.dart'; import 'reference.dart'; +import 'serialization_context.dart'; import 'syntax.g.dart'; -/// [Recordings] combines recordings of calls and instances with metadata. +/// Holds all information recorded during compilation. /// -/// This class acts as the top-level container for recorded usage information. -/// The metadata provides context for the recording, such as version and -/// commentary. The [callsForDefinition] and [instancesForDefinition] store the -/// core data, associating each [Definition] with its corresponding [Reference] -/// details. +/// Associate [Definition]s annotated with `@RecordUse()` from `package:meta` +/// with their corresponding recorded usages. /// -/// The class uses a normalized JSON format, allowing the reuse of locations and -/// constants across multiple recordings to optimize storage. +/// The definition annotated with `@RecordUse()` must be inside the `lib/` +/// directory of the package. If the definition is a member of a class (e.g. a +/// static method), the class must be in the `lib/` directory. +/// +/// The class uses a normalized JSON format, allowing the reuse of constants +/// across multiple recordings to optimize storage. class Recordings { /// [Metadata] such as the recording protocol version. final Metadata metadata; /// The collected [CallReference]s for each [Definition]. - final Map> callsForDefinition; - - late final Map> calls = callsForDefinition - .map((definition, calls) => MapEntry(definition.identifier, calls)); + /// + /// Recorded when `@RecordUse()` is placed on a static member (top-level + /// functions, static methods, getters, setters, or operators) in any + /// container (library, class, mixin, enum, extension, or extension type). + /// + /// For example, to record calls to a static method: + /// + /// + /// ```dart + /// abstract class PirateTranslator { + /// @RecordUse() + /// static String speak(String english) => 'Ahoy $english'; + /// } + /// ``` + /// + /// Supported Locations: + /// - Top-level function / getter / setter. + /// - Static method / getter / setter in a class, mixin, or enum. + /// - Extension/Extension type method / getter / setter / operator (both + /// static and instance). + /// + /// What is Recorded: + /// - [CallWithArguments]: Recorded for direct invocations. + /// - [CallWithArguments.positionalArguments] and + /// [CallWithArguments.namedArguments]: Captured if they are constant; + /// otherwise recorded as [NonConstant]. Any non-provided arguments with + /// default values will have their default values filled in. + /// - [CallReference.receiver]: For extension instance members, the receiver + /// is captured if it is a constant. + /// - [CallTearoff]: Recorded for method tear-offs. + /// - Getters/Setters: Simple access is recorded as a [CallWithArguments]. For + /// setters, the assigned value is captured as a positional argument. + /// + /// Supported Constants: + /// - [NullConstant]: The `null` literal. + /// - [BoolConstant]: `true` and `false`. + /// - [IntConstant]: All constant integer values. + /// - [StringConstant]: All constant string values. + /// - [SymbolConstant]: Both public (e.g. `#mySymbol`) and private (e.g. + /// `#_myPrivateSymbol`). Private symbols include the library URI in the + /// recording to ensure they are unambiguous. + /// - [ListConstant]: Constant lists where every element is also a + /// supported constant. + /// - [MapConstant]: Constant maps where every key and value is a + /// supported constant. + /// - [RecordConstant]: Constant records (positional and named fields) + /// containing supported constants. + /// - [EnumConstant]: Constants of an enum type, provided the enum itself is + /// annotated with `@RecordUse()`. The recording includes the index, name, + /// and any field values (for enhanced enums). + /// - [InstanceConstant]: `const` instances of a `final` class, provided the + /// class is annotated with `@RecordUse()`. The recording includes all + /// constant field values. + /// + /// Unsupported Constants: + /// The following types are explicitly not supported and will be recorded as + /// an [UnsupportedConstant] with a descriptive message if encountered: + /// - Doubles: Double literals are currently excluded from recording to avoid + /// precision/portability issues across different platforms (VM vs JS). + /// - Sets: Constant sets are currently not supported (they are handled + /// differently than Lists/Maps in the compiler backends). + /// - Type Literals: Passing a type itself (e.g. `MyClass`) as a constant + /// argument is not supported. + /// https://github.com/dart-lang/native/issues/3199 + /// - Function/Method Tear-offs: While the tool records the fact that a + /// method was torn off (as a usage), passing a method tear-off as a + /// constant value into another recorded call is not supported (it will not + /// be recorded as a constant value). + /// + /// Usage in a link hook: + /// + /// + /// ```dart + /// final calls = uses.calls[methodId] ?? []; + /// for (final call in calls) { + /// switch (call) { + /// case CallWithArguments( + /// positionalArguments: [StringConstant(value: final english), ...], + /// ): + /// // Shrink a translations file based on all the different translation + /// // keys. + /// print('Translating to pirate: $english'); + /// case _: + /// print('Cannot determine which translations are used.'); + /// } + /// } + /// ``` + /// + /// Notes: + /// - Type Arguments: Intentionally not recorded (e.g., `myMethod()`), + /// as we don't currently have a serialization format for types. + /// https://github.com/dart-lang/native/issues/3198 + /// - Non-redirecting Factory Constructors: Not yet supported for static + /// calls, because they can be the target of redirecting constructors. + /// https://github.com/dart-lang/native/issues/3192 + final Map> calls; /// The collected [InstanceReference]s for each [Definition]. - final Map> instancesForDefinition; - - late final Map> instances = - instancesForDefinition.map( - (definition, instances) => MapEntry(definition.identifier, instances), - ); + /// + /// Recorded when `@RecordUse()` is placed on a `final class` or `enum` to + /// track the lifecycle of instances. + /// + /// For example, to record instances of a class: + /// + /// + /// ```dart + /// @RecordUse() + /// final class PirateShip { + /// final String name; + /// final int cannons; + /// + /// const PirateShip(this.name, this.cannons); + /// } + /// ``` + /// + /// Supported Locations: + /// - `final class` (must be `final` to ensure all creation points are known). + /// - `enum` (implicitly `final`). + /// + /// What is Recorded: + /// - [InstanceConstantReference]: Recorded for constant instances and enum + /// elements. + /// - [InstanceConstantReference.instanceConstant]: The captured constant + /// value. + /// - [InstanceCreationReference]: Recorded for generative constructor + /// invocations (non-const). + /// - [InstanceCreationReference.positionalArguments] and + /// [InstanceCreationReference.namedArguments]: Captured if they are + /// constant; otherwise recorded as [NonConstant]. Any non-provided + /// arguments with default values will have their default values + /// filled in. + /// - [ConstructorTearoffReference]: Recorded for constructor tear-offs. + /// - Redirecting Factories (`=`): Resolved to the effective target class and + /// recorded as an instance creation, constant, or tear-off of that class. + /// - Typedefs: Resolved back to the underlying class. + /// - Redirecting Generative Constructors (`: this.`): Recorded at the entry + /// point only. + /// + /// Supported Constants: + /// - [NullConstant]: The `null` literal. + /// - [BoolConstant]: `true` and `false`. + /// - [IntConstant]: All constant integer values. + /// - [StringConstant]: All constant string values. + /// - [SymbolConstant]: Both public (e.g. `#mySymbol`) and private (e.g. + /// `#_myPrivateSymbol`). Private symbols include the library URI in the + /// recording to ensure they are unambiguous. + /// - [ListConstant]: Constant lists where every element is also a + /// supported constant. + /// - [MapConstant]: Constant maps where every key and value is a + /// supported constant. + /// - [RecordConstant]: Constant records (positional and named fields) + /// containing supported constants. + /// - [EnumConstant]: Constants of an enum type, provided the enum itself is + /// annotated with `@RecordUse()`. The recording includes the index, name, + /// and any field values (for enhanced enums). + /// - [InstanceConstant]: `const` instances of a `final` class, provided the + /// class is annotated with `@RecordUse()`. The recording includes all + /// constant field values. + /// + /// Unsupported Constants: + /// The following types are explicitly not supported and will be recorded as + /// an [UnsupportedConstant] with a descriptive message if encountered: + /// - Doubles: Double literals are currently excluded from recording to avoid + /// precision/portability issues across different platforms (VM vs JS). + /// - Sets: Constant sets are currently not supported (they are handled + /// differently than Lists/Maps in the compiler backends). + /// - Type Literals: Passing a type itself (e.g. `MyClass`) as a constant + /// argument is not supported. + /// https://github.com/dart-lang/native/issues/3199 + /// - Function/Method Tear-offs: While the tool records the fact that a + /// method was torn off (as a usage), passing a method tear-off as a + /// constant value into another recorded call is not supported (it will not + /// be recorded as a constant value). + /// + /// Usage in a link hook: + /// + /// + /// ```dart + /// final ships = uses.instances[classId] ?? []; + /// for (final ship in ships) { + /// switch (ship) { + /// case InstanceConstantReference( + /// instanceConstant: InstanceConstant( + /// fields: {'name': StringConstant(value: final name)}, + /// ), + /// ): + /// // Include the 3d model for this ship in the application but not + /// // bundle the other ships. + /// print('Pirate ship found: $name'); + /// case _: + /// print('Cannot determine which ships are used.'); + /// } + /// } + /// ``` + /// + /// Notes: + /// - Type Arguments: Intentionally not recorded (e.g., `MyClass()`), + /// as we don't currently have a serialization format for types. + /// https://github.com/dart-lang/native/issues/3198 + /// - Non-redirecting Factories: Invocations of non-redirecting factories are + /// NOT recorded as instances. Instead, the body of the factory is analyzed + /// like a static method, and any generative constructor calls inside the + /// body are recorded as instances of the class. + /// - Non-final classes: This is not (yet) supported due to the extra + /// complexity with reasoning about instances of subtypes. If we ever + /// support this we will likely not allow type hierarchies to cross package + /// boundaries due to the ambiguity of to which packages' link hook the + /// information should be sent. + /// https://github.com/dart-lang/native/issues/3200 + final Map> instances; Recordings({ - required this.metadata, - required this.callsForDefinition, - required this.instancesForDefinition, - }); + Metadata? metadata, + required this.calls, + required this.instances, + }) : metadata = metadata ?? Metadata(); /// Decodes a JSON representation into a [Recordings] object. /// /// The format is specifically designed to reduce redundancy and improve - /// efficiency. Identifiers and constants are stored in separate tables, + /// efficiency. Definitions and constants are stored in separate tables, /// allowing them to be referenced by index in the `recordings` map. factory Recordings.fromJson(Map json) { try { final syntax = RecordedUsesSyntax.fromJson(json); + final syntaxErrors = syntax.validate(); + if (syntaxErrors.isNotEmpty) { + final errorsString = syntaxErrors.map((e) => ' - $e').join('\n'); + throw FormatException( + 'Validation errors for record use file:\n$errorsString\n', + ); + } return Recordings._fromSyntax(syntax); } on FormatException catch (e) { - throw ArgumentError(''' + throw FormatException(''' Invalid JSON format for Recordings: ${const JsonEncoder.withIndent(' ').convert(json)} Error: $e @@ -69,140 +276,204 @@ Error: $e } factory Recordings._fromSyntax(RecordedUsesSyntax syntax) { - final constants = []; - for (final constantSyntax in syntax.constants ?? []) { - final constant = ConstantProtected.fromSyntax(constantSyntax, constants); - if (!constants.contains(constant)) { - constants.add(constant); - } - } - - final locations = []; - for (final locationSyntax in syntax.locations ?? []) { - final location = LocationProtected.fromSyntax(locationSyntax); - if (!locations.contains(location)) { - locations.add(location); - } - } + final loadingUnitContext = _deserializeLoadingUnits(syntax); + final definitionContext = _deserializeDefinitions( + syntax, + loadingUnitContext, + ); + final context = _deserializeConstants(syntax, definitionContext); final callsForDefinition = >{}; final instancesForDefinition = >{}; - for (final recordingSyntax in syntax.recordings ?? []) { - final definition = DefinitionProtected.fromSyntax( - recordingSyntax.definition, - ); - if (recordingSyntax.calls case final callSyntaxes?) { + final uses = syntax.uses; + if (uses != null) { + for (final callRecording in uses.staticCalls ?? []) { + final definition = context.definitions[callRecording.definitionIndex]; + final callSyntaxes = callRecording.uses; final callReferences = callSyntaxes .map( (callSyntax) => CallReferenceProtected.fromSyntax( callSyntax, - constants, - locations, + context, ), ) .toList(); - callsForDefinition[definition] = callReferences; + callsForDefinition + .putIfAbsent(definition, () => []) + .addAll(callReferences); } - if (recordingSyntax.instances case final instanceSyntaxes?) { + for (final instanceRecording + in uses.instances ?? []) { + final definition = + context.definitions[instanceRecording.definitionIndex]; + final instanceSyntaxes = instanceRecording.uses; final instanceReferences = instanceSyntaxes .map( (instanceSyntax) => InstanceReferenceProtected.fromSyntax( instanceSyntax, - constants, - locations, + context, ), ) .toList(); - instancesForDefinition[definition] = instanceReferences; + instancesForDefinition + .putIfAbsent(definition, () => []) + .addAll(instanceReferences); } } return Recordings( metadata: MetadataProtected.fromSyntax(syntax.metadata), - callsForDefinition: callsForDefinition, - instancesForDefinition: instancesForDefinition, + calls: callsForDefinition, + instances: instancesForDefinition, + ); + } + + Recordings _canonicalizeChildren(CanonicalizationContext context) => + Recordings( + metadata: metadata, + calls: _canonicalizeReferences(context, calls), + instances: _canonicalizeReferences(context, instances), + ); + + Map> _canonicalizeReferences( + CanonicalizationContext context, + Map> references, + ) { + final map = >{}; + for (final entry in references.entries) { + final definition = context.canonicalizeDefinition(entry.key); + final set = map.putIfAbsent(definition, () => {}); + for (final reference in entry.value) { + set.add(reference.canonicalizeChildren(context) as R); + } + } + final sortedKeys = map.keys.toList()..sort((a, b) => a.compareTo(b)); + return >{ + for (final key in sortedKeys) + key: map[key]!.toList()..sort((a, b) => a.compareTo(b)), + }; + } + + static LoadingUnitDeserializationContext _deserializeLoadingUnits( + RecordedUsesSyntax syntax, + ) { + final loadingUnits = []; + for (final unit in syntax.loadingUnits ?? []) { + loadingUnits.add(LoadingUnit(unit.name)); + } + return LoadingUnitDeserializationContext(loadingUnits); + } + + static DefinitionDeserializationContext _deserializeDefinitions( + RecordedUsesSyntax syntax, + LoadingUnitDeserializationContext loadingUnitContext, + ) { + final definitions = []; + for (final definitionSyntax in syntax.definitions ?? []) { + definitions.add(DefinitionProtected.fromSyntax(definitionSyntax)); + } + return DefinitionDeserializationContext.fromPrevious( + loadingUnitContext, + definitions, ); } + static DeserializationContext _deserializeConstants( + RecordedUsesSyntax syntax, + DefinitionDeserializationContext definitionContext, + ) { + final constants = []; + // Create a context that includes an empty list for the constants. This + // list will be populated by [_deserializeConstants], providing the + // self-referential access needed to resolve recursive constants (e.g. + // list and map constants). + final context = DeserializationContext.fromPrevious( + definitionContext, + constants, + ); + for (final constantSyntax in syntax.constants ?? []) { + final constant = MaybeConstantProtected.fromSyntax( + constantSyntax, + context, + ); + if (!constants.contains(constant)) { + constants.add(constant); + } + } + return context; + } + /// Encodes this object into a JSON representation. /// /// This method normalizes identifiers and constants for storage efficiency. Map toJson() => _toSyntax().json; RecordedUsesSyntax _toSyntax() { - final constantsIndex = { - ...callsForDefinition.values - .expand((calls) => calls) - .whereType() - .expand( - (call) => [ - ...call.positionalArguments, - ...call.namedArguments.values, - ], - ) - .nonNulls, - ...instancesForDefinition.values - .expand((instances) => instances) - .expand( - (instance) => { - ...instance.instanceConstant.fields.values, - instance.instanceConstant, - }, - ), - }.flatten().asMapToIndices; - - final locationsIndex = { - ...callsForDefinition.values - .expand((calls) => calls) - .map((call) => call.location) - .nonNulls, - ...instancesForDefinition.values - .expand((instances) => instances) - .map((instance) => instance.location) - .nonNulls, - }.asMapToIndices; - - final recordings = []; - if (callsForDefinition.isNotEmpty) { - recordings.addAll( - callsForDefinition.entries.map( - (entry) => RecordingSyntax( - definition: entry.key.toSyntax(), - calls: entry.value - .map((call) => call.toSyntax(constantsIndex, locationsIndex)) - .toList(), - ), + final canonContext = CanonicalizationContext(); + final canon = _canonicalizeChildren(canonContext); + + final sortedLoadingUnits = canonContext.loadingUnits.toList() + ..sort((a, b) => a.name.compareTo(b.name)); + final sortedDefinitions = canonContext.definitions.toList() + ..sort((a, b) => a.compareTo(b)); + final sortedConstants = canonContext.constants.toList() + ..sort((a, b) => a.compareTo(b)); + + final context = SerializationContext( + loadingUnits: sortedLoadingUnits.asMapToIndices, + definitions: sortedDefinitions.asMapToIndices, + constants: sortedConstants.asMapToIndices, + ); + + final callRecordings = []; + for (final entry in canon.calls.entries) { + callRecordings.add( + CallRecordingSyntax( + definitionIndex: context.definitions[entry.key]!, + uses: entry.value.map((call) => call.toSyntax(context)).toList(), ), ); } - if (instancesForDefinition.isNotEmpty) { - recordings.addAll( - instancesForDefinition.entries.map( - (entry) => RecordingSyntax( - definition: entry.key.toSyntax(), - instances: entry.value - .map( - (instance) => - instance.toSyntax(constantsIndex, locationsIndex), - ) - .toList(), - ), + final instanceRecordings = []; + for (final entry in canon.instances.entries) { + instanceRecordings.add( + InstanceRecordingSyntax( + definitionIndex: context.definitions[entry.key]!, + uses: entry.value + .map((instance) => instance.toSyntax(context)) + .toList(), ), ); } + final uses = (callRecordings.isEmpty && instanceRecordings.isEmpty) + ? null + : UsesSyntax( + staticCalls: callRecordings.isEmpty ? null : callRecordings, + instances: instanceRecordings.isEmpty ? null : instanceRecordings, + ); + return RecordedUsesSyntax( metadata: metadata.toSyntax(), - constants: constantsIndex.isEmpty + constants: sortedConstants.isEmpty + ? null + : [ + for (final constant in sortedConstants) + constant.toSyntax(context), + ], + loadingUnits: sortedLoadingUnits.isEmpty ? null - : constantsIndex.keys - .map((constant) => constant.toSyntax(constantsIndex)) - .toList(), - locations: locationsIndex.isEmpty + : [ + for (final unit in sortedLoadingUnits) + LoadingUnitSyntax(name: unit.name), + ], + definitions: sortedDefinitions.isEmpty ? null - : locationsIndex.keys.map((location) => location.toSyntax()).toList(), - recordings: recordings.isEmpty ? null : recordings, + : [ + for (final definition in sortedDefinitions) definition.toSyntax(), + ], + uses: uses, ); } @@ -211,15 +482,17 @@ Error: $e if (identical(this, other)) return true; return other.metadata == metadata && - deepEquals(other.callsForDefinition, callsForDefinition) && - deepEquals(other.instancesForDefinition, instancesForDefinition); + deepEquals(other.calls, calls) && + deepEquals(other.instances, instances); } @override - int get hashCode => Object.hash( - metadata.hashCode, - deepHash(callsForDefinition), - deepHash(instancesForDefinition), + int get hashCode => cacheHashCode( + () => Object.hash( + metadata.hashCode, + deepHash(calls), + deepHash(instances), + ), ); /// Compares this set of usages ('actual') with the [expected] set @@ -244,18 +517,9 @@ Error: $e /// a usage from [expected] cannot be found in `this`, simulating the effect /// of a compiler optimizing away a call entirely. /// - /// If [allowTearOffToStaticPromotion] is `true`, allows an [expected] + /// If [allowTearoffToStaticPromotion] is `true`, allows an [expected] /// function tear-off to match an `actual` static call. /// - /// If [allowLocationNull] is `true`, having a `null` in one and a column and - /// line number in the other is considered semantically equal. Useful for if - /// one compiler does not provide source locations but the other does. - /// - /// If [allowDefinitionLoadingUnitNull] is `true`, allows a definition's - /// loading unit to be `null` in one set but not the other. This handles - /// cases where a compiler might not emit loading unit information for all - /// definitions. - /// /// If [allowMoreConstArguments] is `true`, `null` arguments in an `expected` /// call are ignored during comparison. This can be used to accommodate /// differences in how compilers handle default or optional arguments. @@ -267,10 +531,9 @@ Error: $e Recordings expected, { bool expectedIsSubset = false, bool allowDeadCodeElimination = false, - bool allowTearOffToStaticPromotion = false, - bool allowLocationNull = false, - bool allowDefinitionLoadingUnitNull = false, + bool allowTearoffToStaticPromotion = false, bool allowMoreConstArguments = false, + bool allowPromotionOfUnsupported = false, bool allowMetadataMismatch = false, String Function(String)? uriMapping, String Function(String)? loadingUnitMapping, @@ -278,36 +541,33 @@ Error: $e if (!allowMetadataMismatch && metadata != expected.metadata) { return false; } - // ignore: invalid_use_of_visible_for_testing_member - bool definitionMatches(Definition a, Definition b) => a.semanticEquals( - b, - allowLoadingUnitNull: allowDefinitionLoadingUnitNull, - uriMapping: uriMapping, - loadingUnitMapping: loadingUnitMapping, - ); + bool definitionMatches(Definition a, Definition b) => + // ignore: invalid_use_of_visible_for_testing_member + a.semanticEquals(b, uriMapping: uriMapping); if (!_compareUsageMap( - actual: callsForDefinition, - expected: expected.callsForDefinition, + actual: calls, + expected: expected.calls, expectedIsSubset: expectedIsSubset, allowDeadCodeElimination: allowDeadCodeElimination, definitionMatches: definitionMatches, - // ignore: invalid_use_of_visible_for_testing_member - referenceMatches: (CallReference a, CallReference b) => a.semanticEquals( - b, - allowTearOffToStaticPromotion: allowTearOffToStaticPromotion, - allowLocationNull: allowLocationNull, - allowMoreConstArguments: allowMoreConstArguments, - uriMapping: uriMapping, - loadingUnitMapping: loadingUnitMapping, - ), + referenceMatches: (CallReference a, CallReference b) => + // ignore: invalid_use_of_visible_for_testing_member + a.semanticEquals( + b, + allowTearoffToStaticPromotion: allowTearoffToStaticPromotion, + allowMoreConstArguments: allowMoreConstArguments, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + uriMapping: uriMapping, + loadingUnitMapping: loadingUnitMapping, + ), )) { return false; } if (!_compareUsageMap( - actual: instancesForDefinition, - expected: expected.instancesForDefinition, + actual: instances, + expected: expected.instances, expectedIsSubset: expectedIsSubset, allowDeadCodeElimination: allowDeadCodeElimination, definitionMatches: definitionMatches, @@ -315,9 +575,10 @@ Error: $e // ignore: invalid_use_of_visible_for_testing_member a.semanticEquals( b, - allowLocationNull: allowLocationNull, uriMapping: uriMapping, loadingUnitMapping: loadingUnitMapping, + allowMoreConstArguments: allowMoreConstArguments, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, ), )) { return false; @@ -355,12 +616,9 @@ Error: $e final actualUsage = actualUsages[i]; - if (definitionMatches( - actualUsage.key, - expectedUsage.key, - )) { + if (definitionMatches(actualUsage.key, expectedUsage.key)) { // Definitions match semantically. Now check the references. - // The list of references for this definition must be an exact + // The list of references for this identifier must be an exact // semantic match. final referencesMatch = _matchReferences( actual: actualUsage.value, @@ -432,33 +690,50 @@ Error: $e return true; } -} -extension FlattenConstantsExtension on Iterable { - Set flatten() { - final constants = {}; - for (final constant in this) { - depthFirstSearch(constant, constants); + /// Returns a new [Recordings] that only contains usages of definitions + /// filtered by the provided criteria. + /// + /// If [definitionPackageName] is provided, only usages of definitions + /// defined in that package are included. + Recordings filter({String? definitionPackageName}) { + bool belongsToPackage(Definition definition) { + if (definitionPackageName == null) return true; + final uri = definition.library; + return uri.startsWith('package:$definitionPackageName/'); } - return constants; - } - void depthFirstSearch(Constant constant, Set collected) { - final children = switch (constant) { - ListConstant() => constant.value, - MapConstant() => constant.value.values, - InstanceConstant() => constant.fields.values, - _ => [], + final newCallsForDefinition = { + for (final entry in calls.entries) + if (belongsToPackage(entry.key)) + entry.key: [ + for (final call in entry.value) + call.filter(definitionPackageName: definitionPackageName), + ], }; - for (final child in children) { - if (!collected.contains(child)) { - depthFirstSearch(child, collected); - } - } - collected.add(constant); + + final newInstancesForDefinition = { + for (final entry in instances.entries) + if (belongsToPackage(entry.key)) + entry.key: [ + for (final instance in entry.value) + instance.filter(definitionPackageName: definitionPackageName), + ], + }; + + return Recordings( + metadata: metadata, + calls: newCallsForDefinition, + instances: newInstancesForDefinition, + ); } } +extension RecordingsProtected on Recordings { + Recordings canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context); +} + extension MapifyIterableExtension on Iterable { /// Transform list to map, faster than using list.indexOf Map get asMapToIndices { diff --git a/pkgs/record_use/lib/src/reference.dart b/pkgs/record_use/lib/src/reference.dart index 84f74b2d45..6dfbb4a8e5 100644 --- a/pkgs/record_use/lib/src/reference.dart +++ b/pkgs/record_use/lib/src/reference.dart @@ -4,189 +4,351 @@ import 'package:meta/meta.dart'; +import 'canonicalization_context.dart'; import 'constant.dart'; +import 'definition.dart'; import 'helper.dart'; -import 'identifier.dart'; -import 'location.dart' show Location; +import 'loading_unit.dart'; +import 'serialization_context.dart'; import 'syntax.g.dart'; -/// A reference to *something*. +/// A reference to a [Definition] from a [LoadingUnit]. /// -/// The something might be a call or an instance, matching a [CallReference] or +/// The reference might be a call or an instance, matching a [CallReference] or /// an [InstanceReference]. +/// /// All references have in common that they occur in a [loadingUnit], which we /// record to be able to piece together which loading units are "related", for /// example all needing the same asset. sealed class Reference { - final String? loadingUnit; - final Location? location; + final LoadingUnit loadingUnit; + + const Reference({required this.loadingUnit}); + + /// Canonicalizes this [Reference]. + Reference _canonicalizeChildren(CanonicalizationContext context); - const Reference({required this.loadingUnit, required this.location}); + /// Returns a new [Reference] that only contains information allowed + /// by the provided criteria. + Reference _filter({String? definitionPackageName}); @override bool operator ==(Object other) { if (identical(this, other)) return true; - return other is Reference && - other.loadingUnit == loadingUnit && - other.location == location; + return other is Reference && other.loadingUnit == loadingUnit; } @override - int get hashCode => Object.hash(loadingUnit, location); + int get hashCode => cacheHashCode(() => loadingUnit.hashCode); + + int _compareTo(Reference other) { + var result = loadingUnit.name.compareTo(other.loadingUnit.name); + if (result != 0) return result; + result = _orderingTypePriority.compareTo(other._orderingTypePriority); + if (result != 0) return result; + return _compareToInternal(other); + } - Map toJson( - Map constants, - Map locations, - ) => _toSyntax(constants, locations).json; + int _compareToInternal(covariant Reference other); - JsonObjectSyntax _toSyntax( - Map constants, - Map locations, - ); + /// A stable priority for this type. + @protected + int get _orderingTypePriority; bool _semanticEqualsShared( - Reference other, - bool allowLocationNull, { + Reference other, { String Function(String)? uriMapping, String Function(String)? loadingUnitMapping, }) { - final mappedLoadingUnit = loadingUnit == null || loadingUnitMapping == null - ? loadingUnit - : loadingUnitMapping(loadingUnit!); - if (other.loadingUnit != mappedLoadingUnit) { - return false; + final unit = loadingUnit.name; + final otherUnit = other.loadingUnit.name; + final mappedUnit = loadingUnitMapping == null + ? unit + : loadingUnitMapping(unit); + return mappedUnit == otherUnit; + } + + @override + String toString() => loadingUnit.name; +} + +mixin _HasArguments { + List get positionalArguments; + Map get namedArguments; + + int _compareToArguments(covariant _HasArguments other) { + if (positionalArguments.length != other.positionalArguments.length) { + return positionalArguments.length.compareTo( + other.positionalArguments.length, + ); } - if ((location == null) != (other.location == null)) { - return false; + for (var i = 0; i < positionalArguments.length; i++) { + final result = positionalArguments[i].compareTo( + other.positionalArguments[i], + ); + if (result != 0) return result; } - if (location != null && - other.location != null && - // ignore: invalid_use_of_visible_for_testing_member - !location!.semanticEquals( - other.location!, - allowLocationNull: allowLocationNull, - uriMapping: uriMapping, - )) { + if (namedArguments.length != other.namedArguments.length) { + return namedArguments.length.compareTo(other.namedArguments.length); + } + final thisSorted = namedArguments.keys.toList()..sort(); + final otherSorted = other.namedArguments.keys.toList()..sort(); + for (var i = 0; i < thisSorted.length; i++) { + var result = thisSorted[i].compareTo(otherSorted[i]); + if (result != 0) return result; + result = namedArguments[thisSorted[i]]!.compareTo( + other.namedArguments[otherSorted[i]]!, + ); + if (result != 0) return result; + } + return 0; + } + + List _canonicalizePositional( + CanonicalizationContext context, + ) => [for (final c in positionalArguments) context.canonicalizeConstant(c)]; + + Map _canonicalizeNamed( + CanonicalizationContext context, + ) { + final sortedNamedArgs = namedArguments.entries.toList() + ..sort((a, b) => a.key.compareTo(b.key)); + return { + for (final e in sortedNamedArgs) + e.key: context.canonicalizeConstant(e.value), + }; + } + + List _filterPositional({String? definitionPackageName}) => [ + for (final c in positionalArguments) + c.filter(definitionPackageName: definitionPackageName), + ]; + + Map _filterNamed({String? definitionPackageName}) => + namedArguments.map( + (key, value) => MapEntry( + key, + value.filter(definitionPackageName: definitionPackageName), + ), + ); + + bool _semanticEqualsArguments( + _HasArguments other, { + required bool allowMoreConstArguments, + required bool allowPromotionOfUnsupported, + }) { + if (positionalArguments.length != other.positionalArguments.length) { return false; } + for (final (index, argument) in other.positionalArguments.indexed) { + if (argument is NonConstant && allowMoreConstArguments) { + continue; + } + // ignore: invalid_use_of_visible_for_testing_member + if (!positionalArguments[index].semanticEquals( + argument, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } + for (final entry in other.namedArguments.entries) { + final name = entry.key; + final argument = entry.value; + if (argument is NonConstant && allowMoreConstArguments) { + continue; + } + // ignore: invalid_use_of_visible_for_testing_member + if (!namedArguments[name]!.semanticEquals( + argument, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + } return true; } } -/// A reference to a call to some [Identifier]. +/// A reference to a call to some [Definition]. /// /// This might be an actual call, in which case we record the arguments, or a /// tear-off, in which case we can't record the arguments. sealed class CallReference extends Reference { - const CallReference({required super.loadingUnit, required super.location}); + /// The argument in the receiver position. + /// + /// Is `null` for static (extension) methods. + final MaybeConstant? receiver; - static CallReference fromJson( - Map json, - List constants, - List locations, - ) => _fromSyntax(CallSyntax.fromJson(json), constants, locations); + const CallReference({required super.loadingUnit, this.receiver}); + + @override + int _compareToInternal(covariant CallReference other) { + if (receiver != null && other.receiver != null) { + final result = receiver!.compareTo(other.receiver!); + if (result != 0) return result; + } else if (receiver != null) { + return 1; + } else if (other.receiver != null) { + return -1; + } + return _compareToCallInternal(other); + } + + int _compareToCallInternal(covariant CallReference other); static CallReference _fromSyntax( CallSyntax syntax, - List constants, - List locations, - ) { - final locationIndex = syntax.at; - final location = locationIndex == null ? null : locations[locationIndex]; - return switch (syntax) { - TearoffCallSyntax() => CallTearOff( - loadingUnit: syntax.loadingUnit, - location: location, - ), - WithArgumentsCallSyntax( - :final named, - :final positional, - :final loadingUnit, - ) => - CallWithArguments( - positionalArguments: (positional ?? []) - .map( - (constantsIndex) => - constantsIndex != null ? constants[constantsIndex] : null, - ) - .toList(), - namedArguments: (named ?? {}).map( - (name, constantsIndex) => MapEntry(name, constants[constantsIndex]), - ), - loadingUnit: loadingUnit, - location: location, + DeserializationContext context, + ) => switch (syntax) { + TearoffCallSyntax(:final receiver) => CallTearoff( + loadingUnit: context.loadingUnits[syntax.loadingUnitIndex], + receiver: receiver != null ? context.constants[receiver] : null, + ), + WithArgumentsCallSyntax( + :final named, + :final positional, + :final loadingUnitIndex, + :final receiver, + ) => + CallWithArguments( + positionalArguments: (positional ?? []) + .map((index) => _argumentFromSyntax(index, context)) + .toList(), + namedArguments: (named ?? {}).map( + (name, index) => MapEntry(name, _argumentFromSyntax(index, context)), ), - _ => throw UnimplementedError('Unknown CallSyntax type'), - }; + loadingUnit: context.loadingUnits[loadingUnitIndex], + receiver: receiver != null ? context.constants[receiver] : null, + ), + _ => throw UnimplementedError('Unknown CallSyntax type'), + }; + + static MaybeConstant _argumentFromSyntax( + int? index, + DeserializationContext context, + ) { + if (index == null) return const NonConstant(); + return context.constants[index]; } + CallSyntax _toSyntax(SerializationContext context); + @override - CallSyntax _toSyntax( - Map constants, - Map locations, - ); + CallReference _filter({String? definitionPackageName}); /// Compares this [CallWithArguments] with [other] for semantic equality. /// - /// If [allowTearOffToStaticPromotion] is true, this may be equal to a - /// [CallTearOff]. + /// If [allowTearoffToStaticPromotion] is true, this may be equal to a + /// [CallTearoff]. /// - /// If [allowMoreConstArguments] is true, `null` arguments in [other] + /// If [allowMoreConstArguments] is true, `NonConstantArgument` in [other] /// are ignored during comparison. /// /// The loading unit can be mapped with [loadingUnitMapping]. /// /// The URI in the location can be mapped with [uriMapping]. - /// - /// If [allowLocationNull] is true, a null location is considered equal to - /// any other location. @visibleForTesting bool semanticEquals( CallReference other, { - bool allowTearOffToStaticPromotion = false, + bool allowTearoffToStaticPromotion = false, bool allowMoreConstArguments = false, - bool allowLocationNull = false, + bool allowPromotionOfUnsupported = false, String Function(String)? uriMapping, String Function(String)? loadingUnitMapping, }); + + bool _semanticEqualsCall( + CallReference other, { + bool allowMoreConstArguments = false, + bool allowPromotionOfUnsupported = false, + String Function(String)? uriMapping, + String Function(String)? loadingUnitMapping, + }) { + if (!_semanticEqualsShared( + other, + uriMapping: uriMapping, + loadingUnitMapping: loadingUnitMapping, + )) { + return false; + } + final otherReceiver = other.receiver; + if (receiver == null) { + return otherReceiver == null; + } + if (otherReceiver == null) return false; + // ignore: invalid_use_of_visible_for_testing_member + return receiver!.semanticEquals( + otherReceiver, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + ); + } } -/// A reference to a call to some [Identifier] with [positionalArguments] and +/// A reference to a call to some [Definition] with [positionalArguments] and /// [namedArguments]. -final class CallWithArguments extends CallReference { - final List positionalArguments; - final Map namedArguments; +/// +/// Any non-provided arguments with default values will have their default +/// values filled in. +final class CallWithArguments extends CallReference with _HasArguments { + @override + final List positionalArguments; + @override + final Map namedArguments; const CallWithArguments({ required this.positionalArguments, required this.namedArguments, required super.loadingUnit, - required super.location, + super.receiver, }); @override - WithArgumentsCallSyntax _toSyntax( - Map constants, - Map locations, - ) { + int get _orderingTypePriority => 0; + + @override + int _compareToCallInternal(covariant CallWithArguments other) => + _compareToArguments(other); + + @override + Reference _canonicalizeChildren(CanonicalizationContext context) => + CallWithArguments( + loadingUnit: context.canonicalizeLoadingUnit(loadingUnit), + receiver: receiver != null + ? context.canonicalizeConstant(receiver!) + : null, + positionalArguments: _canonicalizePositional(context), + namedArguments: _canonicalizeNamed(context), + ); + + @override + CallReference _filter({String? definitionPackageName}) => CallWithArguments( + loadingUnit: loadingUnit, + receiver: receiver?.filter(definitionPackageName: definitionPackageName), + positionalArguments: _filterPositional( + definitionPackageName: definitionPackageName, + ), + namedArguments: _filterNamed(definitionPackageName: definitionPackageName), + ); + + @override + WithArgumentsCallSyntax _toSyntax(SerializationContext context) { final namedArgs = {}; for (final entry in namedArguments.entries) { - if (entry.value != null) { - final index = constants[entry.value!]; - if (index != null) { - namedArgs[entry.key] = index; - } - } + namedArgs[entry.key] = context.constants[entry.value]!; } return WithArgumentsCallSyntax( - at: locations[location]!, - loadingUnit: loadingUnit!, + loadingUnitIndex: context.loadingUnits[loadingUnit]!, named: namedArgs.isNotEmpty ? namedArgs : null, positional: positionalArguments.isEmpty ? null - : positionalArguments.map((constant) => constants[constant]).toList(), + : [ + for (final argument in positionalArguments) + context.constants[argument]!, + ], + receiver: receiver != null ? context.constants[receiver!] : null, ); } @@ -197,169 +359,532 @@ final class CallWithArguments extends CallReference { return other is CallWithArguments && deepEquals(other.positionalArguments, positionalArguments) && - deepEquals(other.namedArguments, namedArguments); + deepEquals(other.namedArguments, namedArguments) && + receiver == other.receiver; } @override - int get hashCode => Object.hash( - deepHash(positionalArguments), - deepHash(namedArguments), - super.hashCode, + int get hashCode => cacheHashCode( + () => Object.hash( + deepHash(positionalArguments), + deepHash(namedArguments), + receiver, + super.hashCode, + ), ); @override @visibleForTesting bool semanticEquals( CallReference other, { - bool allowTearOffToStaticPromotion = false, + bool allowTearoffToStaticPromotion = false, bool allowMoreConstArguments = false, - bool allowLocationNull = false, + bool allowPromotionOfUnsupported = false, String Function(String)? uriMapping, String Function(String)? loadingUnitMapping, }) { switch (other) { case CallWithArguments(): - for (final (index, argument) in other.positionalArguments.indexed) { - if (argument == null && allowMoreConstArguments) { - continue; - } - if (argument != positionalArguments[index]) { - return false; - } - } - for (final entry in other.namedArguments.entries) { - final name = entry.key; - final argument = entry.value; - if (argument == null && allowMoreConstArguments) { - continue; - } - if (argument != namedArguments[name]) { - return false; - } + if (!_semanticEqualsArguments( + other, + allowMoreConstArguments: allowMoreConstArguments, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; } - return _semanticEqualsShared( + return _semanticEqualsCall( other, - allowLocationNull, uriMapping: uriMapping, loadingUnitMapping: loadingUnitMapping, + allowMoreConstArguments: allowMoreConstArguments, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, ); - case CallTearOff(): - return allowTearOffToStaticPromotion; + case CallTearoff(): + return allowTearoffToStaticPromotion; } } + + @override + String toString() { + final parts = []; + if (receiver != null) { + parts.add('receiver: $receiver'); + } + if (positionalArguments.isNotEmpty) { + parts.add('positional: ${positionalArguments.join(', ')}'); + } + if (namedArguments.isNotEmpty) { + final namedString = namedArguments.entries + .map((e) => '${e.key}=${e.value}') + .join(', '); + parts.add( + 'named: $namedString', + ); + } + parts.add('loadingUnit: ${loadingUnit.name}'); + return 'CallWithArguments(${parts.join(', ')})'; + } } -/// A reference to a tear-off use of the [Identifier]. This means that we can't +/// A reference to a tear-off use of the [Definition]. This means that we can't /// record the arguments possibly passed to the method somewhere else. -final class CallTearOff extends CallReference { - const CallTearOff({required super.loadingUnit, required super.location}); +final class CallTearoff extends CallReference { + const CallTearoff({required super.loadingUnit, super.receiver}); + + @override + int get _orderingTypePriority => 1; @override - TearoffCallSyntax _toSyntax( - Map constants, - Map locations, - ) => TearoffCallSyntax(at: locations[location]!, loadingUnit: loadingUnit!); + int _compareToCallInternal(covariant CallTearoff other) => 0; + + @override + Reference _canonicalizeChildren(CanonicalizationContext context) => + CallTearoff( + loadingUnit: context.canonicalizeLoadingUnit(loadingUnit), + receiver: receiver != null + ? context.canonicalizeConstant(receiver!) + : null, + ); + + @override + CallReference _filter({String? definitionPackageName}) => CallTearoff( + loadingUnit: loadingUnit, + receiver: receiver?.filter(definitionPackageName: definitionPackageName), + ); + + @override + TearoffCallSyntax _toSyntax(SerializationContext context) => + TearoffCallSyntax( + loadingUnitIndex: context.loadingUnits[loadingUnit]!, + receiver: receiver != null ? context.constants[receiver!] : null, + ); @override @visibleForTesting bool semanticEquals( CallReference other, { - bool allowTearOffToStaticPromotion = false, + bool allowTearoffToStaticPromotion = false, bool allowMoreConstArguments = false, - bool allowLocationNull = false, + bool allowPromotionOfUnsupported = false, String Function(String)? uriMapping, String Function(String)? loadingUnitMapping, }) { switch (other) { case CallWithArguments(): return false; - case CallTearOff(): - return _semanticEqualsShared( + case CallTearoff(): + return _semanticEqualsCall( other, - allowLocationNull, uriMapping: uriMapping, loadingUnitMapping: loadingUnitMapping, + allowMoreConstArguments: allowMoreConstArguments, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, ); } } + + @override + String toString() { + final parts = []; + if (receiver != null) { + parts.add('receiver: $receiver'); + } + parts.add('loadingUnit: ${loadingUnit.name}'); + return 'CallTearoff(${parts.join(', ')})'; + } } -final class InstanceReference extends Reference { - final InstanceConstant instanceConstant; +// TODO(https://github.com/dart-lang/native/issues/2908): Support enum +// constant instances here as well. Enums cannot have constructor calls or +// constructor tearoffs though. So how to do the type hierarchy here? +// TODO(https://github.com/dart-lang/native/issues/3057): Extension type const +// instances? +// +sealed class InstanceReference extends Reference { + const InstanceReference({required super.loadingUnit}); - const InstanceReference({ + @override + int _compareToInternal(covariant InstanceReference other) => + _compareToInstanceInternal(other); + + int _compareToInstanceInternal(covariant InstanceReference other); + + static InstanceReference _fromSyntax( + InstanceSyntax syntax, + DeserializationContext context, + ) => switch (syntax) { + ConstantInstanceSyntax( + :final constantIndex, + :final loadingUnitIndex, + ) => + InstanceConstantReference( + instanceConstant: context.constants[constantIndex] as Constant, + loadingUnit: context.loadingUnits[loadingUnitIndex], + ), + CreationInstanceSyntax( + :final named, + :final positional, + :final loadingUnitIndex, + :final definitionIndex, + ) => + InstanceCreationReference( + definition: context.definitions[definitionIndex], + positionalArguments: (positional ?? []) + .map((index) => CallReference._argumentFromSyntax(index, context)) + .toList(), + namedArguments: (named ?? {}).map( + (name, index) => MapEntry( + name, + CallReference._argumentFromSyntax(index, context), + ), + ), + loadingUnit: context.loadingUnits[loadingUnitIndex], + ), + TearoffInstanceSyntax( + :final loadingUnitIndex, + :final definitionIndex, + ) => + ConstructorTearoffReference( + definition: context.definitions[definitionIndex], + loadingUnit: context.loadingUnits[loadingUnitIndex], + ), + _ => throw UnimplementedError('Unknown InstanceSyntax type'), + }; + + InstanceSyntax _toSyntax(SerializationContext context); + + @override + InstanceReference _filter({String? definitionPackageName}); + + /// Compares this [InstanceReference] with [other] for semantic equality. + /// + /// The loading unit can be mapped with [loadingUnitMapping]. + /// + /// The URI in the location can be mapped with [uriMapping]. + @visibleForTesting + bool semanticEquals( + InstanceReference other, { + String Function(String)? uriMapping, + String Function(String)? loadingUnitMapping, + bool allowMoreConstArguments = false, + bool allowPromotionOfUnsupported = false, + }); +} + +final class InstanceConstantReference extends InstanceReference { + final Constant instanceConstant; + + const InstanceConstantReference({ required this.instanceConstant, required super.loadingUnit, - required super.location, }); - factory InstanceReference.fromJson( - Map json, - List constants, - List locations, - ) => _fromSyntax(InstanceSyntax.fromJson(json), constants, locations); + @override + int get _orderingTypePriority => 2; - static InstanceReference _fromSyntax( - InstanceSyntax syntax, - List constants, - List locations, - ) { - final locationIndex = syntax.at; - final location = locationIndex == null ? null : locations[locationIndex]; - return InstanceReference( - instanceConstant: constants[syntax.constantIndex] as InstanceConstant, - loadingUnit: syntax.loadingUnit, - location: location, + @override + int _compareToInstanceInternal(covariant InstanceConstantReference other) => + instanceConstant.compareTo(other.instanceConstant); + + @override + Reference _canonicalizeChildren(CanonicalizationContext context) => + InstanceConstantReference( + loadingUnit: context.canonicalizeLoadingUnit(loadingUnit), + instanceConstant: + context.canonicalizeConstant(instanceConstant) as Constant, + ); + + @override + InstanceReference _filter({String? definitionPackageName}) => + InstanceConstantReference( + loadingUnit: loadingUnit, + instanceConstant: + instanceConstant.filter( + definitionPackageName: definitionPackageName, + ) + as Constant, + ); + + @override + ConstantInstanceSyntax _toSyntax(SerializationContext context) => + ConstantInstanceSyntax( + constantIndex: context.constants[instanceConstant]!, + loadingUnitIndex: context.loadingUnits[loadingUnit]!, + ); + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(super == other)) return false; + + return other is InstanceConstantReference && + other.instanceConstant == instanceConstant; + } + + @override + int get hashCode => + cacheHashCode(() => Object.hash(instanceConstant, super.hashCode)); + + @override + @visibleForTesting + bool semanticEquals( + InstanceReference other, { + String Function(String)? uriMapping, + String Function(String)? loadingUnitMapping, + bool allowMoreConstArguments = false, + bool allowPromotionOfUnsupported = false, + }) { + if (other is! InstanceConstantReference) return false; + // ignore: invalid_use_of_visible_for_testing_member + if (!instanceConstant.semanticEquals( + other.instanceConstant, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + return _semanticEqualsShared( + other, + uriMapping: uriMapping, + loadingUnitMapping: loadingUnitMapping, + ); + } + + @override + String toString() { + final parts = []; + parts.add('instanceConstant: $instanceConstant'); + parts.add('loadingUnit: ${loadingUnit.name}'); + return 'InstanceConstantReference(${parts.join(', ')})'; + } +} + +/// Recorded for generative constructor invocations (non-const). +/// +/// Any non-provided arguments with default values will have their default +/// values filled in. +final class InstanceCreationReference extends InstanceReference + with _HasArguments { + final Definition definition; + @override + final List positionalArguments; + @override + final Map namedArguments; + + const InstanceCreationReference({ + required this.definition, + required this.positionalArguments, + required this.namedArguments, + required super.loadingUnit, + }); + + @override + int get _orderingTypePriority => 3; + + @override + int _compareToInstanceInternal(covariant InstanceCreationReference other) { + final result = definition.compareTo(other.definition); + if (result != 0) return result; + return _compareToArguments(other); + } + + @override + Reference _canonicalizeChildren(CanonicalizationContext context) => + InstanceCreationReference( + definition: context.canonicalizeDefinition(definition), + loadingUnit: context.canonicalizeLoadingUnit(loadingUnit), + positionalArguments: _canonicalizePositional(context), + namedArguments: _canonicalizeNamed(context), + ); + + @override + InstanceReference _filter({String? definitionPackageName}) => + InstanceCreationReference( + definition: definition, + loadingUnit: loadingUnit, + positionalArguments: _filterPositional( + definitionPackageName: definitionPackageName, + ), + namedArguments: _filterNamed( + definitionPackageName: definitionPackageName, + ), + ); + + @override + CreationInstanceSyntax _toSyntax(SerializationContext context) { + final namedArgs = {}; + for (final entry in namedArguments.entries) { + namedArgs[entry.key] = context.constants[entry.value]!; + } + + return CreationInstanceSyntax( + definitionIndex: context.definitions[definition]!, + loadingUnitIndex: context.loadingUnits[loadingUnit]!, + named: namedArgs.isNotEmpty ? namedArgs : null, + positional: positionalArguments.isEmpty + ? null + : [ + for (final argument in positionalArguments) + context.constants[argument]!, + ], ); } @override - InstanceSyntax _toSyntax( - Map constants, - Map locations, - ) => InstanceSyntax( - at: locations[location]!, - constantIndex: constants[instanceConstant]!, - loadingUnit: loadingUnit!, + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (!(super == other)) return false; + + return other is InstanceCreationReference && + other.definition == definition && + deepEquals(other.positionalArguments, positionalArguments) && + deepEquals(other.namedArguments, namedArguments); + } + + @override + int get hashCode => cacheHashCode( + () => Object.hash( + definition, + deepHash(positionalArguments), + deepHash(namedArguments), + super.hashCode, + ), ); + @override + @visibleForTesting + bool semanticEquals( + InstanceReference other, { + String Function(String)? uriMapping, + String Function(String)? loadingUnitMapping, + bool allowMoreConstArguments = false, + bool allowPromotionOfUnsupported = false, + }) { + if (other is! InstanceCreationReference) return false; + // ignore: invalid_use_of_visible_for_testing_member + if (!definition.semanticEquals(other.definition, uriMapping: uriMapping)) { + return false; + } + if (!_semanticEqualsArguments( + other, + allowMoreConstArguments: allowMoreConstArguments, + allowPromotionOfUnsupported: allowPromotionOfUnsupported, + )) { + return false; + } + return _semanticEqualsShared( + other, + uriMapping: uriMapping, + loadingUnitMapping: loadingUnitMapping, + ); + } + + @override + String toString() { + final parts = []; + parts.add('definition: $definition'); + if (positionalArguments.isNotEmpty) { + parts.add('positional: ${positionalArguments.join(', ')}'); + } + if (namedArguments.isNotEmpty) { + final namedString = namedArguments.entries + .map((e) => '${e.key}=${e.value}') + .join(', '); + parts.add( + 'named: $namedString', + ); + } + parts.add('loadingUnit: ${loadingUnit.name}'); + return 'InstanceCreationReference(${parts.join(', ')})'; + } +} + +final class ConstructorTearoffReference extends InstanceReference { + final Definition definition; + + const ConstructorTearoffReference({ + required this.definition, + required super.loadingUnit, + }); + + @override + int get _orderingTypePriority => 4; + + @override + int _compareToInstanceInternal(covariant ConstructorTearoffReference other) => + definition.compareTo(other.definition); + + @override + Reference _canonicalizeChildren(CanonicalizationContext context) => + ConstructorTearoffReference( + definition: context.canonicalizeDefinition(definition), + loadingUnit: context.canonicalizeLoadingUnit(loadingUnit), + ); + + @override + InstanceReference _filter({String? definitionPackageName}) => this; + + @override + TearoffInstanceSyntax _toSyntax(SerializationContext context) => + TearoffInstanceSyntax( + definitionIndex: context.definitions[definition]!, + loadingUnitIndex: context.loadingUnits[loadingUnit]!, + ); + @override bool operator ==(Object other) { if (identical(this, other)) return true; if (!(super == other)) return false; - return other is InstanceReference && - other.instanceConstant == instanceConstant; + return other is ConstructorTearoffReference && + other.definition == definition; } @override - int get hashCode => Object.hash(instanceConstant, super.hashCode); + int get hashCode => + cacheHashCode(() => Object.hash(definition, super.hashCode)); - /// Compares this [InstanceReference] with [other] for semantic equality. - /// - /// The loading unit can be mapped with [loadingUnitMapping]. - /// - /// The URI in the location can be mapped with [uriMapping]. - /// - /// If [allowLocationNull] is true, a null location is considered equal to - /// any other location. + @override @visibleForTesting bool semanticEquals( InstanceReference other, { - bool allowLocationNull = false, String Function(String)? uriMapping, String Function(String)? loadingUnitMapping, + bool allowMoreConstArguments = false, + bool allowPromotionOfUnsupported = false, }) { - if (!deepEquals(instanceConstant, other.instanceConstant)) { + if (other is! ConstructorTearoffReference) return false; + // ignore: invalid_use_of_visible_for_testing_member + if (!definition.semanticEquals(other.definition, uriMapping: uriMapping)) { return false; } return _semanticEqualsShared( other, - allowLocationNull, uriMapping: uriMapping, loadingUnitMapping: loadingUnitMapping, ); } + + @override + String toString() { + final parts = []; + parts.add('definition: $definition'); + parts.add('loadingUnit: ${loadingUnit.name}'); + return 'ConstructorTearoffReference(${parts.join(', ')})'; + } +} + +/// Package private (protected) methods for [Reference]. +/// +/// This avoids bloating the public API and public API docs and prevents +/// internal types from leaking from the API. +extension ReferenceProtected on Reference { + Reference canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context); + + Reference filter({String? definitionPackageName}) => + _filter(definitionPackageName: definitionPackageName); + + int compareTo(Reference other) => _compareTo(other); } /// Package private (protected) methods for [CallReference]. @@ -367,16 +892,20 @@ final class InstanceReference extends Reference { /// This avoids bloating the public API and public API docs and prevents /// internal types from leaking from the API. extension CallReferenceProtected on CallReference { - CallSyntax toSyntax( - Map constants, - Map locations, - ) => _toSyntax(constants, locations); + CallSyntax toSyntax(SerializationContext context) => _toSyntax(context); + + CallReference canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context) as CallReference; + + CallReference filter({String? definitionPackageName}) => + _filter(definitionPackageName: definitionPackageName); + + int compareTo(Reference other) => _compareTo(other); static CallReference fromSyntax( CallSyntax syntax, - List constants, - List locations, - ) => CallReference._fromSyntax(syntax, constants, locations); + DeserializationContext context, + ) => CallReference._fromSyntax(syntax, context); } /// Package private (protected) methods for [InstanceReference]. @@ -384,14 +913,18 @@ extension CallReferenceProtected on CallReference { /// This avoids bloating the public API and public API docs and prevents /// internal types from leaking from the API. extension InstanceReferenceProtected on InstanceReference { - InstanceSyntax toSyntax( - Map constants, - Map locations, - ) => _toSyntax(constants, locations); + InstanceSyntax toSyntax(SerializationContext context) => _toSyntax(context); + + InstanceReference canonicalizeChildren(CanonicalizationContext context) => + _canonicalizeChildren(context) as InstanceReference; + + InstanceReference filter({String? definitionPackageName}) => + _filter(definitionPackageName: definitionPackageName); + + int compareTo(Reference other) => _compareTo(other); static InstanceReference fromSyntax( InstanceSyntax syntax, - List constants, - List locations, - ) => InstanceReference._fromSyntax(syntax, constants, locations); + DeserializationContext context, + ) => InstanceReference._fromSyntax(syntax, context); } diff --git a/pkgs/record_use/lib/src/serialization_context.dart b/pkgs/record_use/lib/src/serialization_context.dart new file mode 100644 index 0000000000..ce2d410ac2 --- /dev/null +++ b/pkgs/record_use/lib/src/serialization_context.dart @@ -0,0 +1,109 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// This library defines the context objects used to manage reference pools +/// during serialization and deserialization of normalized JSON. +/// +/// A **pool** is a deduplicated collection of semantic objects (such as +/// [Constant]s) that are represented as a list at the top level of the JSON. +/// Other objects reference these by their integer index into the pool. +/// +/// ### Layer Responsibilities +/// +/// The **Syntax Layer** ([ConstantSyntax], [RecordedUsesSyntax], etc.) is +/// designed to be context-free, acting as a thin wrapper around JSON data. This +/// aligns with the capabilities of standard JSON Schema. The syntax defines how +/// pools are physically encoded in JSON as flat, top-level arrays (e.g., +/// [RecordedUsesSyntax.constants]). It uses integer indices to represent +/// relationships, keeping the JSON structure normalized and deduplicated. +/// +/// The **Semantic Layer** ([Constant]s, [Recordings], etc.) translates these +/// flat indices into rich, interconnected semantic objects. It uses +/// [DeserializationContext] and [SerializationContext] to map between the +/// integer indices in the JSON and deduplicated [Constant] objects, ensuring +/// identity is preserved across the system. +/// +/// ### (De)serialization Order +/// +/// The order of operations ensures that all dependencies are available at each +/// step: +/// +/// 1. **Loading Units**: Loading unit identifiers are deserialized from or +/// serialized to the [RecordedUsesSyntax.loadingUnits] pool first. +/// 2. **Definitions**: [Definition] objects are deserialized from or +/// serialized to the [RecordedUsesSyntax.definitions] pool second. +/// 3. **Constants**: [Constant] objects are deserialized from or serialized +/// to the [RecordedUsesSyntax.constants] pool third. They may contain +/// references to the definitions pool (e.g. for [InstanceConstant]) and the +/// constants pool (for recursive collections). +/// 4. **Recordings**: Recordings are (de)serialized last from or to +/// [RecordedUsesSyntax.uses] as they depend on loading units, +/// [Constant]s, and [Definition]s. +library; + +import 'package:meta/meta.dart'; + +import 'constant.dart'; +import 'definition.dart'; +import 'loading_unit.dart'; +import 'recordings.dart'; +import 'syntax.g.dart'; + +/// Context providing access to the loading unit pool during deserialization. +@immutable +base class LoadingUnitDeserializationContext { + final List loadingUnits; + + const LoadingUnitDeserializationContext(this.loadingUnits); +} + +/// Context providing access to the [Definition] pool during deserialization. +@immutable +base class DefinitionDeserializationContext + extends LoadingUnitDeserializationContext { + final List definitions; + + DefinitionDeserializationContext.fromPrevious( + LoadingUnitDeserializationContext previous, + this.definitions, + ) : super(previous.loadingUnits); +} + +/// The final deserialization state where all pools are resolved. +@immutable +final class DeserializationContext extends DefinitionDeserializationContext { + /// The mapping from the unique integer index in + /// [RecordedUsesSyntax.constants] to the semantic [MaybeConstant]s. + final List constants; + + DeserializationContext.fromPrevious( + DefinitionDeserializationContext previous, + this.constants, + ) : super.fromPrevious(previous, previous.definitions); +} + +/// The serialization state containing indices for all pools. +/// +/// Canonicalization is responsible for collecting all reachable objects across +/// the recording and providing the basis for these index maps. +@immutable +final class SerializationContext { + /// The mapping from semantic [LoadingUnit] objects to their unique integer + /// index within the loading unit pool ([RecordedUsesSyntax.loadingUnits]). + final Map loadingUnits; + + /// The mapping from semantic [Definition] objects to their unique integer + /// index within the definitions pool ([RecordedUsesSyntax.definitions]). + final Map definitions; + + /// The mapping from semantic [MaybeConstant] objects to their unique integer + /// index within the constants pool ([RecordedUsesSyntax.constants]). + final Map constants; + + const SerializationContext({ + required this.loadingUnits, + required this.definitions, + required this.constants, + }); +} diff --git a/pkgs/record_use/lib/src/syntax.g.dart b/pkgs/record_use/lib/src/syntax.g.dart index e74db3505d..530cf0ecfd 100644 --- a/pkgs/record_use/lib/src/syntax.g.dart +++ b/pkgs/record_use/lib/src/syntax.g.dart @@ -71,33 +71,33 @@ class CallSyntax extends JsonObjectSyntax { }) : super.fromJson(); CallSyntax({ - int? at, - required String loadingUnit, + required int loadingUnitIndex, + int? receiver, required String type, super.path = const [], }) : super() { - _at = at; - _loadingUnit = loadingUnit; + _loadingUnitIndex = loadingUnitIndex; + _receiver = receiver; _type = type; json.sortOnKey(); } - int? get at => _reader.get('@'); + int get loadingUnitIndex => _reader.get('loading_unit_index'); - set _at(int? value) { - json.setOrRemove('@', value); + set _loadingUnitIndex(int value) { + json.setOrRemove('loading_unit_index', value); } - List _validateAt() => _reader.validate('@'); + List _validateLoadingUnitIndex() => + _reader.validate('loading_unit_index'); - String get loadingUnit => _reader.get('loading_unit'); + int? get receiver => _reader.get('receiver'); - set _loadingUnit(String value) { - json.setOrRemove('loading_unit', value); + set _receiver(int? value) { + json.setOrRemove('receiver', value); } - List _validateLoadingUnit() => - _reader.validate('loading_unit'); + List _validateReceiver() => _reader.validate('receiver'); String get type => _reader.get('type'); @@ -110,8 +110,8 @@ class CallSyntax extends JsonObjectSyntax { @override List validate() => [ ...super.validate(), - ..._validateAt(), - ..._validateLoadingUnit(), + ..._validateLoadingUnitIndex(), + ..._validateReceiver(), ..._validateType(), ]; @@ -119,23 +119,112 @@ class CallSyntax extends JsonObjectSyntax { String toString() => 'CallSyntax($json)'; } +class CallRecordingSyntax extends JsonObjectSyntax { + CallRecordingSyntax.fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + CallRecordingSyntax({ + required int definitionIndex, + required List uses, + super.path = const [], + }) : super() { + _definitionIndex = definitionIndex; + _uses = uses; + json.sortOnKey(); + } + + int get definitionIndex => _reader.get('definition_index'); + + set _definitionIndex(int value) { + json.setOrRemove('definition_index', value); + } + + List _validateDefinitionIndex() => + _reader.validate('definition_index'); + + List get uses { + final jsonValue = _reader.list('uses'); + return [ + for (final (index, element) in jsonValue.indexed) + CallSyntax.fromJson( + element as Map, + path: [...path, 'uses', index], + ), + ]; + } + + set _uses(List value) { + json['uses'] = [for (final item in value) item.json]; + } + + List _validateUses() { + final listErrors = _reader.validateList>( + 'uses', + ); + if (listErrors.isNotEmpty) { + return listErrors; + } + final elements = uses; + return [for (final element in elements) ...element.validate()]; + } + + @override + List validate() => [ + ...super.validate(), + ..._validateDefinitionIndex(), + ..._validateUses(), + ]; + + @override + String toString() => 'CallRecordingSyntax($json)'; +} + +class ClassNameSyntax extends NameSyntax { + ClassNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + ClassNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'class'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'ClassNameSyntax($json)'; +} + +extension ClassNameSyntaxExtension on NameSyntax { + bool get isClassName => kind == 'class'; + + ClassNameSyntax get asClassName => ClassNameSyntax.fromJson(json, path: path); +} + class ConstantSyntax extends JsonObjectSyntax { factory ConstantSyntax.fromJson( Map json, { List path = const [], }) { final result = ConstantSyntax._fromJson(json, path: path); - if (result.isInstanceConstant) { - return result.asInstanceConstant; + if (result.isBoolConstant) { + return result.asBoolConstant; } - if (result.isNullConstant) { - return result.asNullConstant; + if (result.isDoubleConstant) { + return result.asDoubleConstant; } - if (result.isStringConstant) { - return result.asStringConstant; + if (result.isEnumConstant) { + return result.asEnumConstant; } - if (result.isBoolConstant) { - return result.asBoolConstant; + if (result.isInstanceConstant) { + return result.asInstanceConstant; } if (result.isIntConstant) { return result.asIntConstant; @@ -146,6 +235,24 @@ class ConstantSyntax extends JsonObjectSyntax { if (result.isMapConstant) { return result.asMapConstant; } + if (result.isNonConstantConstant) { + return result.asNonConstantConstant; + } + if (result.isNullConstant) { + return result.asNullConstant; + } + if (result.isRecordConstant) { + return result.asRecordConstant; + } + if (result.isStringConstant) { + return result.asStringConstant; + } + if (result.isSymbolConstant) { + return result.asSymbolConstant; + } + if (result.isUnsupportedConstant) { + return result.asUnsupportedConstant; + } return result; } @@ -168,745 +275,1658 @@ class ConstantSyntax extends JsonObjectSyntax { List _validateType() => _reader.validate('type'); @override - List validate() => [...super.validate(), ..._validateType()]; + List validate() => [ + ...super.validate(), + ..._validateType(), + ..._validateExtraRulesConstant(), + ]; + + List _validateExtraRulesConstant() { + final result = []; + if (_reader.tryTraverse(['type']) == 'double') { + final objectErrors = _reader.validate?>('value'); + result.addAll(objectErrors); + if (objectErrors.isEmpty) { + final jsonValue = _reader.get?>('value'); + if (jsonValue != null) { + final reader = _JsonReader(jsonValue, [...path, 'value']); + result.addAll(reader.validate('type')); + } + } + } + if (_reader.tryTraverse(['type']) == 'instance') { + result.addAll(_reader.validate('definition_index')); + } + if (_reader.tryTraverse(['type']) == 'symbol') { + result.addAll(_reader.validate('name')); + } + return result; + } @override String toString() => 'ConstantSyntax($json)'; } -class DefinitionSyntax extends JsonObjectSyntax { - DefinitionSyntax.fromJson( +class ConstantInstanceSyntax extends InstanceSyntax { + ConstantInstanceSyntax.fromJson( super.json, { - super.path = const [], - }) : super.fromJson(); + super.path, + }) : super._fromJson(); - DefinitionSyntax({ - required IdentifierSyntax identifier, - String? loadingUnit, + ConstantInstanceSyntax({ + required int constantIndex, + required super.loadingUnitIndex, super.path = const [], - }) : super() { - _identifier = identifier; - _loadingUnit = loadingUnit; + }) : super(type: 'constant') { + _constantIndex = constantIndex; json.sortOnKey(); } - IdentifierSyntax get identifier { - final jsonValue = _reader.map$('identifier'); - return IdentifierSyntax.fromJson(jsonValue, path: [...path, 'identifier']); + /// Setup all fields for [ConstantInstanceSyntax] that are not in + /// [InstanceSyntax]. + void setup({required int constantIndex}) { + _constantIndex = constantIndex; + json.sortOnKey(); } - set _identifier(IdentifierSyntax value) { - json['identifier'] = value.json; - } + int get constantIndex => _reader.get('constant_index'); - List _validateIdentifier() { - final mapErrors = _reader.validate>('identifier'); - if (mapErrors.isNotEmpty) { - return mapErrors; - } - return identifier.validate(); + set _constantIndex(int value) { + json.setOrRemove('constant_index', value); } - String? get loadingUnit => _reader.get('loading_unit'); + List _validateConstantIndex() => + _reader.validate('constant_index'); - set _loadingUnit(String? value) { - json.setOrRemove('loading_unit', value); - } + @override + List validate() => [...super.validate(), ..._validateConstantIndex()]; - List _validateLoadingUnit() => - _reader.validate('loading_unit'); + @override + String toString() => 'ConstantInstanceSyntax($json)'; +} + +extension ConstantInstanceSyntaxExtension on InstanceSyntax { + bool get isConstantInstance => type == 'constant'; + + ConstantInstanceSyntax get asConstantInstance => + ConstantInstanceSyntax.fromJson(json, path: path); +} + +class ConstructorNameSyntax extends NameSyntax { + ConstructorNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + ConstructorNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'constructor'); @override List validate() => [ ...super.validate(), - ..._validateIdentifier(), - ..._validateLoadingUnit(), ]; @override - String toString() => 'DefinitionSyntax($json)'; + String toString() => 'ConstructorNameSyntax($json)'; } -class IdentifierSyntax extends JsonObjectSyntax { - IdentifierSyntax.fromJson( +extension ConstructorNameSyntaxExtension on NameSyntax { + bool get isConstructorName => kind == 'constructor'; + + ConstructorNameSyntax get asConstructorName => + ConstructorNameSyntax.fromJson(json, path: path); +} + +class CreationInstanceSyntax extends InstanceSyntax { + CreationInstanceSyntax.fromJson( super.json, { - super.path = const [], - }) : super.fromJson(); + super.path, + }) : super._fromJson(); - IdentifierSyntax({ - required String name, - String? scope, - required String uri, + CreationInstanceSyntax({ + required int definitionIndex, + required super.loadingUnitIndex, + Map? named, + List? positional, super.path = const [], - }) : super() { - _name = name; - _scope = scope; - _uri = uri; + }) : super(type: 'creation') { + _definitionIndex = definitionIndex; + _named = named; + _positional = positional; json.sortOnKey(); } - String get name => _reader.get('name'); + /// Setup all fields for [CreationInstanceSyntax] that are not in + /// [InstanceSyntax]. + void setup({ + required int definitionIndex, + required Map? named, + required List? positional, + }) { + _definitionIndex = definitionIndex; + _named = named; + _positional = positional; + json.sortOnKey(); + } - set _name(String value) { - json.setOrRemove('name', value); + int get definitionIndex => _reader.get('definition_index'); + + set _definitionIndex(int value) { + json.setOrRemove('definition_index', value); } - List _validateName() => _reader.validate('name'); + List _validateDefinitionIndex() => + _reader.validate('definition_index'); - String? get scope => _reader.get('scope'); + Map? get named => _reader.optionalMap( + 'named', + ); - set _scope(String? value) { - json.setOrRemove('scope', value); + set _named(Map? value) { + _checkArgumentMapKeys( + value, + ); + json.setOrRemove('named', value); } - List _validateScope() => _reader.validate('scope'); + List _validateNamed() => _reader.validateOptionalMap( + 'named', + ); - String get uri => _reader.get('uri'); + List? get positional => _reader.optionalList('positional'); - set _uri(String value) { - json.setOrRemove('uri', value); + set _positional(List? value) { + json.setOrRemove('positional', value); } - List _validateUri() => _reader.validate('uri'); + List _validatePositional() => + _reader.validateOptionalList('positional'); @override List validate() => [ ...super.validate(), - ..._validateName(), - ..._validateScope(), - ..._validateUri(), + ..._validateDefinitionIndex(), + ..._validateNamed(), + ..._validatePositional(), ]; @override - String toString() => 'IdentifierSyntax($json)'; + String toString() => 'CreationInstanceSyntax($json)'; } -class InstanceSyntax extends JsonObjectSyntax { - InstanceSyntax.fromJson( +extension CreationInstanceSyntaxExtension on InstanceSyntax { + bool get isCreationInstance => type == 'creation'; + + CreationInstanceSyntax get asCreationInstance => + CreationInstanceSyntax.fromJson(json, path: path); +} + +class DefinitionSyntax extends JsonObjectSyntax { + DefinitionSyntax.fromJson( super.json, { super.path = const [], }) : super.fromJson(); - InstanceSyntax({ - int? at, - required int constantIndex, - required String loadingUnit, + DefinitionSyntax({ + required List definitionPath, + required String uri, super.path = const [], }) : super() { - _at = at; - _constantIndex = constantIndex; - _loadingUnit = loadingUnit; + _definitionPath = definitionPath; + _uri = uri; json.sortOnKey(); } - int? get at => _reader.get('@'); - - set _at(int? value) { - json.setOrRemove('@', value); + List get definitionPath { + final jsonValue = _reader.list('path'); + return [ + for (final (index, element) in jsonValue.indexed) + NameSyntax.fromJson( + element as Map, + path: [...path, 'path', index], + ), + ]; } - List _validateAt() => _reader.validate('@'); - - int get constantIndex => _reader.get('constant_index'); + set _definitionPath(List value) { + json['path'] = [for (final item in value) item.json]; + } - set _constantIndex(int value) { - json.setOrRemove('constant_index', value); + List _validateDefinitionPath() { + final listErrors = _reader.validateList>( + 'path', + ); + if (listErrors.isNotEmpty) { + return listErrors; + } + final elements = definitionPath; + return [for (final element in elements) ...element.validate()]; } - List _validateConstantIndex() => - _reader.validate('constant_index'); + static final _uriPattern = RegExp(r'^package:'); - String get loadingUnit => _reader.get('loading_unit'); + String get uri => _reader.string('uri', _uriPattern); - set _loadingUnit(String value) { - json.setOrRemove('loading_unit', value); + set _uri(String value) { + if (!_uriPattern.hasMatch(value)) { + throw ArgumentError.value( + value, + 'value', + 'Value does not satisify pattern: ${_uriPattern.pattern}.', + ); + } + json.setOrRemove('uri', value); } - List _validateLoadingUnit() => - _reader.validate('loading_unit'); + List _validateUri() => _reader.validateString('uri', _uriPattern); @override List validate() => [ ...super.validate(), - ..._validateAt(), - ..._validateConstantIndex(), - ..._validateLoadingUnit(), + ..._validateDefinitionPath(), + ..._validateUri(), ]; @override - String toString() => 'InstanceSyntax($json)'; + String toString() => 'DefinitionSyntax($json)'; } -class InstanceConstantSyntax extends ConstantSyntax { - InstanceConstantSyntax.fromJson( +class DoubleConstantSyntax extends ConstantSyntax { + DoubleConstantSyntax.fromJson( super.json, { super.path, }) : super._fromJson(); - InstanceConstantSyntax({JsonObjectSyntax? value, super.path = const []}) - : super(type: 'Instance') { + DoubleConstantSyntax({ + required DoubleConstantValueSyntax value, + super.path = const [], + }) : super(type: 'double') { _value = value; json.sortOnKey(); } - /// Setup all fields for [InstanceConstantSyntax] that are not in + /// Setup all fields for [DoubleConstantSyntax] that are not in /// [ConstantSyntax]. - void setup({required JsonObjectSyntax? value}) { + void setup({required DoubleConstantValueSyntax value}) { _value = value; json.sortOnKey(); } - JsonObjectSyntax? get value { - final jsonValue = _reader.optionalMap('value'); - if (jsonValue == null) return null; - return JsonObjectSyntax.fromJson(jsonValue, path: [...path, 'value']); + DoubleConstantValueSyntax get value { + final jsonValue = _reader.map$('value'); + return DoubleConstantValueSyntax.fromJson( + jsonValue, + path: [...path, 'value'], + ); } - set _value(JsonObjectSyntax? value) { - json.setOrRemove('value', value?.json); + set _value(DoubleConstantValueSyntax value) { + json['value'] = value.json; } List _validateValue() { - final mapErrors = _reader.validate?>('value'); + final mapErrors = _reader.validate>('value'); if (mapErrors.isNotEmpty) { return mapErrors; } - return value?.validate() ?? []; + return value.validate(); } @override List validate() => [...super.validate(), ..._validateValue()]; @override - String toString() => 'InstanceConstantSyntax($json)'; + String toString() => 'DoubleConstantSyntax($json)'; } -extension InstanceConstantSyntaxExtension on ConstantSyntax { - bool get isInstanceConstant => type == 'Instance'; +extension DoubleConstantSyntaxExtension on ConstantSyntax { + bool get isDoubleConstant => type == 'double'; - InstanceConstantSyntax get asInstanceConstant => - InstanceConstantSyntax.fromJson(json, path: path); + DoubleConstantSyntax get asDoubleConstant => + DoubleConstantSyntax.fromJson(json, path: path); } -class IntConstantSyntax extends ConstantSyntax { - IntConstantSyntax.fromJson( +class DoubleConstantValueSyntax extends JsonObjectSyntax { + factory DoubleConstantValueSyntax.fromJson( + Map json, { + List path = const [], + }) { + final result = DoubleConstantValueSyntax._fromJson(json, path: path); + if (result.isNegativeInfinityDoubleConstantValue) { + return result.asNegativeInfinityDoubleConstantValue; + } + if (result.isNotANumberDoubleConstantValue) { + return result.asNotANumberDoubleConstantValue; + } + if (result.isNumberDoubleConstantValue) { + return result.asNumberDoubleConstantValue; + } + if (result.isPositiveInfinityDoubleConstantValue) { + return result.asPositiveInfinityDoubleConstantValue; + } + return result; + } + + DoubleConstantValueSyntax._fromJson( super.json, { - super.path, - }) : super._fromJson(); + super.path = const [], + }) : super.fromJson(); - IntConstantSyntax({required int value, super.path = const []}) - : super(type: 'int') { + DoubleConstantValueSyntax({ + required String type, + double? value, + super.path = const [], + }) : super() { + _type = type; _value = value; json.sortOnKey(); } - /// Setup all fields for [IntConstantSyntax] that are not in - /// [ConstantSyntax]. - void setup({required int value}) { - _value = value; - json.sortOnKey(); - } + String get type => _reader.get('type'); - int get value => _reader.get('value'); + set _type(String value) { + json.setOrRemove('type', value); + } - set _value(int value) { + List _validateType() => _reader.validate('type'); + + double? get value => _reader.get('value'); + + set _value(double? value) { json.setOrRemove('value', value); } - List _validateValue() => _reader.validate('value'); - - @override - List validate() => [...super.validate(), ..._validateValue()]; + List _validateValue() => _reader.validate('value'); @override - String toString() => 'IntConstantSyntax($json)'; -} + List validate() => [ + ...super.validate(), + ..._validateType(), + ..._validateValue(), + ..._validateExtraRulesDoubleConstantValue(), + ]; -extension IntConstantSyntaxExtension on ConstantSyntax { - bool get isIntConstant => type == 'int'; + List _validateExtraRulesDoubleConstantValue() { + final result = []; + if (_reader.tryTraverse(['type']) == 'number') { + result.addAll(_reader.validate('value')); + } + return result; + } - IntConstantSyntax get asIntConstant => - IntConstantSyntax.fromJson(json, path: path); + @override + String toString() => 'DoubleConstantValueSyntax($json)'; } -class ListConstantSyntax extends ConstantSyntax { - ListConstantSyntax.fromJson( +class EnumConstantSyntax extends ConstantSyntax { + EnumConstantSyntax.fromJson( super.json, { super.path, }) : super._fromJson(); - ListConstantSyntax({List? value, super.path = const []}) - : super(type: 'list') { + EnumConstantSyntax({ + required int definitionIndex, + required int index, + required String name, + Map? value, + super.path = const [], + }) : super(type: 'enum') { + _definitionIndex = definitionIndex; + _index = index; + _name = name; _value = value; json.sortOnKey(); } - /// Setup all fields for [ListConstantSyntax] that are not in + /// Setup all fields for [EnumConstantSyntax] that are not in /// [ConstantSyntax]. - void setup({required List? value}) { + void setup({ + required int definitionIndex, + required int index, + required String name, + required Map? value, + }) { + _definitionIndex = definitionIndex; + _index = index; + _name = name; _value = value; json.sortOnKey(); } - List? get value => _reader.optionalList('value'); + int get definitionIndex => _reader.get('definition_index'); - set _value(List? value) { + set _definitionIndex(int value) { + json.setOrRemove('definition_index', value); + } + + List _validateDefinitionIndex() => + _reader.validate('definition_index'); + + int get index => _reader.get('index'); + + set _index(int value) { + json.setOrRemove('index', value); + } + + List _validateIndex() => _reader.validate('index'); + + String get name => _reader.get('name'); + + set _name(String value) { + json.setOrRemove('name', value); + } + + List _validateName() => _reader.validate('name'); + + Map? get value => _reader.optionalMap( + 'value', + ); + + set _value(Map? value) { + _checkArgumentMapKeys( + value, + ); json.setOrRemove('value', value); } - List _validateValue() => - _reader.validateOptionalList('value'); + List _validateValue() => _reader.validateOptionalMap( + 'value', + ); @override - List validate() => [...super.validate(), ..._validateValue()]; + List validate() => [ + ...super.validate(), + ..._validateDefinitionIndex(), + ..._validateIndex(), + ..._validateName(), + ..._validateValue(), + ]; @override - String toString() => 'ListConstantSyntax($json)'; + String toString() => 'EnumConstantSyntax($json)'; } -extension ListConstantSyntaxExtension on ConstantSyntax { - bool get isListConstant => type == 'list'; +extension EnumConstantSyntaxExtension on ConstantSyntax { + bool get isEnumConstant => type == 'enum'; - ListConstantSyntax get asListConstant => - ListConstantSyntax.fromJson(json, path: path); + EnumConstantSyntax get asEnumConstant => + EnumConstantSyntax.fromJson(json, path: path); } -class LocationSyntax extends JsonObjectSyntax { - LocationSyntax.fromJson( +class EnumNameSyntax extends NameSyntax { + EnumNameSyntax.fromJson( super.json, { - super.path = const [], - }) : super.fromJson(); + super.path, + }) : super._fromJson(); - LocationSyntax({ - int? column, - int? line, - required String uri, + EnumNameSyntax({ + super.disambiguators, + required super.name, super.path = const [], - }) : super() { - _column = column; - _line = line; - _uri = uri; - json.sortOnKey(); - } - - int? get column => _reader.get('column'); - - set _column(int? value) { - json.setOrRemove('column', value); - } + }) : super(kind: 'enum'); - List _validateColumn() => _reader.validate('column'); - - int? get line => _reader.get('line'); + @override + List validate() => [ + ...super.validate(), + ]; - set _line(int? value) { - json.setOrRemove('line', value); - } + @override + String toString() => 'EnumNameSyntax($json)'; +} - List _validateLine() => _reader.validate('line'); +extension EnumNameSyntaxExtension on NameSyntax { + bool get isEnumName => kind == 'enum'; - String get uri => _reader.get('uri'); + EnumNameSyntax get asEnumName => EnumNameSyntax.fromJson(json, path: path); +} - set _uri(String value) { - json.setOrRemove('uri', value); - } +class ExtensionNameSyntax extends NameSyntax { + ExtensionNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); - List _validateUri() => _reader.validate('uri'); + ExtensionNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'extension'); @override List validate() => [ ...super.validate(), - ..._validateColumn(), - ..._validateLine(), - ..._validateUri(), ]; @override - String toString() => 'LocationSyntax($json)'; + String toString() => 'ExtensionNameSyntax($json)'; } -class MapConstantSyntax extends ConstantSyntax { - MapConstantSyntax.fromJson( +extension ExtensionNameSyntaxExtension on NameSyntax { + bool get isExtensionName => kind == 'extension'; + + ExtensionNameSyntax get asExtensionName => + ExtensionNameSyntax.fromJson(json, path: path); +} + +class ExtensionTypeNameSyntax extends NameSyntax { + ExtensionTypeNameSyntax.fromJson( super.json, { super.path, }) : super._fromJson(); - MapConstantSyntax({required JsonObjectSyntax value, super.path = const []}) - : super(type: 'map') { - _value = value; - json.sortOnKey(); - } + ExtensionTypeNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'extension_type'); - /// Setup all fields for [MapConstantSyntax] that are not in - /// [ConstantSyntax]. - void setup({required JsonObjectSyntax value}) { - _value = value; - json.sortOnKey(); - } + @override + List validate() => [ + ...super.validate(), + ]; - JsonObjectSyntax get value { - final jsonValue = _reader.map$('value'); - return JsonObjectSyntax.fromJson(jsonValue, path: [...path, 'value']); - } + @override + String toString() => 'ExtensionTypeNameSyntax($json)'; +} - set _value(JsonObjectSyntax value) { - json['value'] = value.json; - } +extension ExtensionTypeNameSyntaxExtension on NameSyntax { + bool get isExtensionTypeName => kind == 'extension_type'; - List _validateValue() { - final mapErrors = _reader.validate>('value'); - if (mapErrors.isNotEmpty) { - return mapErrors; - } - return value.validate(); - } + ExtensionTypeNameSyntax get asExtensionTypeName => + ExtensionTypeNameSyntax.fromJson(json, path: path); +} + +class GetterNameSyntax extends NameSyntax { + GetterNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + GetterNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'getter'); @override - List validate() => [...super.validate(), ..._validateValue()]; + List validate() => [ + ...super.validate(), + ]; @override - String toString() => 'MapConstantSyntax($json)'; + String toString() => 'GetterNameSyntax($json)'; } -extension MapConstantSyntaxExtension on ConstantSyntax { - bool get isMapConstant => type == 'map'; +extension GetterNameSyntaxExtension on NameSyntax { + bool get isGetterName => kind == 'getter'; - MapConstantSyntax get asMapConstant => - MapConstantSyntax.fromJson(json, path: path); + GetterNameSyntax get asGetterName => + GetterNameSyntax.fromJson(json, path: path); } -class MetadataSyntax extends JsonObjectSyntax { - MetadataSyntax.fromJson( +class InstanceSyntax extends JsonObjectSyntax { + factory InstanceSyntax.fromJson( + Map json, { + List path = const [], + }) { + final result = InstanceSyntax._fromJson(json, path: path); + if (result.isConstantInstance) { + return result.asConstantInstance; + } + if (result.isCreationInstance) { + return result.asCreationInstance; + } + if (result.isTearoffInstance) { + return result.asTearoffInstance; + } + return result; + } + + InstanceSyntax._fromJson( super.json, { super.path = const [], }) : super.fromJson(); - MetadataSyntax({ - required String comment, - required String version, + InstanceSyntax({ + required int loadingUnitIndex, + required String type, super.path = const [], }) : super() { - _comment = comment; - _version = version; + _loadingUnitIndex = loadingUnitIndex; + _type = type; json.sortOnKey(); } - String get comment => _reader.get('comment'); + int get loadingUnitIndex => _reader.get('loading_unit_index'); - set _comment(String value) { - json.setOrRemove('comment', value); + set _loadingUnitIndex(int value) { + json.setOrRemove('loading_unit_index', value); } - List _validateComment() => _reader.validate('comment'); + List _validateLoadingUnitIndex() => + _reader.validate('loading_unit_index'); - String get version => _reader.get('version'); + String get type => _reader.get('type'); - set _version(String value) { - json.setOrRemove('version', value); + set _type(String value) { + json.setOrRemove('type', value); } - List _validateVersion() => _reader.validate('version'); + List _validateType() => _reader.validate('type'); @override List validate() => [ ...super.validate(), - ..._validateComment(), - ..._validateVersion(), + ..._validateLoadingUnitIndex(), + ..._validateType(), + ..._validateExtraRulesInstance(), ]; + List _validateExtraRulesInstance() { + final result = []; + if (_reader.tryTraverse(['type']) == 'creation') { + result.addAll(_reader.validate('definition_index')); + } + return result; + } + @override - String toString() => 'MetadataSyntax($json)'; + String toString() => 'InstanceSyntax($json)'; } -class NullConstantSyntax extends ConstantSyntax { - NullConstantSyntax.fromJson( +class InstanceConstantSyntax extends ConstantSyntax { + InstanceConstantSyntax.fromJson( super.json, { super.path, }) : super._fromJson(); - NullConstantSyntax({super.path = const []}) : super(type: 'Null'); + InstanceConstantSyntax({ + required int definitionIndex, + JsonObjectSyntax? value, + super.path = const [], + }) : super(type: 'instance') { + _definitionIndex = definitionIndex; + _value = value; + json.sortOnKey(); + } + + /// Setup all fields for [InstanceConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({required int definitionIndex, required JsonObjectSyntax? value}) { + _definitionIndex = definitionIndex; + _value = value; + json.sortOnKey(); + } + + int get definitionIndex => _reader.get('definition_index'); + + set _definitionIndex(int value) { + json.setOrRemove('definition_index', value); + } + + List _validateDefinitionIndex() => + _reader.validate('definition_index'); + + JsonObjectSyntax? get value { + final jsonValue = _reader.optionalMap('value'); + if (jsonValue == null) return null; + return JsonObjectSyntax.fromJson(jsonValue, path: [...path, 'value']); + } + + set _value(JsonObjectSyntax? value) { + json.setOrRemove('value', value?.json); + } + + List _validateValue() { + final mapErrors = _reader.validate?>('value'); + if (mapErrors.isNotEmpty) { + return mapErrors; + } + return value?.validate() ?? []; + } @override List validate() => [ ...super.validate(), + ..._validateDefinitionIndex(), + ..._validateValue(), ]; @override - String toString() => 'NullConstantSyntax($json)'; + String toString() => 'InstanceConstantSyntax($json)'; } -extension NullConstantSyntaxExtension on ConstantSyntax { - bool get isNullConstant => type == 'Null'; +extension InstanceConstantSyntaxExtension on ConstantSyntax { + bool get isInstanceConstant => type == 'instance'; - NullConstantSyntax get asNullConstant => - NullConstantSyntax.fromJson(json, path: path); + InstanceConstantSyntax get asInstanceConstant => + InstanceConstantSyntax.fromJson(json, path: path); } -class RecordedUsesSyntax extends JsonObjectSyntax { - RecordedUsesSyntax.fromJson( +class InstanceRecordingSyntax extends JsonObjectSyntax { + InstanceRecordingSyntax.fromJson( super.json, { super.path = const [], }) : super.fromJson(); - RecordedUsesSyntax({ - List? constants, - List? locations, - required MetadataSyntax metadata, - List? recordings, + InstanceRecordingSyntax({ + required int definitionIndex, + required List uses, super.path = const [], }) : super() { - _constants = constants; - _locations = locations; - _metadata = metadata; - _recordings = recordings; + _definitionIndex = definitionIndex; + _uses = uses; json.sortOnKey(); } - List? get constants { - final jsonValue = _reader.optionalList('constants'); - if (jsonValue == null) return null; + int get definitionIndex => _reader.get('definition_index'); + + set _definitionIndex(int value) { + json.setOrRemove('definition_index', value); + } + + List _validateDefinitionIndex() => + _reader.validate('definition_index'); + + List get uses { + final jsonValue = _reader.list('uses'); return [ for (final (index, element) in jsonValue.indexed) - ConstantSyntax.fromJson( + InstanceSyntax.fromJson( element as Map, - path: [...path, 'constants', index], + path: [...path, 'uses', index], ), ]; } - set _constants(List? value) { - if (value == null) { - json.remove('constants'); - } else { - json['constants'] = [for (final item in value) item.json]; - } + set _uses(List value) { + json['uses'] = [for (final item in value) item.json]; } - List _validateConstants() { - final listErrors = _reader.validateOptionalList>( - 'constants', + List _validateUses() { + final listErrors = _reader.validateList>( + 'uses', ); if (listErrors.isNotEmpty) { return listErrors; } - final elements = constants; - if (elements == null) { - return []; - } + final elements = uses; return [for (final element in elements) ...element.validate()]; } - List? get locations { - final jsonValue = _reader.optionalList('locations'); - if (jsonValue == null) return null; + @override + List validate() => [ + ...super.validate(), + ..._validateDefinitionIndex(), + ..._validateUses(), + ]; + + @override + String toString() => 'InstanceRecordingSyntax($json)'; +} + +class IntConstantSyntax extends ConstantSyntax { + IntConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + IntConstantSyntax({required int value, super.path = const []}) + : super(type: 'int') { + _value = value; + json.sortOnKey(); + } + + /// Setup all fields for [IntConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({required int value}) { + _value = value; + json.sortOnKey(); + } + + int get value => _reader.get('value'); + + set _value(int value) { + json.setOrRemove('value', value); + } + + List _validateValue() => _reader.validate('value'); + + @override + List validate() => [...super.validate(), ..._validateValue()]; + + @override + String toString() => 'IntConstantSyntax($json)'; +} + +extension IntConstantSyntaxExtension on ConstantSyntax { + bool get isIntConstant => type == 'int'; + + IntConstantSyntax get asIntConstant => + IntConstantSyntax.fromJson(json, path: path); +} + +class ListConstantSyntax extends ConstantSyntax { + ListConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + ListConstantSyntax({List? value, super.path = const []}) + : super(type: 'list') { + _value = value; + json.sortOnKey(); + } + + /// Setup all fields for [ListConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({required List? value}) { + _value = value; + json.sortOnKey(); + } + + List? get value => _reader.optionalList('value'); + + set _value(List? value) { + json.setOrRemove('value', value); + } + + List _validateValue() => + _reader.validateOptionalList('value'); + + @override + List validate() => [...super.validate(), ..._validateValue()]; + + @override + String toString() => 'ListConstantSyntax($json)'; +} + +extension ListConstantSyntaxExtension on ConstantSyntax { + bool get isListConstant => type == 'list'; + + ListConstantSyntax get asListConstant => + ListConstantSyntax.fromJson(json, path: path); +} + +class LoadingUnitSyntax extends JsonObjectSyntax { + LoadingUnitSyntax.fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + LoadingUnitSyntax({required String name, super.path = const []}) : super() { + _name = name; + json.sortOnKey(); + } + + String get name => _reader.get('name'); + + set _name(String value) { + json.setOrRemove('name', value); + } + + List _validateName() => _reader.validate('name'); + + @override + List validate() => [...super.validate(), ..._validateName()]; + + @override + String toString() => 'LoadingUnitSyntax($json)'; +} + +class MapConstantSyntax extends ConstantSyntax { + MapConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + MapConstantSyntax({ + required List value, + super.path = const [], + }) : super(type: 'map') { + _value = value; + json.sortOnKey(); + } + + /// Setup all fields for [MapConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({required List value}) { + _value = value; + json.sortOnKey(); + } + + List get value { + final jsonValue = _reader.list('value'); return [ for (final (index, element) in jsonValue.indexed) - LocationSyntax.fromJson( + MapEntrySyntax.fromJson( element as Map, - path: [...path, 'locations', index], + path: [...path, 'value', index], ), ]; } - set _locations(List? value) { - if (value == null) { - json.remove('locations'); - } else { - json['locations'] = [for (final item in value) item.json]; - } + set _value(List value) { + json['value'] = [for (final item in value) item.json]; } - List _validateLocations() { - final listErrors = _reader.validateOptionalList>( - 'locations', + List _validateValue() { + final listErrors = _reader.validateList>( + 'value', ); if (listErrors.isNotEmpty) { return listErrors; } - final elements = locations; - if (elements == null) { - return []; - } + final elements = value; return [for (final element in elements) ...element.validate()]; } - MetadataSyntax get metadata { - final jsonValue = _reader.map$('metadata'); - return MetadataSyntax.fromJson(jsonValue, path: [...path, 'metadata']); + @override + List validate() => [...super.validate(), ..._validateValue()]; + + @override + String toString() => 'MapConstantSyntax($json)'; +} + +extension MapConstantSyntaxExtension on ConstantSyntax { + bool get isMapConstant => type == 'map'; + + MapConstantSyntax get asMapConstant => + MapConstantSyntax.fromJson(json, path: path); +} + +class MapEntrySyntax extends JsonObjectSyntax { + MapEntrySyntax.fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + MapEntrySyntax({required int key, required int value, super.path = const []}) + : super() { + _key = key; + _value = value; + json.sortOnKey(); } - set _metadata(MetadataSyntax value) { - json['metadata'] = value.json; + int get key => _reader.get('key'); + + set _key(int value) { + json.setOrRemove('key', value); } - List _validateMetadata() { - final mapErrors = _reader.validate>('metadata'); - if (mapErrors.isNotEmpty) { - return mapErrors; + List _validateKey() => _reader.validate('key'); + + int get value => _reader.get('value'); + + set _value(int value) { + json.setOrRemove('value', value); + } + + List _validateValue() => _reader.validate('value'); + + @override + List validate() => [ + ...super.validate(), + ..._validateKey(), + ..._validateValue(), + ]; + + @override + String toString() => 'MapEntrySyntax($json)'; +} + +class MetadataSyntax extends JsonObjectSyntax { + MetadataSyntax.fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + MetadataSyntax({ + required String comment, + required String version, + super.path = const [], + }) : super() { + _comment = comment; + _version = version; + json.sortOnKey(); + } + + String get comment => _reader.get('comment'); + + set _comment(String value) { + json.setOrRemove('comment', value); + } + + List _validateComment() => _reader.validate('comment'); + + String get version => _reader.get('version'); + + set _version(String value) { + json.setOrRemove('version', value); + } + + List _validateVersion() => _reader.validate('version'); + + @override + List validate() => [ + ...super.validate(), + ..._validateComment(), + ..._validateVersion(), + ]; + + @override + String toString() => 'MetadataSyntax($json)'; +} + +class MethodNameSyntax extends NameSyntax { + MethodNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + MethodNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'method'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'MethodNameSyntax($json)'; +} + +extension MethodNameSyntaxExtension on NameSyntax { + bool get isMethodName => kind == 'method'; + + MethodNameSyntax get asMethodName => + MethodNameSyntax.fromJson(json, path: path); +} + +class MixinNameSyntax extends NameSyntax { + MixinNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + MixinNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'mixin'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'MixinNameSyntax($json)'; +} + +extension MixinNameSyntaxExtension on NameSyntax { + bool get isMixinName => kind == 'mixin'; + + MixinNameSyntax get asMixinName => MixinNameSyntax.fromJson(json, path: path); +} + +class NameSyntax extends JsonObjectSyntax { + factory NameSyntax.fromJson( + Map json, { + List path = const [], + }) { + final result = NameSyntax._fromJson(json, path: path); + if (result.isClassName) { + return result.asClassName; + } + if (result.isConstructorName) { + return result.asConstructorName; + } + if (result.isEnumName) { + return result.asEnumName; + } + if (result.isExtensionName) { + return result.asExtensionName; + } + if (result.isExtensionTypeName) { + return result.asExtensionTypeName; + } + if (result.isGetterName) { + return result.asGetterName; + } + if (result.isMethodName) { + return result.asMethodName; + } + if (result.isMixinName) { + return result.asMixinName; + } + if (result.isOperatorName) { + return result.asOperatorName; + } + if (result.isSetterName) { + return result.asSetterName; + } + return result; + } + + NameSyntax._fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + NameSyntax({ + List? disambiguators, + String? kind, + required String name, + super.path = const [], + }) : super() { + _disambiguators = disambiguators; + _kind = kind; + _name = name; + json.sortOnKey(); + } + + List? get disambiguators => + _reader.optionalStringList('disambiguators'); + + set _disambiguators(List? value) { + json.setOrRemove('disambiguators', value); + } + + List _validateDisambiguators() => + _reader.validateOptionalStringList('disambiguators'); + + String? get kind => _reader.get('kind'); + + set _kind(String? value) { + json.setOrRemove('kind', value); + } + + List _validateKind() => _reader.validate('kind'); + + String get name => _reader.get('name'); + + set _name(String value) { + json.setOrRemove('name', value); + } + + List _validateName() => _reader.validate('name'); + + @override + List validate() => [ + ...super.validate(), + ..._validateDisambiguators(), + ..._validateKind(), + ..._validateName(), + ]; + + @override + String toString() => 'NameSyntax($json)'; +} + +class NegativeInfinityDoubleConstantValueSyntax + extends DoubleConstantValueSyntax { + NegativeInfinityDoubleConstantValueSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + NegativeInfinityDoubleConstantValueSyntax({ + super.value, + super.path = const [], + }) : super(type: 'negative_infinity'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'NegativeInfinityDoubleConstantValueSyntax($json)'; +} + +extension NegativeInfinityDoubleConstantValueSyntaxExtension + on DoubleConstantValueSyntax { + bool get isNegativeInfinityDoubleConstantValue => type == 'negative_infinity'; + + NegativeInfinityDoubleConstantValueSyntax + get asNegativeInfinityDoubleConstantValue => + NegativeInfinityDoubleConstantValueSyntax.fromJson(json, path: path); +} + +class NonConstantConstantSyntax extends ConstantSyntax { + NonConstantConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + NonConstantConstantSyntax({super.path = const []}) + : super(type: 'non_constant'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'NonConstantConstantSyntax($json)'; +} + +extension NonConstantConstantSyntaxExtension on ConstantSyntax { + bool get isNonConstantConstant => type == 'non_constant'; + + NonConstantConstantSyntax get asNonConstantConstant => + NonConstantConstantSyntax.fromJson(json, path: path); +} + +class NotANumberDoubleConstantValueSyntax extends DoubleConstantValueSyntax { + NotANumberDoubleConstantValueSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + NotANumberDoubleConstantValueSyntax({super.value, super.path = const []}) + : super(type: 'not_a_number'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'NotANumberDoubleConstantValueSyntax($json)'; +} + +extension NotANumberDoubleConstantValueSyntaxExtension + on DoubleConstantValueSyntax { + bool get isNotANumberDoubleConstantValue => type == 'not_a_number'; + + NotANumberDoubleConstantValueSyntax get asNotANumberDoubleConstantValue => + NotANumberDoubleConstantValueSyntax.fromJson(json, path: path); +} + +class NullConstantSyntax extends ConstantSyntax { + NullConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + NullConstantSyntax({super.path = const []}) : super(type: 'null'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'NullConstantSyntax($json)'; +} + +extension NullConstantSyntaxExtension on ConstantSyntax { + bool get isNullConstant => type == 'null'; + + NullConstantSyntax get asNullConstant => + NullConstantSyntax.fromJson(json, path: path); +} + +class NumberDoubleConstantValueSyntax extends DoubleConstantValueSyntax { + NumberDoubleConstantValueSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + NumberDoubleConstantValueSyntax({super.value, super.path = const []}) + : super(type: 'number'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'NumberDoubleConstantValueSyntax($json)'; +} + +extension NumberDoubleConstantValueSyntaxExtension + on DoubleConstantValueSyntax { + bool get isNumberDoubleConstantValue => type == 'number'; + + NumberDoubleConstantValueSyntax get asNumberDoubleConstantValue => + NumberDoubleConstantValueSyntax.fromJson(json, path: path); +} + +class OperatorNameSyntax extends NameSyntax { + OperatorNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + OperatorNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'operator'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'OperatorNameSyntax($json)'; +} + +extension OperatorNameSyntaxExtension on NameSyntax { + bool get isOperatorName => kind == 'operator'; + + OperatorNameSyntax get asOperatorName => + OperatorNameSyntax.fromJson(json, path: path); +} + +class PositiveInfinityDoubleConstantValueSyntax + extends DoubleConstantValueSyntax { + PositiveInfinityDoubleConstantValueSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + PositiveInfinityDoubleConstantValueSyntax({ + super.value, + super.path = const [], + }) : super(type: 'positive_infinity'); + + @override + List validate() => [ + ...super.validate(), + ]; + + @override + String toString() => 'PositiveInfinityDoubleConstantValueSyntax($json)'; +} + +extension PositiveInfinityDoubleConstantValueSyntaxExtension + on DoubleConstantValueSyntax { + bool get isPositiveInfinityDoubleConstantValue => type == 'positive_infinity'; + + PositiveInfinityDoubleConstantValueSyntax + get asPositiveInfinityDoubleConstantValue => + PositiveInfinityDoubleConstantValueSyntax.fromJson(json, path: path); +} + +class RecordConstantSyntax extends ConstantSyntax { + RecordConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + RecordConstantSyntax({ + Map? named, + List? positional, + super.path = const [], + }) : super(type: 'record') { + _named = named; + _positional = positional; + json.sortOnKey(); + } + + /// Setup all fields for [RecordConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({ + required Map? named, + required List? positional, + }) { + _named = named; + _positional = positional; + json.sortOnKey(); + } + + Map? get named => _reader.optionalMap( + 'named', + ); + + set _named(Map? value) { + _checkArgumentMapKeys( + value, + ); + json.setOrRemove('named', value); + } + + List _validateNamed() => _reader.validateOptionalMap( + 'named', + ); + + List? get positional => _reader.optionalList('positional'); + + set _positional(List? value) { + json.setOrRemove('positional', value); + } + + List _validatePositional() => + _reader.validateOptionalList('positional'); + + @override + List validate() => [ + ...super.validate(), + ..._validateNamed(), + ..._validatePositional(), + ]; + + @override + String toString() => 'RecordConstantSyntax($json)'; +} + +extension RecordConstantSyntaxExtension on ConstantSyntax { + bool get isRecordConstant => type == 'record'; + + RecordConstantSyntax get asRecordConstant => + RecordConstantSyntax.fromJson(json, path: path); +} + +class RecordedUsesSyntax extends JsonObjectSyntax { + RecordedUsesSyntax.fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + RecordedUsesSyntax({ + List? constants, + List? definitions, + List? loadingUnits, + required MetadataSyntax metadata, + UsesSyntax? uses, + super.path = const [], + }) : super() { + _constants = constants; + _definitions = definitions; + _loadingUnits = loadingUnits; + _metadata = metadata; + _uses = uses; + json.sortOnKey(); + } + + List? get constants { + final jsonValue = _reader.optionalList('constants'); + if (jsonValue == null) return null; + return [ + for (final (index, element) in jsonValue.indexed) + ConstantSyntax.fromJson( + element as Map, + path: [...path, 'constants', index], + ), + ]; + } + + set _constants(List? value) { + if (value == null) { + json.remove('constants'); + } else { + json['constants'] = [for (final item in value) item.json]; + } + } + + List _validateConstants() { + final listErrors = _reader.validateOptionalList>( + 'constants', + ); + if (listErrors.isNotEmpty) { + return listErrors; } - return metadata.validate(); + final elements = constants; + if (elements == null) { + return []; + } + return [for (final element in elements) ...element.validate()]; } - List? get recordings { - final jsonValue = _reader.optionalList('recordings'); + List? get definitions { + final jsonValue = _reader.optionalList('definitions'); if (jsonValue == null) return null; return [ for (final (index, element) in jsonValue.indexed) - RecordingSyntax.fromJson( + DefinitionSyntax.fromJson( element as Map, - path: [...path, 'recordings', index], + path: [...path, 'definitions', index], ), ]; } - set _recordings(List? value) { + set _definitions(List? value) { if (value == null) { - json.remove('recordings'); + json.remove('definitions'); } else { - json['recordings'] = [for (final item in value) item.json]; + json['definitions'] = [for (final item in value) item.json]; } } - List _validateRecordings() { + List _validateDefinitions() { final listErrors = _reader.validateOptionalList>( - 'recordings', + 'definitions', ); if (listErrors.isNotEmpty) { return listErrors; } - final elements = recordings; + final elements = definitions; if (elements == null) { return []; } return [for (final element in elements) ...element.validate()]; } - @override - List validate() => [ - ...super.validate(), - ..._validateConstants(), - ..._validateLocations(), - ..._validateMetadata(), - ..._validateRecordings(), - ]; - - @override - String toString() => 'RecordedUsesSyntax($json)'; -} - -class RecordingSyntax extends JsonObjectSyntax { - RecordingSyntax.fromJson( - super.json, { - super.path = const [], - }) : super.fromJson(); - - RecordingSyntax({ - List? calls, - required DefinitionSyntax definition, - List? instances, - super.path = const [], - }) : super() { - _calls = calls; - _definition = definition; - _instances = instances; - json.sortOnKey(); - } - - List? get calls { - final jsonValue = _reader.optionalList('calls'); + List? get loadingUnits { + final jsonValue = _reader.optionalList('loading_units'); if (jsonValue == null) return null; return [ for (final (index, element) in jsonValue.indexed) - CallSyntax.fromJson( + LoadingUnitSyntax.fromJson( element as Map, - path: [...path, 'calls', index], + path: [...path, 'loading_units', index], ), ]; } - set _calls(List? value) { + set _loadingUnits(List? value) { if (value == null) { - json.remove('calls'); + json.remove('loading_units'); } else { - json['calls'] = [for (final item in value) item.json]; + json['loading_units'] = [for (final item in value) item.json]; } } - List _validateCalls() { + List _validateLoadingUnits() { final listErrors = _reader.validateOptionalList>( - 'calls', + 'loading_units', ); if (listErrors.isNotEmpty) { return listErrors; } - final elements = calls; + final elements = loadingUnits; if (elements == null) { return []; } return [for (final element in elements) ...element.validate()]; } - DefinitionSyntax get definition { - final jsonValue = _reader.map$('definition'); - return DefinitionSyntax.fromJson(jsonValue, path: [...path, 'definition']); + MetadataSyntax get metadata { + final jsonValue = _reader.map$('metadata'); + return MetadataSyntax.fromJson(jsonValue, path: [...path, 'metadata']); } - set _definition(DefinitionSyntax value) { - json['definition'] = value.json; + set _metadata(MetadataSyntax value) { + json['metadata'] = value.json; } - List _validateDefinition() { - final mapErrors = _reader.validate>('definition'); + List _validateMetadata() { + final mapErrors = _reader.validate>('metadata'); if (mapErrors.isNotEmpty) { return mapErrors; } - return definition.validate(); + return metadata.validate(); } - List? get instances { - final jsonValue = _reader.optionalList('instances'); + UsesSyntax? get uses { + final jsonValue = _reader.optionalMap('uses'); if (jsonValue == null) return null; - return [ - for (final (index, element) in jsonValue.indexed) - InstanceSyntax.fromJson( - element as Map, - path: [...path, 'instances', index], - ), - ]; + return UsesSyntax.fromJson(jsonValue, path: [...path, 'uses']); } - set _instances(List? value) { - if (value == null) { - json.remove('instances'); - } else { - json['instances'] = [for (final item in value) item.json]; - } + set _uses(UsesSyntax? value) { + json.setOrRemove('uses', value?.json); } - List _validateInstances() { - final listErrors = _reader.validateOptionalList>( - 'instances', - ); - if (listErrors.isNotEmpty) { - return listErrors; - } - final elements = instances; - if (elements == null) { - return []; + List _validateUses() { + final mapErrors = _reader.validate?>('uses'); + if (mapErrors.isNotEmpty) { + return mapErrors; } - return [for (final element in elements) ...element.validate()]; + return uses?.validate() ?? []; } @override List validate() => [ ...super.validate(), - ..._validateCalls(), - ..._validateDefinition(), - ..._validateInstances(), + ..._validateConstants(), + ..._validateDefinitions(), + ..._validateLoadingUnits(), + ..._validateMetadata(), + ..._validateUses(), + ]; + + @override + String toString() => 'RecordedUsesSyntax($json)'; +} + +class SetterNameSyntax extends NameSyntax { + SetterNameSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + SetterNameSyntax({ + super.disambiguators, + required super.name, + super.path = const [], + }) : super(kind: 'setter'); + + @override + List validate() => [ + ...super.validate(), ]; @override - String toString() => 'RecordingSyntax($json)'; + String toString() => 'SetterNameSyntax($json)'; +} + +extension SetterNameSyntaxExtension on NameSyntax { + bool get isSetterName => kind == 'setter'; + + SetterNameSyntax get asSetterName => + SetterNameSyntax.fromJson(json, path: path); } class StringConstantSyntax extends ConstantSyntax { @@ -916,7 +1936,7 @@ class StringConstantSyntax extends ConstantSyntax { }) : super._fromJson(); StringConstantSyntax({required String value, super.path = const []}) - : super(type: 'String') { + : super(type: 'string') { _value = value; json.sortOnKey(); } @@ -944,12 +1964,81 @@ class StringConstantSyntax extends ConstantSyntax { } extension StringConstantSyntaxExtension on ConstantSyntax { - bool get isStringConstant => type == 'String'; + bool get isStringConstant => type == 'string'; StringConstantSyntax get asStringConstant => StringConstantSyntax.fromJson(json, path: path); } +class SymbolConstantSyntax extends ConstantSyntax { + SymbolConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + SymbolConstantSyntax({ + String? libraryUri, + required String name, + super.path = const [], + }) : super(type: 'symbol') { + _libraryUri = libraryUri; + _name = name; + json.sortOnKey(); + } + + /// Setup all fields for [SymbolConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({required String? libraryUri, required String name}) { + _libraryUri = libraryUri; + _name = name; + json.sortOnKey(); + } + + static final _libraryUriPattern = RegExp(r'^package:'); + + String? get libraryUri => + _reader.optionalString('libraryUri', _libraryUriPattern); + + set _libraryUri(String? value) { + if (value != null && !_libraryUriPattern.hasMatch(value)) { + throw ArgumentError.value( + value, + 'value', + 'Value does not satisify pattern: ${_libraryUriPattern.pattern}.', + ); + } + json.setOrRemove('libraryUri', value); + } + + List _validateLibraryUri() => + _reader.validateOptionalString('libraryUri', _libraryUriPattern); + + String get name => _reader.get('name'); + + set _name(String value) { + json.setOrRemove('name', value); + } + + List _validateName() => _reader.validate('name'); + + @override + List validate() => [ + ...super.validate(), + ..._validateLibraryUri(), + ..._validateName(), + ]; + + @override + String toString() => 'SymbolConstantSyntax($json)'; +} + +extension SymbolConstantSyntaxExtension on ConstantSyntax { + bool get isSymbolConstant => type == 'symbol'; + + SymbolConstantSyntax get asSymbolConstant => + SymbolConstantSyntax.fromJson(json, path: path); +} + class TearoffCallSyntax extends CallSyntax { TearoffCallSyntax.fromJson( super.json, { @@ -957,8 +2046,8 @@ class TearoffCallSyntax extends CallSyntax { }) : super._fromJson(); TearoffCallSyntax({ - super.at, - required super.loadingUnit, + required super.loadingUnitIndex, + super.receiver, super.path = const [], }) : super(type: 'tearoff'); @@ -978,6 +2067,190 @@ extension TearoffCallSyntaxExtension on CallSyntax { TearoffCallSyntax.fromJson(json, path: path); } +class TearoffInstanceSyntax extends InstanceSyntax { + TearoffInstanceSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + TearoffInstanceSyntax({ + required int definitionIndex, + required super.loadingUnitIndex, + super.path = const [], + }) : super(type: 'tearoff') { + _definitionIndex = definitionIndex; + json.sortOnKey(); + } + + /// Setup all fields for [TearoffInstanceSyntax] that are not in + /// [InstanceSyntax]. + void setup({required int definitionIndex}) { + _definitionIndex = definitionIndex; + json.sortOnKey(); + } + + int get definitionIndex => _reader.get('definition_index'); + + set _definitionIndex(int value) { + json.setOrRemove('definition_index', value); + } + + List _validateDefinitionIndex() => + _reader.validate('definition_index'); + + @override + List validate() => [ + ...super.validate(), + ..._validateDefinitionIndex(), + ]; + + @override + String toString() => 'TearoffInstanceSyntax($json)'; +} + +extension TearoffInstanceSyntaxExtension on InstanceSyntax { + bool get isTearoffInstance => type == 'tearoff'; + + TearoffInstanceSyntax get asTearoffInstance => + TearoffInstanceSyntax.fromJson(json, path: path); +} + +class UnsupportedConstantSyntax extends ConstantSyntax { + UnsupportedConstantSyntax.fromJson( + super.json, { + super.path, + }) : super._fromJson(); + + UnsupportedConstantSyntax({required String message, super.path = const []}) + : super(type: 'unsupported') { + _message = message; + json.sortOnKey(); + } + + /// Setup all fields for [UnsupportedConstantSyntax] that are not in + /// [ConstantSyntax]. + void setup({required String message}) { + _message = message; + json.sortOnKey(); + } + + String get message => _reader.get('message'); + + set _message(String value) { + json.setOrRemove('message', value); + } + + List _validateMessage() => _reader.validate('message'); + + @override + List validate() => [...super.validate(), ..._validateMessage()]; + + @override + String toString() => 'UnsupportedConstantSyntax($json)'; +} + +extension UnsupportedConstantSyntaxExtension on ConstantSyntax { + bool get isUnsupportedConstant => type == 'unsupported'; + + UnsupportedConstantSyntax get asUnsupportedConstant => + UnsupportedConstantSyntax.fromJson(json, path: path); +} + +class UsesSyntax extends JsonObjectSyntax { + UsesSyntax.fromJson( + super.json, { + super.path = const [], + }) : super.fromJson(); + + UsesSyntax({ + List? instances, + List? staticCalls, + super.path = const [], + }) : super() { + _instances = instances; + _staticCalls = staticCalls; + json.sortOnKey(); + } + + List? get instances { + final jsonValue = _reader.optionalList('instances'); + if (jsonValue == null) return null; + return [ + for (final (index, element) in jsonValue.indexed) + InstanceRecordingSyntax.fromJson( + element as Map, + path: [...path, 'instances', index], + ), + ]; + } + + set _instances(List? value) { + if (value == null) { + json.remove('instances'); + } else { + json['instances'] = [for (final item in value) item.json]; + } + } + + List _validateInstances() { + final listErrors = _reader.validateOptionalList>( + 'instances', + ); + if (listErrors.isNotEmpty) { + return listErrors; + } + final elements = instances; + if (elements == null) { + return []; + } + return [for (final element in elements) ...element.validate()]; + } + + List? get staticCalls { + final jsonValue = _reader.optionalList('static_calls'); + if (jsonValue == null) return null; + return [ + for (final (index, element) in jsonValue.indexed) + CallRecordingSyntax.fromJson( + element as Map, + path: [...path, 'static_calls', index], + ), + ]; + } + + set _staticCalls(List? value) { + if (value == null) { + json.remove('static_calls'); + } else { + json['static_calls'] = [for (final item in value) item.json]; + } + } + + List _validateStaticCalls() { + final listErrors = _reader.validateOptionalList>( + 'static_calls', + ); + if (listErrors.isNotEmpty) { + return listErrors; + } + final elements = staticCalls; + if (elements == null) { + return []; + } + return [for (final element in elements) ...element.validate()]; + } + + @override + List validate() => [ + ...super.validate(), + ..._validateInstances(), + ..._validateStaticCalls(), + ]; + + @override + String toString() => 'UsesSyntax($json)'; +} + class WithArgumentsCallSyntax extends CallSyntax { WithArgumentsCallSyntax.fromJson( super.json, { @@ -985,10 +2258,10 @@ class WithArgumentsCallSyntax extends CallSyntax { }) : super._fromJson(); WithArgumentsCallSyntax({ - super.at, - required super.loadingUnit, + required super.loadingUnitIndex, Map? named, - List? positional, + List? positional, + super.receiver, super.path = const [], }) : super(type: 'with_arguments') { _named = named; @@ -1000,7 +2273,7 @@ class WithArgumentsCallSyntax extends CallSyntax { /// [CallSyntax]. void setup({ required Map? named, - required List? positional, + required List? positional, }) { _named = named; _positional = positional; @@ -1018,18 +2291,18 @@ class WithArgumentsCallSyntax extends CallSyntax { json.setOrRemove('named', value); } - List _validateNamed() => _reader.validateMap( + List _validateNamed() => _reader.validateOptionalMap( 'named', ); - List? get positional => _reader.optionalList('positional'); + List? get positional => _reader.optionalList('positional'); - set _positional(List? value) { + set _positional(List? value) { json.setOrRemove('positional', value); } List _validatePositional() => - _reader.validateOptionalList('positional'); + _reader.validateOptionalList('positional'); @override List validate() => [ diff --git a/pkgs/record_use/lib/src/version.dart b/pkgs/record_use/lib/src/version.dart index 51ccb8ff81..e81d29ae46 100644 --- a/pkgs/record_use/lib/src/version.dart +++ b/pkgs/record_use/lib/src/version.dart @@ -7,4 +7,4 @@ import 'package:pub_semver/pub_semver.dart' show Version; // TODO: Delete this version number. Instead of relying on versions, we want to // lazy read JSONs so that we don't break on versions that might be // incompatible but we don't access any of the incompatible fields. -final version = Version(0, 4, 0); +final versionInternal = Version(0, 4, 0); diff --git a/pkgs/record_use/pubspec.yaml b/pkgs/record_use/pubspec.yaml index c8e5f7f072..43a393fe61 100644 --- a/pkgs/record_use/pubspec.yaml +++ b/pkgs/record_use/pubspec.yaml @@ -1,11 +1,11 @@ name: record_use description: > The serialization logic and API for the usage recording SDK feature. -version: 0.5.0-wip +version: 0.6.0-wip repository: https://github.com/dart-lang/native/tree/main/pkgs/record_use environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' resolution: workspace diff --git a/pkgs/record_use/test/canonicalization_test.dart b/pkgs/record_use/test/canonicalization_test.dart new file mode 100644 index 0000000000..f139677ba8 --- /dev/null +++ b/pkgs/record_use/test/canonicalization_test.dart @@ -0,0 +1,158 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:record_use/src/canonicalization_context.dart'; +import 'package:test/test.dart'; + +void main() { + group('Canonicalization', () { + test('canonicalizeConstant deduplicates identical constants', () { + final context = CanonicalizationContext(); + // We avoid 'const' to ensure we have non-identical objects that are + // semantically equal, verifying that the canonicalization logic + // correctly deduplicates them. + // ignore: prefer_const_constructors + final c1 = IntConstant(42); + // ignore: prefer_const_constructors + final c2 = IntConstant(42); + + expect(identical(c1, c2), isFalse); + + final canonical1 = context.canonicalizeConstant(c1); + final canonical2 = context.canonicalizeConstant(c2); + + expect(identical(canonical1, canonical2), isTrue); + }); + + test('canonicalizeConstant handles nested constants', () { + final context = CanonicalizationContext(); + // ignore: prefer_const_constructors + final list1 = ListConstant([ + // ignore: prefer_const_constructors + IntConstant(1), + // ignore: prefer_const_constructors + IntConstant(2), + ]); + // ignore: prefer_const_constructors + final list2 = ListConstant([ + // ignore: prefer_const_constructors + IntConstant(1), + // ignore: prefer_const_constructors + IntConstant(2), + ]); + + expect(identical(list1, list2), isFalse); + + final canonical1 = context.canonicalizeConstant(list1) as ListConstant; + final canonical2 = context.canonicalizeConstant(list2) as ListConstant; + + expect(identical(canonical1, canonical2), isTrue); + expect(identical(canonical1.value[0], canonical2.value[0]), isTrue); + }); + + test('Recordings.toJson canonicalizes constants across calls', () { + const definition = Definition('package:a/a.dart', [Name('foo')]); + const constant = IntConstant(42); + + final recordings = Recordings( + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [constant], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + const CallWithArguments( + positionalArguments: [constant], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final constants = json['constants'] as List; + + // The constant 42 should only appear once in the constants table. + expect(constants, hasLength(1)); + expect(constants[0], {'type': 'int', 'value': 42}); + + // Both calls are identical, so they should be deduplicated into one. + final uses = json['uses'] as Map; + final staticCalls = uses['static_calls'] as List; + final recording = staticCalls[0] as Map; + final calls = recording['uses'] as List; + expect(calls, hasLength(1)); + expect((calls[0] as Map)['positional'], [0]); + }); + + test('Recordings.toJson deduplicates and sorts references', () { + const definition = Definition('package:a/a.dart', [Name('foo')]); + const unit1 = LoadingUnit('1'); + const unit2 = LoadingUnit('2'); + + final recordings = Recordings( + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [IntConstant(2)], + namedArguments: {}, + loadingUnit: unit1, + ), + const CallWithArguments( + positionalArguments: [IntConstant(1)], + namedArguments: {}, + loadingUnit: unit1, + ), + const CallWithArguments( + positionalArguments: [IntConstant(1)], + namedArguments: {}, + loadingUnit: unit1, + ), + const CallWithArguments( + positionalArguments: [IntConstant(1)], + namedArguments: {}, + loadingUnit: unit2, + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final uses = json['uses'] as Map; + final staticCalls = uses['static_calls'] as List; + final recording = staticCalls[0] as Map; + final calls = recording['uses'] as List; + + // Should have 3 unique calls after deduplication, sorted by toString. + // CallWithArguments(positional: IntConstant(1), loadingUnit: 1) + // CallWithArguments(positional: IntConstant(1), loadingUnit: 2) + // CallWithArguments(positional: IntConstant(2), loadingUnit: 1) + expect(calls, hasLength(3)); + + final backAgain = Recordings.fromJson(json); + final backCalls = backAgain.calls[definition]!; + expect(backCalls, hasLength(3)); + + // Verify sorting (based on toString which includes positional args and + // loading units) + expect( + backCalls[0].toString(), + contains('positional: IntConstant(1), loadingUnit: 1'), + ); + expect( + backCalls[1].toString(), + contains('positional: IntConstant(2), loadingUnit: 1'), + ); + expect( + backCalls[2].toString(), + contains('positional: IntConstant(1), loadingUnit: 2'), + ); + }); + }); +} diff --git a/pkgs/record_use/test/complex_keys_test.dart b/pkgs/record_use/test/complex_keys_test.dart new file mode 100644 index 0000000000..64d36dc120 --- /dev/null +++ b/pkgs/record_use/test/complex_keys_test.dart @@ -0,0 +1,173 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:pub_semver/pub_semver.dart'; +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +void main() { + const classDefinition = Definition( + 'package:test/test.dart', + [Name('MyClass')], + ); + + test('MapConstant with InstanceConstant keys round-trip', () { + const instanceKey = InstanceConstant( + definition: classDefinition, + fields: { + 'id': IntConstant(1), + 'tag': StringConstant('key'), + }, + ); + + const mapConstant = MapConstant([ + MapEntry(instanceKey, StringConstant('value')), + ]); + + const definition = Definition( + 'package:test/test.dart', + [Name('testMethod')], + ); + + final recordings = Recordings( + metadata: Metadata( + version: Version(1, 0, 0), + comment: 'Test complex keys', + ), + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [mapConstant], + namedArguments: {}, + loadingUnit: LoadingUnit('main.js'), + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final backAgain = Recordings.fromJson(json); + + expect(backAgain, recordings); + }); + + test('MapConstant equality with InstanceConstant keys', () { + const instanceKey = InstanceConstant( + definition: classDefinition, + fields: { + 'id': IntConstant(1), + 'tag': StringConstant('key'), + }, + ); + + const mapConstant = MapConstant([ + MapEntry(instanceKey, StringConstant('value')), + ]); + + expect( + mapConstant.entries.first.key, + const InstanceConstant( + definition: classDefinition, + fields: { + 'id': IntConstant(1), + 'tag': StringConstant('key'), + }, + ), + ); + expect(mapConstant.entries.first.value, const StringConstant('value')); + }); + + test('Deeply nested MapConstant with complex keys round-trip', () { + const listKey = ListConstant([IntConstant(1), IntConstant(2)]); + const mapKey = MapConstant([ + MapEntry(StringConstant('inner'), IntConstant(3)), + ]); + const recordKey = RecordConstant( + positional: [IntConstant(4)], + named: {'a': StringConstant('b')}, + ); + + const complexMap = MapConstant([ + MapEntry(listKey, mapKey), + MapEntry(mapKey, listKey), + MapEntry(recordKey, IntConstant(5)), + ]); + + const definition = Definition( + 'package:test/test.dart', + [Name('complexMethod')], + ); + + final recordings = Recordings( + metadata: Metadata( + version: Version(1, 0, 0), + comment: 'Test deeply nested complex keys', + ), + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [complexMap], + namedArguments: {}, + loadingUnit: LoadingUnit('main.js'), + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final backAgain = Recordings.fromJson(json); + + expect(backAgain, recordings); + }); + + test('Deeply nested complex keys structure', () { + const listKey = ListConstant([IntConstant(1), IntConstant(2)]); + const mapKey = MapConstant([ + MapEntry(StringConstant('inner'), IntConstant(3)), + ]); + const recordKey = RecordConstant( + positional: [IntConstant(4)], + named: {'a': StringConstant('b')}, + ); + + const complexMap = MapConstant([ + MapEntry(listKey, mapKey), + MapEntry(mapKey, listKey), + MapEntry(recordKey, IntConstant(5)), + ]); + + expect(complexMap.entries, hasLength(3)); + final entries = complexMap.entries; + expect( + entries[0].key, + const ListConstant([IntConstant(1), IntConstant(2)]), + ); + expect( + entries[0].value, + const MapConstant([ + MapEntry(StringConstant('inner'), IntConstant(3)), + ]), + ); + expect( + entries[1].key, + const MapConstant([ + MapEntry(StringConstant('inner'), IntConstant(3)), + ]), + ); + expect( + entries[1].value, + const ListConstant([IntConstant(1), IntConstant(2)]), + ); + expect( + entries[2].key, + const RecordConstant( + positional: [IntConstant(4)], + named: {'a': StringConstant('b')}, + ), + ); + expect(entries[2].value, const IntConstant(5)); + }); +} diff --git a/pkgs/record_use/test/double_constant_test.dart b/pkgs/record_use/test/double_constant_test.dart new file mode 100644 index 0000000000..b046e42592 --- /dev/null +++ b/pkgs/record_use/test/double_constant_test.dart @@ -0,0 +1,150 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; + +import 'package:record_use/record_use.dart'; +import 'package:record_use/src/canonicalization_context.dart'; +import 'package:test/test.dart'; + +void main() { + group('DoubleConstant', () { + test('serialization round-trip', () { + final constants = [ + const DoubleConstant(3.14), + const DoubleConstant(0.0), + const DoubleConstant(-0.0), + const DoubleConstant(double.infinity), + const DoubleConstant(double.negativeInfinity), + const DoubleConstant(double.nan), + const DoubleConstant(1.2345678901234567), + const DoubleConstant(0.12345678901234567), + const DoubleConstant( + 0.12345678901234568, + ), // different by 1 in last digit + const DoubleConstant(1.1111111111111112), + const DoubleConstant(0.3333333333333333), + const DoubleConstant(5e-324), // min positive double + const DoubleConstant(1.7976931348623157e308), // max double + ]; + + for (final constant in constants) { + final recordings = Recordings( + calls: { + const Definition('package:a/a.dart', [Name('foo')]): [ + CallWithArguments( + positionalArguments: [constant], + namedArguments: const {}, + loadingUnit: const LoadingUnit('1'), + ), + ], + }, + instances: {}, + ); + + final json = jsonEncode(recordings.toJson()); + final roundTripped = Recordings.fromJson( + jsonDecode(json) as Map, + ); + + final roundTrippedConstant = + (roundTripped.calls.values.first.first as CallWithArguments) + .positionalArguments + .first + as DoubleConstant; + + if (constant.value.isNaN) { + expect(roundTrippedConstant.value.isNaN, isTrue); + } else { + expect(roundTrippedConstant.value, equals(constant.value)); + // Check sign for 0.0 vs -0.0 + expect( + roundTrippedConstant.value.isNegative, + equals(constant.value.isNegative), + ); + } + expect(roundTrippedConstant, equals(constant)); + } + }); + + test('equality and hashCode', () { + const c1 = DoubleConstant(3.14); + const c1b = DoubleConstant(3.14); + const c2 = DoubleConstant(2.71); + const z1 = DoubleConstant(0.0); + const z2 = DoubleConstant(-0.0); + const inf1 = DoubleConstant(double.infinity); + const inf2 = DoubleConstant(double.negativeInfinity); + const nan1 = DoubleConstant(double.nan); + const nan2 = DoubleConstant(double.nan); + + expect(c1, equals(c1b)); + expect(c1.hashCode, equals(c1b.hashCode)); + + expect(c1, isNot(equals(c2))); + + expect(z1, isNot(equals(z2))); + expect(z1.hashCode, isNot(equals(z2.hashCode))); + + expect(inf1, isNot(equals(inf2))); + + expect(nan1, equals(nan2)); + expect(nan1.hashCode, equals(nan2.hashCode)); + + expect(nan1, isNot(equals(c1))); + expect(nan1, isNot(equals(inf1))); + }); + + test('semantic equality', () { + const c1 = DoubleConstant(3.14); + const nan1 = DoubleConstant(double.nan); + const unsupported = UnsupportedConstant('reason'); + + expect(c1.semanticEquals(c1), isTrue); + expect(nan1.semanticEquals(nan1), isTrue); + expect(c1.semanticEquals(nan1), isFalse); + + expect( + c1.semanticEquals(unsupported, allowPromotionOfUnsupported: true), + isTrue, + ); + expect( + nan1.semanticEquals(unsupported, allowPromotionOfUnsupported: true), + isTrue, + ); + }); + + test('canonicalization', () { + final context = CanonicalizationContext(); + const c1 = DoubleConstant(3.14); + const c1b = DoubleConstant(3.14); + const z1 = DoubleConstant(0.0); + const z2 = DoubleConstant(-0.0); + const nan1 = DoubleConstant(double.nan); + const nan2 = DoubleConstant(double.nan); + + expect( + identical( + context.canonicalizeConstant(c1), + context.canonicalizeConstant(c1b), + ), + isTrue, + ); + expect( + identical( + context.canonicalizeConstant(z1), + context.canonicalizeConstant(z2), + ), + isFalse, + ); + expect( + identical( + context.canonicalizeConstant(nan1), + context.canonicalizeConstant(nan2), + ), + isTrue, + ); + }); + }); +} diff --git a/pkgs/record_use/test/extension_receiver_test.dart b/pkgs/record_use/test/extension_receiver_test.dart new file mode 100644 index 0000000000..4ff7be48a2 --- /dev/null +++ b/pkgs/record_use/test/extension_receiver_test.dart @@ -0,0 +1,112 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +const loadingUnit1 = LoadingUnit('1'); + +void main() { + test('Call with receiver in JSON', () { + const json = { + 'metadata': {'version': '1.0.0', 'comment': 'test'}, + 'constants': [ + {'type': 'string', 'value': 'receiver'}, + {'type': 'int', 'value': 42}, + ], + 'loading_units': [ + {'name': '1'}, + ], + 'definitions': [ + { + 'uri': 'package:a/a.dart', + 'path': [ + {'name': 'foo'}, + ], + }, + ], + 'uses': { + 'static_calls': [ + { + 'definition_index': 0, + 'uses': [ + { + 'type': 'with_arguments', + 'loading_unit_index': 0, + 'receiver': 0, + 'positional': [1], + }, + ], + }, + ], + }, + }; + + final recordings = Recordings.fromJson(json); + const definition = Definition('package:a/a.dart', [Name('foo')]); + final calls = recordings.calls[definition]!; + final call = calls[0] as CallWithArguments; + + expect(call.receiver, const StringConstant('receiver')); + expect(call.positionalArguments[0], const IntConstant(42)); + }); + + test('Call with receiver serialization round-trip', () { + const definition = Definition('package:a/a.dart', [Name('foo')]); + final recordings = Recordings( + calls: { + definition: [ + const CallWithArguments( + receiver: StringConstant('receiver'), + positionalArguments: [IntConstant(42)], + namedArguments: {}, + loadingUnit: loadingUnit1, + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final roundTripped = Recordings.fromJson(json); + + expect(roundTripped, equals(recordings)); + + final usesJson = json['uses'] as Map; + final recordingsJson = usesJson['static_calls'] as List; + final recording = recordingsJson[0] as Map; + final call = (recording['uses'] as List)[0] as Map; + expect(call.containsKey('receiver'), isTrue); + final constants = json['constants'] as List; + final receiverConst = constants[call['receiver'] as int] as Map; + expect(receiverConst['value'], 'receiver'); + }); + + test('CallTearoff with receiver serialization round-trip', () { + const definition = Definition('package:a/a.dart', [Name('foo')]); + final recordings = Recordings( + calls: { + definition: [ + const CallTearoff( + receiver: StringConstant('receiver'), + loadingUnit: loadingUnit1, + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final roundTripped = Recordings.fromJson(json); + + expect(roundTripped, equals(recordings)); + + final usesJson = json['uses'] as Map; + final recordingsJson = usesJson['static_calls'] as List; + final recording = recordingsJson[0] as Map; + final call = (recording['uses'] as List)[0] as Map; + expect(call['type'], 'tearoff'); + expect(call.containsKey('receiver'), isTrue); + }); +} diff --git a/pkgs/record_use/test/filter_test.dart b/pkgs/record_use/test/filter_test.dart new file mode 100644 index 0000000000..42f2574341 --- /dev/null +++ b/pkgs/record_use/test/filter_test.dart @@ -0,0 +1,139 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +void main() { + test('filter recordings by package and nested constants', () { + const myPackage = 'my_package'; + const otherPackage = 'other_package'; + + const myDefinition = Definition( + 'package:$myPackage/my_lib.dart', + [Name('myFunc')], + ); + const otherDefinition = Definition( + 'package:$otherPackage/other_lib.dart', + [Name('OtherClass')], + ); + + const otherInstance = InstanceConstant( + definition: otherDefinition, + fields: {}, + ); + + final recordings = Recordings( + calls: { + myDefinition: [ + const CallWithArguments( + positionalArguments: [otherInstance], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + ], + }, + instances: {}, + ); + + final filtered = recordings.filter(definitionPackageName: myPackage); + + expect(filtered.calls, hasLength(1)); + final call = filtered.calls[myDefinition]!.first as CallWithArguments; + expect(call.positionalArguments.first, isA()); + expect( + (call.positionalArguments.first as UnsupportedConstant).message, + contains('other_package'), + ); + }); + + test('filter recordings by package and nested constants in collections', () { + const myPackage = 'my_package'; + const otherPackage = 'other_package'; + + const myDefinition = Definition( + 'package:$myPackage/my_lib.dart', + [Name('myFunc')], + ); + const otherDefinition = Definition( + 'package:$otherPackage/other_lib.dart', + [Name('OtherClass')], + ); + + const otherInstance = InstanceConstant( + definition: otherDefinition, + fields: {}, + ); + + final recordings = Recordings( + calls: { + myDefinition: [ + const CallWithArguments( + positionalArguments: [ + ListConstant([otherInstance]), + MapConstant([MapEntry(StringConstant('key'), otherInstance)]), + ], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + ], + }, + instances: {}, + ); + + final filtered = recordings.filter(definitionPackageName: myPackage); + + expect(filtered.calls, hasLength(1)); + final call = filtered.calls[myDefinition]!.first as CallWithArguments; + + final list = call.positionalArguments[0] as ListConstant; + expect(list.value.first, isA()); + + final map = call.positionalArguments[1] as MapConstant; + expect(map.entries.first.value, isA()); + }); + + test('filter recordings by package and nested enums', () { + const myPackage = 'my_package'; + const otherPackage = 'other_package'; + + const myDefinition = Definition( + 'package:$myPackage/my_lib.dart', + [Name('myFunc')], + ); + const otherEnumDefinition = Definition( + 'package:$otherPackage/other_lib.dart', + [Name('OtherEnum')], + ); + + const otherEnum = EnumConstant( + definition: otherEnumDefinition, + index: 0, + name: 'val1', + ); + + final recordings = Recordings( + calls: { + myDefinition: [ + const CallWithArguments( + positionalArguments: [otherEnum], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + ], + }, + instances: {}, + ); + + final filtered = recordings.filter(definitionPackageName: myPackage); + + expect(filtered.calls, hasLength(1)); + final call = filtered.calls[myDefinition]!.first as CallWithArguments; + expect(call.positionalArguments.first, isA()); + expect( + (call.positionalArguments.first as UnsupportedConstant).message, + contains('OtherEnum'), + ); + }); +} diff --git a/pkgs/record_use/test/instance_references_test.dart b/pkgs/record_use/test/instance_references_test.dart new file mode 100644 index 0000000000..9f9da6f70a --- /dev/null +++ b/pkgs/record_use/test/instance_references_test.dart @@ -0,0 +1,133 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:pub_semver/pub_semver.dart'; +import 'package:record_use/record_use.dart'; +import 'package:record_use/src/canonicalization_context.dart'; +import 'package:record_use/src/recordings.dart'; +import 'package:test/test.dart'; + +void main() { + const definition = Definition( + 'package:test/test.dart', + [Name('MyClass')], + ); + + const constructorDefinition = Definition( + 'package:test/test.dart', + [Name('MyClass'), Name('', kind: .constructorKind)], + ); + + const loadingUnitRoot = LoadingUnit('root'); + const loadingUnitOther = LoadingUnit('other'); + + final metadata = Metadata( + version: Version(1, 0, 0), + comment: 'Test for new instance formats', + ); + + final recordings = Recordings( + metadata: metadata, + calls: {}, + instances: { + definition: [ + const InstanceCreationReference( + definition: constructorDefinition, + positionalArguments: [IntConstant(1), IntConstant(2)], + namedArguments: {'param': StringConstant('named_arg_value')}, + loadingUnit: loadingUnitRoot, + ), + const ConstructorTearoffReference( + definition: constructorDefinition, + loadingUnit: loadingUnitOther, + ), + const InstanceConstantReference( + instanceConstant: EnumConstant( + definition: definition, + index: 0, + name: 'value1', + ), + loadingUnit: loadingUnitRoot, + ), + const InstanceConstantReference( + instanceConstant: EnumConstant( + definition: definition, + index: 1, + name: 'enhancedValue', + fields: { + 'description': StringConstant('A description'), + 'count': IntConstant(123), + 'nested': InstanceConstant( + definition: definition, + fields: {'inner': BoolConstant(true)}, + ), + }, + ), + loadingUnit: loadingUnitRoot, + ), + ], + }, + ); + + test('Deserialize creation and tearoff instances', () { + final instances = recordings.instances[definition]; + expect(instances, isNotNull); + expect(instances, hasLength(4)); + + final creation = instances![0]; + expect(creation, isA()); + if (creation is InstanceCreationReference) { + expect(creation.definition, constructorDefinition); + expect(creation.loadingUnit.name, loadingUnitRoot.name); + expect(creation.positionalArguments, hasLength(2)); + expect(creation.positionalArguments[0], isA()); + expect((creation.positionalArguments[0] as IntConstant).value, 1); + expect((creation.positionalArguments[1] as IntConstant).value, 2); + expect(creation.namedArguments, hasLength(1)); + expect(creation.namedArguments['param'], isA()); + expect( + (creation.namedArguments['param'] as StringConstant).value, + 'named_arg_value', + ); + } + + final tearoff = instances[1]; + expect(tearoff, isA()); + if (tearoff is ConstructorTearoffReference) { + expect(tearoff.definition, constructorDefinition); + expect(tearoff.loadingUnit.name, loadingUnitOther.name); + } + + final enumInstance = instances[2]; + expect(enumInstance, isA()); + if (enumInstance is InstanceConstantReference) { + expect(enumInstance.instanceConstant, isA()); + expect((enumInstance.instanceConstant as EnumConstant).name, 'value1'); + } + + final enhancedEnumInstance = instances[3]; + expect(enhancedEnumInstance, isA()); + if (enhancedEnumInstance is InstanceConstantReference) { + expect(enhancedEnumInstance.instanceConstant, isA()); + final enumConstant = + enhancedEnumInstance.instanceConstant as EnumConstant; + expect(enumConstant.name, 'enhancedValue'); + expect(enumConstant.fields, hasLength(3)); + expect( + (enumConstant.fields['description'] as StringConstant).value, + 'A description', + ); + expect((enumConstant.fields['count'] as IntConstant).value, 123); + final nested = enumConstant.fields['nested'] as InstanceConstant; + expect((nested.fields['inner'] as BoolConstant).value, true); + } + }); + + test('Round trip serialization', () { + final canon = recordings.canonicalizeChildren(CanonicalizationContext()); + final serializedJson = canon.toJson(); + final roundTrippedRecordings = Recordings.fromJson(serializedJson); + expect(roundTrippedRecordings, equals(canon)); + }); +} diff --git a/pkgs/record_use/test/int_constant_test.dart b/pkgs/record_use/test/int_constant_test.dart new file mode 100644 index 0000000000..4f9da2a8f9 --- /dev/null +++ b/pkgs/record_use/test/int_constant_test.dart @@ -0,0 +1,64 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +void main() { + group('IntConstant', () { + test('serialization round-trip', () { + final constants = [ + const IntConstant(0), + const IntConstant(1), + const IntConstant(-1), + const IntConstant(42), + const IntConstant(-42), + // 53-bit limit (max precise integer in 64-bit float) + const IntConstant(9007199254740991), // 2^53 - 1 + const IntConstant(9007199254740992), // 2^53 + const IntConstant(9007199254740993), // 2^53 + 1 + // 64-bit signed limits + const IntConstant(9223372036854775807), // 2^63 - 1 + const IntConstant(-9223372036854775808), // -2^63 + // Interesting bit patterns + const IntConstant(0xAAAAAAAAAAAAAAAA), + const IntConstant(0x5555555555555555), + const IntConstant(0x7FFFFFFFFFFFFFFF), + const IntConstant(0x8000000000000000), + const IntConstant(0xFF00FF00FF00FF00), + ]; + + for (final constant in constants) { + final recordings = Recordings( + calls: { + const Definition('package:a/a.dart', [Name('foo')]): [ + CallWithArguments( + positionalArguments: [constant], + namedArguments: const {}, + loadingUnit: const LoadingUnit('1'), + ), + ], + }, + instances: const {}, + ); + + final json = jsonEncode(recordings.toJson()); + final roundTripped = Recordings.fromJson( + jsonDecode(json) as Map, + ); + + final roundTrippedConstant = + (roundTripped.calls.values.first.first as CallWithArguments) + .positionalArguments + .first + as IntConstant; + + expect(roundTrippedConstant.value, equals(constant.value)); + expect(roundTrippedConstant, equals(constant)); + } + }); + }); +} diff --git a/pkgs/record_use/test/json_schema/schema_test.dart b/pkgs/record_use/test/json_schema/schema_test.dart index 75992af9bb..c2d2d70d79 100644 --- a/pkgs/record_use/test/json_schema/schema_test.dart +++ b/pkgs/record_use/test/json_schema/schema_test.dart @@ -33,72 +33,201 @@ void main() { missingExpectations: field.$2, ); } + + final constructorInvocationDataUri = testDataUri.resolve( + 'constructor_invocation.json', + ); + for (final field in constructorInvocationFields) { + testField( + schemaUri: schemaUri, + dataUri: constructorInvocationDataUri, + schema: schema, + data: allTestData[constructorInvocationDataUri]!, + field: field.$1, + missingExpectations: field.$2, + ); + } + + final constructorTearoffDataUri = testDataUri.resolve( + 'constructor_tearoff.json', + ); + for (final field in constructorTearoffFields) { + testField( + schemaUri: schemaUri, + dataUri: constructorTearoffDataUri, + schema: schema, + data: allTestData[constructorTearoffDataUri]!, + field: field.$1, + missingExpectations: field.$2, + ); + } } -const constNullIndex = 3; -const constInstanceIndex = 5; -List<(List, void Function(ValidationResults result))> -recordUseFields = [ +const constNonConstantIndex = 0; +const constUnsupportedIndex = 1; +const constNullIndex = 2; +const constDoubleIndex = 5; +const constMapIndex = 9; +const constRecordIndex = 10; +const constEnumIndex = 11; +const constInstanceIndex = 12; +typedef SchemaTestField = ( + List path, + void Function(ValidationResults result) missingExpectations, +); + +List recordUseFields = [ (['constants'], expectOptionalFieldMissing), - for (var index = 0; index < 7; index++) ...[ + for (var index = 0; index < 13; index++) ...[ (['constants', index, 'type'], expectRequiredFieldMissing), - if (index != constNullIndex && index != constInstanceIndex) + if (index != constNullIndex && + index != constNonConstantIndex && + index != constInstanceIndex && + index != constUnsupportedIndex && + index != constRecordIndex && + index != constEnumIndex && + index != constDoubleIndex) (['constants', index, 'value'], expectRequiredFieldMissing), if (index == constInstanceIndex) (['constants', index, 'value'], expectOptionalFieldMissing), + if (index == constDoubleIndex) ...[ + (['constants', index, 'value'], expectRequiredFieldMissing), + (['constants', index, 'value', 'type'], expectRequiredFieldMissing), + (['constants', index, 'value', 'value'], expectRequiredFieldMissing), + ], + if (index == constEnumIndex) ...[ + (['constants', index, 'definition_index'], expectRequiredFieldMissing), + (['constants', index, 'index'], expectRequiredFieldMissing), + (['constants', index, 'name'], expectRequiredFieldMissing), + (['constants', index, 'value'], expectOptionalFieldMissing), + ], + if (index == constMapIndex) ...[ + (['constants', index, 'value', 0, 'key'], expectRequiredFieldMissing), + (['constants', index, 'value', 0, 'value'], expectRequiredFieldMissing), + ], + if (index == constUnsupportedIndex) + (['constants', index, 'message'], expectRequiredFieldMissing), + if (index == constRecordIndex) ...[ + (['constants', index, 'positional'], expectOptionalFieldMissing), + (['constants', index, 'named'], expectOptionalFieldMissing), + ], // Note the value for 'Instance' is optional because an empty map is - // omitted. Also, Null has no value field. + // omitted. Also, Null and NonConstant have no value field. ], - (['locations'], expectOptionalFieldMissing), - (['locations', 0, 'uri'], expectRequiredFieldMissing), - (['locations', 0, 'line'], expectOptionalFieldMissing), - (['locations', 0, 'column'], expectOptionalFieldMissing), - (['recordings'], expectOptionalFieldMissing), - (['recordings', 0, 'definition'], expectRequiredFieldMissing), - (['recordings', 0, 'definition', 'identifier'], expectRequiredFieldMissing), - ( - ['recordings', 0, 'definition', 'identifier', 'uri'], + (['definitions'], expectOptionalFieldMissing), + (['definitions', 1, 'uri'], expectRequiredFieldMissing), + (['definitions', 1, 'path'], expectRequiredFieldMissing), + (['definitions', 1, 'path', 0], expectOptionalFieldMissing), + ( + ['definitions', 1, 'path', 0, 'name'], expectRequiredFieldMissing, ), - // TODO(https://github.com/dart-lang/native/issues/1093): Potentially split - // out the concept of a class definition (which should never have a scope), - // and static method definition, which optionally have a scope. And the scope - // is always an enclosing class. ( - ['recordings', 0, 'definition', 'identifier', 'scope'], + ['definitions', 1, 'path', 0, 'kind'], + expectOptionalFieldMissing, + ), + ( + [ + 'definitions', + 1, + 'path', + 0, + 'disambiguators', + ], + expectOptionalFieldMissing, + ), + (['loading_units'], expectOptionalFieldMissing), + (['loading_units', 0, 'name'], expectRequiredFieldMissing), + (['uses'], expectOptionalFieldMissing), + (['uses', 'static_calls'], expectOptionalFieldMissing), + (['uses', 'static_calls', 0, 'definition_index'], expectRequiredFieldMissing), + + (['uses', 'static_calls', 0, 'uses'], expectRequiredFieldMissing), + (['uses', 'static_calls', 0, 'uses', 0, 'type'], expectRequiredFieldMissing), + ( + ['uses', 'static_calls', 0, 'uses', 0, 'named'], + expectOptionalFieldMissing, + ), + ( + ['uses', 'static_calls', 0, 'uses', 0, 'named', 'a'], + expectOptionalFieldMissing, + ), + ( + ['uses', 'static_calls', 0, 'uses', 0, 'named', 'd'], + expectOptionalFieldMissing, + ), + ( + ['uses', 'static_calls', 0, 'uses', 0, 'positional'], + expectOptionalFieldMissing, + ), + ( + ['uses', 'static_calls', 0, 'uses', 0, 'positional', 0], + expectOptionalFieldMissing, + ), + ( + ['uses', 'static_calls', 0, 'uses', 0, 'positional', 3], expectOptionalFieldMissing, ), ( - ['recordings', 0, 'definition', 'identifier', 'name'], + ['uses', 'static_calls', 0, 'uses', 0, 'loading_unit_index'], expectRequiredFieldMissing, ), - // TODO: Why is this optional in the package test data? - (['recordings', 0, 'definition', 'loading_unit'], expectOptionalFieldMissing), - - // TODO(https://github.com/dart-lang/native/issues/1093): Whether calls or - // instances is required depends on whether the definition is a class or - // method. This should be cleaned up. - (['recordings', 0, 'calls'], expectOptionalFieldMissing), - (['recordings', 0, 'calls', 0, 'type'], expectRequiredFieldMissing), - (['recordings', 0, 'calls', 0, 'named'], expectOptionalFieldMissing), - (['recordings', 0, 'calls', 0, 'named', 'a'], expectOptionalFieldMissing), - (['recordings', 0, 'calls', 0, 'positional'], expectOptionalFieldMissing), - (['recordings', 0, 'calls', 0, 'positional', 0], expectOptionalFieldMissing), - (['recordings', 0, 'calls', 0, 'loading_unit'], expectRequiredFieldMissing), - (['recordings', 0, 'calls', 0, '@'], expectOptionalFieldMissing), - (['recordings', 1, 'instances'], expectOptionalFieldMissing), - ( - ['recordings', 1, 'instances', 0, 'constant_index'], + (['uses', 'instances'], expectOptionalFieldMissing), + (['uses', 'instances', 0, 'uses'], expectRequiredFieldMissing), + ( + ['uses', 'instances', 0, 'uses', 0, 'type'], + expectRequiredFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'constant_index'], expectRequiredFieldMissing, ), ( - ['recordings', 1, 'instances', 0, 'loading_unit'], + ['uses', 'instances', 0, 'uses', 0, 'loading_unit_index'], expectRequiredFieldMissing, ), - (['recordings', 1, 'instances', 0, '@'], expectOptionalFieldMissing), +]; + +List constructorInvocationFields = [ + ( + ['uses', 'instances', 0, 'uses', 0, 'definition_index'], + expectRequiredFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'loading_unit_index'], + expectRequiredFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'type'], + expectRequiredFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'positional'], + expectOptionalFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'named', 'param'], + expectOptionalFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'named', 'other'], + expectOptionalFieldMissing, + ), +]; - // TODO: Locations are not always provided by dart2js for const values. So we - // need to make it optional. +List constructorTearoffFields = [ + ( + ['uses', 'instances', 0, 'uses', 0, 'definition_index'], + expectRequiredFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'loading_unit_index'], + expectRequiredFieldMissing, + ), + ( + ['uses', 'instances', 0, 'uses', 0, 'type'], + expectRequiredFieldMissing, + ), ]; void testAllTestData( @@ -137,8 +266,6 @@ Uri packageUri = findPackageRoot('record_use'); /// Test removing a field or modifying it. /// -/// Changing a field to a wrong type is always expected to fail. -/// /// Removing a field can be valid, the expectations must be passed in /// [missingExpectations]. void testField({ @@ -160,8 +287,7 @@ void testField({ final index = field.last as int; dataToModify.removeAt(index); } else { - // ignore: avoid_dynamic_calls - dataToModify.remove(field.last); + (dataToModify as Map).remove(field.last); } final result = schema.validate(dataDecoded); @@ -175,11 +301,28 @@ void testField({ dataDecoded, field.sublist(0, field.length - 1), ); - // ignore: avoid_dynamic_calls - final originalValue = dataToModify[field.last]; - final wrongTypeValue = originalValue is int ? '123' : 123; - // ignore: avoid_dynamic_calls - dataToModify[field.last] = wrongTypeValue; + final Object? originalValue; + if (dataToModify is List) { + originalValue = dataToModify[field.last as int]; + } else { + originalValue = (dataToModify as Map)[field.last]; + } + final wrongTypeValue = originalValue is num ? '123' : 123; + if (originalValue == null) { + // If the field allows null, it likely also allows int. So use a string + // to ensure it's invalid. + if (dataToModify is List) { + dataToModify[field.last as int] = 'invalid'; + } else { + (dataToModify as Map)[field.last] = 'invalid'; + } + } else { + if (dataToModify is List) { + dataToModify[field.last as int] = wrongTypeValue; + } else { + (dataToModify as Map)[field.last] = wrongTypeValue; + } + } final result = schema.validate(dataDecoded); expect(result.isValid, isFalse); diff --git a/pkgs/record_use/test/json_schema/uri_pattern_test.dart b/pkgs/record_use/test/json_schema/uri_pattern_test.dart new file mode 100644 index 0000000000..3ed8a6eb71 --- /dev/null +++ b/pkgs/record_use/test/json_schema/uri_pattern_test.dart @@ -0,0 +1,45 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:json_schema/json_schema.dart'; +import 'package:native_test_helpers/native_test_helpers.dart'; +import 'package:test/test.dart'; + +import '../test_data.dart'; + +void main() { + final schemaUri = packageUri.resolve('doc/schema/record_use.schema.json'); + final schemaJson = + jsonDecode(File.fromUri(schemaUri).readAsStringSync()) + as Map; + final schema = JsonSchema.create(schemaJson); + + group('Definition.uri pattern', () { + test('JSON schema validation succeeds for package URI', () { + final json = recordedUses.toJson(); + final result = schema.validate(json); + expect(result.isValid, isTrue); + }); + + test('JSON schema validation fails for non-package URI', () { + final json = recordedUses.toJson(); + // Modify the first definition's URI to be invalid. + final definitions = json['definitions'] as List; + final definition = definitions[0] as Map; + definition['uri'] = 'dart:core'; // Should start with package: + + final result = schema.validate(json); + expect(result.isValid, isFalse); + expect( + result.errors.any((e) => e.message.contains('pattern')), + isTrue, + ); + }); + }); +} + +Uri packageUri = findPackageRoot('record_use'); diff --git a/pkgs/record_use/test/maybe_constant_test.dart b/pkgs/record_use/test/maybe_constant_test.dart new file mode 100644 index 0000000000..4d362eee7e --- /dev/null +++ b/pkgs/record_use/test/maybe_constant_test.dart @@ -0,0 +1,193 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +const loadingUnit1 = LoadingUnit('1'); + +void main() { + test('MaybeConstant arguments in JSON', () { + const json = { + 'metadata': {'version': '1.0.0', 'comment': 'test'}, + 'constants': [ + {'type': 'int', 'value': 42}, + {'type': 'unsupported', 'message': 'MethodTearoff'}, + {'type': 'non_constant'}, + ], + 'loading_units': [ + {'name': '1'}, + ], + 'definitions': [ + { + 'uri': 'package:a/a.dart', + 'path': [ + {'name': 'foo'}, + ], + }, + ], + 'uses': { + 'static_calls': [ + { + 'definition_index': 0, + 'uses': [ + { + 'type': 'with_arguments', + 'loading_unit_index': 0, + 'positional': [0, 1, 2], + 'named': {'a': 0, 'b': 1, 'c': 2}, + }, + ], + }, + ], + }, + }; + + final recordings = Recordings.fromJson(json); + const definition = Definition('package:a/a.dart', [Name('foo')]); + final calls = recordings.calls[definition]!; + final call = calls[0] as CallWithArguments; + + expect(call.positionalArguments, hasLength(3)); + expect(call.positionalArguments[0], const IntConstant(42)); + expect( + call.positionalArguments[1], + const UnsupportedConstant('MethodTearoff'), + ); + expect(call.positionalArguments[2], const NonConstant()); + + expect(call.namedArguments, hasLength(3)); + expect(call.namedArguments['a'], const IntConstant(42)); + expect( + call.namedArguments['b'], + const UnsupportedConstant('MethodTearoff'), + ); + expect(call.namedArguments['c'], const NonConstant()); + }); + + test('MaybeConstant serialization round-trip', () { + const definition = Definition('package:a/a.dart', [Name('foo')]); + final recordings = Recordings( + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [ + IntConstant(42), + UnsupportedConstant('MethodTearoff'), + NonConstant(), + RecordConstant( + positional: [IntConstant(1)], + named: {'a': IntConstant(2)}, + ), + EnumConstant( + definition: definition, + index: 0, + name: 'red', + fields: {'hex': IntConstant(0xff0000)}, + ), + SymbolConstant('foo'), + SymbolConstant('_bar', libraryUri: 'package:a/a.dart'), + ], + namedArguments: { + 'a': IntConstant(42), + 'b': UnsupportedConstant('MethodTearoff'), + 'c': NonConstant(), + 'd': RecordConstant( + positional: [IntConstant(3)], + named: {'b': IntConstant(4)}, + ), + 'e': EnumConstant( + definition: definition, + index: 1, + name: 'green', + ), + 'f': SymbolConstant('foo'), + 'g': SymbolConstant('_bar', libraryUri: 'package:a/a.dart'), + }, + loadingUnit: loadingUnit1, + ), + ], + }, + instances: {}, + ); + + final json = recordings.toJson(); + final roundTripped = Recordings.fromJson(json); + + expect(roundTripped, equals(recordings)); + + // Verify JSON structure specifically for named non-constants + final usesJson = json['uses'] as Map; + final recordingsJson = usesJson['static_calls'] as List; + final recording = recordingsJson[0] as Map; + final call = (recording['uses'] as List)[0] as Map; + final named = call['named'] as Map; + expect(named.containsKey('c'), isTrue); + expect(named['c'], isNotNull); + final constants = json['constants'] as List; + final nonConstant = constants[named['c'] as int] as Map; + expect(nonConstant['type'], 'non_constant'); + }); + + test('allowPromotionOfUnsupported semantic equality', () { + const definition = Definition('package:a/a.dart', [Name('foo')]); + + final actualRecordings = Recordings( + metadata: Metadata(comment: 'actual'), + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [IntConstant(42)], + namedArguments: {'a': StringConstant('bar')}, + loadingUnit: loadingUnit1, + ), + ], + }, + instances: {}, + ); + + final expectedRecordings = Recordings( + metadata: Metadata(comment: 'expected'), + calls: { + definition: [ + const CallWithArguments( + positionalArguments: [UnsupportedConstant('MethodTearoff')], + namedArguments: {'a': UnsupportedConstant('MethodTearoff')}, + loadingUnit: loadingUnit1, + ), + ], + }, + instances: {}, + ); + + // Should not match by default. + expect( + actualRecordings.semanticEquals( + expectedRecordings, + allowMetadataMismatch: true, + ), + isFalse, + ); + + // Should match when promotion is allowed. + expect( + actualRecordings.semanticEquals( + expectedRecordings, + allowMetadataMismatch: true, + allowPromotionOfUnsupported: true, + ), + isTrue, + ); + + // Verify it doesn't work the other way around (actual is less specific). + expect( + expectedRecordings.semanticEquals( + actualRecordings, + allowMetadataMismatch: true, + allowPromotionOfUnsupported: true, + ), + isFalse, + ); + }); +} diff --git a/pkgs/record_use/test/non_constant_in_collection_test.dart b/pkgs/record_use/test/non_constant_in_collection_test.dart new file mode 100644 index 0000000000..8857cda455 --- /dev/null +++ b/pkgs/record_use/test/non_constant_in_collection_test.dart @@ -0,0 +1,83 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +void main() { + test('NonConstant in ListConstant throws FormatException', () { + final json = { + 'metadata': {'version': '1.0.0', 'comment': 'test'}, + 'constants': [ + {'type': 'non_constant'}, + { + 'type': 'list', + 'value': [0], + }, + ], + }; + + expect(() => Recordings.fromJson(json), throwsFormatException); + }); + + test('NonConstant in MapConstant key throws FormatException', () { + final json = { + 'metadata': {'version': '1.0.0', 'comment': 'test'}, + 'constants': [ + {'type': 'non_constant'}, + {'type': 'int', 'value': 1}, + { + 'type': 'map', + 'value': [ + {'key': 0, 'value': 1}, + ], + }, + ], + }; + + expect(() => Recordings.fromJson(json), throwsFormatException); + }); + + test('NonConstant in MapConstant value throws FormatException', () { + final json = { + 'metadata': {'version': '1.0.0', 'comment': 'test'}, + 'constants': [ + {'type': 'non_constant'}, + {'type': 'int', 'value': 1}, + { + 'type': 'map', + 'value': [ + {'key': 1, 'value': 0}, + ], + }, + ], + }; + + expect(() => Recordings.fromJson(json), throwsFormatException); + }); + + test('NonConstant in InstanceConstant field throws FormatException', () { + final json = { + 'metadata': {'version': '1.0.0', 'comment': 'test'}, + 'constants': [ + {'type': 'non_constant'}, + { + 'type': 'instance', + 'definition_index': 0, + 'value': {'field': 0}, + }, + ], + 'definitions': [ + { + 'uri': 'package:a/a.dart', + 'path': [ + {'name': 'MyClass'}, + ], + }, + ], + }; + + expect(() => Recordings.fromJson(json), throwsFormatException); + }); +} diff --git a/pkgs/record_use/test/semantic_equality_golden_test.dart b/pkgs/record_use/test/semantic_equality_golden_test.dart deleted file mode 100644 index a2cdab6bb4..0000000000 --- a/pkgs/record_use/test/semantic_equality_golden_test.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:convert'; -import 'dart:io'; - -import 'package:record_use/record_use_internal.dart'; -import 'package:test/test.dart'; - -import 'storage_2_test.dart'; - -const dart2jsNotSupported = { - // No support for instance constants. - // https://github.com/dart-lang/native/issues/2893 - 'instance_class.json', - 'instance_complex.json', - 'instance_duplicates.json', - 'instance_method.json', - 'instance_not_annotation.json', - 'nested.json', - 'record_enum.json', - 'record_instance_constant_empty.json', - // No support for lists and map constants. - // https://github.com/dart-lang/native/issues/2896 - 'types_of_arguments.json', - // Named arguments are converted to positional arguments. - // https://github.com/dart-lang/native/issues/2883 - 'named_and_positional.json', - 'named_both.json', - 'named_optional.json', - 'named_required.json', - // Extension methods are broken. - // https://github.com/dart-lang/native/issues/2926 - 'extension.json', -}; - -// dart2js also records loadDeferredLibrary calls. -// https://github.com/dart-lang/native/issues/2892 -const dart2jsDeferLoadedLibrary = { - 'loading_units_simple.json', - 'loading_units_multiple.json', -}; - -void main() { - final testDataUri = packageUri.resolve('test_data/json_dart2js/'); - final expectDataUri = packageUri.resolve('test_data/json/'); - final allTestData = loadTestsData(testDataUri); - - for (final entry in allTestData.entries) { - final dataUri = entry.key; - final dataString = entry.value; - - final fileName = dataUri.pathSegments.last; - if (dart2jsNotSupported.contains(fileName)) continue; - final expectUri = expectDataUri.resolve(fileName); - final expectFile = File.fromUri(expectUri); - final expectString = expectFile.readAsStringSync(); - test('$dataUri $expectUri', () { - final uses = Recordings.fromJson( - jsonDecode(dataString) as Map, - ); - final expectedUses = Recordings.fromJson( - jsonDecode(expectString) as Map, - ); - if (!uses.semanticEquals( - expectedUses, - allowMetadataMismatch: true, - // Definition loading units are not working in dart2js backend. - // https://github.com/dart-lang/native/issues/2890 - allowDefinitionLoadingUnitNull: true, - allowMoreConstArguments: true, - allowTearOffToStaticPromotion: true, - expectedIsSubset: dart2jsDeferLoadedLibrary.contains(fileName), - uriMapping: (String uri) => - uri.replaceFirst('memory:sdk/tests/web/native/', ''), - loadingUnitMapping: (String unit) => - const { - 'out': '1', - 'out_1': '2', - }[unit] ?? - unit, - )) { - fail('not semantic equals'); - } - }); - } -} diff --git a/pkgs/record_use/test/semantic_equality_test.dart b/pkgs/record_use/test/semantic_equality_test.dart index c4fd7547a7..e31d99ab5d 100644 --- a/pkgs/record_use/test/semantic_equality_test.dart +++ b/pkgs/record_use/test/semantic_equality_test.dart @@ -3,120 +3,95 @@ // BSD-style license that can be found in the LICENSE file. import 'package:pub_semver/pub_semver.dart'; -import 'package:record_use/record_use_internal.dart'; +import 'package:record_use/record_use.dart'; import 'package:test/test.dart'; void main() { const definition1 = Definition( - identifier: Identifier(importUri: 'package:a/a.dart', name: 'definition1'), - loadingUnit: '1', + 'package:a/a.dart', + [Name('definition1')], ); const definition2 = Definition( - identifier: Identifier(importUri: 'package:a/a.dart', name: 'definition2'), - loadingUnit: '1', + 'package:a/a.dart', + [Name('definition2')], ); - const definition1differentUri = Definition( - identifier: Identifier(importUri: 'package:a/b.dart', name: 'definition1'), - loadingUnit: '1', - ); - const definition1differentLoadingUnit = Definition( - identifier: Identifier(importUri: 'package:a/a.dart', name: 'definition1'), - loadingUnit: '2', + const definition1differentLibrary = Definition( + 'package:a/b.dart', + [Name('definition1')], ); const definition3 = Definition( - identifier: Identifier( - importUri: 'package:a/a.dart', - scope: 'SomeClass', - name: 'definition1', - ), - loadingUnit: '1', + 'package:a/a.dart', + [Name('SomeClass'), Name('definition1')], ); const callDefintion1Static = CallWithArguments( positionalArguments: [], namedArguments: {}, - loadingUnit: null, - location: Location(uri: 'package:a/a.dart', line: 1, column: 1), + loadingUnit: LoadingUnit(''), ); const callDefintion1Static2 = CallWithArguments( positionalArguments: [], namedArguments: {}, - loadingUnit: null, - location: Location(uri: 'package:a/a.dart', line: 3, column: 1), + loadingUnit: LoadingUnit(''), ); const callDefinition2Static = CallWithArguments( positionalArguments: [], namedArguments: {}, - loadingUnit: null, - location: Location(uri: 'package:a/a.dart', line: 2, column: 2), + loadingUnit: LoadingUnit(''), ); - const callDefinition1TearOff = CallTearOff( - loadingUnit: null, - location: Location(uri: 'package:a/a.dart', line: 1, column: 1), + const callDefinition1Tearoff = CallTearoff( + loadingUnit: LoadingUnit(''), ); - const definition1differentUri2 = Definition( - identifier: Identifier(importUri: 'memory:a/a.dart', name: 'definition1'), - loadingUnit: '1', + const definition1differentLibrary2 = Definition( + 'memory:a/a.dart', + [Name('definition1')], ); const callDefintion1StaticDifferentUri = CallWithArguments( positionalArguments: [], namedArguments: {}, - loadingUnit: null, - location: Location(uri: 'memory:a/a.dart', line: 1, column: 1), + loadingUnit: LoadingUnit(''), + ); + final metadata = Metadata( + version: Version(1, 0, 0), + comment: '', ); - final metadata = Metadata.fromJson({ - 'version': Version(1, 0, 0).toString(), - 'comment': '', - }); test('Definition semantic equality', () { expect(definition1.semanticEquals(definition1), isTrue); expect(definition1.semanticEquals(definition2), isFalse); - expect(definition1.semanticEquals(definition1differentUri), isFalse); + expect(definition1.semanticEquals(definition1differentLibrary), isFalse); expect( definition1.semanticEquals( - definition1differentUri, + definition1differentLibrary, uriMapping: (uri) => uri.replaceFirst('a.dart', 'b.dart'), ), isTrue, ); - expect( - definition1.semanticEquals(definition1differentLoadingUnit), - isFalse, - ); - expect( - definition1.semanticEquals( - definition1differentLoadingUnit, - loadingUnitMapping: (String unit) => - const {'1': '2'}[unit] ?? unit, - ), - isTrue, - ); expect(definition1.semanticEquals(definition3), isFalse); }); test('Strict equality', () { final recordings1 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static, callDefintion1Static2], definition2: [callDefinition2Static], }, - instancesForDefinition: const {}, + instances: const {}, ); final recordings2 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition2: [callDefinition2Static], definition1: [callDefintion1Static2, callDefintion1Static], }, - instancesForDefinition: const {}, + instances: const {}, ); final recordings3 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static], }, - instancesForDefinition: const {}, + instances: const {}, ); // Identical. expect(recordings1.semanticEquals(recordings1), isTrue); @@ -129,18 +104,18 @@ void main() { test('otherIsSubset', () { final recordings1 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static], definition2: [callDefinition2Static], }, - instancesForDefinition: const {}, + instances: const {}, ); final recordings2 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static], }, - instancesForDefinition: const {}, + instances: const {}, ); expect( recordings1.semanticEquals(recordings2, expectedIsSubset: true), @@ -160,18 +135,18 @@ void main() { test('allowDeadCodeElimination', () { final recordings1 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static], }, - instancesForDefinition: const {}, + instances: const {}, ); final recordings2 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static], definition2: [callDefinition2Static], }, - instancesForDefinition: const {}, + instances: const {}, ); expect( recordings1.semanticEquals( @@ -197,32 +172,32 @@ void main() { ); }); - test('allowTearOffToStaticPromotion', () { + test('allowTearoffToStaticPromotion', () { final recordings1 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [callDefintion1Static], }, - instancesForDefinition: const {}, + instances: const {}, ); final recordings2 = Recordings( metadata: metadata, - callsForDefinition: { - definition1: [callDefinition1TearOff], + calls: { + definition1: [callDefinition1Tearoff], }, - instancesForDefinition: const {}, + instances: const {}, ); expect( recordings1.semanticEquals( recordings2, - allowTearOffToStaticPromotion: true, + allowTearoffToStaticPromotion: true, ), isTrue, ); expect( recordings1.semanticEquals( recordings2, - allowTearOffToStaticPromotion: false, + allowTearoffToStaticPromotion: false, ), isFalse, ); @@ -230,7 +205,7 @@ void main() { expect( recordings2.semanticEquals( recordings1, - allowTearOffToStaticPromotion: true, + allowTearoffToStaticPromotion: true, ), isFalse, ); @@ -239,21 +214,21 @@ void main() { test('allowUriMismatch', () { final recordings1 = Recordings( metadata: metadata, - callsForDefinition: { + calls: { definition1: [ callDefintion1Static, ], }, - instancesForDefinition: const {}, + instances: const {}, ); final recordings2 = Recordings( metadata: metadata, - callsForDefinition: { - definition1differentUri2: [ + calls: { + definition1differentLibrary2: [ callDefintion1StaticDifferentUri, ], }, - instancesForDefinition: const {}, + instances: const {}, ); expect( recordings1.semanticEquals( @@ -267,4 +242,94 @@ void main() { isFalse, ); }); + + test('CallWithArguments positional arguments different length', () { + final recordings1 = Recordings( + metadata: metadata, + calls: { + definition1: [ + const CallWithArguments( + positionalArguments: [IntConstant(1)], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + ], + }, + instances: const {}, + ); + final recordings2 = Recordings( + metadata: metadata, + calls: { + definition1: [ + const CallWithArguments( + positionalArguments: [IntConstant(1), IntConstant(2)], + namedArguments: {}, + loadingUnit: LoadingUnit(''), + ), + ], + }, + instances: const {}, + ); + expect( + recordings1.semanticEquals(recordings2), + isFalse, + ); + }); + + test('InstanceConstantReference semantic equality with EnumConstant', () { + final recordings1 = Recordings( + metadata: metadata, + calls: const {}, + instances: { + definition1: [ + const InstanceConstantReference( + instanceConstant: EnumConstant( + definition: definition1, + index: 0, + name: 'a', + fields: {'f': IntConstant(1)}, + ), + loadingUnit: LoadingUnit(''), + ), + ], + }, + ); + final recordings2 = Recordings( + metadata: metadata, + calls: const {}, + instances: { + definition1: [ + const InstanceConstantReference( + instanceConstant: EnumConstant( + definition: definition1, + index: 0, + name: 'a', + fields: {'f': IntConstant(1)}, + ), + loadingUnit: LoadingUnit(''), + ), + ], + }, + ); + final recordings3 = Recordings( + metadata: metadata, + calls: const {}, + instances: { + definition1: [ + const InstanceConstantReference( + instanceConstant: EnumConstant( + definition: definition1, + index: 1, + name: 'b', + fields: {'f': IntConstant(1)}, + ), + loadingUnit: LoadingUnit(''), + ), + ], + }, + ); + + expect(recordings1.semanticEquals(recordings2), isTrue); + expect(recordings1.semanticEquals(recordings3), isFalse); + }); } diff --git a/pkgs/record_use/test/storage_2_test.dart b/pkgs/record_use/test/storage_2_test.dart index a4f4f0bb42..0d6d0025ff 100644 --- a/pkgs/record_use/test/storage_2_test.dart +++ b/pkgs/record_use/test/storage_2_test.dart @@ -6,7 +6,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:native_test_helpers/native_test_helpers.dart'; -import 'package:record_use/record_use_internal.dart'; +import 'package:record_use/record_use.dart'; import 'package:test/test.dart'; void main() { diff --git a/pkgs/record_use/test/storage_test.dart b/pkgs/record_use/test/storage_test.dart index d62610da4a..8bf73290d1 100644 --- a/pkgs/record_use/test/storage_test.dart +++ b/pkgs/record_use/test/storage_test.dart @@ -4,14 +4,15 @@ import 'dart:convert'; -import 'package:record_use/record_use_internal.dart'; +import 'package:record_use/record_use.dart'; import 'package:test/test.dart'; import 'test_data.dart'; void main() { group('object 1', () { - final json = jsonDecode(recordedUsesJson) as Map; + final json = (jsonDecode(recordedUsesJson) as Map) + ..remove('\$schema'); test('JSON', () => expect(recordedUses.toJson(), json)); test('Object', () => expect(Recordings.fromJson(json), recordedUses)); @@ -26,7 +27,8 @@ void main() { }); group('object 2', () { - final json2 = jsonDecode(recordedUsesJson2) as Map; + final json2 = (jsonDecode(recordedUsesJson2) as Map) + ..remove('\$schema'); test('JSON', () => expect(recordedUses2.toJson(), json2)); test('Object', () => expect(Recordings.fromJson(json2), recordedUses2)); diff --git a/pkgs/record_use/test/syntax/uri_pattern_test.dart b/pkgs/record_use/test/syntax/uri_pattern_test.dart new file mode 100644 index 0000000000..dc8ca5f7e7 --- /dev/null +++ b/pkgs/record_use/test/syntax/uri_pattern_test.dart @@ -0,0 +1,63 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +import '../test_data.dart'; + +void main() { + group('Definition.uri pattern', () { + test('Recordings.fromJson fails for non-package URI', () { + final json = recordedUses.toJson(); + // Modify the first definition's URI to be invalid. + final definitions = json['definitions'] as List; + final definition = definitions[0] as Map; + definition['uri'] = 'file:///foo.dart'; // Should start with package: + + expect( + () => Recordings.fromJson(json), + throwsA( + isA().having( + (e) => e.message, + 'message', + contains('Expected a String satisfying ^package:'), + ), + ), + ); + }); + + test('Definition constructor does not throw (currently)', () { + // The Definition class itself doesn't have the regex check in its + // constructor, only the generated syntax class has it. + expect( + () => const Definition('dart:core', [Name('foo')]), + returnsNormally, + ); + }); + + test('Recordings.fromJson fails for non-package libraryUri in symbol', () { + final json = recordedUses.toJson(); + // Ensure the constants table exists. + final constants = (json['constants'] ??= []) as List; + // Add a constant that has an invalid URI. + constants.add({ + 'type': 'symbol', + 'name': '_foo', + 'libraryUri': 'file:///foo.dart', // Should start with package: + }); + + expect( + () => Recordings.fromJson(json), + throwsA( + isA().having( + (e) => e.message, + 'message', + contains('Expected a String satisfying ^package:'), + ), + ), + ); + }); + }); +} diff --git a/pkgs/record_use/test/syntax/validation_test.dart b/pkgs/record_use/test/syntax/validation_test.dart new file mode 100644 index 0000000000..ab510a6ded --- /dev/null +++ b/pkgs/record_use/test/syntax/validation_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +import '../test_data.dart'; + +void main() { + group('Recordings.fromJson validation', () { + test('Recordings.fromJson fails for invalid JSON', () { + final json = recordedUses.toJson(); + // Modify the first definition's URI to be an invalid type. + final definitions = json['definitions'] as List; + final definition = definitions[0] as Map; + definition['uri'] = 123; // Should be a string + + expect( + () => Recordings.fromJson(json), + throwsA( + isA().having( + (e) => e.message, + 'message', + contains('Validation errors for record use file:'), + ), + ), + ); + }); + }); +} diff --git a/pkgs/record_use/test/test_data.dart b/pkgs/record_use/test/test_data.dart index 4ebb3dc2e0..0a986d263f 100644 --- a/pkgs/record_use/test/test_data.dart +++ b/pkgs/record_use/test/test_data.dart @@ -2,32 +2,39 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'dart:io'; + +import 'package:native_test_helpers/native_test_helpers.dart'; import 'package:pub_semver/pub_semver.dart'; -import 'package:record_use/record_use_internal.dart'; +import 'package:record_use/record_use.dart'; +import 'package:record_use/src/canonicalization_context.dart'; +import 'package:record_use/src/recordings.dart'; -final callId = Identifier( - importUri: Uri.parse( - 'file://lib/_internal/js_runtime/lib/js_helper.dart', - ).toString(), - scope: 'MyClass', - name: 'get:loadDeferredLibrary', +const callId = Definition( + 'package:js_runtime/js_helper.dart', + [Name('MyClass'), Name('get:loadDeferredLibrary')], +); +const instanceId = Definition( + 'package:js_runtime/js_helper.dart', + [Name('MyAnnotation')], ); -final instanceId = Identifier( - importUri: Uri.parse( - 'file://lib/_internal/js_runtime/lib/js_helper.dart', - ).toString(), - name: 'MyAnnotation', +const enumId = Definition( + 'package:js_runtime/js_helper.dart', + [Name('MyEnum')], ); +const loadingUnitOJs = LoadingUnit('o.js'); +const loadingUnit3 = LoadingUnit('3'); + final recordedUses = Recordings( - metadata: Metadata.fromJson({ - 'version': Version(1, 6, 2, pre: 'wip', build: '5.-.2.z').toString(), - 'comment': + metadata: Metadata( + version: Version(1, 6, 2, pre: 'wip', build: '5.-.2.z'), + comment: 'Recorded references at compile time and their argument values, as' ' far as known, to definitions annotated with @RecordUse', - }), - callsForDefinition: { - Definition(identifier: callId, loadingUnit: 'part_15.js'): [ + ), + calls: { + callId: [ const CallWithArguments( positionalArguments: [ StringConstant('lib_SHA1'), @@ -38,13 +45,14 @@ final recordedUses = Recordings( 'freddy': StringConstant('mercury'), 'leroy': StringConstant('jenkins'), }, - loadingUnit: 'o.js', - location: Location(uri: 'lib/test.dart', line: 12, column: 36), + loadingUnit: loadingUnitOJs, ), const CallWithArguments( positionalArguments: [ StringConstant('lib_SHA1'), - MapConstant({'key': IntConstant(99)}), + MapConstant([ + MapEntry(StringConstant('key'), IntConstant(99)), + ]), ListConstant([ StringConstant('camus'), ListConstant([ @@ -59,268 +67,66 @@ final recordedUses = Recordings( 'freddy': IntConstant(0), 'leroy': StringConstant('jenkins'), }, - loadingUnit: 'o.js', - location: Location(uri: 'lib/test2.dart'), + loadingUnit: loadingUnitOJs, ), ], }, - instancesForDefinition: { - Definition(identifier: instanceId): [ - const InstanceReference( + instances: { + instanceId: [ + const InstanceConstantReference( instanceConstant: InstanceConstant( + definition: instanceId, fields: {'a': IntConstant(42), 'b': NullConstant()}, ), - loadingUnit: '3', - location: Location(uri: 'lib/test3.dart'), + loadingUnit: loadingUnit3, ), - const InstanceReference( - instanceConstant: InstanceConstant(fields: {}), - loadingUnit: '3', - location: Location(uri: 'lib/test3.dart'), + const InstanceConstantReference( + instanceConstant: InstanceConstant(definition: instanceId, fields: {}), + loadingUnit: loadingUnit3, + ), + ], + enumId: [ + const InstanceConstantReference( + instanceConstant: EnumConstant( + definition: enumId, + index: 0, + name: 'val1', + fields: {'a': IntConstant(42)}, + ), + loadingUnit: loadingUnit3, ), ], }, -); +).canonicalizeChildren(CanonicalizationContext()); final recordedUses2 = Recordings( - metadata: Metadata.fromJson({ - 'version': Version(1, 6, 2, pre: 'wip', build: '5.-.2.z').toString(), - 'comment': + metadata: Metadata( + version: Version(1, 6, 2, pre: 'wip', build: '5.-.2.z'), + comment: 'Recorded references at compile time and their argument values, as' ' far as known, to definitions annotated with @RecordUse', - }), - callsForDefinition: { - Definition(identifier: callId, loadingUnit: 'part_15.js'): [ + ), + calls: { + callId: [ const CallWithArguments( positionalArguments: [BoolConstant(false), IntConstant(1)], namedArguments: { 'freddy': StringConstant('mercury'), 'answer': IntConstant(42), }, - loadingUnit: 'o.js', - location: Location(uri: 'lib/test3.dart'), + loadingUnit: loadingUnitOJs, ), ], }, - instancesForDefinition: {}, -); + instances: {}, +).canonicalizeChildren(CanonicalizationContext()); -const recordedUsesJson = '''{ - "metadata": { - "version": "1.6.2-wip+5.-.2.z", - "comment": "Recorded references at compile time and their argument values, as far as known, to definitions annotated with @RecordUse" - }, - "constants": [ - { - "type": "String", - "value": "lib_SHA1" - }, - { - "type": "bool", - "value": false - }, - { - "type": "int", - "value": 1 - }, - { - "type": "String", - "value": "mercury" - }, - { - "type": "String", - "value": "jenkins" - }, - { - "type": "int", - "value": 99 - }, - { - "type": "map", - "value": { - "key": 5 - } - }, - { - "type": "String", - "value": "camus" - }, - { - "type": "String", - "value": "einstein" - }, - { - "type": "String", - "value": "insert" - }, - { - "type": "list", - "value": [ - 8, - 9, - 1 - ] - }, - { - "type": "list", - "value": [ - 7, - 10, - 8 - ] - }, - { - "type": "int", - "value": 0 - }, - { - "type": "int", - "value": 42 - }, - { - "type": "Null" - }, - { - "type": "Instance", - "value": { - "a": 13, - "b": 14 - } - }, - { - "type": "Instance" - } - ], - "locations": [ - { - "uri": "lib/test.dart", - "line": 12, - "column": 36 - }, - { - "uri": "lib/test2.dart" - }, - { - "uri": "lib/test3.dart" - } - ], - "recordings": [ - { - "definition": { - "identifier": { - "uri": "file://lib/_internal/js_runtime/lib/js_helper.dart", - "scope": "MyClass", - "name": "get:loadDeferredLibrary" - }, - "loading_unit": "part_15.js" - }, - "calls": [ - { - "type": "with_arguments", - "positional": [ - 0, - 1, - 2 - ], - "named": { - "freddy": 3, - "leroy": 4 - }, - "loading_unit": "o.js", - "@": 0 - }, - { - "type": "with_arguments", - "positional": [ - 0, - 6, - 11 - ], - "named": { - "freddy": 12, - "leroy": 4 - }, - "loading_unit": "o.js", - "@": 1 - } - ] - }, - { - "definition": { - "identifier": { - "uri": "file://lib/_internal/js_runtime/lib/js_helper.dart", - "name": "MyAnnotation" - } - }, - "instances": [ - { - "constant_index": 15, - "loading_unit": "3", - "@": 2 - }, - { - "constant_index": 16, - "loading_unit": "3", - "@": 2 - } - ] - } - ] -}'''; +final _testDataUri = findPackageRoot('record_use').resolve('test_data/json/'); -const recordedUsesJson2 = '''{ - "metadata": { - "version": "1.6.2-wip+5.-.2.z", - "comment": "Recorded references at compile time and their argument values, as far as known, to definitions annotated with @RecordUse" - }, - "constants": [ - { - "type": "bool", - "value": false - }, - { - "type": "int", - "value": 1 - }, - { - "type": "String", - "value": "mercury" - }, - { - "type": "int", - "value": 42 - } - ], - "locations": [ - { - "uri": "lib/test3.dart" - } - ], - "recordings": [ - { - "definition": { - "identifier": { - "uri": "file://lib/_internal/js_runtime/lib/js_helper.dart", - "scope": "MyClass", - "name": "get:loadDeferredLibrary" - }, - "loading_unit": "part_15.js" - }, - "calls": [ - { - "type": "with_arguments", - "positional": [ - 0, - 1 - ], - "named": { - "freddy": 2, - "answer": 3 - }, - "loading_unit": "o.js", - "@": 0 - } - ] - } - ] -}'''; +final recordedUsesJson = File.fromUri( + _testDataUri.resolve('recorded_uses_v2.json'), +).readAsStringSync(); + +final recordedUsesJson2 = File.fromUri( + _testDataUri.resolve('recorded_uses_v2_2.json'), +).readAsStringSync(); diff --git a/pkgs/record_use/test/to_string_test.dart b/pkgs/record_use/test/to_string_test.dart new file mode 100644 index 0000000000..8eac3837aa --- /dev/null +++ b/pkgs/record_use/test/to_string_test.dart @@ -0,0 +1,67 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; +import 'package:test/test.dart'; + +const loadingUnitFoo = LoadingUnit('dart.foo'); + +void main() { + group('toString', () { + test('CallWithArguments', () { + const call = CallWithArguments( + positionalArguments: [], + namedArguments: {}, + loadingUnit: loadingUnitFoo, + ); + expect( + call.toString(), + 'CallWithArguments(loadingUnit: dart.foo)', + ); + }); + + test('CallWithArguments with multiple args', () { + const call = CallWithArguments( + positionalArguments: [NonConstant(), NonConstant()], + namedArguments: { + 'bar': NonConstant(), + 'baz': NonConstant(), + }, + loadingUnit: loadingUnitFoo, + ); + expect( + call.toString(), + 'CallWithArguments(positional: NonConstant(), ' + 'NonConstant(), named: bar=NonConstant(), ' + 'baz=NonConstant(), loadingUnit: dart.foo)', + ); + }); + + test('SymbolConstant', () { + expect( + const SymbolConstant('foo').toString(), + '#foo', + ); + expect( + const SymbolConstant('_bar', libraryUri: 'package:a/a.dart').toString(), + 'package:a/a.dart::#_bar', + ); + }); + + test('InstanceConstantReference with EnumConstant', () { + const ref = InstanceConstantReference( + instanceConstant: EnumConstant( + definition: Definition('package:a/a.dart', [Name('MyEnum')]), + index: 0, + name: 'val1', + ), + loadingUnit: loadingUnitFoo, + ); + expect( + ref.toString(), + 'InstanceConstantReference(instanceConstant: EnumConstant(package:a/a.dart#MyEnum, index: 0, name: val1, fields: {}), loadingUnit: dart.foo)', + ); + }); + }); +} diff --git a/pkgs/record_use/test/usage_test.dart b/pkgs/record_use/test/usage_test.dart deleted file mode 100644 index 6dab838760..0000000000 --- a/pkgs/record_use/test/usage_test.dart +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:convert'; - -import 'package:record_use/record_use_internal.dart'; -import 'package:test/test.dart'; - -import 'test_data.dart'; - -void main() { - test('All API calls', () { - expect( - RecordedUsages.fromJson( - jsonDecode(recordedUsesJson) as Map, - ) - .constArgumentsFor( - Identifier( - importUri: Uri.parse( - 'file://lib/_internal/js_runtime/lib/js_helper.dart', - ).toString(), - scope: 'MyClass', - name: 'get:loadDeferredLibrary', - ), - ) - .length, - 2, - ); - }); - - test('All API instances', () { - final instance = - RecordedUsages.fromJson( - jsonDecode(recordedUsesJson) as Map, - ) - .constantsOf( - Identifier( - importUri: Uri.parse( - 'file://lib/_internal/js_runtime/lib/js_helper.dart', - ).toString(), - name: 'MyAnnotation', - ), - ) - .first; - final instanceMap = recordedUses.instancesForDefinition.values - .expand((usage) => usage) - .map( - (instance) => instance.instanceConstant.fields.map( - (key, constant) => MapEntry(key, constant.toValue()), - ), - ) - .first; - for (final entry in instanceMap.entries) { - expect(instance[entry.key], entry.value); - } - }); - - test('Specific API calls', () { - final arguments = - RecordedUsages.fromJson( - jsonDecode(recordedUsesJson) as Map, - ) - .constArgumentsFor( - Identifier( - importUri: Uri.parse( - 'file://lib/_internal/js_runtime/lib/js_helper.dart', - ).toString(), - scope: 'MyClass', - name: 'get:loadDeferredLibrary', - ), - ) - .toList(); - final (named: named0, positional: positional0) = arguments[0]; - expect(named0, const {'freddy': 'mercury', 'leroy': 'jenkins'}); - expect(positional0, const ['lib_SHA1', false, 1]); - final (named: named1, positional: positional1) = arguments[1]; - expect(named1, const {'freddy': 0, 'leroy': 'jenkins'}); - expect(positional1, const [ - 'lib_SHA1', - {'key': 99}, - [ - 'camus', - ['einstein', 'insert', false], - 'einstein', - ], - ]); - }); - - test('Specific API instances', () { - final instance = - RecordedUsages.fromJson( - jsonDecode(recordedUsesJson) as Map, - ) - .constantsOf( - Identifier( - importUri: Uri.parse( - 'file://lib/_internal/js_runtime/lib/js_helper.dart', - ).toString(), - name: 'MyAnnotation', - ), - ) - .first; - expect(instance['a'], 42); - expect(instance['b'], null); - }); - - test('HasNonConstInstance', () { - expect( - RecordedUsages.fromJson( - jsonDecode(recordedUsesJson2) as Map, - ).hasNonConstArguments( - const Identifier( - importUri: - 'package:drop_dylib_recording/src/drop_dylib_recording.dart', - name: 'getMathMethod', - ), - ), - false, - ); - }); -} diff --git a/pkgs/record_use/test_data/drop_data_asset/bin/drop_data_asset_instances.dart b/pkgs/record_use/test_data/drop_data_asset/bin/drop_data_asset_instances.dart index 8d1e5c930f..9699b85d33 100644 --- a/pkgs/record_use/test_data/drop_data_asset/bin/drop_data_asset_instances.dart +++ b/pkgs/record_use/test_data/drop_data_asset/bin/drop_data_asset_instances.dart @@ -5,5 +5,5 @@ import 'package:drop_data_asset/drop_data_asset.dart'; void main(List arguments) { - print('Hello world: ${MyMath.double(3)}!'); + print('Hello world: ${const Double(3).run()}!'); } diff --git a/pkgs/record_use/test_data/drop_data_asset/hook/link.dart b/pkgs/record_use/test_data/drop_data_asset/hook/link.dart index 69f0739d56..86e2f9ae3e 100644 --- a/pkgs/record_use/test_data/drop_data_asset/hook/link.dart +++ b/pkgs/record_use/test_data/drop_data_asset/hook/link.dart @@ -16,7 +16,7 @@ void main(List arguments) async { final recordedUsagesFile = input.recordedUsagesFile; if (recordedUsagesFile == null) { throw ArgumentError( - 'Enable the --enable-experiments=record-use experiment' + 'Enable the --enable-experiment=record-use experiment' ' to use this app.', ); } @@ -28,35 +28,62 @@ void main(List arguments) async { // Tree-shake unused assets using calls for (final methodName in ['add', 'multiply']) { - final calls = usages.constArgumentsFor( - Identifier( - importUri: - 'package:${input.packageName}/src/${input.packageName}.dart', - scope: 'MyMath', - name: methodName, - ), - ); + final calls = + usages.calls[Definition( + 'package:${input.packageName}/src/${input.packageName}.dart', + [ + const Name(kind: .classKind, 'MyMath'), + Name(methodName), + ], + )] ?? + const []; print('Checking calls to $methodName...'); for (final call in calls) { - print( - 'A call was made to "$methodName" with the arguments (' - '${call.positional[0] as int},${call.positional[1] as int})', - ); + switch (call) { + case CallWithArguments( + positionalArguments: [ + IntConstant(value: final v0), + IntConstant(value: final v1), + ], + ): + print( + 'A call was made to "$methodName" with the arguments ($v0,$v1)', + ); + case _: + throw UnsupportedError( + 'Cannot determine math operations for "$methodName".', + ); + } symbols.add(methodName); } } - // Tree-shake unused assets - final instances = usages.constantsOf( - Identifier( - importUri: 'package:${input.packageName}/src/${input.packageName}.dart', - name: 'RecordCallToC', - ), - ); - for (final instance in instances) { - final symbol = instance['symbol'] as String; - print('An instance of "$instance" was found with the field "$symbol"'); - symbols.add(symbol); + const classNameToSymbol = { + 'Double': 'double', + 'Square': 'square', + }; + + // Tree-shake unused assets using instances + for (final className in classNameToSymbol.keys) { + final instances = + usages.instances[Definition( + 'package:${input.packageName}/src/${input.packageName}.dart', + [Name(kind: .classKind, className)], + )] ?? + const []; + print('Checking instances of $className...'); + for (final instance in instances) { + switch (instance) { + case InstanceConstantReference(:final instanceConstant): + print('An instance of "$className" was found: $instanceConstant'); + // Map class name to asset symbol + symbols.add(classNameToSymbol[className]!); + case _: + throw UnsupportedError( + 'Cannot determine math classes for "$className".', + ); + } + } } final neededCodeAssets = [ @@ -66,15 +93,13 @@ void main(List arguments) async { print('Keeping only ${neededCodeAssets.map((e) => e.id).join(', ')}.'); output.assets.data.addAll(neededCodeAssets); - - output.dependencies.add(recordedUsagesFile); }); } -Future recordedUsages(Uri recordedUsagesFile) async { +Future recordedUsages(Uri recordedUsagesFile) async { final file = File.fromUri(recordedUsagesFile); final string = await file.readAsString(); - final usages = RecordedUsages.fromJson( + final usages = Recordings.fromJson( jsonDecode(string) as Map, ); return usages; diff --git a/pkgs/record_use/test_data/drop_data_asset/lib/src/drop_data_asset.dart b/pkgs/record_use/test_data/drop_data_asset/lib/src/drop_data_asset.dart index 518d9ca93e..a6ecb2d77d 100644 --- a/pkgs/record_use/test_data/drop_data_asset/lib/src/drop_data_asset.dart +++ b/pkgs/record_use/test_data/drop_data_asset/lib/src/drop_data_asset.dart @@ -12,17 +12,20 @@ class MyMath { @RecordUse() static int multiply(int a, int b) => a * b; +} - @RecordCallToC('double') - static int double(int a) => a + a; +@RecordUse() +final class Double { + final int value; + const Double(this.value); - @RecordCallToC('square') - static int square(int a) => a * a; + int run() => value + value; } @RecordUse() -class RecordCallToC { - final String symbol; +final class Square { + final int value; + const Square(this.value); - const RecordCallToC(this.symbol); + int run() => value * value; } diff --git a/pkgs/record_use/test_data/drop_data_asset/pubspec.yaml b/pkgs/record_use/test_data/drop_data_asset/pubspec.yaml index 0f59cfd840..b56eff0452 100644 --- a/pkgs/record_use/test_data/drop_data_asset/pubspec.yaml +++ b/pkgs/record_use/test_data/drop_data_asset/pubspec.yaml @@ -4,7 +4,7 @@ description: Add four data assets, remove three in linking based on recorded usa publish_to: none environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' resolution: workspace diff --git a/pkgs/record_use/test_data/drop_dylib_recording/bin/drop_dylib_recording_instances.dart b/pkgs/record_use/test_data/drop_dylib_recording/bin/drop_dylib_recording_instances.dart index f2165871d3..7a3f002237 100644 --- a/pkgs/record_use/test_data/drop_dylib_recording/bin/drop_dylib_recording_instances.dart +++ b/pkgs/record_use/test_data/drop_dylib_recording/bin/drop_dylib_recording_instances.dart @@ -5,5 +5,5 @@ import 'package:drop_dylib_recording/drop_dylib_recording.dart'; void main(List arguments) { - print('Hello world: ${MyMath.double(3)}!'); + print('Hello world: ${const Double(3).run()}!'); } diff --git a/pkgs/record_use/test_data/drop_dylib_recording/hook/link.dart b/pkgs/record_use/test_data/drop_dylib_recording/hook/link.dart index 1fe33c449f..bc78d65adf 100644 --- a/pkgs/record_use/test_data/drop_dylib_recording/hook/link.dart +++ b/pkgs/record_use/test_data/drop_dylib_recording/hook/link.dart @@ -16,7 +16,7 @@ void main(List arguments) async { final recordedUsagesFile = input.recordedUsagesFile; if (recordedUsagesFile == null) { throw ArgumentError( - 'Enable the --enable-experiments=record-use experiment' + 'Enable the --enable-experiment=record-use experiment' ' to use this app.', ); } @@ -32,35 +32,73 @@ void main(List arguments) async { final dataLines = []; // Tree-shake unused assets using calls for (final methodName in ['add', 'multiply']) { - final calls = usages.constArgumentsFor( - Identifier( - importUri: - 'package:drop_dylib_recording/src/drop_dylib_recording.dart', - scope: 'MyMath', - name: methodName, - ), - ); + final calls = + usages.calls[Definition( + 'package:drop_dylib_recording/src/drop_dylib_recording.dart', + [ + const Name( + kind: .classKind, + 'MyMath', + ), + Name( + kind: .methodKind, + methodName, + disambiguators: {.staticDisambiguator}, + ), + ], + )] ?? + const []; for (final call in calls) { - dataLines.add( - 'A call was made to "$methodName" with the arguments (' - '${call.positional[0] as int},${call.positional[1] as int})', - ); + switch (call) { + case CallWithArguments( + positionalArguments: [ + IntConstant(value: final v0), + IntConstant(value: final v1), + ], + ): + dataLines.add( + 'A call was made to "$methodName" with the arguments ($v0,$v1)', + ); + case _: + throw UnsupportedError( + 'Cannot determine math operations for "$methodName".', + ); + } symbols.add(methodName); } } argumentsFile.writeAsStringSync(dataLines.join('\n')); - // Tree-shake unused assets - final instances = usages.constantsOf( - const Identifier( - importUri: 'package:drop_dylib_recording/src/drop_dylib_recording.dart', - name: 'RecordCallToC', - ), - ); - for (final instance in instances) { - final symbol = instance['symbol'] as String; - symbols.add(symbol); + const classNameToSymbol = { + 'Double': 'add', + 'Square': 'multiply', + }; + + // Tree-shake unused assets using instances + for (final className in classNameToSymbol.keys) { + final instances = + usages.instances[Definition( + 'package:drop_dylib_recording/src/drop_dylib_recording.dart', + [ + Name( + kind: .classKind, + className, + ), + ], + )] ?? + const []; + for (final instance in instances) { + switch (instance) { + case InstanceConstantReference(:final instanceConstant): + print('An instance of "$className" was found: $instanceConstant'); + symbols.add(classNameToSymbol[className]!); + case _: + throw UnsupportedError( + 'Cannot determine math classes for "$className".', + ); + } + } } final neededCodeAssets = [ @@ -70,15 +108,13 @@ void main(List arguments) async { print('Keeping only ${neededCodeAssets.map((e) => e.id).join(', ')}.'); output.assets.code.addAll(neededCodeAssets); - - output.dependencies.add(recordedUsagesFile); }); } -Future recordedUsages(Uri recordedUsagesFile) async { +Future recordedUsages(Uri recordedUsagesFile) async { final file = File.fromUri(recordedUsagesFile); final string = await file.readAsString(); - final usages = RecordedUsages.fromJson( + final usages = Recordings.fromJson( jsonDecode(string) as Map, ); return usages; diff --git a/pkgs/record_use/test_data/drop_dylib_recording/lib/src/drop_dylib_recording.dart b/pkgs/record_use/test_data/drop_dylib_recording/lib/src/drop_dylib_recording.dart index fed463acd2..deeae25946 100644 --- a/pkgs/record_use/test_data/drop_dylib_recording/lib/src/drop_dylib_recording.dart +++ b/pkgs/record_use/test_data/drop_dylib_recording/lib/src/drop_dylib_recording.dart @@ -14,17 +14,20 @@ class MyMath { @RecordUse() static int multiply(int a, int b) => bindings.multiply(a, b); +} - @RecordCallToC('add') - static int double(int a) => bindings.add(a, a); +@RecordUse() +final class Double { + final int value; + const Double(this.value); - @RecordCallToC('multiply') - static int square(int a) => bindings.multiply(a, a); + int run() => bindings.add(value, value); } @RecordUse() -class RecordCallToC { - final String symbol; +final class Square { + final int value; + const Square(this.value); - const RecordCallToC(this.symbol); + int run() => bindings.multiply(value, value); } diff --git a/pkgs/record_use/test_data/drop_dylib_recording/pubspec.yaml b/pkgs/record_use/test_data/drop_dylib_recording/pubspec.yaml index 9b054b0677..f086f58c9a 100644 --- a/pkgs/record_use/test_data/drop_dylib_recording/pubspec.yaml +++ b/pkgs/record_use/test_data/drop_dylib_recording/pubspec.yaml @@ -5,7 +5,7 @@ version: 1.0.0 publish_to: none environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' resolution: workspace diff --git a/pkgs/record_use/test_data/json/basic.json b/pkgs/record_use/test_data/json/basic.json new file mode 100644 index 0000000000..4dbbf540dc --- /dev/null +++ b/pkgs/record_use/test_data/json/basic.json @@ -0,0 +1,52 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "int", + "value": 99 + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod2" + } + ], + "uri": "package:record_use_test/basic.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/complex.json b/pkgs/record_use/test_data/json/complex.json index 2921adecf1..e32171b725 100644 --- a/pkgs/record_use/test_data/json/complex.json +++ b/pkgs/record_use/test_data/json/complex.json @@ -1,44 +1,59 @@ { "$schema": "../../doc/schema/record_use.schema.json", "constants": [ + { + "type": "non_constant" + }, { "type": "int", "value": 42 } ], - "locations": [ + "definitions": [ { - "uri": "complex.dart" + "path": [ + { + "kind": "class", + "name": "OtherClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "generate" + } + ], + "uri": "package:record_use_test/complex.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - null, - null, - null, - null, - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "generate", - "scope": "OtherClass", - "uri": "complex.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0, + 0, + 0, + 0, + 1 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/const_argument_instance.json b/pkgs/record_use/test_data/json/const_argument_instance.json new file mode 100644 index 0000000000..89568d005b --- /dev/null +++ b/pkgs/record_use/test_data/json/const_argument_instance.json @@ -0,0 +1,52 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "int", + "value": 14 + }, + { + "definition_index": 0, + "type": "instance", + "value": { + "i": 0 + } + } + ], + "definitions": [ + { + "path": [ + { + "kind": "method", + "name": "someStaticMethod2" + } + ], + "uri": "package:record_use_test/const_argument_instance.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 1 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/constructor_invocation.json b/pkgs/record_use/test_data/json/constructor_invocation.json new file mode 100644 index 0000000000..f1895b490d --- /dev/null +++ b/pkgs/record_use/test_data/json/constructor_invocation.json @@ -0,0 +1,75 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "non_constant" + }, + { + "type": "int", + "value": 1 + }, + { + "type": "int", + "value": 2 + }, + { + "type": "string", + "value": "named_arg_value" + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/test.dart" + }, + { + "path": [ + { + "kind": "class", + "name": "MyClass" + }, + { + "kind": "constructor", + "name": "" + } + ], + "uri": "package:record_use_test/test.dart" + } + ], + "loading_units": [ + { + "name": "root" + } + ], + "metadata": { + "comment": "Constructor invocation recording", + "version": "1.0.0" + }, + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "definition_index": 1, + "loading_unit_index": 0, + "named": { + "other": 0, + "param": 3 + }, + "positional": [ + 1, + 2 + ], + "type": "creation" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/constructor_tearoff.json b/pkgs/record_use/test_data/json/constructor_tearoff.json new file mode 100644 index 0000000000..62db265481 --- /dev/null +++ b/pkgs/record_use/test_data/json/constructor_tearoff.json @@ -0,0 +1,50 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/test.dart" + }, + { + "path": [ + { + "kind": "class", + "name": "MyClass" + }, + { + "kind": "constructor", + "name": "named" + } + ], + "uri": "package:record_use_test/test.dart" + } + ], + "loading_units": [ + { + "name": "root" + } + ], + "metadata": { + "comment": "Constructor tearoff recording", + "version": "1.0.0" + }, + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "definition_index": 1, + "loading_unit_index": 0, + "type": "tearoff" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/enum_const_arg.json b/pkgs/record_use/test_data/json/enum_const_arg.json new file mode 100644 index 0000000000..2eff91019e --- /dev/null +++ b/pkgs/record_use/test_data/json/enum_const_arg.json @@ -0,0 +1,57 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "int", + "value": 1 + }, + { + "type": "string", + "value": "b" + }, + { + "definition_index": 0, + "type": "instance", + "value": { + "_name": 1, + "index": 0 + } + } + ], + "definitions": [ + { + "path": [ + { + "kind": "method", + "name": "doSomething" + } + ], + "uri": "package:record_use_test/enum_const_arg.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 2 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/extension.json b/pkgs/record_use/test_data/json/extension.json index a9bb08c9ab..ecacb5d0dd 100644 --- a/pkgs/record_use/test_data/json/extension.json +++ b/pkgs/record_use/test_data/json/extension.json @@ -2,38 +2,44 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "String", + "type": "string", "value": "42" } ], - "locations": [ + "definitions": [ { - "uri": "extension.dart" + "path": [ + { + "kind": "method", + "name": "_extension#0|callWithArgs" + } + ], + "uri": "package:record_use_test/extension.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "_extension#0|callWithArgs", - "uri": "extension.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/instance_class.json b/pkgs/record_use/test_data/json/instance_class.json index c845673ffd..addd7c856d 100644 --- a/pkgs/record_use/test_data/json/instance_class.json +++ b/pkgs/record_use/test_data/json/instance_class.json @@ -6,37 +6,45 @@ "value": 42 }, { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { "i": 0 } } ], - "locations": [ + "definitions": [ { - "uri": "instance_class.dart" + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/instance_class.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "instance_class.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 1, - "loading_unit": "1" - } - ] - } - ] + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 1, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/instance_complex.json b/pkgs/record_use/test_data/json/instance_complex.json index caf5f6feb8..31c3694f5d 100644 --- a/pkgs/record_use/test_data/json/instance_complex.json +++ b/pkgs/record_use/test_data/json/instance_complex.json @@ -2,23 +2,12 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "int", - "value": 15 - }, - { - "type": "String", - "value": "s" + "type": "null" }, { "type": "bool", "value": false }, - { - "type": "map", - "value": { - "h": 2 - } - }, { "type": "bool", "value": true @@ -27,58 +16,91 @@ "type": "int", "value": 3 }, + { + "type": "int", + "value": 15 + }, + { + "type": "string", + "value": "h" + }, + { + "type": "string", + "value": "l" + }, + { + "type": "string", + "value": "s" + }, { "type": "map", - "value": { - "l": 5 - } + "value": [ + { + "key": 5, + "value": 1 + } + ] }, { - "type": "list", + "type": "map", "value": [ - 6 + { + "key": 6, + "value": 3 + } ] }, { - "type": "Null" + "type": "list", + "value": [ + 9 + ] }, { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { - "i": 0, - "s": 1, - "m": 3, - "b": 4, - "l": 7, - "n": 8 + "b": 2, + "i": 4, + "l": 10, + "m": 8, + "n": 0, + "s": 7 } } ], - "locations": [ + "definitions": [ { - "uri": "instance_complex.dart" + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/instance_complex.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "instance_complex.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 9, - "loading_unit": "1" - } - ] - } - ] + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 11, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/instance_duplicates.json b/pkgs/record_use/test_data/json/instance_duplicates.json index dded9b866c..6c36e29948 100644 --- a/pkgs/record_use/test_data/json/instance_duplicates.json +++ b/pkgs/record_use/test_data/json/instance_duplicates.json @@ -6,52 +6,61 @@ "value": 42 }, { - "type": "Instance", + "type": "int", + "value": 43 + }, + { + "definition_index": 0, + "type": "instance", "value": { "i": 0 } }, { - "type": "int", - "value": 43 - }, - { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { - "i": 2 + "i": 1 } } ], - "locations": [ + "definitions": [ { - "uri": "instance_duplicates.dart" + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/instance_duplicates.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "instance_duplicates.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 1, - "loading_unit": "1" - }, - { - "@": 0, - "constant_index": 3, - "loading_unit": "1" - } - ] - } - ] + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 2, + "loading_unit_index": 0, + "type": "constant" + }, + { + "constant_index": 3, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/instance_method.json b/pkgs/record_use/test_data/json/instance_method.json index 12fba2bce6..b9e76a58fc 100644 --- a/pkgs/record_use/test_data/json/instance_method.json +++ b/pkgs/record_use/test_data/json/instance_method.json @@ -1,42 +1,7 @@ { "$schema": "../../doc/schema/record_use.schema.json", - "constants": [ - { - "type": "int", - "value": 42 - }, - { - "type": "Instance", - "value": { - "i": 0 - } - } - ], - "locations": [ - { - "uri": "instance_method.dart" - } - ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" - }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "instance_method.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 1, - "loading_unit": "1" - } - ] - } - ] + } } diff --git a/pkgs/record_use/test_data/json/instance_not_annotation.json b/pkgs/record_use/test_data/json/instance_not_annotation.json index d51f08a7f7..8f83fab2a4 100644 --- a/pkgs/record_use/test_data/json/instance_not_annotation.json +++ b/pkgs/record_use/test_data/json/instance_not_annotation.json @@ -2,34 +2,42 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "Instance" + "definition_index": 0, + "type": "instance" } ], - "locations": [ + "definitions": [ { - "uri": "instance_not_annotation.dart" + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/instance_not_annotation.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "instance_not_annotation.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 0, - "loading_unit": "1" - } - ] - } - ] + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 0, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/loading_units_multiple.json b/pkgs/record_use/test_data/json/loading_units_multiple.json index a0c8446914..93732c1f4b 100644 --- a/pkgs/record_use/test_data/json/loading_units_multiple.json +++ b/pkgs/record_use/test_data/json/loading_units_multiple.json @@ -6,46 +6,57 @@ "value": 42 } ], - "locations": [ + "definitions": [ { - "uri": "loading_units_multiple.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/loading_units_multiple_helper_shared.dart" + } + ], + "loading_units": [ + { + "name": "1" }, { - "uri": "loading_units_multiple_helper.dart" + "name": "2" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 1, - "loading_unit": "2", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "loading_units_multiple_helper_shared.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 1, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/loading_units_simple.json b/pkgs/record_use/test_data/json/loading_units_simple.json index a1047ebf87..3fb0e766ed 100644 --- a/pkgs/record_use/test_data/json/loading_units_simple.json +++ b/pkgs/record_use/test_data/json/loading_units_simple.json @@ -6,58 +6,78 @@ "value": 42 } ], - "locations": [ + "definitions": [ { - "uri": "loading_units_simple.dart" - }, - { - "uri": "loading_units_simple_helper.dart" - } - ], - "metadata": { - "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 + "disambiguators": [ + "static" ], - "type": "with_arguments" + "kind": "method", + "name": "someStaticMethod" } ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "loading_units_simple.dart" - }, - "loading_unit": "1" - } + "uri": "package:record_use_test/loading_units_simple.dart" }, { - "calls": [ + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, { - "@": 1, - "loading_unit": "2", - "positional": [ - 0 + "disambiguators": [ + "static" ], - "type": "with_arguments" + "kind": "method", + "name": "someStaticMethod" } ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "loading_units_simple_helper.dart" - }, - "loading_unit": "2" - } + "uri": "package:record_use_test/loading_units_simple_helper.dart" + } + ], + "loading_units": [ + { + "name": "1" + }, + { + "name": "2" } - ] + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] + }, + { + "definition_index": 1, + "uses": [ + { + "loading_unit_index": 1, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/map_complex_keys.json b/pkgs/record_use/test_data/json/map_complex_keys.json new file mode 100644 index 0000000000..7fd2b37279 --- /dev/null +++ b/pkgs/record_use/test_data/json/map_complex_keys.json @@ -0,0 +1,77 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "bool", + "value": true + }, + { + "type": "int", + "value": 1 + }, + { + "type": "string", + "value": "bool-key" + }, + { + "type": "string", + "value": "int-key" + }, + { + "type": "map", + "value": [ + { + "key": 0, + "value": 2 + }, + { + "key": 1, + "value": 3 + } + ] + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/map_complex_keys.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 4 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/named_and_positional.json b/pkgs/record_use/test_data/json/named_and_positional.json index abed16dab0..6e79600787 100644 --- a/pkgs/record_use/test_data/json/named_and_positional.json +++ b/pkgs/record_use/test_data/json/named_and_positional.json @@ -2,98 +2,107 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "int", - "value": 3 + "type": "null" }, { - "type": "Null" + "type": "int", + "value": 1 }, { "type": "int", - "value": 5 + "value": 2 }, { "type": "int", - "value": 1 + "value": 3 }, { "type": "int", - "value": 2 + "value": 4 }, { "type": "int", - "value": 4 + "value": 5 + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/named_and_positional.dart" } ], - "locations": [ + "loading_units": [ { - "uri": "named_and_positional.dart" + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "named": { - "l": 1, - "k": 0 + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "k": 3, + "l": 0 + }, + "positional": [ + 3 + ], + "type": "with_arguments" }, - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "k": 3, - "l": 1 + { + "loading_unit_index": 0, + "named": { + "k": 1, + "l": 0 + }, + "positional": [ + 5 + ], + "type": "with_arguments" }, - "positional": [ - 2 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "l": 4, - "k": 0 + { + "loading_unit_index": 0, + "named": { + "k": 3, + "l": 2 + }, + "positional": [ + 5 + ], + "type": "with_arguments" }, - "positional": [ - 2 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "l": 4, - "k": 5 - }, - "positional": [ - 2 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "named_and_positional.dart" - }, - "loading_unit": "1" + { + "loading_unit_index": 0, + "named": { + "k": 4, + "l": 2 + }, + "positional": [ + 5 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/named_both.json b/pkgs/record_use/test_data/json/named_both.json index 1c4ff3798d..68f2ea195d 100644 --- a/pkgs/record_use/test_data/json/named_both.json +++ b/pkgs/record_use/test_data/json/named_both.json @@ -2,90 +2,99 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "int", - "value": 3 + "type": "null" }, { - "type": "Null" + "type": "int", + "value": 1 }, { "type": "int", - "value": 5 + "value": 2 }, { "type": "int", - "value": 1 + "value": 3 }, { "type": "int", - "value": 2 + "value": 4 }, { "type": "int", - "value": 4 + "value": 5 } ], - "locations": [ + "definitions": [ { - "uri": "named_both.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/named_both.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 0, - "l": 1, - "k": 0 - }, - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 2, - "k": 3, - "l": 1 + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "i": 3, + "k": 3, + "l": 0 + }, + "type": "with_arguments" }, - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 2, - "l": 4, - "k": 0 + { + "loading_unit_index": 0, + "named": { + "i": 5, + "k": 1, + "l": 0 + }, + "type": "with_arguments" }, - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 2, - "l": 4, - "k": 5 + { + "loading_unit_index": 0, + "named": { + "i": 5, + "k": 3, + "l": 2 + }, + "type": "with_arguments" }, - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "named_both.dart" - }, - "loading_unit": "1" + { + "loading_unit_index": 0, + "named": { + "i": 5, + "k": 4, + "l": 2 + }, + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/named_optional.json b/pkgs/record_use/test_data/json/named_optional.json index c87a530253..33849b8ec8 100644 --- a/pkgs/record_use/test_data/json/named_optional.json +++ b/pkgs/record_use/test_data/json/named_optional.json @@ -10,43 +10,54 @@ "value": 4 } ], - "locations": [ + "definitions": [ { - "uri": "named_optional.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/named_optional.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 0 - }, - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 1 + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "i": 0 + }, + "type": "with_arguments" }, - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "named_optional.dart" - }, - "loading_unit": "1" + { + "loading_unit_index": 0, + "named": { + "i": 1 + }, + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/named_required.json b/pkgs/record_use/test_data/json/named_required.json index e419058f4a..44f20138b0 100644 --- a/pkgs/record_use/test_data/json/named_required.json +++ b/pkgs/record_use/test_data/json/named_required.json @@ -10,43 +10,54 @@ "value": 5 } ], - "locations": [ + "definitions": [ { - "uri": "named_required.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/named_required.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 0 - }, - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "named": { - "i": 1 + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "i": 0 + }, + "type": "with_arguments" }, - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "named_required.dart" - }, - "loading_unit": "1" + { + "loading_unit_index": 0, + "named": { + "i": 1 + }, + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/named_with_function_arg.json b/pkgs/record_use/test_data/json/named_with_function_arg.json index 131da92af3..d784d0ed2b 100644 --- a/pkgs/record_use/test_data/json/named_with_function_arg.json +++ b/pkgs/record_use/test_data/json/named_with_function_arg.json @@ -2,41 +2,50 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "String", + "type": "non_constant" + }, + { + "type": "string", "value": "hello-world" } ], - "locations": [ + "definitions": [ + { + "path": [ + { + "kind": "method", + "name": "Ext|foo" + } + ], + "uri": "package:record_use_test/named_with_function_arg.dart" + } + ], + "loading_units": [ { - "uri": "named_with_function_arg.dart" + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "named": { - "s": 0 - }, - "positional": [ - null - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "Ext|foo", - "uri": "named_with_function_arg.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "s": 1 + }, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/nested.json b/pkgs/record_use/test_data/json/nested.json index 4a6f7136d0..bf37ead445 100644 --- a/pkgs/record_use/test_data/json/nested.json +++ b/pkgs/record_use/test_data/json/nested.json @@ -6,71 +6,84 @@ "value": 42 }, { - "type": "Instance", + "type": "string", + "value": "test" + }, + { + "definition_index": 1, + "type": "instance" + }, + { + "definition_index": 0, + "type": "instance", "value": { "i": 0 } }, { - "type": "String", - "value": "test" - }, - { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { - "i": 2 + "i": 1 } + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/nested.dart" }, { - "type": "Instance" + "path": [ + { + "kind": "class", + "name": "MyOtherClass" + } + ], + "uri": "package:record_use_test/nested.dart" } ], - "locations": [ + "loading_units": [ { - "uri": "nested.dart" + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "nested.dart" - }, - "loading_unit": "1" + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 3, + "loading_unit_index": 0, + "type": "constant" + }, + { + "constant_index": 4, + "loading_unit_index": 0, + "type": "constant" + } + ] }, - "instances": [ - { - "@": 0, - "constant_index": 1, - "loading_unit": "1" - }, - { - "@": 0, - "constant_index": 3, - "loading_unit": "1" - } - ] - }, - { - "definition": { - "identifier": { - "name": "MyOtherClass", - "uri": "nested.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 4, - "loading_unit": "1" - } - ] - } - ] + { + "definition_index": 1, + "uses": [ + { + "constant_index": 2, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/nested_instance_constant.json b/pkgs/record_use/test_data/json/nested_instance_constant.json new file mode 100644 index 0000000000..cb1849302d --- /dev/null +++ b/pkgs/record_use/test_data/json/nested_instance_constant.json @@ -0,0 +1,50 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "string", + "value": "id" + }, + { + "definition_index": 0, + "type": "instance", + "value": { + "id": 0 + } + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "Recorded" + } + ], + "uri": "package:record_use_test/nested_instance_constant.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 1, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/partfile_main.json b/pkgs/record_use/test_data/json/partfile_main.json index 8fe7060824..c9f10cff7f 100644 --- a/pkgs/record_use/test_data/json/partfile_main.json +++ b/pkgs/record_use/test_data/json/partfile_main.json @@ -6,35 +6,47 @@ "value": 42 } ], - "locations": [ + "definitions": [ { - "uri": "partfile_main.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/partfile_main.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "partfile_main.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/positional_both.json b/pkgs/record_use/test_data/json/positional_both.json index 462226b828..7f5af027a9 100644 --- a/pkgs/record_use/test_data/json/positional_both.json +++ b/pkgs/record_use/test_data/json/positional_both.json @@ -3,60 +3,71 @@ "constants": [ { "type": "int", - "value": 5 + "value": 3 }, { "type": "int", - "value": 3 + "value": 4 }, { "type": "int", - "value": 6 + "value": 5 }, { "type": "int", - "value": 4 + "value": 6 } ], - "locations": [ + "definitions": [ { - "uri": "positional_both.dart" - } - ], - "metadata": { - "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ + "path": [ { - "@": 0, - "loading_unit": "1", - "positional": [ - 0, - 1 - ], - "type": "with_arguments" + "kind": "class", + "name": "SomeClass" }, { - "@": 0, - "loading_unit": "1", - "positional": [ - 2, - 3 + "disambiguators": [ + "static" ], - "type": "with_arguments" + "kind": "method", + "name": "someStaticMethod" } ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "positional_both.dart" - }, - "loading_unit": "1" - } + "uri": "package:record_use_test/positional_both.dart" + } + ], + "loading_units": [ + { + "name": "1" } - ] + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 2, + 0 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 3, + 1 + ], + "type": "with_arguments" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/positional_both_with_type_argument.json b/pkgs/record_use/test_data/json/positional_both_with_type_argument.json new file mode 100644 index 0000000000..0cb5a54042 --- /dev/null +++ b/pkgs/record_use/test_data/json/positional_both_with_type_argument.json @@ -0,0 +1,73 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "int", + "value": 3 + }, + { + "type": "int", + "value": 4 + }, + { + "type": "int", + "value": 5 + }, + { + "type": "int", + "value": 6 + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/positional_both_with_type_argument.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 2, + 0 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 3, + 1 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/positional_optional.json b/pkgs/record_use/test_data/json/positional_optional.json index 49c83f62e3..09c6c69a7e 100644 --- a/pkgs/record_use/test_data/json/positional_optional.json +++ b/pkgs/record_use/test_data/json/positional_optional.json @@ -10,43 +10,54 @@ "value": 4 } ], - "locations": [ + "definitions": [ { - "uri": "positional_optional.dart" - } - ], - "metadata": { - "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ + "path": [ { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" + "kind": "class", + "name": "SomeClass" }, { - "@": 0, - "loading_unit": "1", - "positional": [ - 1 + "disambiguators": [ + "static" ], - "type": "with_arguments" + "kind": "method", + "name": "someStaticMethod" } ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "positional_optional.dart" - }, - "loading_unit": "1" - } + "uri": "package:record_use_test/positional_optional.dart" } - ] + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 1 + ], + "type": "with_arguments" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/record_enum.json b/pkgs/record_use/test_data/json/record_enum.json index dfe100249c..cc1aae4c73 100644 --- a/pkgs/record_use/test_data/json/record_enum.json +++ b/pkgs/record_use/test_data/json/record_enum.json @@ -6,48 +6,57 @@ "value": 0 }, { - "type": "String", + "type": "string", "value": "a" }, { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { - "index": 0, - "_name": 1 + "_name": 1, + "index": 0 } }, { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { "a": 2 } } ], - "locations": [ + "definitions": [ { - "uri": "record_enum.dart" + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/record_enum.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "record_enum.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 3, - "loading_unit": "1" - } - ] - } - ] + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 3, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/record_instance_constant.json b/pkgs/record_use/test_data/json/record_instance_constant.json index ee23c9d3d6..b9e76a58fc 100644 --- a/pkgs/record_use/test_data/json/record_instance_constant.json +++ b/pkgs/record_use/test_data/json/record_instance_constant.json @@ -1,48 +1,7 @@ { "$schema": "../../doc/schema/record_use.schema.json", - "constants": [ - { - "type": "int", - "value": 42 - }, - { - "type": "Instance", - "value": { - "i": 0 - } - }, - { - "type": "Instance", - "value": { - "a": 1 - } - } - ], - "locations": [ - { - "uri": "record_instance_constant.dart" - } - ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" - }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "record_instance_constant.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 2, - "loading_unit": "1" - } - ] - } - ] + } } diff --git a/pkgs/record_use/test_data/json/record_instance_constant_empty.json b/pkgs/record_use/test_data/json/record_instance_constant_empty.json index e83ed4c255..4f0408a96d 100644 --- a/pkgs/record_use/test_data/json/record_instance_constant_empty.json +++ b/pkgs/record_use/test_data/json/record_instance_constant_empty.json @@ -2,40 +2,49 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "Instance" + "definition_index": 0, + "type": "instance" }, { - "type": "Instance", + "definition_index": 0, + "type": "instance", "value": { "a": 0 } } ], - "locations": [ + "definitions": [ { - "uri": "record_instance_constant_empty.dart" + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/record_instance_constant_empty.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "record_instance_constant_empty.dart" - }, - "loading_unit": "1" - }, - "instances": [ - { - "@": 0, - "constant_index": 1, - "loading_unit": "1" - } - ] - } - ] + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 1, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/recorded_uses.json b/pkgs/record_use/test_data/json/recorded_uses.json index a0a915af7c..6f29bc1db5 100644 --- a/pkgs/record_use/test_data/json/recorded_uses.json +++ b/pkgs/record_use/test_data/json/recorded_uses.json @@ -2,97 +2,166 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "String", - "value": "42" + "type": "non_constant" }, { - "type": "bool", - "value": false + "message": "MethodTearoff", + "type": "unsupported" }, { - "type": "map", - "value": { - "h": 1 - } + "type": "null" }, { - "type": "Null" + "type": "bool", + "value": false }, { "type": "int", "value": 42 }, { - "type": "Instance", + "type": "double", "value": { - "i": 4 + "type": "number", + "value": 3.14 } }, + { + "type": "string", + "value": "42" + }, + { + "type": "string", + "value": "h" + }, { "type": "list", "value": [ 4 ] - } - ], - "locations": [ + }, + { + "type": "map", + "value": [ + { + "key": 7, + "value": 3 + } + ] + }, { - "column": 30, - "line": 12, - "uri": "complex.dart" + "named": { + "a": 6 + }, + "positional": [ + 4 + ], + "type": "record" + }, + { + "definition_index": 0, + "index": 0, + "name": "red", + "type": "enum", + "value": { + "hex": 4 + } + }, + { + "definition_index": 2, + "type": "instance", + "value": { + "i": 4 + } } ], - "metadata": { - "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", - "version": "0.4.0" - }, - "recordings": [ + "definitions": [ { - "calls": [ + "path": [ { - "@": 0, - "loading_unit": "1", - "named": { - "a": 0, - "b": 1, - "c": 4 - }, - "positional": [ - 0, - 2, - 3, - null, - 4, - 5, - 6 - ], - "type": "with_arguments" + "kind": "enum", + "name": "Color" } ], - "definition": { - "identifier": { - "name": "generate", - "scope": "OtherClass", - "uri": "complex.dart" - }, - "loading_unit": "1" - } + "uri": "package:record_use_test/color.dart" }, { - "definition": { - "identifier": { - "name": "MyClass", - "uri": "instance_class.dart" + "path": [ + { + "kind": "class", + "name": "OtherClass" }, - "loading_unit": "1" - }, - "instances": [ { - "@": 0, - "constant_index": 5, - "loading_unit": "1" + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "generate" } - ] + ], + "uri": "package:record_use_test/complex.dart" + }, + { + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/instance_class.dart" + } + ], + "loading_units": [ + { + "name": "1" } - ] + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "instances": [ + { + "definition_index": 2, + "uses": [ + { + "constant_index": 12, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ], + "static_calls": [ + { + "definition_index": 1, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "a": 6, + "b": 3, + "c": 4, + "d": 0 + }, + "positional": [ + 6, + 9, + 2, + 0, + 4, + 12, + 8, + 1, + 10, + 11, + 5 + ], + "type": "with_arguments" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/recorded_uses_v2.json b/pkgs/record_use/test_data/json/recorded_uses_v2.json new file mode 100644 index 0000000000..cbae3234aa --- /dev/null +++ b/pkgs/record_use/test_data/json/recorded_uses_v2.json @@ -0,0 +1,205 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "null" + }, + { + "type": "bool", + "value": false + }, + { + "type": "int", + "value": 0 + }, + { + "type": "int", + "value": 1 + }, + { + "type": "int", + "value": 42 + }, + { + "type": "int", + "value": 99 + }, + { + "type": "string", + "value": "camus" + }, + { + "type": "string", + "value": "einstein" + }, + { + "type": "string", + "value": "insert" + }, + { + "type": "string", + "value": "jenkins" + }, + { + "type": "string", + "value": "key" + }, + { + "type": "string", + "value": "lib_SHA1" + }, + { + "type": "string", + "value": "mercury" + }, + { + "definition_index": 0, + "type": "instance" + }, + { + "type": "list", + "value": [ + 7, + 8, + 1 + ] + }, + { + "type": "map", + "value": [ + { + "key": 10, + "value": 5 + } + ] + }, + { + "definition_index": 2, + "index": 0, + "name": "val1", + "type": "enum", + "value": { + "a": 4 + } + }, + { + "definition_index": 0, + "type": "instance", + "value": { + "a": 4, + "b": 0 + } + }, + { + "type": "list", + "value": [ + 6, + 14, + 7 + ] + } + ], + "definitions": [ + { + "path": [ + { + "name": "MyAnnotation" + } + ], + "uri": "package:js_runtime/js_helper.dart" + }, + { + "path": [ + { + "name": "MyClass" + }, + { + "name": "get:loadDeferredLibrary" + } + ], + "uri": "package:js_runtime/js_helper.dart" + }, + { + "path": [ + { + "name": "MyEnum" + } + ], + "uri": "package:js_runtime/js_helper.dart" + } + ], + "loading_units": [ + { + "name": "3" + }, + { + "name": "o.js" + } + ], + "metadata": { + "comment": "Recorded references at compile time and their argument values, as far as known, to definitions annotated with @RecordUse", + "version": "1.6.2-wip+5.-.2.z" + }, + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 13, + "loading_unit_index": 0, + "type": "constant" + }, + { + "constant_index": 17, + "loading_unit_index": 0, + "type": "constant" + } + ] + }, + { + "definition_index": 2, + "uses": [ + { + "constant_index": 16, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ], + "static_calls": [ + { + "definition_index": 1, + "uses": [ + { + "loading_unit_index": 1, + "named": { + "freddy": 12, + "leroy": 9 + }, + "positional": [ + 11, + 1, + 3 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 1, + "named": { + "freddy": 2, + "leroy": 9 + }, + "positional": [ + 11, + 15, + 18 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/recorded_uses_v2_2.json b/pkgs/record_use/test_data/json/recorded_uses_v2_2.json new file mode 100644 index 0000000000..d86324e311 --- /dev/null +++ b/pkgs/record_use/test_data/json/recorded_uses_v2_2.json @@ -0,0 +1,64 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "type": "bool", + "value": false + }, + { + "type": "int", + "value": 1 + }, + { + "type": "int", + "value": 42 + }, + { + "type": "string", + "value": "mercury" + } + ], + "definitions": [ + { + "path": [ + { + "name": "MyClass" + }, + { + "name": "get:loadDeferredLibrary" + } + ], + "uri": "package:js_runtime/js_helper.dart" + } + ], + "loading_units": [ + { + "name": "o.js" + } + ], + "metadata": { + "comment": "Recorded references at compile time and their argument values, as far as known, to definitions annotated with @RecordUse", + "version": "1.6.2-wip+5.-.2.z" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "named": { + "answer": 2, + "freddy": 3 + }, + "positional": [ + 0, + 1 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/simple.json b/pkgs/record_use/test_data/json/simple.json index 913f55fc09..e74a303839 100644 --- a/pkgs/record_use/test_data/json/simple.json +++ b/pkgs/record_use/test_data/json/simple.json @@ -6,35 +6,47 @@ "value": 42 } ], - "locations": [ + "definitions": [ { - "uri": "simple.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/simple.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "simple.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/tearoff.json b/pkgs/record_use/test_data/json/tearoff.json index 1a57ee2041..c44b0e1202 100644 --- a/pkgs/record_use/test_data/json/tearoff.json +++ b/pkgs/record_use/test_data/json/tearoff.json @@ -1,31 +1,43 @@ { "$schema": "../../doc/schema/record_use.schema.json", - "locations": [ + "definitions": [ { - "uri": "tearoff.dart" + "path": [ + { + "kind": "class", + "name": "SomeClass" + }, + { + "disambiguators": [ + "static" + ], + "kind": "method", + "name": "someStaticMethod" + } + ], + "uri": "package:record_use_test/tearoff.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "type": "tearoff" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "tearoff.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "type": "tearoff" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/top_level_method.json b/pkgs/record_use/test_data/json/top_level_method.json index d4a0b1dba5..58902402ea 100644 --- a/pkgs/record_use/test_data/json/top_level_method.json +++ b/pkgs/record_use/test_data/json/top_level_method.json @@ -6,34 +6,40 @@ "value": 42 } ], - "locations": [ + "definitions": [ { - "uri": "top_level_method.dart" + "path": [ + { + "kind": "method", + "name": "someTopLevelMethod" + } + ], + "uri": "package:record_use_test/top_level_method.dart" + } + ], + "loading_units": [ + { + "name": "1" } ], "metadata": { "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", "version": "0.4.0" }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someTopLevelMethod", - "uri": "top_level_method.dart" - }, - "loading_unit": "1" + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + } + ] } - } - ] + ] + } } diff --git a/pkgs/record_use/test_data/json/types_of_arguments.json b/pkgs/record_use/test_data/json/types_of_arguments.json index 7582cda8f9..e2db83e4d2 100644 --- a/pkgs/record_use/test_data/json/types_of_arguments.json +++ b/pkgs/record_use/test_data/json/types_of_arguments.json @@ -2,127 +2,151 @@ "$schema": "../../doc/schema/record_use.schema.json", "constants": [ { - "type": "int", - "value": 42 - }, - { - "type": "Null" + "type": "non_constant" }, { - "type": "String", - "value": "s" + "type": "null" }, { "type": "bool", "value": true }, { - "type": "String", + "type": "int", + "value": 42 + }, + { + "type": "string", + "value": "a" + }, + { + "type": "string", "value": "a1" }, { - "type": "String", + "type": "string", "value": "a2" }, { - "type": "list", - "value": [ - 4, - 5 - ] + "type": "string", + "value": "b" }, { - "type": "String", + "type": "string", "value": "b1" }, { - "type": "String", + "type": "string", "value": "b2" }, + { + "type": "string", + "value": "s" + }, { "type": "list", "value": [ - 7, - 8 + 5, + 6 ] }, { - "type": "map", - "value": { - "a": 6, - "b": 9 - } - } - ], - "locations": [ - { - "uri": "types_of_arguments.dart" - } - ], - "metadata": { - "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", - "version": "0.4.0" - }, - "recordings": [ + "type": "list", + "value": [ + 8, + 9 + ] + }, { - "calls": [ - { - "@": 0, - "loading_unit": "1", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "1", - "positional": [ - 1 - ], - "type": "with_arguments" - }, + "type": "map", + "value": [ { - "@": 0, - "loading_unit": "1", - "positional": [ - 2 - ], - "type": "with_arguments" + "key": 4, + "value": 11 }, { - "@": 0, - "loading_unit": "1", - "positional": [ - 3 - ], - "type": "with_arguments" - }, + "key": 7, + "value": 12 + } + ] + } + ], + "definitions": [ + { + "path": [ { - "@": 0, - "loading_unit": "1", - "positional": [ - 10 - ], - "type": "with_arguments" + "kind": "class", + "name": "SomeClass" }, { - "@": 0, - "loading_unit": "1", - "positional": [ - null + "disambiguators": [ + "static" ], - "type": "with_arguments" + "kind": "method", + "name": "someStaticMethod" } ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "types_of_arguments.dart" - }, - "loading_unit": "1" - } + "uri": "package:record_use_test/types_of_arguments.dart" } - ] + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 0 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 1 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 2 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 3 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 10 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 13 + ], + "type": "with_arguments" + } + ] + } + ] + } } diff --git a/pkgs/record_use/test_data/json/unsupported_collections.json b/pkgs/record_use/test_data/json/unsupported_collections.json new file mode 100644 index 0000000000..f3ba3b40a1 --- /dev/null +++ b/pkgs/record_use/test_data/json/unsupported_collections.json @@ -0,0 +1,71 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "message": "Function/Method tear-offs are not supported for recording.", + "type": "unsupported" + }, + { + "type": "string", + "value": "key" + }, + { + "type": "list", + "value": [ + 0 + ] + }, + { + "type": "map", + "value": [ + { + "key": 1, + "value": 0 + } + ] + } + ], + "definitions": [ + { + "path": [ + { + "kind": "method", + "name": "recorded" + } + ], + "uri": "package:record_use_test/unsupported_collections.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "static_calls": [ + { + "definition_index": 0, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 2 + ], + "type": "with_arguments" + }, + { + "loading_unit_index": 0, + "positional": [ + 3 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json/unsupported_instance.json b/pkgs/record_use/test_data/json/unsupported_instance.json new file mode 100644 index 0000000000..fe6f70e9b6 --- /dev/null +++ b/pkgs/record_use/test_data/json/unsupported_instance.json @@ -0,0 +1,73 @@ +{ + "$schema": "../../doc/schema/record_use.schema.json", + "constants": [ + { + "message": "Function/Method tear-offs are not supported for recording.", + "type": "unsupported" + }, + { + "definition_index": 0, + "type": "instance", + "value": { + "field": 0 + } + } + ], + "definitions": [ + { + "path": [ + { + "kind": "class", + "name": "MyClass" + } + ], + "uri": "package:record_use_test/unsupported_instance.dart" + }, + { + "path": [ + { + "kind": "method", + "name": "recorded" + } + ], + "uri": "package:record_use_test/unsupported_instance.dart" + } + ], + "loading_units": [ + { + "name": "1" + } + ], + "metadata": { + "comment": "Recorded usages of objects tagged with a `RecordUse` annotation", + "version": "0.4.0" + }, + "uses": { + "instances": [ + { + "definition_index": 0, + "uses": [ + { + "constant_index": 1, + "loading_unit_index": 0, + "type": "constant" + } + ] + } + ], + "static_calls": [ + { + "definition_index": 1, + "uses": [ + { + "loading_unit_index": 0, + "positional": [ + 1 + ], + "type": "with_arguments" + } + ] + } + ] + } +} diff --git a/pkgs/record_use/test_data/json_dart2js/complex.json b/pkgs/record_use/test_data/json_dart2js/complex.json deleted file mode 100644 index e756ac667a..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/complex.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "constants": [ - { - "type": "String", - "value": "somestring" - }, - { - "type": "int", - "value": 42 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/complex.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - null, - null, - 0, - null, - 1 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "generate", - "scope": "OtherClass", - "uri": "memory:sdk/tests/web/native/complex.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/different.json b/pkgs/record_use/test_data/json_dart2js/different.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/different.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/extension.json b/pkgs/record_use/test_data/json_dart2js/extension.json deleted file mode 100644 index c899ca27d2..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/extension.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "constants": [ - { - "type": "String", - "value": "42" - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/extension.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - null, - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "_extension#0|callWithArgs", - "uri": "memory:sdk/tests/web/native/extension.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/instance_class.json b/pkgs/record_use/test_data/json_dart2js/instance_class.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/instance_class.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/instance_complex.json b/pkgs/record_use/test_data/json_dart2js/instance_complex.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/instance_complex.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/instance_duplicates.json b/pkgs/record_use/test_data/json_dart2js/instance_duplicates.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/instance_duplicates.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/instance_method.json b/pkgs/record_use/test_data/json_dart2js/instance_method.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/instance_method.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/instance_not_annotation.json b/pkgs/record_use/test_data/json_dart2js/instance_not_annotation.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/instance_not_annotation.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/loading_units_multiple.json b/pkgs/record_use/test_data/json_dart2js/loading_units_multiple.json deleted file mode 100644 index d5cb2c920b..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/loading_units_multiple.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - }, - { - "type": "String", - "value": "helper" - }, - { - "type": "String", - "value": "" - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/loading_units_multiple_helper.dart" - }, - { - "uri": "memory:sdk/tests/web/native/loading_units_multiple.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out_1", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 1, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/loading_units_multiple_helper_shared.dart" - } - } - }, - { - "calls": [ - { - "@": 1, - "loading_unit": "out", - "positional": [ - 1, - 2 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "loadDeferredLibrary", - "uri": "dart:_js_helper" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/loading_units_simple.json b/pkgs/record_use/test_data/json_dart2js/loading_units_simple.json deleted file mode 100644 index 4e24c1ae02..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/loading_units_simple.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - }, - { - "type": "String", - "value": "helper" - }, - { - "type": "String", - "value": "" - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/loading_units_simple_helper.dart" - }, - { - "uri": "memory:sdk/tests/web/native/loading_units_simple.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out_1", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/loading_units_simple_helper.dart" - } - } - }, - { - "calls": [ - { - "@": 1, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/loading_units_simple.dart" - } - } - }, - { - "calls": [ - { - "@": 1, - "loading_unit": "out", - "positional": [ - 1, - 2 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "loadDeferredLibrary", - "uri": "dart:_js_helper" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/named_and_positional.json b/pkgs/record_use/test_data/json_dart2js/named_and_positional.json deleted file mode 100644 index 097365499e..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/named_and_positional.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 3 - }, - { - "type": "Null" - }, - { - "type": "int", - "value": 5 - }, - { - "type": "int", - "value": 1 - }, - { - "type": "int", - "value": 2 - }, - { - "type": "int", - "value": 4 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/named_and_positional.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0, - 0, - 1 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 3, - 1 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 0, - 4 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 5, - 4 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/named_and_positional.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/named_both.json b/pkgs/record_use/test_data/json_dart2js/named_both.json deleted file mode 100644 index 205da2e89a..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/named_both.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 3 - }, - { - "type": "Null" - }, - { - "type": "int", - "value": 5 - }, - { - "type": "int", - "value": 1 - }, - { - "type": "int", - "value": 2 - }, - { - "type": "int", - "value": 4 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/named_both.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0, - 0, - 1 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 3, - 1 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 0, - 4 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 5, - 4 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/named_both.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/named_optional.json b/pkgs/record_use/test_data/json_dart2js/named_optional.json deleted file mode 100644 index 87df390a26..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/named_optional.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 3 - }, - { - "type": "int", - "value": 4 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/named_optional.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 1 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/named_optional.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/named_required.json b/pkgs/record_use/test_data/json_dart2js/named_required.json deleted file mode 100644 index 10ab9265f7..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/named_required.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 3 - }, - { - "type": "int", - "value": 5 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/named_required.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 1 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/named_required.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/nested.json b/pkgs/record_use/test_data/json_dart2js/nested.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/nested.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/partfile_main.json b/pkgs/record_use/test_data/json_dart2js/partfile_main.json deleted file mode 100644 index 8bbf02e7be..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/partfile_main.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/partfile_main.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/partfile_main.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/positional_both.json b/pkgs/record_use/test_data/json_dart2js/positional_both.json deleted file mode 100644 index 3e39ec238e..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/positional_both.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 5 - }, - { - "type": "int", - "value": 3 - }, - { - "type": "int", - "value": 6 - }, - { - "type": "int", - "value": 4 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/positional_both.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0, - 1 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2, - 3 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/positional_both.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/positional_optional.json b/pkgs/record_use/test_data/json_dart2js/positional_optional.json deleted file mode 100644 index 0dcb015762..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/positional_optional.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 3 - }, - { - "type": "int", - "value": 4 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/positional_optional.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 1 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/positional_optional.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/record_enum.json b/pkgs/record_use/test_data/json_dart2js/record_enum.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/record_enum.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/record_instance_constant_empty.json b/pkgs/record_use/test_data/json_dart2js/record_instance_constant_empty.json deleted file mode 100644 index 1108c1c4e3..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/record_instance_constant_empty.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - } -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/simple.json b/pkgs/record_use/test_data/json_dart2js/simple.json deleted file mode 100644 index 79ce2ca2dc..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/simple.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/simple.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/simple.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/tearoff.json b/pkgs/record_use/test_data/json_dart2js/tearoff.json deleted file mode 100644 index 0dcbedd5b9..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/tearoff.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/tearoff.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/tearoff.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/top_level_method.json b/pkgs/record_use/test_data/json_dart2js/top_level_method.json deleted file mode 100644 index ef93e460cd..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/top_level_method.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/top_level_method.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someTopLevelMethod", - "uri": "memory:sdk/tests/web/native/top_level_method.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/json_dart2js/types_of_arguments.json b/pkgs/record_use/test_data/json_dart2js/types_of_arguments.json deleted file mode 100644 index 03cc80c37a..0000000000 --- a/pkgs/record_use/test_data/json_dart2js/types_of_arguments.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "constants": [ - { - "type": "int", - "value": 42 - }, - { - "type": "Null" - }, - { - "type": "String", - "value": "s" - }, - { - "type": "bool", - "value": true - } - ], - "locations": [ - { - "uri": "memory:sdk/tests/web/native/types_of_arguments.dart" - } - ], - "metadata": { - "comment": "Resources referenced by annotated resource identifiers", - "AppTag": "TBD", - "environment": { - "dart.web.assertions_enabled": "false", - "dart.tool.dart2js": "true", - "dart.tool.dart2js.minify": "false", - "dart.tool.dart2js.disable_rti_optimization": "false", - "dart.tool.dart2js.primitives:trust": "false", - "dart.tool.dart2js.types:trust": "false" - }, - "version": "0.4.0" - }, - "recordings": [ - { - "calls": [ - { - "@": 0, - "loading_unit": "out", - "positional": [ - 0 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 1 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 2 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - 3 - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - null - ], - "type": "with_arguments" - }, - { - "@": 0, - "loading_unit": "out", - "positional": [ - null - ], - "type": "with_arguments" - } - ], - "definition": { - "identifier": { - "name": "someStaticMethod", - "scope": "SomeClass", - "uri": "memory:sdk/tests/web/native/types_of_arguments.dart" - } - } - } - ] -} \ No newline at end of file diff --git a/pkgs/record_use/test_data/library_uris/bin/my_bin.dart b/pkgs/record_use/test_data/library_uris/bin/my_bin.dart new file mode 100644 index 0000000000..94a8dc474e --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/bin/my_bin.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:library_uris/library_uris.dart'; +import 'package:library_uris_helper/library_uris_helper.dart'; +import 'package:meta/meta.dart'; + +void main() { + helloFoo(); + MyClass.myMethod('bar'); + helloBar(); + ClassInHelper.methodInHelper('bar'); + methodInBin(); +} + +// ignore: experimental_member_use +@RecordUse() +void methodInBin() { + print('The answer to the universe, life, and everything.'); +} diff --git a/pkgs/record_use/test_data/library_uris/hook/build.dart b/pkgs/record_use/test_data/library_uris/hook/build.dart new file mode 100644 index 0000000000..2723c5ee31 --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/hook/build.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:hooks/hooks.dart'; + +void main(List arguments) async { + await build( + arguments, + (input, output) async { + // Do nothing. + }, + ); +} diff --git a/pkgs/record_use/test_data/library_uris/hook/link.dart b/pkgs/record_use/test_data/library_uris/hook/link.dart new file mode 100644 index 0000000000..bba3b3cecf --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/hook/link.dart @@ -0,0 +1,73 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// This hook is a test that checks that library URIs are as expected inside +// the link hook. +// This test is run on CI by executing `dart build cli` in this package. + +import 'dart:convert'; +import 'dart:io'; + +import 'package:hooks/hooks.dart'; +import 'package:record_use/record_use.dart'; + +void main(List arguments) async { + await link( + arguments, + (input, output) async { + // ignore: experimental_member_use + final recordedUsagesFile = input.recordedUsagesFile; + if (recordedUsagesFile == null) { + throw UnsupportedError('Run with --enable-experiment=record-use.'); + } + final recordings = await readUsagesFile(recordedUsagesFile); + + // This package. + final myMethodDefinition = recordings.calls.keys.firstWhere( + (i) => i.path.last.name == 'myMethod', + ); + expect( + myMethodDefinition.library, + 'package:library_uris/src/definition.dart', + ); + + // The helper package. + final helperMethodDefinition = recordings.calls.keys.firstWhere( + (i) => i.path.last.name == 'methodInHelper', + ); + expect( + helperMethodDefinition.library, + 'package:library_uris_helper/src/helper_definition.dart', + ); + + // Outside the lib dir, no package: uri. + final methodInBinDefinition = recordings.calls.keys.firstWhere( + (i) => i.path.last.name == 'methodInBin', + ); + expect( + methodInBinDefinition.library, + // TODO(https://github.com/dart-lang/native/issues/2891): What should + // this be? We don't have library uris for bin. + 'package:library_uris/../bin/my_bin.dart', + ); + }, + ); +} + +void expect(String actual, String expected) { + if (actual != expected) { + throw ArgumentError( + 'Expected "$expected" got "$actual"', + ); + } +} + +Future readUsagesFile(Uri recordedUsagesFile) async { + final file = File.fromUri(recordedUsagesFile); + final string = await file.readAsString(); + final usages = Recordings.fromJson( + jsonDecode(string) as Map, + ); + return usages; +} diff --git a/pkgs/record_use/test_data/library_uris/lib/library_uris.dart b/pkgs/record_use/test_data/library_uris/lib/library_uris.dart new file mode 100644 index 0000000000..c928a46f9b --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/lib/library_uris.dart @@ -0,0 +1,6 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/call.dart'; +export 'src/definition.dart'; diff --git a/pkgs/record_use/test_data/library_uris/lib/src/call.dart b/pkgs/record_use/test_data/library_uris/lib/src/call.dart new file mode 100644 index 0000000000..67a752dd2c --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/lib/src/call.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:library_uris_helper/library_uris_helper.dart'; + +import 'definition.dart'; + +void helloFoo() { + MyClass.myMethod('foo'); + ClassInHelper.methodInHelper('foo'); + helloBar(); +} diff --git a/pkgs/record_use/test_data/library_uris/lib/src/definition.dart b/pkgs/record_use/test_data/library_uris/lib/src/definition.dart new file mode 100644 index 0000000000..01accd7681 --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/lib/src/definition.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:meta/meta.dart'; + +class MyClass { + // ignore: experimental_member_use + @RecordUse() + static void myMethod(String argument) { + print('Hello $argument'); + } +} diff --git a/pkgs/record_use/test_data/library_uris/pubspec.yaml b/pkgs/record_use/test_data/library_uris/pubspec.yaml new file mode 100644 index 0000000000..471100fde4 --- /dev/null +++ b/pkgs/record_use/test_data/library_uris/pubspec.yaml @@ -0,0 +1,25 @@ +name: library_uris +description: >- + This is an automated CI test that checks that library uris are as expected + inside the link hook. + + It is run on CI by executing `dart build cli` in this package. + + For dart2js, `dart compile js --write-resources` and inspect the contents of + the file. + +version: 0.1.0 + +publish_to: none + +resolution: workspace + +environment: + sdk: '>=3.10.0 <4.0.0' + +dependencies: + hooks: any + library_uris_helper: + path: ../library_uris_helper + meta: ^1.18.0 + record_use: any diff --git a/pkgs/record_use/test_data/library_uris_helper/lib/library_uris_helper.dart b/pkgs/record_use/test_data/library_uris_helper/lib/library_uris_helper.dart new file mode 100644 index 0000000000..dc81ec2ff3 --- /dev/null +++ b/pkgs/record_use/test_data/library_uris_helper/lib/library_uris_helper.dart @@ -0,0 +1,6 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/helper_call.dart'; +export 'src/helper_definition.dart'; diff --git a/pkgs/record_use/test_data/library_uris_helper/lib/src/helper_call.dart b/pkgs/record_use/test_data/library_uris_helper/lib/src/helper_call.dart new file mode 100644 index 0000000000..0b202403c6 --- /dev/null +++ b/pkgs/record_use/test_data/library_uris_helper/lib/src/helper_call.dart @@ -0,0 +1,9 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'helper_definition.dart'; + +void helloBar() { + ClassInHelper.methodInHelper('bar'); +} diff --git a/pkgs/record_use/test_data/library_uris_helper/lib/src/helper_definition.dart b/pkgs/record_use/test_data/library_uris_helper/lib/src/helper_definition.dart new file mode 100644 index 0000000000..e9ee50a9aa --- /dev/null +++ b/pkgs/record_use/test_data/library_uris_helper/lib/src/helper_definition.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:meta/meta.dart'; + +class ClassInHelper { + // ignore: experimental_member_use + @RecordUse() + static void methodInHelper(String argument) { + print('Hello $argument'); + } +} diff --git a/pkgs/record_use/test_data/library_uris_helper/pubspec.yaml b/pkgs/record_use/test_data/library_uris_helper/pubspec.yaml new file mode 100644 index 0000000000..87ca9072bf --- /dev/null +++ b/pkgs/record_use/test_data/library_uris_helper/pubspec.yaml @@ -0,0 +1,14 @@ +name: library_uris_helper +description: helper for library_uris + +version: 0.1.0 + +publish_to: none + +resolution: workspace + +environment: + sdk: '>=3.10.0 <4.0.0' + +dependencies: + meta: ^1.18.0 diff --git a/pkgs/record_use/test_data/manifest.yaml b/pkgs/record_use/test_data/manifest.yaml index 66b9eba1b3..5f6a94e2b1 100644 --- a/pkgs/record_use/test_data/manifest.yaml +++ b/pkgs/record_use/test_data/manifest.yaml @@ -1,24 +1,37 @@ -- drop_dylib_recording/pubspec.yaml -- drop_dylib_recording/lib/src/drop_dylib_recording_bindings.dart -- drop_dylib_recording/lib/src/drop_dylib_recording.dart -- drop_dylib_recording/lib/drop_dylib_recording.dart -- drop_dylib_recording/src/native_add.h -- drop_dylib_recording/src/native_multiply.h -- drop_dylib_recording/src/native_add.c -- drop_dylib_recording/src/native_multiply.c -- drop_dylib_recording/hook/link.dart -- drop_dylib_recording/hook/build.dart -- drop_dylib_recording/bin/drop_dylib_recording_calls.dart -- drop_dylib_recording/bin/drop_dylib_recording_instances.dart -- drop_data_asset/pubspec.yaml -- drop_data_asset/assets/double.txt -- drop_data_asset/assets/square.txt +# The list of files to copy to a temporary folder to ensure running tests from +# a completely clean setup. +# Automatically generated by manifest_generator.dart. - drop_data_asset/assets/add.txt +- drop_data_asset/assets/double.txt - drop_data_asset/assets/multiply.txt +- drop_data_asset/assets/square.txt +- drop_data_asset/bin/drop_data_asset_calls.dart +- drop_data_asset/bin/drop_data_asset_instances.dart +- drop_data_asset/hook/build.dart +- drop_data_asset/hook/link.dart - drop_data_asset/lib/drop_data_asset.dart - drop_data_asset/lib/src/drop_data_asset.dart -- drop_data_asset/README.md -- drop_data_asset/hook/link.dart -- drop_data_asset/hook/build.dart -- drop_data_asset/bin/drop_data_asset_instances.dart -- drop_data_asset/bin/drop_data_asset_calls.dart +- drop_data_asset/pubspec.yaml +- drop_dylib_recording/bin/drop_dylib_recording_calls.dart +- drop_dylib_recording/bin/drop_dylib_recording_instances.dart +- drop_dylib_recording/hook/build.dart +- drop_dylib_recording/hook/link.dart +- drop_dylib_recording/lib/drop_dylib_recording.dart +- drop_dylib_recording/lib/src/drop_dylib_recording.dart +- drop_dylib_recording/lib/src/drop_dylib_recording_bindings.dart +- drop_dylib_recording/pubspec.yaml +- drop_dylib_recording/src/native_add.c +- drop_dylib_recording/src/native_add.h +- drop_dylib_recording/src/native_multiply.c +- drop_dylib_recording/src/native_multiply.h +- library_uris/bin/my_bin.dart +- library_uris/hook/build.dart +- library_uris/hook/link.dart +- library_uris/lib/library_uris.dart +- library_uris/lib/src/call.dart +- library_uris/lib/src/definition.dart +- library_uris/pubspec.yaml +- library_uris_helper/lib/library_uris_helper.dart +- library_uris_helper/lib/src/helper_call.dart +- library_uris_helper/lib/src/helper_definition.dart +- library_uris_helper/pubspec.yaml diff --git a/pkgs/record_use/tool/generate_syntax.dart b/pkgs/record_use/tool/generate_syntax.dart index 2b46d3d109..953f3a3b58 100644 --- a/pkgs/record_use/tool/generate_syntax.dart +++ b/pkgs/record_use/tool/generate_syntax.dart @@ -17,7 +17,10 @@ void main(List args) { final analyzedSchema = SchemaAnalyzer( schema, - nameOverrides: {'@': 'at'}, + nameOverrides: { + 'path': 'definitionPath', + 'non_constant': 'NonConstant', + }, ).analyze(); final textDumpFile = File.fromUri( Platform.script.resolve('../lib/src/syntax.g.txt'), diff --git a/pkgs/repo_lint_rules/CHANGELOG.md b/pkgs/repo_lint_rules/CHANGELOG.md deleted file mode 100644 index 1b9970e51f..0000000000 --- a/pkgs/repo_lint_rules/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.1.0-wip - -- Initial version. diff --git a/pkgs/repo_lint_rules/analysis_options.yaml b/pkgs/repo_lint_rules/analysis_options.yaml deleted file mode 100644 index c0462a3a77..0000000000 --- a/pkgs/repo_lint_rules/analysis_options.yaml +++ /dev/null @@ -1,19 +0,0 @@ -include: package:dart_flutter_team_lints/analysis_options.yaml - -analyzer: - language: - strict-raw-types: true - plugins: - # - custom_lint # https://github.com/dart-lang/sdk/issues/60784 - -linter: - rules: - - avoid_positional_boolean_parameters - - prefer_const_declarations - - prefer_expression_function_bodies - - prefer_final_in_for_each - - prefer_final_locals - -custom_lint: - rules: - - avoid_import_outside_src diff --git a/pkgs/repo_lint_rules/lib/repo_lint_rules.dart b/pkgs/repo_lint_rules/lib/repo_lint_rules.dart deleted file mode 100644 index db9d8c2431..0000000000 --- a/pkgs/repo_lint_rules/lib/repo_lint_rules.dart +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:custom_lint_builder/custom_lint_builder.dart'; -import 'src/avoid_import_outside_src_rule.dart'; - -PluginBase createPlugin() => _MyLintRulesPlugin(); - -class _MyLintRulesPlugin extends PluginBase { - @override - List getLintRules(CustomLintConfigs configs) => [ - AvoidImportOutsideSrcRule(), - ]; -} diff --git a/pkgs/repo_lint_rules/lib/src/avoid_import_outside_src_rule.dart b/pkgs/repo_lint_rules/lib/src/avoid_import_outside_src_rule.dart deleted file mode 100644 index 6af5bd3aa4..0000000000 --- a/pkgs/repo_lint_rules/lib/src/avoid_import_outside_src_rule.dart +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:analyzer/error/listener.dart'; -import 'package:custom_lint_builder/custom_lint_builder.dart'; - -class AvoidImportOutsideSrcRule extends DartLintRule { - AvoidImportOutsideSrcRule() : super(code: _code); - - static const _code = LintCode( - name: 'avoid_import_outside_src', - problemMessage: - "Avoid importing files outside 'lib/src/' from files within 'lib/src/'.", - correctionMessage: - "Files outside 'lib/src/' likely only export definitions from inside 'lib/src/'. " - 'Import the file with the definition directly.', - ); - - @override - void run( - CustomLintResolver resolver, - ErrorReporter reporter, - CustomLintContext context, - ) { - context.registry.addImportDirective((node) { - final importedUri = node.uri.stringValue; - if (importedUri == null) { - return; - } - final importingFile = resolver.source.uri; - - if (importedUri.startsWith('package:')) { - // Package imports are of no interest. Use prefer_relative_imports to - // prevent package imports of the same package. - return; - } - if (importedUri.startsWith('dart:')) { - return; - } - final importedUriAbsolute = importingFile.resolve(importedUri); - if (_isInSrcDirectory(importingFile)) { - if (!_isInSrcDirectory(importedUriAbsolute)) { - reporter.atNode(node, code); - } - } - }); - } - - bool _isInSrcDirectory(Uri uri) { - if (uri.toFilePath(windows: false).contains('lib/src/')) { - return true; - } - if (uri.toFilePath(windows: false).contains('lib/')) { - return false; - } - return false; - } -} diff --git a/pkgs/repo_lint_rules/pubspec.yaml b/pkgs/repo_lint_rules/pubspec.yaml deleted file mode 100644 index f881794329..0000000000 --- a/pkgs/repo_lint_rules/pubspec.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: repo_lint_rules -description: Custom lints for this repository -version: 0.1.0-wip - -publish_to: none - -resolution: workspace - -environment: - sdk: '>=3.9.0 <4.0.0' - -dependencies: - analyzer: ^7.3.0 - custom_lint_builder: ^0.7.5 - dart_flutter_team_lints: ^3.5.2 - path: ^1.9.1 - -dev_dependencies: - custom_lint: ^0.7.5 diff --git a/pkgs/swift2objc/CHANGELOG.md b/pkgs/swift2objc/CHANGELOG.md index 4e32d87dd2..04ad45c7c3 100644 --- a/pkgs/swift2objc/CHANGELOG.md +++ b/pkgs/swift2objc/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.0-wip + +- Added support for inout parameters. Preserve inout types in AST and generate + correct & pass-by-reference invocation syntax. + ## 0.1.0 - MVP version. diff --git a/pkgs/swift2objc/lib/src/ast/_core/interfaces/declaration.dart b/pkgs/swift2objc/lib/src/ast/_core/interfaces/declaration.dart index ba0ac5478d..2ee2b308f6 100644 --- a/pkgs/swift2objc/lib/src/ast/_core/interfaces/declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/_core/interfaces/declaration.dart @@ -7,19 +7,28 @@ import '../../ast_node.dart'; import '../../declarations/built_in/built_in_declaration.dart'; import '../shared/referred_type.dart'; import 'availability.dart'; +import 'nestable_declaration.dart'; /// A common interface for all Swift entities declarations. abstract interface class Declaration implements AstNode, Availability { abstract final String id; abstract final String name; abstract final InputConfig? source; + abstract final int? lineNumber; } extension AsDeclaredType on T { DeclaredType get asDeclaredType => DeclaredType(id: id, declaration: this); } -extension DeclarationIsBuiltIn on Declaration { +extension DeclarationExtensions on Declaration { bool get isBuiltIn => this is BuiltInDeclaration || source == builtInInputConfig; + + String get fullName { + final parent = this is InnerNestableDeclaration + ? (this as InnerNestableDeclaration).nestingParent + : null; + return parent != null ? '${parent.fullName}.$name' : name; + } } diff --git a/pkgs/swift2objc/lib/src/ast/_core/interfaces/enum_declaration.dart b/pkgs/swift2objc/lib/src/ast/_core/interfaces/enum_declaration.dart deleted file mode 100644 index d8cedc727d..0000000000 --- a/pkgs/swift2objc/lib/src/ast/_core/interfaces/enum_declaration.dart +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'declaration.dart'; -import 'nestable_declaration.dart'; -import 'protocol_conformable.dart'; -import 'type_parameterizable.dart'; - -/// An interface for describing the declaration of a Swift enum. -/// See `NormalEnumDeclaration`, `AssociatedValueEnumDeclaration` and -/// `RawValueEnumDeclaration` for concrete implementations. -abstract interface class EnumDeclaration - implements - Declaration, - TypeParameterizable, - ProtocolConformable, - OuterNestableDeclaration, - InnerNestableDeclaration { - abstract List cases; -} - -/// An interface describing an enum case. See `NormalEnumCase`, -/// `AssociatedValueEnumCase` and `RawValueEnumCase` for concrete -/// implementations. -abstract interface class EnumCase implements Declaration {} diff --git a/pkgs/swift2objc/lib/src/ast/_core/shared/referred_type.dart b/pkgs/swift2objc/lib/src/ast/_core/shared/referred_type.dart index c99e1802e3..d9b7435fe8 100644 --- a/pkgs/swift2objc/lib/src/ast/_core/shared/referred_type.dart +++ b/pkgs/swift2objc/lib/src/ast/_core/shared/referred_type.dart @@ -143,3 +143,94 @@ class OptionalType extends AstNode implements ReferredType { visitor.visit(child); } } + +class InoutType extends AstNode implements ReferredType { + final ReferredType child; + + @override + bool get isObjCRepresentable => false; + + @override + String get swiftType => child.swiftType; + + @override + bool _sameAs(ReferredType other) => + other is InoutType && child.sameAs(other.child); + + @override + ReferredType get aliasedType => InoutType(child.aliasedType); + + InoutType(this.child); + + @override + String toString() => 'inout $child'; + + @override + void visit(Visitation visitation) => visitation.visitInoutType(this); + + @override + void visitChildren(Visitor visitor) { + super.visitChildren(visitor); + visitor.visit(child); + } +} + +/// Describes a reference to a Swift Tuple type (e.g., `(Int, String)`). +class TupleType extends AstNode implements ReferredType { + final List elements; + + @override + bool get isObjCRepresentable => false; + + @override + String get swiftType { + final elementStrings = elements + .map((e) { + final label = e.label != null ? '${e.label}: ' : ''; + return '$label${e.type.swiftType}'; + }) + .join(', '); + return '($elementStrings)'; + } + + @override + bool _sameAs(ReferredType other) { + if (other is! TupleType) return false; + if (elements.length != other.elements.length) return false; + for (var i = 0; i < elements.length; i++) { + if (!elements[i].type.sameAs(other.elements[i].type)) return false; + if (elements[i].label != other.elements[i].label) return false; + } + return true; + } + + @override + ReferredType get aliasedType => + TupleType(elements.map((e) => e.aliasedElement).toList()); + + TupleType(this.elements); + + @override + String toString() => swiftType; + + @override + void visit(Visitation visitation) => visitation.visitTupleType(this); + + @override + void visitChildren(Visitor visitor) { + super.visitChildren(visitor); + for (final element in elements) { + visitor.visit(element.type); + } + } +} + +class TupleElement { + final String? label; + final ReferredType type; + + TupleElement({this.label, required this.type}); + + TupleElement get aliasedElement => + TupleElement(label: label, type: type.aliasedType); +} diff --git a/pkgs/swift2objc/lib/src/ast/declarations/built_in/built_in_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/built_in/built_in_declaration.dart index 124fbd81ad..dc10a02002 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/built_in/built_in_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/built_in/built_in_declaration.dart @@ -17,6 +17,9 @@ class BuiltInDeclaration extends AstNode @override final String name; + @override + final int? lineNumber; + @override InputConfig? get source => null; @@ -26,7 +29,11 @@ class BuiltInDeclaration extends AstNode @override bool get hasObjCAnnotation => true; - const BuiltInDeclaration({required this.id, required this.name}); + const BuiltInDeclaration({ + required this.id, + required this.name, + this.lineNumber, + }); @override void visit(Visitation visitation) => visitation.visitBuiltInDeclaration(this); @@ -42,6 +49,7 @@ const _objectDecl = BuiltInDeclaration( name: 'NSObject', ); const _stringDecl = BuiltInDeclaration(id: 's:SS', name: 'String'); +const _selfDecl = BuiltInDeclaration(id: '', name: 'Self'); final objectType = _objectDecl.asDeclaredType; final stringType = _stringDecl.asDeclaredType; @@ -50,6 +58,7 @@ final floatType = _floatDecl.asDeclaredType; final doubleType = _doubleDecl.asDeclaredType; final boolType = _boolDecl.asDeclaredType; final voidType = _voidDecl.asDeclaredType; +final selfType = _selfDecl.asDeclaredType; const builtInDeclarations = [ _boolDecl, @@ -60,6 +69,10 @@ const builtInDeclarations = [ _stringDecl, _voidDecl, + // TODO(https://github.com/dart-lang/native/issues/2954): This shouldn't be + // treated as an ordinary built-in. + BuiltInDeclaration(id: 's:s6HasherV', name: 'Hasher'), + // Certain types are toll-free bridged between Swift and ObjC. These types // don't need @objc compatible wrappers. There's no complete list of these // types in the documentation. The closest thing is this, but it's incomplete: diff --git a/pkgs/swift2objc/lib/src/ast/declarations/compounds/class_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/class_declaration.dart index 70cc10c9d7..79685ebaa4 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/compounds/class_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/class_declaration.dart @@ -32,10 +32,13 @@ class ClassDeclaration extends AstNode List availability; @override - covariant List properties; + final int? lineNumber; @override - covariant List methods; + List properties; + + @override + List methods; @override List> conformedProtocols; @@ -76,6 +79,7 @@ class ClassDeclaration extends AstNode required this.name, required this.source, required this.availability, + this.lineNumber, this.properties = const [], this.methods = const [], this.nestingParent, diff --git a/pkgs/swift2objc/lib/src/ast/declarations/enums/associated_value_enum_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/enum_declaration.dart similarity index 56% rename from pkgs/swift2objc/lib/src/ast/declarations/enums/associated_value_enum_declaration.dart rename to pkgs/swift2objc/lib/src/ast/declarations/compounds/enum_declaration.dart index 09fdafcd6e..17f7aaae84 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/enums/associated_value_enum_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/enum_declaration.dart @@ -4,17 +4,20 @@ import '../../../config.dart'; import '../../_core/interfaces/availability.dart'; -import '../../_core/interfaces/enum_declaration.dart'; +import '../../_core/interfaces/compound_declaration.dart'; +import '../../_core/interfaces/declaration.dart'; import '../../_core/interfaces/nestable_declaration.dart'; import '../../_core/interfaces/parameterizable.dart'; import '../../_core/shared/parameter.dart'; import '../../_core/shared/referred_type.dart'; import '../../ast_node.dart'; -import '../compounds/protocol_declaration.dart'; +import 'members/initializer_declaration.dart'; +import 'members/method_declaration.dart'; +import 'members/property_declaration.dart'; +import 'protocol_declaration.dart'; -/// Describes the declaration of a Swift enum with associated values. -class AssociatedValueEnumDeclaration extends AstNode - implements EnumDeclaration { +/// Describes the declaration of a Swift enum. +class EnumDeclaration extends AstNode implements CompoundDeclaration { @override String id; @@ -28,7 +31,18 @@ class AssociatedValueEnumDeclaration extends AstNode List availability; @override - covariant List cases; + final int? lineNumber; + + List cases; + + @override + List properties; + + @override + List methods; + + @override + List initializers; @override List typeParams; @@ -42,26 +56,32 @@ class AssociatedValueEnumDeclaration extends AstNode @override List nestedDeclarations; - AssociatedValueEnumDeclaration({ + EnumDeclaration({ required this.id, required this.name, required this.source, required this.availability, + this.lineNumber, required this.cases, - required this.typeParams, - required this.conformedProtocols, + required this.properties, + required this.methods, + required this.initializers, + this.conformedProtocols = const [], + this.typeParams = const [], this.nestingParent, this.nestedDeclarations = const [], }); @override - void visit(Visitation visitation) => - visitation.visitAssociatedValueEnumDeclaration(this); + void visit(Visitation visitation) => visitation.visitEnumDeclaration(this); @override void visitChildren(Visitor visitor) { super.visitChildren(visitor); visitor.visitAll(cases); + visitor.visitAll(properties); + visitor.visitAll(methods); + visitor.visitAll(initializers); visitor.visitAll(typeParams); visitor.visitAll(conformedProtocols); visitor.visit(nestingParent); @@ -69,9 +89,9 @@ class AssociatedValueEnumDeclaration extends AstNode } } -/// Describes the declaration of a Swift enum case with associated values. -class AssociatedValueEnumCase extends AstNode - implements EnumCase, Parameterizable { +/// Describes the declaration of a Swift enum case. +class EnumCaseDeclaration extends AstNode + implements Declaration, Parameterizable { @override String id; @@ -85,12 +105,16 @@ class AssociatedValueEnumCase extends AstNode List availability; @override - covariant List params; + final int? lineNumber; - AssociatedValueEnumCase({ + @override + List params; + + EnumCaseDeclaration({ required this.id, required this.name, required this.source, + this.lineNumber, required this.availability, required this.params, }); @@ -100,10 +124,13 @@ class AssociatedValueEnumCase extends AstNode super.visitChildren(visitor); visitor.visitAll(params); } + + @override + String toString() => '$name(${params.map((p) => '$p').join(', ')})'; } -/// Describes an associated value of an Swift enum case. -class AssociatedValueParam extends AstNode implements Parameter { +/// Describes an associated value of a Swift enum case. +class EnumCaseParam extends AstNode implements Parameter { @override String name; @@ -113,11 +140,14 @@ class AssociatedValueParam extends AstNode implements Parameter { @override covariant Null internalName; - AssociatedValueParam({required this.name, required this.type}); + EnumCaseParam({required this.name, required this.type}); @override void visitChildren(Visitor visitor) { super.visitChildren(visitor); visitor.visit(type); } + + @override + String toString() => '${name == '' ? '' : '$name: '}$type'; } diff --git a/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/initializer_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/initializer_declaration.dart index 3ecf5e71b1..1966048586 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/initializer_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/initializer_declaration.dart @@ -33,6 +33,9 @@ class InitializerDeclaration extends AstNode @override InputConfig? source; + @override + final int? lineNumber; + @override List availability; @@ -61,6 +64,7 @@ class InitializerDeclaration extends AstNode InitializerDeclaration({ required this.id, required this.source, + this.lineNumber, required this.availability, required this.params, this.statements = const [], diff --git a/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/method_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/method_declaration.dart index 5963acffae..05100b8b38 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/method_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/method_declaration.dart @@ -24,6 +24,9 @@ class MethodDeclaration extends AstNode @override InputConfig? source; + @override + final int? lineNumber; + @override List availability; @@ -54,6 +57,7 @@ class MethodDeclaration extends AstNode bool isStatic; bool mutating; + bool isOperator = false; String get fullName => [name, for (final p in params) p.name].join(':'); @@ -64,6 +68,7 @@ class MethodDeclaration extends AstNode required this.availability, required this.returnType, required this.params, + this.lineNumber, this.typeParams = const [], this.hasObjCAnnotation = false, this.statements = const [], @@ -72,6 +77,7 @@ class MethodDeclaration extends AstNode this.throws = false, this.async = false, this.mutating = false, + this.isOperator = false, }) : assert(!isStatic || !isOverriding); @override diff --git a/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/property_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/property_declaration.dart index 61fe7417c9..d671edcf3d 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/property_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/members/property_declaration.dart @@ -23,6 +23,9 @@ class PropertyDeclaration extends AstNode @override InputConfig? source; + @override + final int? lineNumber; + @override List availability; @@ -45,6 +48,8 @@ class PropertyDeclaration extends AstNode bool hasSetter; + bool hasExplicitGetter; + PropertyStatements? getter; PropertyStatements? setter; @@ -62,11 +67,13 @@ class PropertyDeclaration extends AstNode required this.source, required this.availability, required this.type, + this.lineNumber, this.hasSetter = false, this.isConstant = false, this.hasObjCAnnotation = false, this.getter, this.setter, + this.hasExplicitGetter = false, this.isStatic = false, this.throws = false, this.async = false, diff --git a/pkgs/swift2objc/lib/src/ast/declarations/compounds/protocol_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/protocol_declaration.dart index ee09548a2e..e73c5208e2 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/compounds/protocol_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/protocol_declaration.dart @@ -27,10 +27,13 @@ class ProtocolDeclaration extends AstNode implements CompoundDeclaration { List availability; @override - covariant List properties; + final int? lineNumber; @override - covariant List methods; + List properties; + + @override + List methods; @override List> conformedProtocols; @@ -51,6 +54,7 @@ class ProtocolDeclaration extends AstNode implements CompoundDeclaration { required this.id, required this.name, required this.source, + this.lineNumber, required this.availability, required this.properties, required this.methods, diff --git a/pkgs/swift2objc/lib/src/ast/declarations/compounds/struct_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/compounds/struct_declaration.dart index 5360d9ad6c..eaa8332e27 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/compounds/struct_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/compounds/struct_declaration.dart @@ -28,10 +28,13 @@ class StructDeclaration extends AstNode implements CompoundDeclaration { List availability; @override - covariant List properties; + final int? lineNumber; @override - covariant List methods; + List properties; + + @override + List methods; @override List> conformedProtocols; @@ -52,6 +55,7 @@ class StructDeclaration extends AstNode implements CompoundDeclaration { required this.id, required this.name, required this.source, + this.lineNumber, required this.availability, this.properties = const [], this.methods = const [], diff --git a/pkgs/swift2objc/lib/src/ast/declarations/enums/normal_enum_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/enums/normal_enum_declaration.dart deleted file mode 100644 index 667e20c49d..0000000000 --- a/pkgs/swift2objc/lib/src/ast/declarations/enums/normal_enum_declaration.dart +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import '../../../config.dart'; -import '../../_core/interfaces/availability.dart'; -import '../../_core/interfaces/enum_declaration.dart'; -import '../../_core/interfaces/nestable_declaration.dart'; -import '../../_core/shared/referred_type.dart'; -import '../../ast_node.dart'; -import '../compounds/protocol_declaration.dart'; - -/// Describes the declaration of a basic Swift enum -/// (i.e with no raw values or associated values). -class NormalEnumDeclaration extends AstNode implements EnumDeclaration { - @override - String id; - - @override - String name; - - @override - InputConfig? source; - - @override - List availability; - - @override - covariant List cases; - - @override - List typeParams; - - @override - List> conformedProtocols; - - @override - OuterNestableDeclaration? nestingParent; - - @override - List nestedDeclarations; - - NormalEnumDeclaration({ - required this.id, - required this.name, - required this.source, - required this.availability, - required this.cases, - required this.typeParams, - required this.conformedProtocols, - this.nestingParent, - this.nestedDeclarations = const [], - }); - - @override - void visit(Visitation visitation) => - visitation.visitNormalEnumDeclaration(this); - - @override - void visitChildren(Visitor visitor) { - super.visitChildren(visitor); - visitor.visitAll(cases); - visitor.visitAll(typeParams); - visitor.visitAll(conformedProtocols); - visitor.visit(nestingParent); - visitor.visitAll(nestedDeclarations); - } -} - -/// Describes the declaration of a basic Swift enum case -/// (i.e with no raw values or associated values). -class NormalEnumCase extends AstNode implements EnumCase { - @override - String id; - - @override - String name; - - @override - InputConfig? source; - - @override - List availability; - - NormalEnumCase({ - required this.id, - required this.name, - required this.source, - required this.availability, - }); -} diff --git a/pkgs/swift2objc/lib/src/ast/declarations/enums/raw_value_enum_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/enums/raw_value_enum_declaration.dart deleted file mode 100644 index a15e360b96..0000000000 --- a/pkgs/swift2objc/lib/src/ast/declarations/enums/raw_value_enum_declaration.dart +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import '../../../config.dart'; -import '../../_core/interfaces/availability.dart'; -import '../../_core/interfaces/enum_declaration.dart'; -import '../../_core/interfaces/nestable_declaration.dart'; -import '../../_core/interfaces/objc_annotatable.dart'; -import '../../_core/shared/referred_type.dart'; -import '../../ast_node.dart'; -import '../compounds/protocol_declaration.dart'; - -/// Describes the declaration of a Swift enum with raw values. -class RawValueEnumDeclaration extends AstNode - implements EnumDeclaration, ObjCAnnotatable { - @override - String id; - - @override - String name; - - @override - InputConfig? source; - - @override - List availability; - - @override - covariant List> cases; - - @override - List typeParams; - - @override - List> conformedProtocols; - - @override - bool hasObjCAnnotation; - - @override - OuterNestableDeclaration? nestingParent; - - @override - List nestedDeclarations; - - ReferredType rawValueType; - - RawValueEnumDeclaration({ - required this.id, - required this.name, - required this.source, - required this.availability, - required this.cases, - required this.typeParams, - required this.conformedProtocols, - required this.hasObjCAnnotation, - required this.rawValueType, - this.nestingParent, - this.nestedDeclarations = const [], - }); - - @override - void visit(Visitation visitation) => - visitation.visitRawValueEnumDeclaration(this); - - @override - void visitChildren(Visitor visitor) { - super.visitChildren(visitor); - visitor.visitAll(cases); - visitor.visitAll(typeParams); - visitor.visitAll(conformedProtocols); - visitor.visit(nestingParent); - visitor.visitAll(nestedDeclarations); - visitor.visit(rawValueType); - } -} - -/// Describes the declaration of a Swift enum case with a raw value of type `T`. -class RawValueEnumCase extends AstNode implements EnumCase { - @override - String id; - - @override - String name; - - @override - InputConfig? source; - - @override - List availability; - - T rawValue; - - RawValueEnumCase({ - required this.id, - required this.name, - required this.source, - required this.availability, - required this.rawValue, - }); -} diff --git a/pkgs/swift2objc/lib/src/ast/declarations/globals/globals.dart b/pkgs/swift2objc/lib/src/ast/declarations/globals/globals.dart index 8b0343f11a..d74591df1a 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/globals/globals.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/globals/globals.dart @@ -30,6 +30,9 @@ class GlobalFunctionDeclaration extends AstNode implements FunctionDeclaration { @override InputConfig? source; + @override + final int? lineNumber; + @override List availability; @@ -55,6 +58,7 @@ class GlobalFunctionDeclaration extends AstNode implements FunctionDeclaration { required this.id, required this.name, required this.source, + this.lineNumber, required this.availability, required this.params, required this.returnType, @@ -88,6 +92,9 @@ class GlobalVariableDeclaration extends AstNode implements VariableDeclaration { @override InputConfig? source; + @override + final int? lineNumber; + @override List availability; @@ -107,6 +114,7 @@ class GlobalVariableDeclaration extends AstNode implements VariableDeclaration { required this.id, required this.name, required this.source, + this.lineNumber, required this.availability, required this.type, required this.isConstant, diff --git a/pkgs/swift2objc/lib/src/ast/declarations/typealias_declaration.dart b/pkgs/swift2objc/lib/src/ast/declarations/typealias_declaration.dart index da72140bc6..3c1fe21273 100644 --- a/pkgs/swift2objc/lib/src/ast/declarations/typealias_declaration.dart +++ b/pkgs/swift2objc/lib/src/ast/declarations/typealias_declaration.dart @@ -19,6 +19,9 @@ class TypealiasDeclaration extends AstNode implements InnerNestableDeclaration { @override InputConfig? source; + @override + final int? lineNumber; + @override List availability; @@ -31,6 +34,7 @@ class TypealiasDeclaration extends AstNode implements InnerNestableDeclaration { required this.id, required this.name, required this.source, + this.lineNumber, required this.target, required this.availability, }); diff --git a/pkgs/swift2objc/lib/src/ast/visitor.dart b/pkgs/swift2objc/lib/src/ast/visitor.dart index a24e426736..a143d72590 100644 --- a/pkgs/swift2objc/lib/src/ast/visitor.dart +++ b/pkgs/swift2objc/lib/src/ast/visitor.dart @@ -5,21 +5,18 @@ import '../context.dart'; import '_core/interfaces/compound_declaration.dart'; import '_core/interfaces/declaration.dart'; -import '_core/interfaces/enum_declaration.dart'; import '_core/interfaces/function_declaration.dart'; import '_core/interfaces/variable_declaration.dart'; import '_core/shared/referred_type.dart'; import 'ast_node.dart'; import 'declarations/built_in/built_in_declaration.dart'; import 'declarations/compounds/class_declaration.dart'; +import 'declarations/compounds/enum_declaration.dart'; import 'declarations/compounds/members/initializer_declaration.dart'; import 'declarations/compounds/members/method_declaration.dart'; import 'declarations/compounds/members/property_declaration.dart'; import 'declarations/compounds/protocol_declaration.dart'; import 'declarations/compounds/struct_declaration.dart'; -import 'declarations/enums/associated_value_enum_declaration.dart'; -import 'declarations/enums/normal_enum_declaration.dart'; -import 'declarations/enums/raw_value_enum_declaration.dart'; import 'declarations/globals/globals.dart'; import 'declarations/typealias_declaration.dart'; @@ -81,6 +78,7 @@ abstract class Visitation { void visitDeclaredType(DeclaredType node) => visitReferredType(node); void visitGenericType(GenericType node) => visitReferredType(node); void visitOptionalType(OptionalType node) => visitReferredType(node); + void visitInoutType(InoutType node) => visitReferredType(node); void visitDeclaration(Declaration node) => visitAstNode(node); void visitBuiltInDeclaration(BuiltInDeclaration node) => visitDeclaration(node); @@ -106,16 +104,11 @@ abstract class Visitation { visitCompoundDeclaration(node); void visitStructDeclaration(StructDeclaration node) => visitCompoundDeclaration(node); - void visitEnumDeclaration(EnumDeclaration node) => visitDeclaration(node); - void visitAssociatedValueEnumDeclaration( - AssociatedValueEnumDeclaration node, - ) => visitEnumDeclaration(node); - void visitNormalEnumDeclaration(NormalEnumDeclaration node) => - visitEnumDeclaration(node); - void visitRawValueEnumDeclaration(RawValueEnumDeclaration node) => - visitEnumDeclaration(node); + void visitEnumDeclaration(EnumDeclaration node) => + visitCompoundDeclaration(node); void visitTypealiasDeclaration(TypealiasDeclaration node) => visitDeclaration(node); + void visitTupleType(TupleType node) => visitReferredType(node); /// Default behavior for all visit methods. void visitAstNode(AstNode node) => node.visitChildren(visitor); diff --git a/pkgs/swift2objc/lib/src/generator/_core/utils.dart b/pkgs/swift2objc/lib/src/generator/_core/utils.dart index 47f8a47406..11be18d6e7 100644 --- a/pkgs/swift2objc/lib/src/generator/_core/utils.dart +++ b/pkgs/swift2objc/lib/src/generator/_core/utils.dart @@ -10,11 +10,13 @@ import '../../ast/_core/interfaces/can_throw.dart'; import '../../ast/_core/interfaces/declaration.dart'; import '../../ast/_core/shared/parameter.dart'; -String generateParameters(List params) { +String generateParameters(List params, {bool isOperator = false}) { return params .map((param) { final String labels; - if (param.internalName != null) { + if (isOperator) { + labels = param.internalName ?? param.name; + } else if (param.internalName != null) { labels = '${param.name} ${param.internalName}'; } else { labels = param.name; diff --git a/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart b/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart index 88bbeedd15..5ce8f850ec 100644 --- a/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart +++ b/pkgs/swift2objc/lib/src/generator/generators/class_generator.dart @@ -154,6 +154,7 @@ List _generateClassProperty(PropertyDeclaration property) { if (property.isStatic) { header.write('static '); } + final prefixes = [if (property.unowned) 'unowned', if (property.weak) 'weak']; var prefix = prefixes.isEmpty ? '' : '${prefixes.join(' ')} '; diff --git a/pkgs/swift2objc/lib/src/parser/_core/utils.dart b/pkgs/swift2objc/lib/src/parser/_core/utils.dart index f40a14d37f..29bbbc3f1c 100644 --- a/pkgs/swift2objc/lib/src/parser/_core/utils.dart +++ b/pkgs/swift2objc/lib/src/parser/_core/utils.dart @@ -64,6 +64,19 @@ String parseSymbolName(Json symbolJson) => symbolJson['declarationFragments'] .firstJsonWhereKey('kind', 'identifier')['spelling'] .get(); +int? parseLineNumber(Json symbolJson) { + final locationJson = symbolJson['location']; + if (!locationJson.exists) return null; + + final positionJson = locationJson['position']; + if (!positionJson.exists) return null; + + final lineJson = positionJson['line']; + if (!lineJson.exists) return null; + + return lineJson.get(); +} + bool parseSymbolHasObjcAnnotation(Json symbolJson) => symbolJson['declarationFragments'].any( (json) => matchFragment(json, 'attribute', '@objc'), @@ -121,6 +134,20 @@ extension Deduper on Iterable { {for (final t in this) id(t): t}.values; } +extension Remover on List { + List removeWhereType() { + final removed = []; + removeWhere((t) { + if (t is U) { + removed.add(t); + return true; + } + return false; + }); + return removed; + } +} + ReferredType parseTypeAfterSeparator( Context context, TokenList fragments, diff --git a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_compound_declaration.dart b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_compound_declaration.dart index b19c690257..aa5b17a2d8 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_compound_declaration.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_compound_declaration.dart @@ -4,6 +4,7 @@ import '../../../ast/_core/interfaces/availability.dart'; import '../../../ast/_core/interfaces/compound_declaration.dart'; +import '../../../ast/_core/interfaces/declaration.dart'; import '../../../ast/_core/interfaces/nestable_declaration.dart'; import '../../../ast/declarations/compounds/class_declaration.dart'; import '../../../ast/declarations/compounds/members/initializer_declaration.dart'; @@ -22,17 +23,15 @@ typedef CompoundTearOff = required String name, required InputConfig? source, required List availability, - required List properties, - required List methods, - required List initializers, - required List nestedDeclarations, }); -T _parseCompoundDeclaration( +typedef ParsedCompound = ({T compound, List excessMembers}); + +ParsedCompound parseCompoundDeclaration( Context context, ParsedSymbol symbol, - CompoundTearOff tearoffConstructor, ParsedSymbolgraph symbolgraph, + CompoundTearOff tearoffConstructor, ) { final compoundId = parseSymbolId(symbol.json); @@ -44,10 +43,6 @@ T _parseCompoundDeclaration( name: parseSymbolName(symbol.json), source: symbol.source, availability: parseAvailability(symbol.json), - methods: [], - properties: [], - initializers: [], - nestedDeclarations: [], ); symbol.declaration = compound; @@ -71,25 +66,25 @@ T _parseCompoundDeclaration( .toList(); compound.methods.addAll( - memberDeclarations.whereType().dedupeBy( + memberDeclarations.removeWhereType().dedupeBy( (m) => m.fullName, ), ); compound.properties.addAll( - memberDeclarations.whereType(), + memberDeclarations.removeWhereType(), ); compound.initializers.addAll( - memberDeclarations.whereType().dedupeBy( + memberDeclarations.removeWhereType().dedupeBy( (m) => m.fullName, ), ); compound.nestedDeclarations.addAll( - memberDeclarations.whereType(), + memberDeclarations.removeWhereType(), ); compound.nestedDeclarations.fillNestingParents(compound); - return compound; + return (compound: compound, excessMembers: memberDeclarations); } ClassDeclaration parseClassDeclaration( @@ -97,12 +92,26 @@ ClassDeclaration parseClassDeclaration( ParsedSymbol classSymbol, ParsedSymbolgraph symbolgraph, ) { - return _parseCompoundDeclaration( + return parseCompoundDeclaration( context, classSymbol, - ClassDeclaration.new, symbolgraph, - ); + ({ + required String id, + required String name, + required InputConfig? source, + required List availability, + }) => ClassDeclaration( + id: id, + name: name, + source: source, + availability: availability, + properties: [], + methods: [], + initializers: [], + nestedDeclarations: [], + ), + ).compound; } StructDeclaration parseStructDeclaration( @@ -110,10 +119,24 @@ StructDeclaration parseStructDeclaration( ParsedSymbol classSymbol, ParsedSymbolgraph symbolgraph, ) { - return _parseCompoundDeclaration( + return parseCompoundDeclaration( context, classSymbol, - StructDeclaration.new, symbolgraph, - ); + ({ + required String id, + required String name, + required InputConfig? source, + required List availability, + }) => StructDeclaration( + id: id, + name: name, + source: source, + availability: availability, + properties: [], + methods: [], + initializers: [], + nestedDeclarations: [], + ), + ).compound; } diff --git a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_enum_declaration.dart b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_enum_declaration.dart new file mode 100644 index 0000000000..397da2962a --- /dev/null +++ b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_enum_declaration.dart @@ -0,0 +1,64 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import '../../../ast/_core/interfaces/availability.dart'; +import '../../../ast/declarations/compounds/enum_declaration.dart'; +import '../../../config.dart'; +import '../../../context.dart'; +import '../../_core/parsed_symbolgraph.dart'; +import '../../_core/utils.dart'; +import 'parse_compound_declaration.dart'; +import 'parse_function_declaration.dart'; + +EnumDeclaration parseEnumDeclaration( + Context context, + ParsedSymbol symbol, + ParsedSymbolgraph symbolgraph, +) { + final (compound: enumDecl, :excessMembers) = parseCompoundDeclaration( + context, + symbol, + symbolgraph, + ({ + required String id, + required String name, + required InputConfig? source, + required List availability, + }) => EnumDeclaration( + id: id, + name: name, + source: source, + availability: availability, + cases: [], + properties: [], + methods: [], + initializers: [], + nestedDeclarations: [], + ), + ); + enumDecl.cases.addAll(excessMembers.removeWhereType()); + return enumDecl; +} + +EnumCaseDeclaration parseEnumCaseDeclaration( + Context context, + ParsedSymbol symbol, + ParsedSymbolgraph symbolgraph, +) { + return EnumCaseDeclaration( + id: parseSymbolId(symbol.json), + name: parseSymbolName(symbol.json), + source: symbol.source, + availability: parseAvailability(symbol.json), + params: + parseFunctionInfo( + context, + symbol.json['declarationFragments'], + symbolgraph, + isEnumCase: true, + ).params + .map((param) => EnumCaseParam(name: param.name, type: param.type)) + .toList(), + ); +} diff --git a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_function_declaration.dart b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_function_declaration.dart index aedfc19f00..495d66e632 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_function_declaration.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_function_declaration.dart @@ -40,16 +40,19 @@ MethodDeclaration parseMethodDeclaration( ParsedSymbol symbol, ParsedSymbolgraph symbolgraph, { bool isStatic = false, + bool isOperator = false, }) { final info = parseFunctionInfo( context, symbol.json['declarationFragments'], symbolgraph, + isOperator: isOperator, ); return MethodDeclaration( id: parseSymbolId(symbol.json), name: parseSymbolName(symbol.json), source: symbol.source, + lineNumber: parseLineNumber(symbol.json), availability: parseAvailability(symbol.json), returnType: _parseFunctionReturnType(context, symbol.json, symbolgraph), params: info.params, @@ -58,6 +61,7 @@ MethodDeclaration parseMethodDeclaration( throws: info.throws, async: info.async, mutating: info.mutating, + isOperator: isOperator, ); } @@ -71,8 +75,10 @@ typedef ParsedFunctionInfo = ({ ParsedFunctionInfo parseFunctionInfo( Context context, Json declarationFragments, - ParsedSymbolgraph symbolgraph, -) { + ParsedSymbolgraph symbolgraph, { + bool isEnumCase = false, + bool isOperator = false, +}) { // `declarationFragments` describes each part of the function declaration, // things like the `func` keyword, brackets, spaces, etc. // For the most part, We only care about the parameter fragments and @@ -109,7 +115,16 @@ ParsedFunctionInfo parseFunctionInfo( while (true) { final keyword = maybeConsume('keyword'); if (keyword != null) { - if (keyword == 'func' || keyword == 'init') { + if (keyword == 'func' || keyword == 'init' || keyword == 'case') { + if (keyword == 'func' && isOperator) { + final ws1 = maybeConsume('text'); + final op = maybeConsume('identifier'); + final ws2 = maybeConsume('text'); + + if (ws1 == null || op == null || ws2 == null) { + throw malformedInitializerException; + } + } break; } else { prefixAnnotations.add(keyword); @@ -122,37 +137,59 @@ ParsedFunctionInfo parseFunctionInfo( } final openParen = tokens.indexWhere((tok) => matchFragment(tok, 'text', '(')); - if (openParen == -1) throw malformedInitializerException; - - tokens = tokens.slice(openParen + 1); - - // Parse parameters until we find a ')'. - if (maybeConsume('text') == ')') { - // Empty param list. - } else { - while (true) { - final externalParam = maybeConsume('externalParam'); - if (externalParam == null) throw malformedInitializerException; - - var sep = maybeConsume('text'); - String? internalParam; - if (sep == '') { - internalParam = maybeConsume('internalParam'); - if (internalParam == null) throw malformedInitializerException; - sep = maybeConsume('text'); - } + if (openParen != -1) { + tokens = tokens.slice(openParen + 1); - if (sep != ':') throw malformedInitializerException; - final (type, remainingTokens) = parseType(context, symbolgraph, tokens); - tokens = remainingTokens; - - parameters.add( - Parameter(name: externalParam, internalName: internalParam, type: type), - ); - - final end = maybeConsume('text'); - if (end == ')') break; - if (end != ',') throw malformedInitializerException; + // Parse parameters until we find a ')'. + if (maybeConsume('text') == ')') { + // Empty param list. + } else { + while (true) { + final externalParam = maybeConsume('externalParam'); + String? internalParam; + if (externalParam != null) { + var sep = maybeConsume('text'); + if (sep == '') { + internalParam = maybeConsume('internalParam'); + if (internalParam == null) { + throw malformedInitializerException; + } + sep = maybeConsume('text'); + } + + if (sep != ':') { + throw malformedInitializerException; + } + } else if (isOperator) { + internalParam = maybeConsume('internalParam'); + if (internalParam == null) { + throw malformedInitializerException; + } + if (maybeConsume('text') != ':') { + throw malformedInitializerException; + } + } else if (!isEnumCase) { + // Enum cases are allowed to omit both param names. Other param lists + // must at least specify the external name. + throw malformedInitializerException; + } + final (type, remainingTokens) = parseType(context, symbolgraph, tokens); + tokens = remainingTokens; + + parameters.add( + Parameter( + name: isOperator ? (internalParam ?? '') : (externalParam ?? ''), + internalName: isOperator ? null : internalParam, + type: type, + ), + ); + + final end = maybeConsume('text'); + if (end == ')') break; + if (end != ',') { + throw malformedInitializerException; + } + } } } diff --git a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_initializer_declaration.dart b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_initializer_declaration.dart index fccaae304a..c2b7b299dd 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_initializer_declaration.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_initializer_declaration.dart @@ -30,6 +30,7 @@ InitializerDeclaration parseInitializerDeclaration( return InitializerDeclaration( id: id, source: symbol.source, + lineNumber: parseLineNumber(symbol.json), availability: parseAvailability(symbol.json), params: info.params, hasObjCAnnotation: parseSymbolHasObjcAnnotation(symbol.json), diff --git a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_typealias_declaration.dart b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_typealias_declaration.dart index 4b4e5b976c..20bd2af5c6 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_typealias_declaration.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_typealias_declaration.dart @@ -9,7 +9,7 @@ import '../../_core/token_list.dart'; import '../../_core/utils.dart'; import '../parse_type.dart'; -TypealiasDeclaration? parseTypealiasDeclaration( +TypealiasDeclaration parseTypealiasDeclaration( Context context, ParsedSymbol symbol, ParsedSymbolgraph symbolgraph, diff --git a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_variable_declaration.dart b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_variable_declaration.dart index b72d7c2e74..124a0fdb49 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_variable_declaration.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/declaration_parsers/parse_variable_declaration.dart @@ -18,10 +18,12 @@ PropertyDeclaration parsePropertyDeclaration( bool isStatic = false, }) { final info = parsePropertyInfo(symbol.json['declarationFragments']); + return PropertyDeclaration( id: parseSymbolId(symbol.json), name: parseSymbolName(symbol.json), source: symbol.source, + lineNumber: parseLineNumber(symbol.json), availability: parseAvailability(symbol.json), type: _parseVariableType(context, symbol.json, symbolgraph), hasObjCAnnotation: parseSymbolHasObjcAnnotation(symbol.json), @@ -32,7 +34,8 @@ PropertyDeclaration parsePropertyDeclaration( unowned: info.unowned, weak: info.weak, lazy: info.lazy, - hasSetter: info.constant ? false : info.setter, + hasSetter: info.constant ? false : (info.getter ? info.setter : true), + hasExplicitGetter: info.getter, ); } @@ -47,6 +50,7 @@ GlobalVariableDeclaration parseGlobalVariableDeclaration( id: parseSymbolId(symbol.json), name: parseSymbolName(symbol.json), source: symbol.source, + lineNumber: parseLineNumber(symbol.json), availability: parseAvailability(symbol.json), type: _parseVariableType(context, symbol.json, symbolgraph), isConstant: info.constant || !info.setter, @@ -138,8 +142,8 @@ ParsedPropertyInfo parsePropertyInfo(Json json) { 'Properties can not have a setter without a getter', ); } else { - // has implicit getter and implicit setter - return (true, true); + // Stored property - no explicit getter or setter + return (false, false); } } } diff --git a/pkgs/swift2objc/lib/src/parser/parsers/parse_declarations.dart b/pkgs/swift2objc/lib/src/parser/parsers/parse_declarations.dart index cff1a6741c..afc702dd8e 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/parse_declarations.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/parse_declarations.dart @@ -9,11 +9,21 @@ import '../_core/parsed_symbolgraph.dart'; import '../_core/utils.dart'; import 'declaration_parsers/parse_built_in_declaration.dart'; import 'declaration_parsers/parse_compound_declaration.dart'; +import 'declaration_parsers/parse_enum_declaration.dart'; import 'declaration_parsers/parse_function_declaration.dart'; import 'declaration_parsers/parse_initializer_declaration.dart'; import 'declaration_parsers/parse_typealias_declaration.dart'; import 'declaration_parsers/parse_variable_declaration.dart'; +final class UnsupportedSymbolException implements Exception { + String message; + bool isWarning; + UnsupportedSymbolException(this.message, {this.isWarning = false}); + + @override + String toString() => message; +} + List parseDeclarations( Context context, ParsedSymbolgraph symbolgraph, @@ -72,6 +82,13 @@ Declaration parseDeclaration( symbolgraph, isStatic: true, ), + 'swift.func.op' => parseMethodDeclaration( + context, + parsedSymbol, + symbolgraph, + isStatic: true, + isOperator: true, + ), 'swift.property' => parsePropertyDeclaration( context, parsedSymbol, @@ -104,7 +121,16 @@ Declaration parseDeclaration( parsedSymbol, symbolgraph, ), - _ => throw Exception('Symbol of type $symbolType is not implemented yet.'), + 'swift.enum' => parseEnumDeclaration(context, parsedSymbol, symbolgraph), + 'swift.enum.case' => parseEnumCaseDeclaration( + context, + parsedSymbol, + symbolgraph, + ), + _ => throw UnsupportedSymbolException( + 'Symbol of type $symbolType is not supported yet: ' + '${parseSymbolId(symbolJson)}', + ), }; return parsedSymbol.declaration!; @@ -119,7 +145,11 @@ Declaration? tryParseDeclaration( return parseDeclaration(context, parsedSymbol, symbolgraph); } catch (e) { if (parsedSymbol.source != builtInInputConfig) { - context.logger.severe('$e'); + if (e is UnsupportedSymbolException && e.isWarning) { + context.logger.warning('$e'); + } else { + context.logger.severe('$e'); + } } } return null; diff --git a/pkgs/swift2objc/lib/src/parser/parsers/parse_type.dart b/pkgs/swift2objc/lib/src/parser/parsers/parse_type.dart index ad371a31d5..de09338db7 100644 --- a/pkgs/swift2objc/lib/src/parser/parsers/parse_type.dart +++ b/pkgs/swift2objc/lib/src/parser/parsers/parse_type.dart @@ -49,7 +49,9 @@ import 'parse_declarations.dart'; ) { final token = fragments[0]; final parselet = _prefixParsets[_tokenId(token)]; - if (parselet == null) throw Exception('Invalid type at "${token.path}"'); + if (parselet == null) { + throw Exception('Invalid type at "${token.path}": $token'); + } return parselet(context, symbolgraph, token, fragments.slice(1)); } @@ -73,7 +75,10 @@ import 'parse_declarations.dart'; // kind of 'text', and the spelling is what distinguishes them. String _tokenId(Json token) { final kind = token['kind'].get(); - return kind == 'text' ? 'text: ${token['spelling'].get()}' : kind; + if (kind == 'text' || kind == 'keyword') { + return '$kind: ${token['spelling'].get()}'; + } + return kind; } // ======================== @@ -94,12 +99,23 @@ typedef PrefixParselet = Json token, TokenList fragments, ) { - final id = token['preciseIdentifier'].get(); + final preciseIdJson = token['preciseIdentifier']; + if (!preciseIdJson.exists) { + final spelling = token['spelling'].get(); + if (spelling == 'Self') { + return (selfType, fragments); + } + throw Exception( + 'Type at "${token.path}" has no preciseIdentifier ' + 'and is not Self: $token', + ); + } + final id = preciseIdJson.get(); final symbol = symbolgraph.symbols[id]; if (symbol == null) { throw Exception( - 'The type at "${token.path}" does not exist among parsed symbols.', + 'The type at "${token.path}" does not exist among parsed symbols: $token', ); } @@ -113,16 +129,69 @@ typedef PrefixParselet = Json token, TokenList fragments, ) { - final nextToken = fragments[0]; - if (_tokenId(nextToken) != 'text: )') { - throw Exception('Tuples not supported yet, at ${token.path}'); + var currentFragments = fragments; + final elements = []; + + while (currentFragments.isNotEmpty && + _tokenId(currentFragments[0]) != 'text: )') { + String? label; + + if (currentFragments.length > 1 && + _tokenId(currentFragments[1]) == 'text: :') { + label = currentFragments[0]['spelling'].get(); + currentFragments = currentFragments.slice(2); + } + + final (elementType, nextFragments) = parseType( + context, + symbolgraph, + currentFragments, + ); + + elements.add(TupleElement(label: label, type: elementType)); + currentFragments = nextFragments; + + if (currentFragments.isNotEmpty && + _tokenId(currentFragments[0]) == 'text: ,') { + currentFragments = currentFragments.slice(1); + } + } + + if (currentFragments.isNotEmpty && + _tokenId(currentFragments[0]) == 'text: )') { + currentFragments = currentFragments.slice(1); + } else { + throw Exception('Expected closing parenthesis for tuple at ${token.path}'); + } + + if (elements.isEmpty) { + return (voidType, currentFragments); + } + + if (elements.length == 1) { + return (elements[0].type, currentFragments); + } + + return (TupleType(elements), currentFragments); +} + +(ReferredType, TokenList) _inoutParselet( + Context context, + ParsedSymbolgraph symbolgraph, + Json token, + TokenList fragments, +) { + if (_tokenId(fragments[0]) == 'text: ') { + fragments = fragments.slice(1); } - return (voidType, fragments.slice(1)); + final (type, suffix) = parseType(context, symbolgraph, fragments); + return (InoutType(type), suffix); } Map _prefixParsets = { 'typeIdentifier': _typeIdentifierParselet, 'text: (': _tupleParselet, + 'keyword: inout': _inoutParselet, }; // ======================== diff --git a/pkgs/swift2objc/lib/src/transformer/_core/unique_namer.dart b/pkgs/swift2objc/lib/src/transformer/_core/unique_namer.dart index 2d43971023..152713d44e 100644 --- a/pkgs/swift2objc/lib/src/transformer/_core/unique_namer.dart +++ b/pkgs/swift2objc/lib/src/transformer/_core/unique_namer.dart @@ -6,6 +6,58 @@ import '../../ast/_core/interfaces/compound_declaration.dart'; class UniqueNamer { final Set _usedNames; + final Map operatorNames = { + '+': 'add', + '-': 'subtract', + '*': 'multiply', + '/': 'divide', + '%': 'modulo', + + '==': 'equals', + '!=': 'notEquals', + '===': 'strictEquals', + '!==': 'strictNotEquals', + + '<': 'lessThan', + '<=': 'lessThanOrEquals', + '>': 'greaterThan', + '>=': 'greaterThanOrEquals', + + '!': 'not', + '&&': 'logicalAnd', + '||': 'logicalOr', + + '&': 'and', + '|': 'or', + '^': 'xor', + '~': 'bitwiseNot', + + '<<': 'shiftLeft', + '>>': 'shiftRight', + + '=': 'assign', + '+=': 'addAssign', + '-=': 'subtractAssign', + '*=': 'multiplyAssign', + '/=': 'divideAssign', + '%=': 'moduloAssign', + '&=': 'andAssign', + '|=': 'orAssign', + '^=': 'xorAssign', + '<<=': 'shiftLeftAssign', + '>>=': 'shiftRightAssign', + + '++': 'increment', + '--': 'decrement', + + '??': 'nilCoalescing', + '?': 'question', + + '...': 'closedRange', + '..<': 'halfOpenRange', + + '.': 'dot', + }; UniqueNamer([Iterable usedNames = const []]) : _usedNames = usedNames.toSet(); @@ -17,24 +69,32 @@ class UniqueNamer { }; String makeUnique(String name) { - if (name.isEmpty) { - name = 'unamed'; - } + final uniqueName = _sanitize(name); - if (!_usedNames.contains(name)) { - _usedNames.add(name); - return name; + if (!_usedNames.contains(uniqueName)) { + _usedNames.add(uniqueName); + return uniqueName; } var counter = 0; - var uniqueName = name; + var candidateName = uniqueName; do { counter++; - uniqueName = '$name$counter'; - } while (_usedNames.contains(uniqueName)); + candidateName = '$uniqueName$counter'; + } while (_usedNames.contains(candidateName)); + + _usedNames.add(candidateName); + return candidateName; + } + + String _sanitize(String name) { + if (name.isEmpty) return 'unnamed'; + + if (operatorNames.containsKey(name)) { + return operatorNames[name]!; + } - _usedNames.add(uniqueName); - return uniqueName; + return RegExp(r'\W').hasMatch(name) ? 'operatorOverload' : name; } } diff --git a/pkgs/swift2objc/lib/src/transformer/_core/utils.dart b/pkgs/swift2objc/lib/src/transformer/_core/utils.dart index c073c3dec9..8a0c852bff 100644 --- a/pkgs/swift2objc/lib/src/transformer/_core/utils.dart +++ b/pkgs/swift2objc/lib/src/transformer/_core/utils.dart @@ -11,6 +11,7 @@ import '../../ast/declarations/compounds/members/property_declaration.dart'; import '../../ast/declarations/typealias_declaration.dart'; import '../../transformer/_core/primitive_wrappers.dart'; import '../transform.dart'; +import '../transformers/transform_referred_type.dart'; import 'unique_namer.dart'; // TODO(https://github.com/dart-lang/native/issues/1358): These functions should @@ -24,6 +25,22 @@ import 'unique_namer.dart'; TransformationState state, { bool shouldWrapPrimitives = false, }) { + if (type is InoutType) { + final (newValue, newType) = maybeWrapValue( + type.child, + value, + globalNamer, + state, + shouldWrapPrimitives: shouldWrapPrimitives, + ); + return (newValue, InoutType(newType)); + } + + // Handle tuple types first + if (type is TupleType) { + return _wrapTupleValue(type, value, globalNamer, state); + } + final (wrappedPrimitiveType, returnsWrappedPrimitive) = maybeGetPrimitiveWrapper(type, shouldWrapPrimitives, state); if (returnsWrappedPrimitive) { @@ -33,6 +50,21 @@ import 'unique_namer.dart'; ); } + if (type is OptionalType) { + final (wrappedChildType, childIsPrimitive) = maybeGetPrimitiveWrapper( + type.child, + true, + state, + ); + if (childIsPrimitive) { + final wrapperName = (wrappedChildType as DeclaredType).name; + return ( + '$value == nil ? nil : $wrapperName($value!)', + OptionalType(wrappedChildType), + ); + } + } + if (type.isObjCRepresentable) { return (value, type); } @@ -58,7 +90,7 @@ import 'unique_namer.dart'; ); return ( - '${transformedTypeDeclaration.name}($value)', + '${transformedTypeDeclaration.fullName}($value)', transformedTypeDeclaration.asDeclaredType, ); } else if (type is OptionalType) { @@ -74,10 +106,28 @@ import 'unique_namer.dart'; } } +(String, ReferredType) _wrapTupleValue( + TupleType tupleType, + String tupleExpression, + UniqueNamer globalNamer, + TransformationState state, +) { + final wrapperType = transformReferredType(tupleType, globalNamer, state); + final wrapperClass = + (wrapperType as DeclaredType).declaration as ClassDeclaration; + + return ('${wrapperClass.name}($tupleExpression)', wrapperType); +} + (String value, ReferredType type) maybeUnwrapValue( ReferredType type, String value, ) { + if (type is InoutType) { + final (newValue, newType) = maybeUnwrapValue(type.child, value); + return (newValue, InoutType(newType)); + } + if (!type.isObjCRepresentable) { return (value, type); } @@ -129,3 +179,19 @@ InitializerDeclaration buildWrapperInitializer( hasObjCAnnotation: wrappedClassInstance.hasObjCAnnotation, ); } + +extension SortById on Iterable { + List sortedById() => toList() + ..sort((T a, T b) { + // Sort by line number if both declarations have it + final aLine = a.lineNumber; + final bLine = b.lineNumber; + + if (aLine != null && bLine != null) { + final lineCompare = aLine.compareTo(bLine); + if (lineCompare != 0) return lineCompare; + } + + return a.id.compareTo(b.id); + }); +} diff --git a/pkgs/swift2objc/lib/src/transformer/transform.dart b/pkgs/swift2objc/lib/src/transformer/transform.dart index 272ad6d9f0..af915c8d10 100644 --- a/pkgs/swift2objc/lib/src/transformer/transform.dart +++ b/pkgs/swift2objc/lib/src/transformer/transform.dart @@ -7,14 +7,18 @@ import '../ast/_core/interfaces/declaration.dart'; import '../ast/_core/interfaces/nestable_declaration.dart'; import '../ast/declarations/built_in/built_in_declaration.dart'; import '../ast/declarations/compounds/class_declaration.dart'; +import '../ast/declarations/compounds/enum_declaration.dart'; import '../ast/declarations/compounds/struct_declaration.dart'; import '../ast/declarations/globals/globals.dart'; import '../ast/declarations/typealias_declaration.dart'; import '../ast/visitor.dart'; import '../context.dart'; +import '../parser/_core/utils.dart'; import '_core/dependencies.dart'; import '_core/unique_namer.dart'; +import '_core/utils.dart'; import 'transformers/transform_compound.dart'; +import 'transformers/transform_enum.dart'; import 'transformers/transform_globals.dart'; class TransformationState { @@ -27,6 +31,11 @@ class TransformationState { // Bindings that will be generated as stubs. final stubs = {}; + + late final UniqueNamer globalNamer; + + // Map from tuple signature to generated wrapper class + final tupleWrappers = {}; } /// Transforms the given declarations into the desired ObjC wrapped declarations @@ -53,33 +62,31 @@ List transform( ListDeclsVisitation(includes, directTransitives), state.bindings, ); - final topLevelDecls = listDecls.topLevelDecls; + final topLevelDecls = listDecls.topLevelDecls.toList(); state.stubs.addAll(listDecls.stubDecls); state.bindings.addAll(listDecls.stubDecls); - final globalNamer = UniqueNamer( + state.globalNamer = UniqueNamer( state.bindings.map((declaration) => declaration.name), ); final globals = Globals( - functions: topLevelDecls.whereType().toList(), - variables: topLevelDecls.whereType().toList(), + functions: topLevelDecls.removeWhereType(), + variables: topLevelDecls.removeWhereType(), ); - final nonGlobals = topLevelDecls - .where( - (declaration) => - declaration is! GlobalFunctionDeclaration && - declaration is! GlobalVariableDeclaration, - ) - .toList(); final transformedDeclarations = [ - ...nonGlobals.map((d) => maybeTransformDeclaration(d, globalNamer, state)), - transformGlobals(globals, globalNamer, state), + ...topLevelDecls.map( + (d) => maybeTransformDeclaration(d, state.globalNamer, state), + ), + transformGlobals(globals, state.globalNamer, state), ].nonNulls.toList(); - return (transformedDeclarations + _getPrimitiveWrapperClasses(state)) - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + return [ + ...transformedDeclarations, + ..._getPrimitiveWrapperClasses(state), + ...state.tupleWrappers.values, + ].sortedById(); } Declaration transformDeclaration( @@ -111,10 +118,27 @@ Declaration? maybeTransformDeclaration( } if (declaration is InnerNestableDeclaration && - declaration.nestingParent != null) { + declaration.nestingParent != null && + !nested) { // It's important that nested declarations are only transformed in the - // context of their parent, so that their parentNamer is correct. - assert(nested); + // context of their parent, so that their parentNamer is correct. So find + // the top level declaration this is nested in, and transform that first. + maybeTransformDeclaration( + _topLevelNestingParent(declaration), + state.globalNamer, + state, + ); + + // Now that the parents are transformed, this declaration should haven been + // transformed, and will be in the cache. + // TODO(https://github.com/dart-lang/native/issues/1358): This is brittle. Switch naming to a transformer. + return state.map[declaration] ?? + maybeTransformDeclaration( + declaration, + parentNamer, + state, + nested: true, + ); } return switch (declaration) { @@ -123,15 +147,20 @@ Declaration? maybeTransformDeclaration( parentNamer, state, ), + EnumDeclaration() => transformEnum(declaration, parentNamer, state), TypealiasDeclaration() => null, _ => throw UnimplementedError(), }; } -List _getPrimitiveWrapperClasses(TransformationState state) { - return state.map.entries - .where((entry) => entry.key is BuiltInDeclaration) - .map((entry) => entry.value) - .nonNulls - .toList(); -} +List _getPrimitiveWrapperClasses(TransformationState state) => + state.map.entries + .where((entry) => entry.key is BuiltInDeclaration) + .map((entry) => entry.value) + .nonNulls + .toList(); + +Declaration _topLevelNestingParent(Declaration declaration) => + declaration is InnerNestableDeclaration && declaration.nestingParent != null + ? _topLevelNestingParent(declaration.nestingParent!) + : declaration; diff --git a/pkgs/swift2objc/lib/src/transformer/transformers/const.dart b/pkgs/swift2objc/lib/src/transformer/transformers/const.dart index d5f4af41d4..c6cd96cb51 100644 --- a/pkgs/swift2objc/lib/src/transformer/transformers/const.dart +++ b/pkgs/swift2objc/lib/src/transformer/transformers/const.dart @@ -3,4 +3,5 @@ // BSD-style license that can be found in the LICENSE file. // Certain methods are not allowed to be overriden in swift. -const disallowedMethods = {'hashValue'}; +// TODO(https://github.com/dart-lang/native/issues/2954): Support hash() +const disallowedMethods = {'hashValue', 'hash'}; diff --git a/pkgs/swift2objc/lib/src/transformer/transformers/transform_compound.dart b/pkgs/swift2objc/lib/src/transformer/transformers/transform_compound.dart index 58e4ffb239..1ce9bff8fa 100644 --- a/pkgs/swift2objc/lib/src/transformer/transformers/transform_compound.dart +++ b/pkgs/swift2objc/lib/src/transformer/transformers/transform_compound.dart @@ -5,11 +5,13 @@ import '../../ast/_core/interfaces/compound_declaration.dart'; import '../../ast/_core/interfaces/declaration.dart'; import '../../ast/_core/interfaces/nestable_declaration.dart'; +import '../../ast/_core/shared/parameter.dart'; import '../../ast/declarations/built_in/built_in_declaration.dart'; import '../../ast/declarations/compounds/class_declaration.dart'; import '../../ast/declarations/compounds/members/initializer_declaration.dart'; import '../../ast/declarations/compounds/members/method_declaration.dart'; import '../../ast/declarations/compounds/members/property_declaration.dart'; +import '../../ast/declarations/compounds/struct_declaration.dart'; import '../../parser/_core/utils.dart'; import '../_core/unique_namer.dart'; import '../_core/utils.dart'; @@ -49,21 +51,19 @@ ClassDeclaration transformCompound( state.map[originalCompound] = transformedCompound; - transformedCompound.nestedDeclarations = - originalCompound.nestedDeclarations - .map( - (nested) => - maybeTransformDeclaration( - nested, - compoundNamer, - state, - nested: true, - ) - as InnerNestableDeclaration?, - ) - .nonNulls - .toList() - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + transformedCompound.nestedDeclarations = originalCompound.nestedDeclarations + .map( + (nested) => + maybeTransformDeclaration( + nested, + compoundNamer, + state, + nested: true, + ) + as InnerNestableDeclaration?, + ) + .nonNulls + .sortedById(); transformedCompound.nestedDeclarations.fillNestingParents( transformedCompound, ); @@ -81,7 +81,7 @@ ClassDeclaration transformCompound( .nonNulls .toList(); - final transformedInitializers = originalCompound.initializers + final transformedInitializers = _compoundInitializers(originalCompound) .map( (initializer) => transformInitializer( initializer, @@ -104,20 +104,58 @@ ClassDeclaration transformCompound( .nonNulls .toList(); - transformedCompound.properties = - transformedProperties.whereType().toList() - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + transformedCompound.properties = transformedProperties + .removeWhereType() + .sortedById(); - transformedCompound.initializers = - transformedInitializers.whereType().toList() - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + transformedCompound.initializers = transformedInitializers + .removeWhereType() + .sortedById(); - transformedCompound.methods = - (transformedMethods + - transformedProperties.whereType().toList() + - transformedInitializers.whereType().toList()) - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + transformedCompound.methods = [ + ...transformedMethods, + ...transformedProperties.removeWhereType(), + ...transformedInitializers.removeWhereType(), + ].sortedById(); + + assert(transformedProperties.isEmpty); + assert(transformedInitializers.isEmpty); } return transformedCompound; } + +List _compoundInitializers( + CompoundDeclaration originalCompound, +) { + final initializers = originalCompound.initializers; + if (originalCompound is! StructDeclaration || initializers.isNotEmpty) { + return initializers; + } + final storedProperties = originalCompound.properties + .where((prop) => !prop.isStatic && !prop.hasExplicitGetter) + .sortedById(); + + if (storedProperties.isEmpty) { + return initializers; + } + + final implicitInit = InitializerDeclaration( + id: originalCompound.id.addIdSuffix('implicit_init'), + source: originalCompound.source, + availability: originalCompound.availability, + params: storedProperties + .map( + (prop) => + Parameter(name: prop.name, internalName: null, type: prop.type), + ) + .toList(), + hasObjCAnnotation: true, + isOverriding: false, + throws: false, + async: false, + isFailable: false, + ); + + return [implicitInit]; +} diff --git a/pkgs/swift2objc/lib/src/transformer/transformers/transform_enum.dart b/pkgs/swift2objc/lib/src/transformer/transformers/transform_enum.dart new file mode 100644 index 0000000000..5480a8ddfb --- /dev/null +++ b/pkgs/swift2objc/lib/src/transformer/transformers/transform_enum.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import '../../ast/_core/interfaces/declaration.dart'; +import '../../ast/_core/shared/parameter.dart'; +import '../../ast/declarations/compounds/class_declaration.dart'; +import '../../ast/declarations/compounds/enum_declaration.dart'; +import '../../ast/declarations/compounds/members/method_declaration.dart'; +import '../../ast/declarations/compounds/members/property_declaration.dart'; +import '../../parser/_core/utils.dart'; +import '../_core/unique_namer.dart'; +import '../_core/utils.dart'; +import '../transform.dart'; +import 'transform_compound.dart'; +import 'transform_function.dart'; +import 'transform_variable.dart'; + +ClassDeclaration transformEnum( + EnumDeclaration enumDecl, + UniqueNamer parentNamer, + TransformationState state, +) { + final wrapper = transformCompound(enumDecl, parentNamer, state); + + // Transform enum cases to methods and properties. If the case has associated + // values it becomes a method, otherwise it becomes a property. For each case, + // first create a fake method/property, then transform the fake. Note that + // transforming a property may also generate a method instead of a property. + final cases = enumDecl.cases + .map((c) => _transformEnumCase(c, enumDecl, wrapper, parentNamer, state)) + .nonNulls + .sortedById(); + wrapper.methods.addAll(cases.removeWhereType()); + wrapper.properties.addAll(cases.removeWhereType()); + assert(cases.isEmpty); + + return wrapper; +} + +Declaration? _transformEnumCase( + EnumCaseDeclaration caseDecl, + EnumDeclaration enumDecl, + ClassDeclaration wrapper, + UniqueNamer parentNamer, + TransformationState state, +) { + if (caseDecl.params.isEmpty) { + return transformProperty( + PropertyDeclaration( + id: caseDecl.id, + name: caseDecl.name, + source: caseDecl.source, + availability: caseDecl.availability, + type: enumDecl.asDeclaredType, + hasSetter: false, + isConstant: true, + isStatic: true, + ), + wrapper.wrappedInstance!, + parentNamer, + state, + ); + } else { + return transformMethod( + MethodDeclaration( + id: caseDecl.id, + name: caseDecl.name, + source: caseDecl.source, + availability: caseDecl.availability, + returnType: enumDecl.asDeclaredType, + params: caseDecl.params + .map((param) => Parameter(name: param.name, type: param.type)) + .toList(), + isStatic: true, + ), + wrapper.wrappedInstance!, + parentNamer, + state, + ); + } +} diff --git a/pkgs/swift2objc/lib/src/transformer/transformers/transform_function.dart b/pkgs/swift2objc/lib/src/transformer/transformers/transform_function.dart index b249b950ff..6cd7edbf26 100644 --- a/pkgs/swift2objc/lib/src/transformer/transformers/transform_function.dart +++ b/pkgs/swift2objc/lib/src/transformer/transformers/transform_function.dart @@ -5,6 +5,7 @@ import '../../ast/_core/interfaces/function_declaration.dart'; import '../../ast/_core/shared/parameter.dart'; import '../../ast/_core/shared/referred_type.dart'; +import '../../ast/declarations/built_in/built_in_declaration.dart'; import '../../ast/declarations/compounds/members/method_declaration.dart'; import '../../ast/declarations/compounds/members/property_declaration.dart'; import '../../ast/declarations/globals/globals.dart'; @@ -29,16 +30,32 @@ MethodDeclaration? transformMethod( if (disallowedMethods.contains(originalMethod.name)) { return null; } + if (originalMethod.isOperator && + originalMethod.params.any((p) => p.type.sameAs(selfType))) { + return null; + } + + final wrapperMethodName = originalMethod.isOperator + ? globalNamer.makeUnique(originalMethod.name) + : originalMethod.name; return _transformFunction( originalMethod, globalNamer, state, - wrapperMethodName: originalMethod.name, + wrapperMethodName: wrapperMethodName, originalCallStatementGenerator: (arguments) { final methodSource = originalMethod.isStatic ? wrappedClassInstance.type.swiftType : wrappedClassInstance.name; + + if (originalMethod.isOperator) { + final params = originalMethod.params; + return '${params[0].internalName ?? params[0].name}.wrappedInstance ' + '${originalMethod.name} ' + '${params[1].internalName ?? params[1].name}.wrappedInstance'; + } + return '$methodSource.${originalMethod.name}($arguments)'; }, ); @@ -61,6 +78,19 @@ MethodDeclaration transformGlobalFunction( // -------------------------- Core Implementation -------------------------- +Parameter _transformParam( + int index, + Parameter p, + UniqueNamer globalNamer, + TransformationState state, +) => Parameter( + name: p.name.isEmpty ? '_' : p.name, + internalName: p.name.isEmpty && p.internalName == null + ? 'arg$index' + : p.internalName, + type: transformReferredType(p.type, globalNamer, state), +); + MethodDeclaration _transformFunction( FunctionDeclaration originalFunction, UniqueNamer globalNamer, @@ -68,15 +98,10 @@ MethodDeclaration _transformFunction( required String wrapperMethodName, required String Function(String arguments) originalCallStatementGenerator, }) { - final transformedParams = originalFunction.params - .map( - (param) => Parameter( - name: param.name, - internalName: param.internalName, - type: transformReferredType(param.type, globalNamer, state), - ), - ) - .toList(); + final transformedParams = [ + for (var i = 0; i < originalFunction.params.length; ++i) + _transformParam(i, originalFunction.params[i], globalNamer, state), + ]; final localNamer = UniqueNamer(); final resultName = localNamer.makeUnique('result'); @@ -140,11 +165,14 @@ String generateInvocationParams( ); assert(unwrappedType.sameAs(originalParam.type)); + final invocationValue = originalParam.type is InoutType + ? '&$unwrappedParamValue' + : unwrappedParamValue; argumentsList.add( - originalParam.name == '_' - ? unwrappedParamValue - : '${originalParam.name}: $unwrappedParamValue', + originalParam.name.isEmpty || originalParam.name == '_' + ? invocationValue + : '${originalParam.name}: $invocationValue', ); } return argumentsList.join(', '); @@ -165,7 +193,9 @@ List _generateStatements( originalFunction.params, transformedMethod.params, ); + var originalMethodCall = originalCallGenerator(arguments); + if (transformedMethod.async) { originalMethodCall = 'await $originalMethodCall'; } diff --git a/pkgs/swift2objc/lib/src/transformer/transformers/transform_globals.dart b/pkgs/swift2objc/lib/src/transformer/transformers/transform_globals.dart index 67d93a3b28..b1e12c421f 100644 --- a/pkgs/swift2objc/lib/src/transformer/transformers/transform_globals.dart +++ b/pkgs/swift2objc/lib/src/transformer/transformers/transform_globals.dart @@ -2,7 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import '../../ast/_core/interfaces/declaration.dart'; import '../../ast/declarations/built_in/built_in_declaration.dart'; import '../../ast/declarations/compounds/class_declaration.dart'; import '../../ast/declarations/compounds/members/method_declaration.dart'; @@ -10,6 +9,7 @@ import '../../ast/declarations/compounds/members/property_declaration.dart'; import '../../ast/declarations/globals/globals.dart'; import '../../parser/_core/utils.dart'; import '../_core/unique_namer.dart'; +import '../_core/utils.dart'; import '../transform.dart'; import 'transform_function.dart'; import 'transform_variable.dart'; @@ -39,14 +39,16 @@ ClassDeclaration? transformGlobals( .map((function) => transformGlobalFunction(function, globalNamer, state)) .toList(); - transformedGlobals.properties = - transformedProperties.whereType().toList() - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + transformedGlobals.properties = transformedProperties + .removeWhereType() + .sortedById(); - transformedGlobals.methods = - (transformedMethods + - transformedProperties.whereType().toList()) - ..sort((Declaration a, Declaration b) => a.id.compareTo(b.id)); + transformedGlobals.methods = [ + ...transformedMethods, + ...transformedProperties.removeWhereType(), + ].sortedById(); + + assert(transformedProperties.isEmpty); return transformedGlobals; } diff --git a/pkgs/swift2objc/lib/src/transformer/transformers/transform_referred_type.dart b/pkgs/swift2objc/lib/src/transformer/transformers/transform_referred_type.dart index 6793d2e829..4fb4d0a70e 100644 --- a/pkgs/swift2objc/lib/src/transformer/transformers/transform_referred_type.dart +++ b/pkgs/swift2objc/lib/src/transformer/transformers/transform_referred_type.dart @@ -4,8 +4,13 @@ import '../../ast/_core/interfaces/declaration.dart'; import '../../ast/_core/shared/referred_type.dart'; +import '../../ast/declarations/built_in/built_in_declaration.dart'; +import '../../ast/declarations/compounds/class_declaration.dart'; +import '../../ast/declarations/compounds/members/property_declaration.dart'; import '../../ast/declarations/typealias_declaration.dart'; +import '../_core/primitive_wrappers.dart'; import '../_core/unique_namer.dart'; +import '../_core/utils.dart'; import '../transform.dart'; // TODO(https://github.com/dart-lang/native/issues/1358): Refactor this as a @@ -16,9 +21,34 @@ ReferredType transformReferredType( UniqueNamer globalNamer, TransformationState state, ) { + if (type is OptionalType) { + final (wrappedChildType, childIsPrimitive) = maybeGetPrimitiveWrapper( + type.child, + true, + state, + ); + if (childIsPrimitive) { + return OptionalType(wrappedChildType); + } + } + + if (type is InoutType) { + final (wrappedPrimitive, hasWrappedPrimitive) = maybeGetPrimitiveWrapper( + type.child, + true, + state, + ); + if (hasWrappedPrimitive) { + return InoutType(wrappedPrimitive); + } + return InoutType(transformReferredType(type.child, globalNamer, state)); + } + if (type.isObjCRepresentable) return type; - if (type is GenericType) { + if (type is TupleType) { + return _transformTupleType(type, globalNamer, state); + } else if (type is GenericType) { throw UnimplementedError('Generic types are not supported yet'); } else if (type is DeclaredType) { final decl = type.declaration; @@ -32,3 +62,142 @@ ReferredType transformReferredType( throw UnimplementedError('Unknown type: $type'); } } + +DeclaredType _transformTupleType( + TupleType tupleType, + UniqueNamer globalNamer, + TransformationState state, +) { + final signature = tupleType.swiftType; + + if (state.tupleWrappers.containsKey(signature)) { + return state.tupleWrappers[signature]!.asDeclaredType; + } + + final className = _generateTupleClassName(tupleType, globalNamer, state); + + final wrapperClass = _generateTupleWrapperClass( + tupleType, + className, + globalNamer, + state, + ); + + return wrapperClass.asDeclaredType; +} + +String _generateTupleClassName( + TupleType tuple, + UniqueNamer globalNamer, + TransformationState state, +) { + final parts = []; + + for (var i = 0; i < tuple.elements.length; i++) { + final element = tuple.elements[i]; + if (element.label != null) { + parts.add('${element.label}_${_sanitizeTypeName(element.type)}'); + } else { + parts.add(_sanitizeTypeName(element.type)); + } + } + + return globalNamer.makeUnique('Tuple_${parts.join('_')}'); +} + +String _sanitizeTypeName(ReferredType type) { + return type.swiftType + .replaceAll('<', '_') + .replaceAll('?', 'Optional') + .replaceAll('[', 'Array_') + .replaceAll(RegExp(r'[^\w]'), ''); +} + +ClassDeclaration _generateTupleWrapperClass( + TupleType tupleType, + String className, + UniqueNamer globalNamer, + TransformationState state, +) { + final wrappedInstanceProperty = PropertyDeclaration( + id: 'tuple_${className}_wrappedInstance', + name: 'wrappedInstance', + source: null, + availability: const [], + type: tupleType, + hasSetter: false, + isConstant: false, + hasObjCAnnotation: false, + isStatic: false, + throws: false, + async: false, + unowned: false, + lazy: false, + weak: false, + ); + + final wrapperClass = ClassDeclaration( + id: 'tuple_wrapper_$className', + name: className, + source: null, + availability: const [], + superClass: objectType, + wrappedInstance: wrappedInstanceProperty, + wrapperInitializer: buildWrapperInitializer(wrappedInstanceProperty), + hasObjCAnnotation: true, + ); + + state.tupleWrappers[tupleType.swiftType] = wrapperClass; + + final properties = []; + + for (var i = 0; i < tupleType.elements.length; i++) { + final element = tupleType.elements[i]; + final propertyName = element.label ?? '_$i'; + + final transformedType = transformReferredType( + element.type, + globalNamer, + state, + ); + + final property = PropertyDeclaration( + id: 'tuple_${className}_$propertyName', + name: propertyName, + source: null, + availability: const [], + type: transformedType, + hasSetter: true, + isConstant: false, + hasObjCAnnotation: true, + isStatic: false, + throws: false, + async: false, + unowned: false, + lazy: false, + weak: false, + ); + + final accessor = element.label != null + ? 'wrappedInstance.${element.label}' + : 'wrappedInstance.$i'; + + final (wrappedValue, _) = maybeWrapValue( + element.type, + accessor, + globalNamer, + state, + ); + + property.getter = PropertyStatements([wrappedValue]); + + final (unwrappedValue, _) = maybeUnwrapValue(transformedType, 'newValue'); + property.setter = PropertyStatements(['$accessor = $unwrappedValue']); + + properties.add(property); + } + + wrapperClass.properties = properties; + + return wrapperClass; +} diff --git a/pkgs/swift2objc/pubspec.yaml b/pkgs/swift2objc/pubspec.yaml index 92dc161f00..61915b1c63 100644 --- a/pkgs/swift2objc/pubspec.yaml +++ b/pkgs/swift2objc/pubspec.yaml @@ -4,8 +4,8 @@ name: swift2objc description: 'A tool for generating bindings that allow interop between Dart and Swift code.' -version: 0.1.0 -repository: https://github.com/dart-lang/native/tree/main/pkgs/swiftgen/swift2objc +version: 0.2.0-wip +repository: https://github.com/dart-lang/native/tree/main/pkgs/swift2objc issue_tracker: https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aswift2objc topics: diff --git a/pkgs/swift2objc/test/integration/available_output.swift b/pkgs/swift2objc/test/integration/available_output.swift index aabe913305..43701da3c0 100644 --- a/pkgs/swift2objc/test/integration/available_output.swift +++ b/pkgs/swift2objc/test/integration/available_output.swift @@ -9,9 +9,6 @@ import Foundation get { globalVar } - set { - globalVar = newValue - } } @available(macOS, introduced: 234.5.6) @@ -110,6 +107,12 @@ import Foundation self.wrappedInstance = wrappedInstance } + @available(macOS, introduced: 123.0.0) + @available(iOS, introduced: 100) + @objc public init(prop1: Int, prop2: Int) { + wrappedInstance = NewStruct(prop1: prop1, prop2: prop2) + } + @available(macOS, introduced: 123.0.0) @available(iOS, introduced: 100) @objc public func method1() -> Int { diff --git a/pkgs/swift2objc/test/integration/enum_input.swift b/pkgs/swift2objc/test/integration/enum_input.swift new file mode 100644 index 0000000000..4a45991c1f --- /dev/null +++ b/pkgs/swift2objc/test/integration/enum_input.swift @@ -0,0 +1,74 @@ +// Basic enum. +public enum CompassPoint { + case north + case south + case east + case west +} + +// Raw value enums, int based. +public enum DayOfWeek: Int { + case monday = 1, tuesday, wednesday, thursday, friday, saturday, sunday +} + +public enum MathConstants: Float { + case sqrt2 = 1.41421 + case pi = 3.14159 + case e = 2.71828 + case phi = 1.61803 + case gamma = 0.57721 +} + +public enum Status: String { + case success = "OK" + case failure = "ERROR" +} + +// Enum with associated values. +public enum Barcode { + case upc(numberSystem: Int, manufacturer: Int, product: Int, check: Int) + case qrCode(String) +} + +// Indirect (recursive) enums. +// TODO(swift2objc): indirect recursive enums are not supported yet. +public indirect enum ArithmeticExpression { + case number(Int) + case addition(ArithmeticExpression, ArithmeticExpression) + case multiplication(ArithmeticExpression, ArithmeticExpression) +} + +// CaseIterable enums. +public enum Beverage: CaseIterable { + case coffee, tea, juice +} + +// Enum with methods and properties. +public enum TrafficLight { + case red, yellow, green + + public init?(colorName: String) { + switch colorName.lowercased() { + case "red": self = .red + case "yellow": self = .yellow + case "green": self = .green + default: return nil + } + } + + public var instruction: String { + switch self { + case .red: return "Stop" + case .yellow: return "Prepare to stop" + case .green: return "Proceed" + } + } + + public mutating func advance() { + switch self { + case .red: self = .green + case .green: self = .yellow + case .yellow: self = .red + } + } +} diff --git a/pkgs/swift2objc/test/integration/enum_output.swift b/pkgs/swift2objc/test/integration/enum_output.swift new file mode 100644 index 0000000000..65d1ea7206 --- /dev/null +++ b/pkgs/swift2objc/test/integration/enum_output.swift @@ -0,0 +1,287 @@ +// Test preamble text + +import Foundation + +@objc public class CompassPointWrapper: NSObject { + var wrappedInstance: CompassPoint + + @objc static public var east: CompassPointWrapper { + get { + CompassPointWrapper(CompassPoint.east) + } + } + + @objc static public var west: CompassPointWrapper { + get { + CompassPointWrapper(CompassPoint.west) + } + } + + @objc static public var north: CompassPointWrapper { + get { + CompassPointWrapper(CompassPoint.north) + } + } + + @objc static public var south: CompassPointWrapper { + get { + CompassPointWrapper(CompassPoint.south) + } + } + + init(_ wrappedInstance: CompassPoint) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class TrafficLightWrapper: NSObject { + var wrappedInstance: TrafficLight + + @objc public var instruction: String { + get { + wrappedInstance.instruction + } + } + + @objc static public var red: TrafficLightWrapper { + get { + TrafficLightWrapper(TrafficLight.red) + } + } + + @objc static public var green: TrafficLightWrapper { + get { + TrafficLightWrapper(TrafficLight.green) + } + } + + @objc static public var yellow: TrafficLightWrapper { + get { + TrafficLightWrapper(TrafficLight.yellow) + } + } + + init(_ wrappedInstance: TrafficLight) { + self.wrappedInstance = wrappedInstance + } + + @objc public init?(colorName: String) { + if let instance = TrafficLight(colorName: colorName) { + wrappedInstance = instance + } else { + return nil + } + } + + @objc public func advance() { + return wrappedInstance.advance() + } + +} + +@objc public class MathConstantsWrapper: NSObject { + var wrappedInstance: MathConstants + + @objc static public var e: MathConstantsWrapper { + get { + MathConstantsWrapper(MathConstants.e) + } + } + + @objc static public var pi: MathConstantsWrapper { + get { + MathConstantsWrapper(MathConstants.pi) + } + } + + @objc static public var phi: MathConstantsWrapper { + get { + MathConstantsWrapper(MathConstants.phi) + } + } + + @objc static public var gamma: MathConstantsWrapper { + get { + MathConstantsWrapper(MathConstants.gamma) + } + } + + @objc static public var sqrt2: MathConstantsWrapper { + get { + MathConstantsWrapper(MathConstants.sqrt2) + } + } + + init(_ wrappedInstance: MathConstants) { + self.wrappedInstance = wrappedInstance + } + + @objc public init?(rawValue: Float) { + if let instance = MathConstants(rawValue: rawValue) { + wrappedInstance = instance + } else { + return nil + } + } + +} + +@objc public class ArithmeticExpressionWrapper: NSObject { + var wrappedInstance: ArithmeticExpression + + init(_ wrappedInstance: ArithmeticExpression) { + self.wrappedInstance = wrappedInstance + } + + @objc static public func multiplication(_ arg0: ArithmeticExpressionWrapper, _ arg1: ArithmeticExpressionWrapper) -> ArithmeticExpressionWrapper { + let result = ArithmeticExpression.multiplication(arg0.wrappedInstance, arg1.wrappedInstance) + return ArithmeticExpressionWrapper(result) + } + + @objc static public func number(_ arg0: Int) -> ArithmeticExpressionWrapper { + let result = ArithmeticExpression.number(arg0) + return ArithmeticExpressionWrapper(result) + } + + @objc static public func addition(_ arg0: ArithmeticExpressionWrapper, _ arg1: ArithmeticExpressionWrapper) -> ArithmeticExpressionWrapper { + let result = ArithmeticExpression.addition(arg0.wrappedInstance, arg1.wrappedInstance) + return ArithmeticExpressionWrapper(result) + } + +} + +@objc public class StatusWrapper: NSObject { + var wrappedInstance: Status + + @objc static public var failure: StatusWrapper { + get { + StatusWrapper(Status.failure) + } + } + + @objc static public var success: StatusWrapper { + get { + StatusWrapper(Status.success) + } + } + + init(_ wrappedInstance: Status) { + self.wrappedInstance = wrappedInstance + } + + @objc public init?(rawValue: String) { + if let instance = Status(rawValue: rawValue) { + wrappedInstance = instance + } else { + return nil + } + } + +} + +@objc public class BarcodeWrapper: NSObject { + var wrappedInstance: Barcode + + init(_ wrappedInstance: Barcode) { + self.wrappedInstance = wrappedInstance + } + + @objc static public func upc(numberSystem: Int, manufacturer: Int, product: Int, check: Int) -> BarcodeWrapper { + let result = Barcode.upc(numberSystem: numberSystem, manufacturer: manufacturer, product: product, check: check) + return BarcodeWrapper(result) + } + + @objc static public func qrCode(_ arg0: String) -> BarcodeWrapper { + let result = Barcode.qrCode(arg0) + return BarcodeWrapper(result) + } + +} + +@objc public class BeverageWrapper: NSObject { + var wrappedInstance: Beverage + + @objc static public var tea: BeverageWrapper { + get { + BeverageWrapper(Beverage.tea) + } + } + + @objc static public var juice: BeverageWrapper { + get { + BeverageWrapper(Beverage.juice) + } + } + + @objc static public var coffee: BeverageWrapper { + get { + BeverageWrapper(Beverage.coffee) + } + } + + init(_ wrappedInstance: Beverage) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class DayOfWeekWrapper: NSObject { + var wrappedInstance: DayOfWeek + + @objc static public var friday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.friday) + } + } + + @objc static public var monday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.monday) + } + } + + @objc static public var sunday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.sunday) + } + } + + @objc static public var tuesday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.tuesday) + } + } + + @objc static public var saturday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.saturday) + } + } + + @objc static public var thursday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.thursday) + } + } + + @objc static public var wednesday: DayOfWeekWrapper { + get { + DayOfWeekWrapper(DayOfWeek.wednesday) + } + } + + init(_ wrappedInstance: DayOfWeek) { + self.wrappedInstance = wrappedInstance + } + + @objc public init?(rawValue: Int) { + if let instance = DayOfWeek(rawValue: rawValue) { + wrappedInstance = instance + } else { + return nil + } + } + +} + diff --git a/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift b/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift index 9a34ec5142..5efcd4360d 100644 --- a/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift +++ b/pkgs/swift2objc/test/integration/global_variables_and_functions_output.swift @@ -13,9 +13,6 @@ import Foundation get { MyOtherClassWrapper(globalCustomVariable) } - set { - globalCustomVariable = newValue.wrappedInstance - } } @objc static public var globalGetterVariableWrapper: Double { @@ -43,9 +40,6 @@ import Foundation get { globalRepresentableVariable } - set { - globalRepresentableVariable = newValue - } } @objc static public func globalCustomFunctionWrapper(label1 param1: Int, param2: MyOtherClassWrapper) -> MyOtherClassWrapper { diff --git a/pkgs/swift2objc/test/integration/implicit_initializers_input.swift b/pkgs/swift2objc/test/integration/implicit_initializers_input.swift new file mode 100644 index 0000000000..e645cabb1e --- /dev/null +++ b/pkgs/swift2objc/test/integration/implicit_initializers_input.swift @@ -0,0 +1,31 @@ +public struct MyPerson { + public var name: String + public var age: Int +} + +public struct MyConfig { + public var title: String + public var count: Int + public var enabled: Bool +} + +public struct MyCustomStruct { + public var data: Int + + public init(value: Int) { + self.data = value * 2 + } +} + +public struct MyStaticStruct { + public static var defaultName = "Default" + public var name: String +} + +public struct MyComputedStruct { + public var firstName: String + public var lastName: String + public var fullName: String { + return "\(firstName) \(lastName)" + } +} diff --git a/pkgs/swift2objc/test/integration/implicit_initializers_output.swift b/pkgs/swift2objc/test/integration/implicit_initializers_output.swift new file mode 100644 index 0000000000..03167589b0 --- /dev/null +++ b/pkgs/swift2objc/test/integration/implicit_initializers_output.swift @@ -0,0 +1,165 @@ +// Test preamble text + +import Foundation + +@objc public class MyCustomStructWrapper: NSObject { + var wrappedInstance: MyCustomStruct + + @objc public var data: Int { + get { + wrappedInstance.data + } + set { + wrappedInstance.data = newValue + } + } + + init(_ wrappedInstance: MyCustomStruct) { + self.wrappedInstance = wrappedInstance + } + + @objc public init(value: Int) { + wrappedInstance = MyCustomStruct(value: value) + } + +} + +@objc public class MyStaticStructWrapper: NSObject { + var wrappedInstance: MyStaticStruct + + @objc static public var defaultName: String { + get { + MyStaticStruct.defaultName + } + set { + MyStaticStruct.defaultName = newValue + } + } + + @objc public var name: String { + get { + wrappedInstance.name + } + set { + wrappedInstance.name = newValue + } + } + + init(_ wrappedInstance: MyStaticStruct) { + self.wrappedInstance = wrappedInstance + } + + @objc public init(name: String) { + wrappedInstance = MyStaticStruct(name: name) + } + +} + +@objc public class MyComputedStructWrapper: NSObject { + var wrappedInstance: MyComputedStruct + + @objc public var fullName: String { + get { + wrappedInstance.fullName + } + } + + @objc public var lastName: String { + get { + wrappedInstance.lastName + } + set { + wrappedInstance.lastName = newValue + } + } + + @objc public var firstName: String { + get { + wrappedInstance.firstName + } + set { + wrappedInstance.firstName = newValue + } + } + + init(_ wrappedInstance: MyComputedStruct) { + self.wrappedInstance = wrappedInstance + } + + @objc public init(firstName: String, lastName: String) { + wrappedInstance = MyComputedStruct(firstName: firstName, lastName: lastName) + } + +} + +@objc public class MyConfigWrapper: NSObject { + var wrappedInstance: MyConfig + + @objc public var count: Int { + get { + wrappedInstance.count + } + set { + wrappedInstance.count = newValue + } + } + + @objc public var title: String { + get { + wrappedInstance.title + } + set { + wrappedInstance.title = newValue + } + } + + @objc public var enabled: Bool { + get { + wrappedInstance.enabled + } + set { + wrappedInstance.enabled = newValue + } + } + + init(_ wrappedInstance: MyConfig) { + self.wrappedInstance = wrappedInstance + } + + @objc public init(title: String, count: Int, enabled: Bool) { + wrappedInstance = MyConfig(title: title, count: count, enabled: enabled) + } + +} + +@objc public class MyPersonWrapper: NSObject { + var wrappedInstance: MyPerson + + @objc public var age: Int { + get { + wrappedInstance.age + } + set { + wrappedInstance.age = newValue + } + } + + @objc public var name: String { + get { + wrappedInstance.name + } + set { + wrappedInstance.name = newValue + } + } + + init(_ wrappedInstance: MyPerson) { + self.wrappedInstance = wrappedInstance + } + + @objc public init(name: String, age: Int) { + wrappedInstance = MyPerson(name: name, age: age) + } + +} + diff --git a/pkgs/swift2objc/test/integration/inout_input.swift b/pkgs/swift2objc/test/integration/inout_input.swift new file mode 100644 index 0000000000..7677bd2014 --- /dev/null +++ b/pkgs/swift2objc/test/integration/inout_input.swift @@ -0,0 +1,21 @@ +import Foundation + +public class MyClass { + public func update(_ value: inout Int) { + value += 1 + } +} + +public class MyOtherClass { + public init() {} +} + +public func swapTwoInts(_ a: inout Int, _ b: inout Int) { + let temp = a + a = b + b = temp +} + +public func replaceOther(_ value: inout MyOtherClass) { + value = MyOtherClass() +} diff --git a/pkgs/swift2objc/test/integration/inout_output.swift b/pkgs/swift2objc/test/integration/inout_output.swift new file mode 100644 index 0000000000..9f02e66594 --- /dev/null +++ b/pkgs/swift2objc/test/integration/inout_output.swift @@ -0,0 +1,50 @@ +// Test preamble text + +import Foundation + +@objc public class GlobalsWrapper: NSObject { + @objc static public func swapTwoIntsWrapper(_ a: IntWrapper, _ b: IntWrapper) { + return swapTwoInts(&a.wrappedInstance, &b.wrappedInstance) + } + + @objc static public func replaceOtherWrapper(_ value: MyOtherClassWrapper) { + return replaceOther(&value.wrappedInstance) + } + +} + +@objc public class MyOtherClassWrapper: NSObject { + var wrappedInstance: MyOtherClass + + init(_ wrappedInstance: MyOtherClass) { + self.wrappedInstance = wrappedInstance + } + + @objc override public init() { + wrappedInstance = MyOtherClass() + } + +} + +@objc public class MyClassWrapper: NSObject { + var wrappedInstance: MyClass + + init(_ wrappedInstance: MyClass) { + self.wrappedInstance = wrappedInstance + } + + @objc public func update(_ value: IntWrapper) { + return wrappedInstance.update(&value.wrappedInstance) + } + +} + +@objc public class IntWrapper: NSObject { + var wrappedInstance: Int + + init(_ wrappedInstance: Int) { + self.wrappedInstance = wrappedInstance + } + +} + diff --git a/pkgs/swift2objc/test/integration/integration_test.dart b/pkgs/swift2objc/test/integration/integration_test.dart index aaa99c612b..0a6f6c0757 100644 --- a/pkgs/swift2objc/test/integration/integration_test.dart +++ b/pkgs/swift2objc/test/integration/integration_test.dart @@ -49,7 +49,7 @@ void main([List? args]) { var loggedErrors = 0; Logger.root.onRecord.listen((record) { stderr.writeln('${record.level.name}: ${record.message}'); - if (record.level >= Level.WARNING) ++loggedErrors; + if (record.level >= Level.SEVERE) ++loggedErrors; }); group('Integration tests', () { diff --git a/pkgs/swift2objc/test/integration/nested_types_input.swift b/pkgs/swift2objc/test/integration/nested_types_input.swift index 2d91735182..cb678351a7 100644 --- a/pkgs/swift2objc/test/integration/nested_types_input.swift +++ b/pkgs/swift2objc/test/integration/nested_types_input.swift @@ -12,6 +12,10 @@ public class OuterClass { public static func makeOuter() -> OuterClass { return OuterClass(); } public static func makeInner() -> InnerStruct { return InnerStruct(); } } + + public func makeOther() -> OuterStruct.InnerClass { + return OuterStruct.InnerClass(); + } } public struct OuterStruct { @@ -28,4 +32,8 @@ public struct OuterStruct { public static func makeOuter() -> OuterStruct { return OuterStruct(); } public static func makeInner() -> InnerStruct { return InnerStruct(); } } + + public func makeOther() -> OuterClass.InnerClass { + return OuterClass.InnerClass(); + } } diff --git a/pkgs/swift2objc/test/integration/nested_types_output.swift b/pkgs/swift2objc/test/integration/nested_types_output.swift index 76654a4a53..c734d2cdca 100644 --- a/pkgs/swift2objc/test/integration/nested_types_output.swift +++ b/pkgs/swift2objc/test/integration/nested_types_output.swift @@ -16,12 +16,17 @@ import Foundation @objc static public func makeInnerClass() -> OuterClassWrapper.InnerClassWrapper { let result = OuterClass.makeInnerClass() - return InnerClassWrapper(result) + return OuterClassWrapper.InnerClassWrapper(result) } @objc static public func makeInnerStruct() -> OuterClassWrapper.InnerStructWrapper { let result = OuterClass.makeInnerStruct() - return InnerStructWrapper(result) + return OuterClassWrapper.InnerStructWrapper(result) + } + + @objc public func makeOther() -> OuterStructWrapper.InnerClassWrapper { + let result = wrappedInstance.makeOther() + return OuterStructWrapper.InnerClassWrapper(result) } @objc public class InnerClassWrapper: NSObject { @@ -78,12 +83,17 @@ import Foundation @objc static public func makeInnerStruct() -> OuterStructWrapper.InnerStructWrapper { let result = OuterStruct.makeInnerStruct() - return InnerStructWrapper(result) + return OuterStructWrapper.InnerStructWrapper(result) } @objc static public func makeInnerClass() -> OuterStructWrapper.InnerClassWrapper { let result = OuterStruct.makeInnerClass() - return InnerClassWrapper(result) + return OuterStructWrapper.InnerClassWrapper(result) + } + + @objc public func makeOther() -> OuterClassWrapper.InnerClassWrapper { + let result = wrappedInstance.makeOther() + return OuterClassWrapper.InnerClassWrapper(result) } @objc public class InnerStructWrapper: NSObject { diff --git a/pkgs/swift2objc/test/integration/operators_input.swift b/pkgs/swift2objc/test/integration/operators_input.swift new file mode 100644 index 0000000000..eaa5f0cb75 --- /dev/null +++ b/pkgs/swift2objc/test/integration/operators_input.swift @@ -0,0 +1,24 @@ +infix operator ***: MultiplicationPrecedence + + +public class Vec2 { + public var x: Double + public var y: Double + + public init(x: Double, y: Double) { + self.x = x + self.y = y + } + + public static func + (lhs: Vec2, rhs: Vec2) -> Vec2 { + return Vec2(x: lhs.x + rhs.x, y: lhs.y + rhs.y) + } + + public static func == (lhs: Vec2, rhs: Vec2) -> Bool { + return lhs.x == rhs.x && lhs.y == rhs.y + } + + public static func *** (lhs: Vec2, rhs: Vec2) -> Double { + return (lhs.x * rhs.x) + (lhs.y * rhs.y) + } +} \ No newline at end of file diff --git a/pkgs/swift2objc/test/integration/operators_output.swift b/pkgs/swift2objc/test/integration/operators_output.swift new file mode 100644 index 0000000000..f7890f4b79 --- /dev/null +++ b/pkgs/swift2objc/test/integration/operators_output.swift @@ -0,0 +1,48 @@ +// Test preamble text + +import Foundation + +@objc public class Vec2Wrapper: NSObject { + var wrappedInstance: Vec2 + + @objc public var x: Double { + get { + wrappedInstance.x + } + set { + wrappedInstance.x = newValue + } + } + + @objc public var y: Double { + get { + wrappedInstance.y + } + set { + wrappedInstance.y = newValue + } + } + + init(_ wrappedInstance: Vec2) { + self.wrappedInstance = wrappedInstance + } + + @objc public init(x: Double, y: Double) { + wrappedInstance = Vec2(x: x, y: y) + } + + @objc static public func add(lhs: Vec2Wrapper, rhs: Vec2Wrapper) -> Vec2Wrapper { + let result = lhs.wrappedInstance + rhs.wrappedInstance + return Vec2Wrapper(result) + } + + @objc static public func equals(lhs: Vec2Wrapper, rhs: Vec2Wrapper) -> Bool { + return lhs.wrappedInstance == rhs.wrappedInstance + } + + @objc static public func operatorOverload(lhs: Vec2Wrapper, rhs: Vec2Wrapper) -> Double { + return lhs.wrappedInstance *** rhs.wrappedInstance + } + +} + diff --git a/pkgs/swift2objc/test/integration/optional_output.swift b/pkgs/swift2objc/test/integration/optional_output.swift index 3c7b52b103..bf2510e0d6 100644 --- a/pkgs/swift2objc/test/integration/optional_output.swift +++ b/pkgs/swift2objc/test/integration/optional_output.swift @@ -7,9 +7,6 @@ import Foundation get { globalOptional == nil ? nil : MyStructWrapper(globalOptional!) } - set { - globalOptional = newValue?.wrappedInstance - } } @objc static public func funcOptionalArgsWrapper(label param: MyClassWrapper?) -> MyClassWrapper { diff --git a/pkgs/swift2objc/test/integration/optional_primitives_input.swift b/pkgs/swift2objc/test/integration/optional_primitives_input.swift new file mode 100644 index 0000000000..84a4670e95 --- /dev/null +++ b/pkgs/swift2objc/test/integration/optional_primitives_input.swift @@ -0,0 +1,12 @@ +import Foundation +public class MyClass { + public func optionalIntReturn() -> Int? { return nil } + public func optionalFloatReturn() -> Float? { return nil } + public func optionalDoubleReturn() -> Double? { return nil } + public func optionalBoolReturn() -> Bool? { return nil } + public func optionalIntArg(label param: Int?) {} + public func optionalBoolArg(label param: Bool?) {} + public var optionalIntProperty: Int? +} +public func globalOptionalIntReturn() -> Int? { return nil } +public func globalOptionalIntArg(label param: Int?) {} \ No newline at end of file diff --git a/pkgs/swift2objc/test/integration/optional_primitives_output.swift b/pkgs/swift2objc/test/integration/optional_primitives_output.swift new file mode 100644 index 0000000000..6e4d2dd0ca --- /dev/null +++ b/pkgs/swift2objc/test/integration/optional_primitives_output.swift @@ -0,0 +1,98 @@ +// Test preamble text + +import Foundation + +@objc public class GlobalsWrapper: NSObject { + @objc static public func globalOptionalIntArgWrapper(label param: IntWrapper?) { + return globalOptionalIntArg(label: param?.wrappedInstance) + } + + @objc static public func globalOptionalIntReturnWrapper() -> IntWrapper? { + let result = globalOptionalIntReturn() + return result == nil ? nil : IntWrapper(result!) + } + +} + +@objc public class MyClassWrapper: NSObject { + var wrappedInstance: MyClass + + @objc public var optionalIntProperty: IntWrapper? { + get { + wrappedInstance.optionalIntProperty == nil ? nil : IntWrapper(wrappedInstance.optionalIntProperty!) + } + set { + wrappedInstance.optionalIntProperty = newValue?.wrappedInstance + } + } + + init(_ wrappedInstance: MyClass) { + self.wrappedInstance = wrappedInstance + } + + @objc public func optionalBoolReturn() -> BoolWrapper? { + let result = wrappedInstance.optionalBoolReturn() + return result == nil ? nil : BoolWrapper(result!) + } + + @objc public func optionalFloatReturn() -> FloatWrapper? { + let result = wrappedInstance.optionalFloatReturn() + return result == nil ? nil : FloatWrapper(result!) + } + + @objc public func optionalDoubleReturn() -> DoubleWrapper? { + let result = wrappedInstance.optionalDoubleReturn() + return result == nil ? nil : DoubleWrapper(result!) + } + + @objc public func optionalIntArg(label param: IntWrapper?) { + return wrappedInstance.optionalIntArg(label: param?.wrappedInstance) + } + + @objc public func optionalBoolArg(label param: BoolWrapper?) { + return wrappedInstance.optionalBoolArg(label: param?.wrappedInstance) + } + + @objc public func optionalIntReturn() -> IntWrapper? { + let result = wrappedInstance.optionalIntReturn() + return result == nil ? nil : IntWrapper(result!) + } + +} + +@objc public class BoolWrapper: NSObject { + var wrappedInstance: Bool + + init(_ wrappedInstance: Bool) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class DoubleWrapper: NSObject { + var wrappedInstance: Double + + init(_ wrappedInstance: Double) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class FloatWrapper: NSObject { + var wrappedInstance: Float + + init(_ wrappedInstance: Float) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class IntWrapper: NSObject { + var wrappedInstance: Int + + init(_ wrappedInstance: Int) { + self.wrappedInstance = wrappedInstance + } + +} + diff --git a/pkgs/swift2objc/test/integration/structs_and_properties_output.swift b/pkgs/swift2objc/test/integration/structs_and_properties_output.swift index b29e6bd3b7..88a24006d4 100644 --- a/pkgs/swift2objc/test/integration/structs_and_properties_output.swift +++ b/pkgs/swift2objc/test/integration/structs_and_properties_output.swift @@ -90,5 +90,9 @@ import Foundation self.wrappedInstance = wrappedInstance } + @objc public init(customVariableProperty: MyOtherStructWrapper, customConstantProperty: MyOtherStructWrapper, representableVariableProperty: Int, representableConstantProperty: Int) { + wrappedInstance = MyStruct(customVariableProperty: customVariableProperty.wrappedInstance, customConstantProperty: customConstantProperty.wrappedInstance, representableVariableProperty: representableVariableProperty, representableConstantProperty: representableConstantProperty) + } + } diff --git a/pkgs/swift2objc/test/integration/tuples_input.swift b/pkgs/swift2objc/test/integration/tuples_input.swift new file mode 100644 index 0000000000..d9a283f581 --- /dev/null +++ b/pkgs/swift2objc/test/integration/tuples_input.swift @@ -0,0 +1,90 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test simple tuple return +public class TupleTest { + + public func getNothing() -> () { + return () + } + + public func getSingleValue() -> (Int) { + return (42) + } + + public func getCoordinates() -> (Int, Int) { + return (10, 20) + } + + public func getLabeledTuple() -> (id: Int, name: String) { + return (id: 42, name: "Alice") + } + + public func getMixedTuple() -> (Int, value: String, Bool) { + return (1, value: "test", true) + } + + // Tuple with optional elements + // TODO(https://github.com/dart-lang/native/issues/1743): Enable this when optional primitives are supported. + // public func getTupleWithOptionals() -> (Int?, String?) { + // return (nil, "test") + // } + + // Deeply nested tuple (3 levels) + public func getDeeplyNestedTuple() -> (Int, (String, (Bool, Double))) { + return (1, ("test", (true, 3.14))) + } + + // Large tuple with many elements + public func getLargeTuple() -> (Int, Int, Int, Int, Int) { + return (1, 2, 3, 4, 5) + } + + // All labeled elements + public func getAllLabeledTuple() -> (x: Int, y: Int, z: String) { + return (x: 10, y: 20, z: "point") + } + + public class NestedTupleTest { + public func getNestedTuple() -> (Int, (String, Bool)) { + return (42, ("test", true)) + } + } + + // Test repeated nested tuples (both elements have the same tuple type) + public func getRepeatedNestedTuple() -> ((Int, String), (Int, String)) { + return ((1, "a"), (2, "b")) + } + // Test tuple with cycle + // TODO(https://github.com/dart-lang/native/issues/1358): Enable this when the bug is fixed. + /* + public func getCircularTuple() -> (Foo, Bar)? { + return nil + } + + public class Foo { + public func getCycle() -> (Foo, Bar) { + return (self, Bar()) + } + } + + public class Bar { + public func getCycle() -> (Foo, Bar) { + return (Foo(), self) + } + } + */ + +// TODO(https://github.com/dart-lang/native/issues/1743): Enable this when optional return types are fully supported. +// public class OptionalTupleTest { +// public func getOptionalTuple() -> (Int, String)? { +// return (1, "test") +// } + +// // Optional nested tuple +// public func getOptionalNestedTuple() -> (Int, (String, Bool)?) { +// return (42, nil) +// } +// } +} \ No newline at end of file diff --git a/pkgs/swift2objc/test/integration/tuples_output.swift b/pkgs/swift2objc/test/integration/tuples_output.swift new file mode 100644 index 0000000000..603db3b2d4 --- /dev/null +++ b/pkgs/swift2objc/test/integration/tuples_output.swift @@ -0,0 +1,439 @@ +// Test preamble text + +import Foundation + +@objc public class TupleTestWrapper: NSObject { + var wrappedInstance: TupleTest + + init(_ wrappedInstance: TupleTest) { + self.wrappedInstance = wrappedInstance + } + + @objc public func getLabeledTuple() -> Tuple_id_Int_name_String { + let result = wrappedInstance.getLabeledTuple() + return Tuple_id_Int_name_String(result) + } + + @objc public func getAllLabeledTuple() -> Tuple_x_Int_y_Int_z_String { + let result = wrappedInstance.getAllLabeledTuple() + return Tuple_x_Int_y_Int_z_String(result) + } + + @objc public func getDeeplyNestedTuple() -> Tuple_Int_StringBoolDouble { + let result = wrappedInstance.getDeeplyNestedTuple() + return Tuple_Int_StringBoolDouble(result) + } + + @objc public func getRepeatedNestedTuple() -> Tuple_IntString_IntString { + let result = wrappedInstance.getRepeatedNestedTuple() + return Tuple_IntString_IntString(result) + } + + @objc public func getLargeTuple() -> Tuple_Int_Int_Int_Int_Int { + let result = wrappedInstance.getLargeTuple() + return Tuple_Int_Int_Int_Int_Int(result) + } + + @objc public func getMixedTuple() -> Tuple_Int_value_String_Bool { + let result = wrappedInstance.getMixedTuple() + return Tuple_Int_value_String_Bool(result) + } + + @objc public func getNothing() { + return wrappedInstance.getNothing() + } + + @objc public func getCoordinates() -> Tuple_Int_Int { + let result = wrappedInstance.getCoordinates() + return Tuple_Int_Int(result) + } + + @objc public func getSingleValue() -> Int { + return wrappedInstance.getSingleValue() + } + + @objc public class NestedTupleTestWrapper: NSObject { + var wrappedInstance: TupleTest.NestedTupleTest + + init(_ wrappedInstance: TupleTest.NestedTupleTest) { + self.wrappedInstance = wrappedInstance + } + + @objc public func getNestedTuple() -> Tuple_Int_StringBool { + let result = wrappedInstance.getNestedTuple() + return Tuple_Int_StringBool(result) + } + + } + +} + +@objc public class Tuple_Bool_Double: NSObject { + var wrappedInstance: (Bool, Double) + + @objc public var _0: Bool { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Double { + get { + wrappedInstance.1 + } + set { + wrappedInstance.1 = newValue + } + } + + init(_ wrappedInstance: (Bool, Double)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_IntString_IntString: NSObject { + var wrappedInstance: ((Int, String), (Int, String)) + + @objc public var _0: Tuple_Int_String { + get { + Tuple_Int_String(wrappedInstance.0) + } + set { + wrappedInstance.0 = newValue.wrappedInstance + } + } + + @objc public var _1: Tuple_Int_String { + get { + Tuple_Int_String(wrappedInstance.1) + } + set { + wrappedInstance.1 = newValue.wrappedInstance + } + } + + init(_ wrappedInstance: ((Int, String), (Int, String))) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_Int_Int: NSObject { + var wrappedInstance: (Int, Int) + + @objc public var _0: Int { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Int { + get { + wrappedInstance.1 + } + set { + wrappedInstance.1 = newValue + } + } + + init(_ wrappedInstance: (Int, Int)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_Int_Int_Int_Int_Int: NSObject { + var wrappedInstance: (Int, Int, Int, Int, Int) + + @objc public var _0: Int { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Int { + get { + wrappedInstance.1 + } + set { + wrappedInstance.1 = newValue + } + } + + @objc public var _2: Int { + get { + wrappedInstance.2 + } + set { + wrappedInstance.2 = newValue + } + } + + @objc public var _3: Int { + get { + wrappedInstance.3 + } + set { + wrappedInstance.3 = newValue + } + } + + @objc public var _4: Int { + get { + wrappedInstance.4 + } + set { + wrappedInstance.4 = newValue + } + } + + init(_ wrappedInstance: (Int, Int, Int, Int, Int)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_Int_String: NSObject { + var wrappedInstance: (Int, String) + + @objc public var _0: Int { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: String { + get { + wrappedInstance.1 + } + set { + wrappedInstance.1 = newValue + } + } + + init(_ wrappedInstance: (Int, String)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_Int_StringBool: NSObject { + var wrappedInstance: (Int, (String, Bool)) + + @objc public var _0: Int { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Tuple_String_Bool { + get { + Tuple_String_Bool(wrappedInstance.1) + } + set { + wrappedInstance.1 = newValue.wrappedInstance + } + } + + init(_ wrappedInstance: (Int, (String, Bool))) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_Int_StringBoolDouble: NSObject { + var wrappedInstance: (Int, (String, (Bool, Double))) + + @objc public var _0: Int { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Tuple_String_BoolDouble { + get { + Tuple_String_BoolDouble(wrappedInstance.1) + } + set { + wrappedInstance.1 = newValue.wrappedInstance + } + } + + init(_ wrappedInstance: (Int, (String, (Bool, Double)))) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_Int_value_String_Bool: NSObject { + var wrappedInstance: (Int, value: String, Bool) + + @objc public var _0: Int { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var value: String { + get { + wrappedInstance.value + } + set { + wrappedInstance.value = newValue + } + } + + @objc public var _2: Bool { + get { + wrappedInstance.2 + } + set { + wrappedInstance.2 = newValue + } + } + + init(_ wrappedInstance: (Int, value: String, Bool)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_String_Bool: NSObject { + var wrappedInstance: (String, Bool) + + @objc public var _0: String { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Bool { + get { + wrappedInstance.1 + } + set { + wrappedInstance.1 = newValue + } + } + + init(_ wrappedInstance: (String, Bool)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_String_BoolDouble: NSObject { + var wrappedInstance: (String, (Bool, Double)) + + @objc public var _0: String { + get { + wrappedInstance.0 + } + set { + wrappedInstance.0 = newValue + } + } + + @objc public var _1: Tuple_Bool_Double { + get { + Tuple_Bool_Double(wrappedInstance.1) + } + set { + wrappedInstance.1 = newValue.wrappedInstance + } + } + + init(_ wrappedInstance: (String, (Bool, Double))) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_id_Int_name_String: NSObject { + var wrappedInstance: (id: Int, name: String) + + @objc public var id: Int { + get { + wrappedInstance.id + } + set { + wrappedInstance.id = newValue + } + } + + @objc public var name: String { + get { + wrappedInstance.name + } + set { + wrappedInstance.name = newValue + } + } + + init(_ wrappedInstance: (id: Int, name: String)) { + self.wrappedInstance = wrappedInstance + } + +} + +@objc public class Tuple_x_Int_y_Int_z_String: NSObject { + var wrappedInstance: (x: Int, y: Int, z: String) + + @objc public var x: Int { + get { + wrappedInstance.x + } + set { + wrappedInstance.x = newValue + } + } + + @objc public var y: Int { + get { + wrappedInstance.y + } + set { + wrappedInstance.y = newValue + } + } + + @objc public var z: String { + get { + wrappedInstance.z + } + set { + wrappedInstance.z = newValue + } + } + + init(_ wrappedInstance: (x: Int, y: Int, z: String)) { + self.wrappedInstance = wrappedInstance + } + +} + diff --git a/pkgs/swift2objc/test/unit/implicit_initializer_test.dart b/pkgs/swift2objc/test/unit/implicit_initializer_test.dart new file mode 100644 index 0000000000..bc3fc00e0f --- /dev/null +++ b/pkgs/swift2objc/test/unit/implicit_initializer_test.dart @@ -0,0 +1,170 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:swift2objc/src/ast/declarations/built_in/built_in_declaration.dart'; +import 'package:swift2objc/src/ast/declarations/compounds/members/initializer_declaration.dart'; +import 'package:swift2objc/src/ast/declarations/compounds/members/property_declaration.dart'; +import 'package:swift2objc/src/ast/declarations/compounds/struct_declaration.dart'; +import 'package:swift2objc/src/transformer/_core/unique_namer.dart'; +import 'package:swift2objc/src/transformer/transform.dart'; +import 'package:swift2objc/src/transformer/transformers/transform_compound.dart'; +import 'package:test/test.dart'; + +void main() { + group('Implicit Initializer Generation', () { + test('generates implicit init for struct with stored properties', () { + final struct = StructDeclaration( + id: 'TestStruct', + name: 'Person', + source: null, + availability: [], + properties: [ + PropertyDeclaration( + id: 'TestStruct::name', + name: 'name', + lineNumber: 1, + source: null, + availability: [], + type: stringType, + hasSetter: true, + isStatic: false, + ), + PropertyDeclaration( + id: 'TestStruct::age', + name: 'age', + lineNumber: 2, + source: null, + availability: [], + type: intType, + hasSetter: true, + isStatic: false, + ), + ], + initializers: [], + ); + + final state = TransformationState(); + final result = transformCompound(struct, UniqueNamer(), state); + + expect(result.initializers.length, equals(1)); + expect(result.initializers.first.params.length, equals(2)); + expect(result.initializers.first.params[0].name, equals('name')); + expect(result.initializers.first.params[1].name, equals('age')); + }); + + test('does not generate implicit init when explicit init exists', () { + final struct = StructDeclaration( + id: 'TestStruct', + name: 'Person', + source: null, + availability: [], + properties: [ + PropertyDeclaration( + id: 'TestStruct::name', + name: 'name', + source: null, + availability: [], + type: stringType, + hasSetter: true, + isStatic: false, + ), + ], + initializers: [ + // Has explicit initializer + InitializerDeclaration( + id: 'TestStruct::init', + source: null, + availability: [], + params: [], + hasObjCAnnotation: true, + isOverriding: false, + throws: false, + async: false, + isFailable: false, + ), + ], + ); + + final state = TransformationState(); + final result = transformCompound(struct, UniqueNamer(), state); + + expect(result.initializers.length, equals(1)); + }); + + test('excludes static properties from implicit init', () { + final struct = StructDeclaration( + id: 'TestStruct', + name: 'Config', + source: null, + availability: [], + properties: [ + PropertyDeclaration( + id: 'TestStruct::name', + name: 'name', + source: null, + availability: [], + type: stringType, + hasSetter: true, + isStatic: false, + ), + PropertyDeclaration( + id: 'TestStruct::defaultName', + name: 'defaultName', + source: null, + availability: [], + type: stringType, + hasSetter: true, + isStatic: true, + ), + ], + initializers: [], + ); + + final state = TransformationState(); + final result = transformCompound(struct, UniqueNamer(), state); + + expect(result.initializers.length, equals(1)); + expect(result.initializers.first.params.length, equals(1)); + expect(result.initializers.first.params[0].name, equals('name')); + }); + + test('excludes computed properties (no setter) from implicit init', () { + final struct = StructDeclaration( + id: 'TestStruct', + name: 'Person', + source: null, + availability: [], + properties: [ + PropertyDeclaration( + id: 'TestStruct::firstName', + name: 'firstName', + source: null, + availability: [], + type: stringType, + hasSetter: true, + isStatic: false, + ), + PropertyDeclaration( + id: 'TestStruct::fullName', + name: 'fullName', + source: null, + availability: [], + type: stringType, + hasSetter: false, + isStatic: false, + hasExplicitGetter: true, + ), + ], + initializers: [], + ); + + final state = TransformationState(); + final result = transformCompound(struct, UniqueNamer(), state); + + expect(result.initializers.length, equals(1)); + expect(result.initializers.first.params.length, equals(1)); + expect(result.initializers.first.params[0].name, equals('firstName')); + }); + }); +} diff --git a/pkgs/swift2objc/test/unit/parse_function_info_test.dart b/pkgs/swift2objc/test/unit/parse_function_info_test.dart index 9ca96c3115..60e10f1b49 100644 --- a/pkgs/swift2objc/test/unit/parse_function_info_test.dart +++ b/pkgs/swift2objc/test/unit/parse_function_info_test.dart @@ -21,23 +21,24 @@ void main() { decl.id: ParsedSymbol(source: null, json: Json(null), declaration: decl), }; final emptySymbolgraph = ParsedSymbolgraph(symbols: parsedSymbols); - group('Function Valid json', () { - void expectEqualParams( - List actualParams, - List expectedParams, - ) { - expect(actualParams.length, expectedParams.length); - - for (var i = 0; i < actualParams.length; i++) { - final actualParam = actualParams[i]; - final expectedParam = expectedParams[i]; - - expect(actualParam.name, expectedParam.name); - expect(actualParam.internalName, expectedParam.internalName); - expect(actualParam.type.sameAs(expectedParam.type), isTrue); - } + + void expectEqualParams( + List actualParams, + List expectedParams, + ) { + expect(actualParams.length, expectedParams.length); + + for (var i = 0; i < actualParams.length; i++) { + final actualParam = actualParams[i]; + final expectedParam = expectedParams[i]; + + expect(actualParam.name, expectedParam.name); + expect(actualParam.internalName, expectedParam.internalName); + expect(actualParam.type.sameAs(expectedParam.type), isTrue); } + } + group('Function Valid json', () { test('Two params with one internal name', () { final json = Json( jsonDecode(''' @@ -585,4 +586,161 @@ void main() { ); }); }); + + group('Operator functions', () { + test('Operator with two params (internalParam only)', () { + final json = Json( + jsonDecode(''' + [ + { "kind": "keyword", "spelling": "static" }, + { "kind": "text", "spelling": " " }, + { "kind": "keyword", "spelling": "func" }, + { "kind": "text", "spelling": " " }, + { "kind": "identifier", "spelling": "+" }, + { "kind": "text", "spelling": " " }, + { "kind": "text", "spelling": "(" }, + { "kind": "internalParam", "spelling": "lhs" }, + { "kind": "text", "spelling": ": " }, + { + "kind": "typeIdentifier", + "spelling": "Int", + "preciseIdentifier": "s:Si" + }, + { "kind": "text", "spelling": ", " }, + { "kind": "internalParam", "spelling": "rhs" }, + { "kind": "text", "spelling": ": " }, + { + "kind": "typeIdentifier", + "spelling": "Int", + "preciseIdentifier": "s:Si" + }, + { "kind": "text", "spelling": ") -> " }, + { + "kind": "typeIdentifier", + "spelling": "Int", + "preciseIdentifier": "s:Si" + } + ] + '''), + ); + + final info = parseFunctionInfo( + context, + json, + emptySymbolgraph, + isOperator: true, + ); + + final expectedParams = [ + Parameter(name: 'lhs', type: intType), + Parameter(name: 'rhs', type: intType), + ]; + + expectEqualParams(info.params, expectedParams); + expect(info.throws, isFalse); + expect(info.async, isFalse); + }); + + test('Custom operator ***', () { + final json = Json( + jsonDecode(''' + [ + { "kind": "keyword", "spelling": "static" }, + { "kind": "text", "spelling": " " }, + { "kind": "keyword", "spelling": "func" }, + { "kind": "text", "spelling": " " }, + { "kind": "identifier", "spelling": "***" }, + { "kind": "text", "spelling": " " }, + { "kind": "text", "spelling": "(" }, + { "kind": "internalParam", "spelling": "lhs" }, + { "kind": "text", "spelling": ": " }, + { + "kind": "typeIdentifier", + "spelling": "Double", + "preciseIdentifier": "s:Sd" + }, + { "kind": "text", "spelling": ", " }, + { "kind": "internalParam", "spelling": "rhs" }, + { "kind": "text", "spelling": ": " }, + { + "kind": "typeIdentifier", + "spelling": "Double", + "preciseIdentifier": "s:Sd" + }, + { "kind": "text", "spelling": ") -> " }, + { + "kind": "typeIdentifier", + "spelling": "Double", + "preciseIdentifier": "s:Sd" + } + ] + '''), + ); + + final info = parseFunctionInfo( + context, + json, + emptySymbolgraph, + isOperator: true, + ); + + final expectedParams = [ + Parameter(name: 'lhs', type: doubleType), + Parameter(name: 'rhs', type: doubleType), + ]; + + expectEqualParams(info.params, expectedParams); + expect(info.throws, isFalse); + expect(info.async, isFalse); + }); + + test('Operator parameters should have no internalName', () { + final json = Json( + jsonDecode(''' + [ + { "kind": "keyword", "spelling": "static" }, + { "kind": "text", "spelling": " " }, + { "kind": "keyword", "spelling": "func" }, + { "kind": "text", "spelling": " " }, + { "kind": "identifier", "spelling": "==" }, + { "kind": "text", "spelling": " " }, + { "kind": "text", "spelling": "(" }, + { "kind": "internalParam", "spelling": "lhs" }, + { "kind": "text", "spelling": ": " }, + { + "kind": "typeIdentifier", + "spelling": "Int", + "preciseIdentifier": "s:Si" + }, + { "kind": "text", "spelling": ", " }, + { "kind": "internalParam", "spelling": "rhs" }, + { "kind": "text", "spelling": ": " }, + { + "kind": "typeIdentifier", + "spelling": "Int", + "preciseIdentifier": "s:Si" + }, + { "kind": "text", "spelling": ") -> " }, + { + "kind": "typeIdentifier", + "spelling": "Bool", + "preciseIdentifier": "s:Sb" + } + ] + '''), + ); + + final info = parseFunctionInfo( + context, + json, + emptySymbolgraph, + isOperator: true, + ); + + expect(info.params[0].name, equals('lhs')); + expect(info.params[0].internalName, isNull); + expect(info.params[1].name, equals('rhs')); + expect(info.params[1].internalName, isNull); + }); + }); } diff --git a/pkgs/swift2objc/test/unit/parse_type_test.dart b/pkgs/swift2objc/test/unit/parse_type_test.dart index 491f1b3399..13d326a0c3 100644 --- a/pkgs/swift2objc/test/unit/parse_type_test.dart +++ b/pkgs/swift2objc/test/unit/parse_type_test.dart @@ -67,6 +67,68 @@ void main() { expect(remaining.length, 0); }); + test('Inout', () { + final fragments = Json( + jsonDecode(''' + [ + { + "kind": "keyword", + "spelling": "inout" + }, + { + "kind": "text", + "spelling": " " + }, + { + "kind": "typeIdentifier", + "spelling": "Int", + "preciseIdentifier": "s:Si" + } + ] + '''), + ); + + final (type, remaining) = parseType( + context, + parsedSymbols, + TokenList(fragments), + ); + + expect(type.sameAs(InoutType(intType)), isTrue); + expect(remaining.length, 0); + }); + + test('Inout non-primitive', () { + final fragments = Json( + jsonDecode(''' + [ + { + "kind": "keyword", + "spelling": "inout" + }, + { + "kind": "text", + "spelling": " " + }, + { + "kind": "typeIdentifier", + "spelling": "Foo", + "preciseIdentifier": "Foo" + } + ] + '''), + ); + + final (type, remaining) = parseType( + context, + parsedSymbols, + TokenList(fragments), + ); + + expect(type.sameAs(InoutType(classFoo.asDeclaredType)), isTrue); + expect(remaining.length, 0); + }); + test('Empty tuple', () { final fragments = Json( jsonDecode(''' @@ -226,4 +288,94 @@ void main() { expect(type.sameAs(OptionalType(intType)), isTrue); expect(remaining.length, 2); }); + + test('Labeled and Nested Tuple', () { + final fragments = Json( + jsonDecode(''' + [ + {"kind": "text", "spelling": "("}, + {"kind": "text", "spelling": "id"}, + {"kind": "text", "spelling": ": "}, + {"kind": "typeIdentifier", "spelling": "Int", "preciseIdentifier": "s:Si"}, + {"kind": "text", "spelling": ", "}, + {"kind": "text", "spelling": "data"}, + {"kind": "text", "spelling": ": "}, + {"kind": "text", "spelling": "("}, + {"kind": "typeIdentifier", "spelling": "String", "preciseIdentifier": "s:SS"}, + {"kind": "text", "spelling": ", "}, + {"kind": "typeIdentifier", "spelling": "Bool", "preciseIdentifier": "s:Sb"}, + {"kind": "text", "spelling": ")"}, + {"kind": "text", "spelling": ")"} + ] + '''), + ); + + final (type, remaining) = parseType( + context, + parsedSymbols, + TokenList(fragments), + ); + + expect(type is TupleType, isTrue); + final tuple = type as TupleType; + + // Verify first level + expect(tuple.elements.length, 2); + expect(tuple.elements[0].label, 'id'); + expect(tuple.elements[1].label, 'data'); + + // Verify nesting + final nestedTuple = tuple.elements[1].type as TupleType; + expect(nestedTuple.elements.length, 2); + expect(nestedTuple.elements[0].type.swiftType, 'String'); + expect(remaining.length, 0); + }); + test('Simple unlabeled tuple', () { + final fragments = Json( + jsonDecode(''' + [ + {"kind": "text", "spelling": "("}, + {"kind": "typeIdentifier", "spelling": "Int", "preciseIdentifier": "s:Si"}, + {"kind": "text", "spelling": ", "}, + {"kind": "typeIdentifier", "spelling": "String", "preciseIdentifier": "s:SS"}, + {"kind": "text", "spelling": ")"} + ] + '''), + ); + + final (type, remaining) = parseType( + context, + parsedSymbols, + TokenList(fragments), + ); + + expect(type is TupleType, isTrue); + final tuple = type as TupleType; + expect(tuple.elements.length, 2); + expect(tuple.elements[0].label, isNull); + expect(tuple.elements[1].label, isNull); + expect(tuple.elements[0].type.swiftType, 'Int'); + expect(tuple.elements[1].type.swiftType, 'String'); + expect(remaining.length, 0); + }); + + test('Empty tuple (Void)', () { + final fragments = Json( + jsonDecode(''' + [ + {"kind": "text", "spelling": "("}, + {"kind": "text", "spelling": ")"} + ] + '''), + ); + + final (type, remaining) = parseType( + context, + parsedSymbols, + TokenList(fragments), + ); + + expect(type, voidType); + expect(remaining.length, 0); + }); } diff --git a/pkgs/swift2objc/test/unit/unique_namer_test.dart b/pkgs/swift2objc/test/unit/unique_namer_test.dart new file mode 100644 index 0000000000..13ac8cf193 --- /dev/null +++ b/pkgs/swift2objc/test/unit/unique_namer_test.dart @@ -0,0 +1,49 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:swift2objc/src/transformer/_core/unique_namer.dart'; +import 'package:test/test.dart'; + +void main() { + group('UniqueNamer Sanitization Tests', () { + late UniqueNamer namer; + + setUp(() { + namer = UniqueNamer(); + }); + + test('converts basic operators to valid names', () { + expect(namer.makeUnique('+'), equals('add')); + expect(namer.makeUnique('-'), equals('subtract')); + expect(namer.makeUnique('=='), equals('equals')); + }); + + test('handles custom multi-character operators', () { + expect(namer.makeUnique('***'), equals('operatorOverload')); + }); + + test('falls back to ASCII for unknown symbols', () { + final result = namer.makeUnique(r'$'); + expect(result, equals('operatorOverload')); + }); + + test('preserves uniqueness even after sanitization', () { + namer.makeUnique('add'); + expect(namer.makeUnique('+'), equals('add1')); + }); + + test('handles mixed alphanumeric and symbols', () { + expect(namer.makeUnique('set+value'), equals('operatorOverload')); + }); + + test('returns unnamed for empty strings', () { + expect(namer.makeUnique(''), equals('unnamed')); + }); + + test('handles multiple mixed alphanumeric and symbols', () { + expect(namer.makeUnique('set+value'), equals('operatorOverload')); + expect(namer.makeUnique('get-item'), equals('operatorOverload1')); + }); + }); +} diff --git a/pkgs/swiftgen/example/avf_audio_bindings.dart b/pkgs/swiftgen/example/avf_audio_bindings.dart index 3bd6ffa250..38d8da0335 100644 --- a/pkgs/swiftgen/example/avf_audio_bindings.dart +++ b/pkgs/swiftgen/example/avf_audio_bindings.dart @@ -482,11 +482,13 @@ extension type AVAudioPlayerWrapper._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [AVAudioPlayerWrapper]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_AVAudioPlayerWrapper, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_AVAudioPlayerWrapper, + ); /// alloc static AVAudioPlayerWrapper alloc() { diff --git a/pkgs/swiftgen/example/pubspec.yaml b/pkgs/swiftgen/example/pubspec.yaml index 4e74884e1c..8daae28c07 100644 --- a/pkgs/swiftgen/example/pubspec.yaml +++ b/pkgs/swiftgen/example/pubspec.yaml @@ -12,9 +12,9 @@ environment: dependencies: ffi: ^2.1.0 - ffigen: ^20.0.0 + ffigen: ^20.1.1 logging: ^1.3.0 - objective_c: ^9.1.0-dev + objective_c: ^9.2.3 pub_semver: ^2.2.0 swift2objc: ^0.1.0 swiftgen: diff --git a/pkgs/swiftgen/pubspec.yaml b/pkgs/swiftgen/pubspec.yaml index 316fcadd34..e8bc9d7f02 100644 --- a/pkgs/swiftgen/pubspec.yaml +++ b/pkgs/swiftgen/pubspec.yaml @@ -19,9 +19,9 @@ environment: dependencies: ffi: ^2.1.0 - ffigen: ^20.0.0 + ffigen: ^20.1.1 logging: ^1.3.0 - objective_c: ^9.2.0 + objective_c: ^9.2.3 package_config: ^2.2.0 path: ^1.9.1 swift2objc: ^0.1.0 diff --git a/pkgs/swiftgen/test/integration/callbacks.swift b/pkgs/swiftgen/test/integration/callbacks.swift new file mode 100644 index 0000000000..4711bc45b4 --- /dev/null +++ b/pkgs/swiftgen/test/integration/callbacks.swift @@ -0,0 +1,18 @@ +import Foundation + +@objc class TestMessageService: NSObject { + @objc static func fetchGreeting(completion: @escaping (String) -> Void) { + DispatchQueue.global().asyncAfter(deadline: .now() + 0.1) { + completion("Hello from Swift!") + } + } + + @objc static func fetchGreetingAsync() async -> String { + try? await Task.sleep(for: .seconds(0.1)) + return "Hello from Swift async!" + } + + @objc static func echoAsyncObject(anObject: NSObject) async -> NSObject? { + return anObject + } +} diff --git a/pkgs/swiftgen/test/integration/callbacks_bindings.dart b/pkgs/swiftgen/test/integration/callbacks_bindings.dart new file mode 100644 index 0000000000..41222b16a9 --- /dev/null +++ b/pkgs/swiftgen/test/integration/callbacks_bindings.dart @@ -0,0 +1,743 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// coverage:ignore-file + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint, unused_import +import 'dart:ffi' as ffi; +import 'package:objective_c/objective_c.dart' as objc; +import 'package:ffi/ffi.dart' as pkg_ffi; + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer _17w5sbb_wrapBlockingBlock_xtuoz7( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); + +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer _17w5sbb_wrapListenerBlock_xtuoz7( + ffi.Pointer block, +); + +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSObject { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSObject?) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSObject.fromPointer(arg0, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSObject?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSObject.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _17w5sbb_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSObject?) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSObject.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => fn( + arg0.address == 0 + ? null + : objc.NSObject.fromPointer(arg0, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _17w5sbb_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); + } + + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ) { + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} + +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSObject$CallExtension + on objc.ObjCBlock { + void call(objc.NSObject? arg0) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0?.ref.pointer ?? ffi.nullptr); +} + +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSString { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSString) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: true, release: true)), + keepIsolateAlive, + ), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSString) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final wrapper = _17w5sbb_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSString) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final wrapper = _17w5sbb_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); + } + + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ) { + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} + +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSString$CallExtension + on objc.ObjCBlock { + void call(objc.NSString arg0) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0.ref.pointer); +} + +/// TestMessageService +extension type TestMessageService._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [TestMessageService] that points to the same underlying object as [other]. + TestMessageService.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [TestMessageService] that wraps the given raw object pointer. + TestMessageService.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); + } + + /// Returns whether [obj] is an instance of [TestMessageService]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_TestMessageService, + ); + + /// alloc + static TestMessageService alloc() { + final $ret = _objc_msgSend_151sglz(_class_TestMessageService, _sel_alloc); + return TestMessageService.fromPointer($ret, retain: false, release: true); + } + + /// allocWithZone: + static TestMessageService allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_TestMessageService, + _sel_allocWithZone_, + zone, + ); + return TestMessageService.fromPointer($ret, retain: false, release: true); + } + + /// echoAsyncObjectWithAnObject:completionHandler: + static void echoAsyncObjectWithAnObject( + objc.NSObject anObject, { + required objc.ObjCBlock + completionHandler, + }) { + _objc_msgSend_o762yo( + _class_TestMessageService, + _sel_echoAsyncObjectWithAnObject_completionHandler_, + anObject.ref.pointer, + completionHandler.ref.pointer, + ); + } + + /// fetchGreetingAsyncWithCompletionHandler: + static void fetchGreetingAsyncWithCompletionHandler( + objc.ObjCBlock completionHandler, + ) { + _objc_msgSend_f167m6( + _class_TestMessageService, + _sel_fetchGreetingAsyncWithCompletionHandler_, + completionHandler.ref.pointer, + ); + } + + /// fetchGreetingWithCompletion: + static void fetchGreetingWithCompletion( + objc.ObjCBlock completion, + ) { + _objc_msgSend_f167m6( + _class_TestMessageService, + _sel_fetchGreetingWithCompletion_, + completion.ref.pointer, + ); + } + + /// new + static TestMessageService new$() { + final $ret = _objc_msgSend_151sglz(_class_TestMessageService, _sel_new); + return TestMessageService.fromPointer($ret, retain: false, release: true); + } + + /// Returns a new instance of TestMessageService constructed with the default `new` method. + TestMessageService() : this.as(new$().object$); +} + +extension TestMessageService$Methods on TestMessageService { + /// init + TestMessageService init() { + objc.checkOsVersionInternal( + 'TestMessageService.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return TestMessageService.fromPointer($ret, retain: false, release: true); + } +} + +late final _class_TestMessageService = objc.getClass( + "callbacks.TestMessageService", +); +final _objc_msgSend_151sglz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_19nvye5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1cwp428 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_f167m6 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_o762yo = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_alloc = objc.registerName("alloc"); +late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); +late final _sel_echoAsyncObjectWithAnObject_completionHandler_ = objc + .registerName("echoAsyncObjectWithAnObject:completionHandler:"); +late final _sel_fetchGreetingAsyncWithCompletionHandler_ = objc.registerName( + "fetchGreetingAsyncWithCompletionHandler:", +); +late final _sel_fetchGreetingWithCompletion_ = objc.registerName( + "fetchGreetingWithCompletion:", +); +late final _sel_init = objc.registerName("init"); +late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); +late final _sel_new = objc.registerName("new"); +typedef instancetype = ffi.Pointer; +typedef Dartinstancetype = objc.ObjCObject; diff --git a/pkgs/swiftgen/test/integration/callbacks_test.dart b/pkgs/swiftgen/test/integration/callbacks_test.dart new file mode 100644 index 0000000000..8f09f41042 --- /dev/null +++ b/pkgs/swiftgen/test/integration/callbacks_test.dart @@ -0,0 +1,56 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +@Timeout(Duration(minutes: 2)) +library; + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:objective_c/objective_c.dart'; +import 'package:test/test.dart'; + +import 'callbacks_bindings.dart'; +import 'util.dart'; + +void main() { + group('Callbacks', () { + setUpAll(() async { + final gen = TestGenerator('callbacks'); + await gen.generateAndVerifyBindings(); + DynamicLibrary.open(gen.dylibFile); + }); + + test('callback', () async { + final result = Completer(); + TestMessageService.fetchGreetingWithCompletion( + ObjCBlock_ffiVoid_NSString.listener((NSString msg) { + result.complete(msg.toDartString()); + }), + ); + expect(await result.future, 'Hello from Swift!'); + }); + + test('async', () async { + final result = Completer(); + TestMessageService.fetchGreetingAsyncWithCompletionHandler( + ObjCBlock_ffiVoid_NSString.listener((NSString msg) { + result.complete(msg.toDartString()); + }), + ); + expect(await result.future, 'Hello from Swift async!'); + }); + + test('regress #2592', () async { + // Regression test for https://github.com/dart-lang/native/issues/2952. + final theObject = NSObject(); + final result = Completer(); + TestMessageService.echoAsyncObjectWithAnObject( + theObject, + completionHandler: ObjCBlock_ffiVoid_NSObject.listener(result.complete), + ); + expect(await result.future, theObject); + }); + }); +} diff --git a/pkgs/swiftgen/test/integration/classes_bindings.dart b/pkgs/swiftgen/test/integration/classes_bindings.dart index 4184225845..d8d9b4bfc6 100644 --- a/pkgs/swiftgen/test/integration/classes_bindings.dart +++ b/pkgs/swiftgen/test/integration/classes_bindings.dart @@ -12,85 +12,85 @@ import 'dart:ffi' as ffi; import 'package:objective_c/objective_c.dart' as objc; import 'package:ffi/ffi.dart' as pkg_ffi; -late final _class_TestClassWrapper = objc.getClass("classes.TestClassWrapper"); -late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); -final _objc_msgSend_19nvye5 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - bool Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_create = objc.registerName("create"); -final _objc_msgSend_151sglz = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _class_TestOtherClassWrapper = objc.getClass( - "classes.TestOtherClassWrapper", -); -late final _sel_times10WithX_ = objc.registerName("times10WithX:"); -final _objc_msgSend_12hwf9n = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Long Function( - ffi.Pointer, - ffi.Pointer, - ffi.Long, - ) - > - >() - .asFunction< - int Function( - ffi.Pointer, - ffi.Pointer, - int, - ) - >(); -typedef instancetype = ffi.Pointer; -typedef Dartinstancetype = objc.ObjCObject; -late final _sel_init = objc.registerName("init"); -late final _sel_new = objc.registerName("new"); -late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); -final _objc_msgSend_1cwp428 = objc.msgSendPointer - .cast< - ffi.NativeFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - > - >() - .asFunction< - ffi.Pointer Function( - ffi.Pointer, - ffi.Pointer, - ffi.Pointer, - ) - >(); -late final _sel_alloc = objc.registerName("alloc"); +/// TestClassWrapper +extension type TestClassWrapper._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [TestClassWrapper] that points to the same underlying object as [other]. + TestClassWrapper.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [TestClassWrapper] that wraps the given raw object pointer. + TestClassWrapper.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); + } + + /// Returns whether [obj] is an instance of [TestClassWrapper]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_TestClassWrapper, + ); + + /// alloc + static TestClassWrapper alloc() { + final $ret = _objc_msgSend_151sglz(_class_TestClassWrapper, _sel_alloc); + return TestClassWrapper.fromPointer($ret, retain: false, release: true); + } + + /// allocWithZone: + static TestClassWrapper allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_TestClassWrapper, + _sel_allocWithZone_, + zone, + ); + return TestClassWrapper.fromPointer($ret, retain: false, release: true); + } + + /// create + static TestClassWrapper create() { + final $ret = _objc_msgSend_151sglz(_class_TestClassWrapper, _sel_create); + return TestClassWrapper.fromPointer($ret, retain: true, release: true); + } + + /// new + static TestClassWrapper new$() { + final $ret = _objc_msgSend_151sglz(_class_TestClassWrapper, _sel_new); + return TestClassWrapper.fromPointer($ret, retain: false, release: true); + } + + /// Returns a new instance of TestClassWrapper constructed with the default `new` method. + TestClassWrapper() : this.as(new$().object$); +} + +extension TestClassWrapper$Methods on TestClassWrapper { + /// init + TestClassWrapper init() { + objc.checkOsVersionInternal( + 'TestClassWrapper.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return TestClassWrapper.fromPointer($ret, retain: false, release: true); + } + + /// myMethod + TestOtherClassWrapper myMethod() { + final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_myMethod); + return TestOtherClassWrapper.fromPointer($ret, retain: true, release: true); + } +} /// TestOtherClassWrapper extension type TestOtherClassWrapper._(objc.ObjCObject object$) @@ -110,11 +110,13 @@ extension type TestOtherClassWrapper._(objc.ObjCObject object$) } /// Returns whether [obj] is an instance of [TestOtherClassWrapper]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_TestOtherClassWrapper, - ); + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_TestOtherClassWrapper, + ); /// alloc static TestOtherClassWrapper alloc() { @@ -182,82 +184,83 @@ extension TestOtherClassWrapper$Methods on TestOtherClassWrapper { } } +late final _class_TestClassWrapper = objc.getClass("classes.TestClassWrapper"); +late final _class_TestOtherClassWrapper = objc.getClass( + "classes.TestOtherClassWrapper", +); +final _objc_msgSend_12hwf9n = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Long Function( + ffi.Pointer, + ffi.Pointer, + ffi.Long, + ) + > + >() + .asFunction< + int Function( + ffi.Pointer, + ffi.Pointer, + int, + ) + >(); +final _objc_msgSend_151sglz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_19nvye5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1cwp428 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _sel_alloc = objc.registerName("alloc"); +late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); +late final _sel_create = objc.registerName("create"); +late final _sel_init = objc.registerName("init"); +late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); late final _sel_myMethod = objc.registerName("myMethod"); - -/// TestClassWrapper -extension type TestClassWrapper._(objc.ObjCObject object$) - implements objc.ObjCObject, objc.NSObject { - /// Constructs a [TestClassWrapper] that points to the same underlying object as [other]. - TestClassWrapper.as(objc.ObjCObject other) : object$ = other { - assert(isA(object$)); - } - - /// Constructs a [TestClassWrapper] that wraps the given raw object pointer. - TestClassWrapper.fromPointer( - ffi.Pointer other, { - bool retain = false, - bool release = false, - }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { - assert(isA(object$)); - } - - /// Returns whether [obj] is an instance of [TestClassWrapper]. - static bool isA(objc.ObjCObject obj) => _objc_msgSend_19nvye5( - obj.ref.pointer, - _sel_isKindOfClass_, - _class_TestClassWrapper, - ); - - /// alloc - static TestClassWrapper alloc() { - final $ret = _objc_msgSend_151sglz(_class_TestClassWrapper, _sel_alloc); - return TestClassWrapper.fromPointer($ret, retain: false, release: true); - } - - /// allocWithZone: - static TestClassWrapper allocWithZone(ffi.Pointer zone) { - final $ret = _objc_msgSend_1cwp428( - _class_TestClassWrapper, - _sel_allocWithZone_, - zone, - ); - return TestClassWrapper.fromPointer($ret, retain: false, release: true); - } - - /// create - static TestClassWrapper create() { - final $ret = _objc_msgSend_151sglz(_class_TestClassWrapper, _sel_create); - return TestClassWrapper.fromPointer($ret, retain: true, release: true); - } - - /// new - static TestClassWrapper new$() { - final $ret = _objc_msgSend_151sglz(_class_TestClassWrapper, _sel_new); - return TestClassWrapper.fromPointer($ret, retain: false, release: true); - } - - /// Returns a new instance of TestClassWrapper constructed with the default `new` method. - TestClassWrapper() : this.as(new$().object$); -} - -extension TestClassWrapper$Methods on TestClassWrapper { - /// init - TestClassWrapper init() { - objc.checkOsVersionInternal( - 'TestClassWrapper.init', - iOS: (false, (2, 0, 0)), - macOS: (false, (10, 0, 0)), - ); - final $ret = _objc_msgSend_151sglz( - object$.ref.retainAndReturnPointer(), - _sel_init, - ); - return TestClassWrapper.fromPointer($ret, retain: false, release: true); - } - - /// myMethod - TestOtherClassWrapper myMethod() { - final $ret = _objc_msgSend_151sglz(object$.ref.pointer, _sel_myMethod); - return TestOtherClassWrapper.fromPointer($ret, retain: true, release: true); - } -} +late final _sel_new = objc.registerName("new"); +late final _sel_times10WithX_ = objc.registerName("times10WithX:"); +typedef instancetype = ffi.Pointer; +typedef Dartinstancetype = objc.ObjCObject; diff --git a/pkgs/swiftgen/test/integration/protocols.swift b/pkgs/swiftgen/test/integration/protocols.swift new file mode 100644 index 0000000000..3436da419d --- /dev/null +++ b/pkgs/swiftgen/test/integration/protocols.swift @@ -0,0 +1,29 @@ +import Foundation + +@objc protocol TestWeatherServiceDelegate: AnyObject { + @objc func didUpdateWeather(_ weather: String) +} + +@objc protocol TestAsyncProtocol: AnyObject { + @objc func fetchData(param: String) async -> String +} + +@objc class TestWeatherService: NSObject { + @objc static func fetchWeather(delegate: TestWeatherServiceDelegate) { + DispatchQueue.global().asyncAfter(deadline: .now() + 0.1) { + delegate.didUpdateWeather("Sunny, 25°C") + } + } +} + +@objc class TestSwiftInvoker: NSObject { + @objc static func invokeAsyncMethod(protocolInstance: TestAsyncProtocol, param: String) async -> String { + return await protocolInstance.fetchData(param: param) + } + + @objc static func invokeAsyncMethodOnBackgroundThread(protocolInstance: TestAsyncProtocol, param: String) async -> String { + return await Task.detached { + return await protocolInstance.fetchData(param: param) + }.value + } +} diff --git a/pkgs/swiftgen/test/integration/protocols_bindings.dart b/pkgs/swiftgen/test/integration/protocols_bindings.dart new file mode 100644 index 0000000000..8ca1d2f3b0 --- /dev/null +++ b/pkgs/swiftgen/test/integration/protocols_bindings.dart @@ -0,0 +1,1826 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// coverage:ignore-file + +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint, unused_import +import 'dart:ffi' as ffi; +import 'package:objective_c/objective_c.dart' as objc; +import 'package:ffi/ffi.dart' as pkg_ffi; + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _1yx5rho_protocolTrampoline_18v1jvf( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>() +external void _1yx5rho_protocolTrampoline_jk1ljc( + ffi.Pointer target, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer _1yx5rho_wrapBlockingBlock_18v1jvf( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer _1yx5rho_wrapBlockingBlock_jk1ljc( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); + +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) +>(isLeaf: true) +external ffi.Pointer _1yx5rho_wrapBlockingBlock_xtuoz7( + ffi.Pointer block, + ffi.Pointer listnerBlock, + ffi.Pointer context, +); + +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer _1yx5rho_wrapListenerBlock_18v1jvf( + ffi.Pointer block, +); + +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer _1yx5rho_wrapListenerBlock_jk1ljc( + ffi.Pointer block, +); + +@ffi.Native< + ffi.Pointer Function(ffi.Pointer) +>(isLeaf: true) +external ffi.Pointer _1yx5rho_wrapListenerBlock_xtuoz7( + ffi.Pointer block, +); + +/// Construction methods for `objc.ObjCBlock`. +abstract final class ObjCBlock_ffiVoid_NSString { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock( + pointer, + retain: retain, + release: release, + ); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + > + ptr, + ) => objc.ObjCBlock( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock fromFunction( + void Function(objc.NSString) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: true, release: true)), + keepIsolateAlive, + ), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock listener( + void Function(objc.NSString) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final wrapper = _1yx5rho_wrapListenerBlock_xtuoz7(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock blocking( + void Function(objc.NSString) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0) => + fn(objc.NSString.fromPointer(arg0, retain: false, release: true)), + keepIsolateAlive, + ); + final wrapper = _1yx5rho_wrapBlockingBlock_xtuoz7( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock( + wrapper, + retain: false, + release: true, + ); + } + + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + objc.objectRelease(block.cast()); + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ) { + try { + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer arg0) + > + >() + .asFunction)>()(arg0); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ) => + (objc.getBlockClosure(block) + as void Function(ffi.Pointer))(arg0); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} + +/// Call operator for `objc.ObjCBlock`. +extension ObjCBlock_ffiVoid_NSString$CallExtension + on objc.ObjCBlock { + void call(objc.NSString arg0) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0.ref.pointer); +} + +/// Construction methods for `objc.ObjCBlock, objc.NSString)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSString { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock, objc.NSString)> + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => objc.ObjCBlock, objc.NSString)>( + pointer, + retain: retain, + release: release, + ); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock, objc.NSString)> + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + > + ptr, + ) => objc.ObjCBlock, objc.NSString)>( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock, objc.NSString)> + fromFunction( + void Function(ffi.Pointer, objc.NSString) fn, { + bool keepIsolateAlive = true, + }) => objc.ObjCBlock, objc.NSString)>( + objc.newClosureBlock( + _closureCallable, + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: true, release: true), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock, objc.NSString)> + listener( + void Function(ffi.Pointer, objc.NSString) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _1yx5rho_wrapListenerBlock_18v1jvf(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, objc.NSString) + >(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock, objc.NSString)> + blocking( + void Function(ffi.Pointer, objc.NSString) fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + (ffi.Pointer arg0, ffi.Pointer arg1) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: false, release: true), + ), + keepIsolateAlive, + ); + final wrapper = _1yx5rho_wrapBlockingBlock_18v1jvf( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function(ffi.Pointer, objc.NSString) + >(wrapper, retain: false, release: true); + } + + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + objc.objectRelease(block.cast()); + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) { + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function(ffi.Pointer, ffi.Pointer) + >()(arg0, arg1); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} + +/// Call operator for `objc.ObjCBlock, objc.NSString)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSString$CallExtension + on objc.ObjCBlock, objc.NSString)> { + void call(ffi.Pointer arg0, objc.NSString arg1) => ref + .pointer + .ref + .invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0, arg1.ref.pointer); +} + +/// Construction methods for `objc.ObjCBlock, objc.NSString, objc.ObjCBlock)>`. +abstract final class ObjCBlock_ffiVoid_ffiVoid_NSString_ffiVoidNSString { + /// Returns a block that wraps the given raw block pointer. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + > + fromPointer( + ffi.Pointer pointer, { + bool retain = false, + bool release = false, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + >(pointer, retain: retain, release: release); + + /// Creates a block from a C function pointer. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + > + fromFunctionPointer( + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + > + ptr, + ) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + >( + objc.newPointerBlock(_fnPtrCallable, ptr.cast()), + retain: false, + release: true, + ); + + /// Creates a block from a Dart function. + /// + /// This block must be invoked by native code running on the same thread as + /// the isolate that registered it. Invoking the block on the wrong thread + /// will result in a crash. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + > + fromFunction( + void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) => + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + >( + objc.newClosureBlock( + _closureCallable, + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: true, release: true), + ObjCBlock_ffiVoid_NSString.fromPointer( + arg2, + retain: true, + release: true, + ), + ), + keepIsolateAlive, + ), + retain: false, + release: true, + ); + + /// Creates a listener block from a Dart function. + /// + /// This is based on FFI's NativeCallable.listener, and has the same + /// capabilities and limitations. This block can be invoked from any thread, + /// but only supports void functions, and is not run synchronously. See + /// NativeCallable.listener for more details. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + > + listener( + void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _listenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: false, release: true), + ObjCBlock_ffiVoid_NSString.fromPointer( + arg2, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _1yx5rho_wrapListenerBlock_jk1ljc(raw); + objc.objectRelease(raw.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); + } + + /// Creates a blocking block from a Dart function. + /// + /// This callback can be invoked from any native thread, and will block the + /// caller until the callback is handled by the Dart isolate that created + /// the block. Async functions are not supported. + /// + /// If `keepIsolateAlive` is true, this block will keep this isolate alive + /// until it is garbage collected by both Dart and ObjC. If the owner isolate + /// has shut down, and the block is invoked by native code, it may block + /// indefinitely, or have other undefined behavior. + static objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + > + blocking( + void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + fn, { + bool keepIsolateAlive = true, + }) { + final raw = objc.newClosureBlock( + _blockingCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: false, release: true), + ObjCBlock_ffiVoid_NSString.fromPointer( + arg2, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final rawListener = objc.newClosureBlock( + _blockingListenerCallable.nativeFunction.cast(), + ( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => fn( + arg0, + objc.NSString.fromPointer(arg1, retain: false, release: true), + ObjCBlock_ffiVoid_NSString.fromPointer( + arg2, + retain: false, + release: true, + ), + ), + keepIsolateAlive, + ); + final wrapper = _1yx5rho_wrapBlockingBlock_jk1ljc( + raw, + rawListener, + objc.objCContext, + ); + objc.objectRelease(raw.cast()); + objc.objectRelease(rawListener.cast()); + return objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + >(wrapper, retain: false, release: true); + } + + static void _listenerTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + objc.objectRelease(block.cast()); + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _listenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_listenerTrampoline) + ..keepIsolateAlive = false; + static void _blockingTrampoline( + ffi.Pointer block, + ffi.Pointer waiter, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) { + try { + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + } catch (e) { + } finally { + objc.signalWaiter(waiter); + objc.objectRelease(block.cast()); + } + } + + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.isolateLocal(_blockingTrampoline) + ..keepIsolateAlive = false; + static ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + _blockingListenerCallable = + ffi.NativeCallable< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >.listener(_blockingTrampoline) + ..keepIsolateAlive = false; + static void _fnPtrTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => block.ref.target + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(arg0, arg1, arg2); + static ffi.Pointer _fnPtrCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_fnPtrTrampoline) + .cast(); + static void _closureTrampoline( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) => + (objc.getBlockClosure(block) + as void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ))(arg0, arg1, arg2); + static ffi.Pointer _closureCallable = + ffi.Pointer.fromFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(_closureTrampoline) + .cast(); +} + +/// Call operator for `objc.ObjCBlock, objc.NSString, objc.ObjCBlock)>`. +extension ObjCBlock_ffiVoid_ffiVoid_NSString_ffiVoidNSString$CallExtension + on + objc.ObjCBlock< + ffi.Void Function( + ffi.Pointer, + objc.NSString, + objc.ObjCBlock, + ) + > { + void call( + ffi.Pointer arg0, + objc.NSString arg1, + objc.ObjCBlock arg2, + ) => ref.pointer.ref.invoke + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer block, + ffi.Pointer arg0, + ffi.Pointer arg1, + ffi.Pointer arg2, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >()(ref.pointer, arg0, arg1.ref.pointer, arg2.ref.pointer); +} + +/// TestAsyncProtocol +extension type TestAsyncProtocol._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol { + /// Constructs a [TestAsyncProtocol] that points to the same underlying object as [other]. + TestAsyncProtocol.as(objc.ObjCObject other) : object$ = other; + + /// Constructs a [TestAsyncProtocol] that wraps the given raw object pointer. + TestAsyncProtocol.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [TestAsyncProtocol]. + static bool conformsTo(objc.ObjCObject obj) { + return _objc_msgSend_e3qsqz( + obj.ref.pointer, + _sel_conformsToProtocol_, + _protocol_TestAsyncProtocol, + ); + } +} + +extension TestAsyncProtocol$Methods on TestAsyncProtocol { + /// fetchDataWithParam:completionHandler: + void fetchDataWithParam( + objc.NSString param, { + required objc.ObjCBlock completionHandler, + }) { + _objc_msgSend_o762yo( + object$.ref.pointer, + _sel_fetchDataWithParam_completionHandler_, + param.ref.pointer, + completionHandler.ref.pointer, + ); + } +} + +interface class TestAsyncProtocol$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_TestAsyncProtocol.cast()); + + /// Builds an object that implements the TestAsyncProtocol protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static TestAsyncProtocol implement({ + required void Function( + objc.NSString, + objc.ObjCBlock, + ) + fetchDataWithParam_completionHandler_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder(debugName: 'TestAsyncProtocol'); + TestAsyncProtocol$Builder.fetchDataWithParam_completionHandler_.implement( + builder, + fetchDataWithParam_completionHandler_, + ); + builder.addProtocol($protocol); + return TestAsyncProtocol.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); + } + + /// Adds the implementation of the TestAsyncProtocol protocol to an existing + /// [objc.ObjCProtocolBuilder]. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilder( + objc.ObjCProtocolBuilder builder, { + required void Function( + objc.NSString, + objc.ObjCBlock, + ) + fetchDataWithParam_completionHandler_, + bool $keepIsolateAlive = true, + }) { + TestAsyncProtocol$Builder.fetchDataWithParam_completionHandler_.implement( + builder, + fetchDataWithParam_completionHandler_, + ); + builder.addProtocol($protocol); + } + + /// Builds an object that implements the TestAsyncProtocol protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static TestAsyncProtocol implementAsListener({ + required void Function( + objc.NSString, + objc.ObjCBlock, + ) + fetchDataWithParam_completionHandler_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder(debugName: 'TestAsyncProtocol'); + TestAsyncProtocol$Builder.fetchDataWithParam_completionHandler_ + .implementAsListener(builder, fetchDataWithParam_completionHandler_); + builder.addProtocol($protocol); + return TestAsyncProtocol.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); + } + + /// Adds the implementation of the TestAsyncProtocol protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsListener( + objc.ObjCProtocolBuilder builder, { + required void Function( + objc.NSString, + objc.ObjCBlock, + ) + fetchDataWithParam_completionHandler_, + bool $keepIsolateAlive = true, + }) { + TestAsyncProtocol$Builder.fetchDataWithParam_completionHandler_ + .implementAsListener(builder, fetchDataWithParam_completionHandler_); + builder.addProtocol($protocol); + } + + /// Builds an object that implements the TestAsyncProtocol protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as blocking listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static TestAsyncProtocol implementAsBlocking({ + required void Function( + objc.NSString, + objc.ObjCBlock, + ) + fetchDataWithParam_completionHandler_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder(debugName: 'TestAsyncProtocol'); + TestAsyncProtocol$Builder.fetchDataWithParam_completionHandler_ + .implementAsBlocking(builder, fetchDataWithParam_completionHandler_); + builder.addProtocol($protocol); + return TestAsyncProtocol.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); + } + + /// Adds the implementation of the TestAsyncProtocol protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsBlocking( + objc.ObjCProtocolBuilder builder, { + required void Function( + objc.NSString, + objc.ObjCBlock, + ) + fetchDataWithParam_completionHandler_, + bool $keepIsolateAlive = true, + }) { + TestAsyncProtocol$Builder.fetchDataWithParam_completionHandler_ + .implementAsBlocking(builder, fetchDataWithParam_completionHandler_); + builder.addProtocol($protocol); + } + + /// fetchDataWithParam:completionHandler: + static final fetchDataWithParam_completionHandler_ = + objc.ObjCProtocolListenableMethod< + void Function( + objc.NSString, + objc.ObjCBlock, + ) + >( + _protocol_TestAsyncProtocol, + _sel_fetchDataWithParam_completionHandler_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1yx5rho_protocolTrampoline_jk1ljc) + .cast(), + objc.getProtocolMethodSignature( + _protocol_TestAsyncProtocol, + _sel_fetchDataWithParam_completionHandler_, + isRequired: true, + isInstanceMethod: true, + ), + ( + void Function( + objc.NSString, + objc.ObjCBlock, + ) + func, + ) => ObjCBlock_ffiVoid_ffiVoid_NSString_ffiVoidNSString.fromFunction( + ( + ffi.Pointer _, + objc.NSString arg1, + objc.ObjCBlock arg2, + ) => func(arg1, arg2), + ), + ( + void Function( + objc.NSString, + objc.ObjCBlock, + ) + func, + ) => ObjCBlock_ffiVoid_ffiVoid_NSString_ffiVoidNSString.listener( + ( + ffi.Pointer _, + objc.NSString arg1, + objc.ObjCBlock arg2, + ) => func(arg1, arg2), + ), + ( + void Function( + objc.NSString, + objc.ObjCBlock, + ) + func, + ) => ObjCBlock_ffiVoid_ffiVoid_NSString_ffiVoidNSString.blocking( + ( + ffi.Pointer _, + objc.NSString arg1, + objc.ObjCBlock arg2, + ) => func(arg1, arg2), + ), + ); +} + +/// TestSwiftInvoker +extension type TestSwiftInvoker._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [TestSwiftInvoker] that points to the same underlying object as [other]. + TestSwiftInvoker.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [TestSwiftInvoker] that wraps the given raw object pointer. + TestSwiftInvoker.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); + } + + /// Returns whether [obj] is an instance of [TestSwiftInvoker]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_TestSwiftInvoker, + ); + + /// alloc + static TestSwiftInvoker alloc() { + final $ret = _objc_msgSend_151sglz(_class_TestSwiftInvoker, _sel_alloc); + return TestSwiftInvoker.fromPointer($ret, retain: false, release: true); + } + + /// allocWithZone: + static TestSwiftInvoker allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_TestSwiftInvoker, + _sel_allocWithZone_, + zone, + ); + return TestSwiftInvoker.fromPointer($ret, retain: false, release: true); + } + + /// invokeAsyncMethodOnBackgroundThreadWithProtocolInstance:param:completionHandler: + static void invokeAsyncMethodOnBackgroundThreadWithProtocolInstance( + TestAsyncProtocol protocolInstance, { + required objc.NSString param, + required objc.ObjCBlock completionHandler, + }) { + _objc_msgSend_18qun1e( + _class_TestSwiftInvoker, + _sel_invokeAsyncMethodOnBackgroundThreadWithProtocolInstance_param_completionHandler_, + protocolInstance.ref.pointer, + param.ref.pointer, + completionHandler.ref.pointer, + ); + } + + /// invokeAsyncMethodWithProtocolInstance:param:completionHandler: + static void invokeAsyncMethodWithProtocolInstance( + TestAsyncProtocol protocolInstance, { + required objc.NSString param, + required objc.ObjCBlock completionHandler, + }) { + _objc_msgSend_18qun1e( + _class_TestSwiftInvoker, + _sel_invokeAsyncMethodWithProtocolInstance_param_completionHandler_, + protocolInstance.ref.pointer, + param.ref.pointer, + completionHandler.ref.pointer, + ); + } + + /// new + static TestSwiftInvoker new$() { + final $ret = _objc_msgSend_151sglz(_class_TestSwiftInvoker, _sel_new); + return TestSwiftInvoker.fromPointer($ret, retain: false, release: true); + } + + /// Returns a new instance of TestSwiftInvoker constructed with the default `new` method. + TestSwiftInvoker() : this.as(new$().object$); +} + +extension TestSwiftInvoker$Methods on TestSwiftInvoker { + /// init + TestSwiftInvoker init() { + objc.checkOsVersionInternal( + 'TestSwiftInvoker.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return TestSwiftInvoker.fromPointer($ret, retain: false, release: true); + } +} + +/// TestWeatherService +extension type TestWeatherService._(objc.ObjCObject object$) + implements objc.ObjCObject, objc.NSObject { + /// Constructs a [TestWeatherService] that points to the same underlying object as [other]. + TestWeatherService.as(objc.ObjCObject other) : object$ = other { + assert(isA(object$)); + } + + /// Constructs a [TestWeatherService] that wraps the given raw object pointer. + TestWeatherService.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCObject(other, retain: retain, release: release) { + assert(isA(object$)); + } + + /// Returns whether [obj] is an instance of [TestWeatherService]. + static bool isA(objc.ObjCObject? obj) => obj == null + ? false + : _objc_msgSend_19nvye5( + obj.ref.pointer, + _sel_isKindOfClass_, + _class_TestWeatherService, + ); + + /// alloc + static TestWeatherService alloc() { + final $ret = _objc_msgSend_151sglz(_class_TestWeatherService, _sel_alloc); + return TestWeatherService.fromPointer($ret, retain: false, release: true); + } + + /// allocWithZone: + static TestWeatherService allocWithZone(ffi.Pointer zone) { + final $ret = _objc_msgSend_1cwp428( + _class_TestWeatherService, + _sel_allocWithZone_, + zone, + ); + return TestWeatherService.fromPointer($ret, retain: false, release: true); + } + + /// fetchWeatherWithDelegate: + static void fetchWeatherWithDelegate(TestWeatherServiceDelegate delegate) { + _objc_msgSend_xtuoz7( + _class_TestWeatherService, + _sel_fetchWeatherWithDelegate_, + delegate.ref.pointer, + ); + } + + /// new + static TestWeatherService new$() { + final $ret = _objc_msgSend_151sglz(_class_TestWeatherService, _sel_new); + return TestWeatherService.fromPointer($ret, retain: false, release: true); + } + + /// Returns a new instance of TestWeatherService constructed with the default `new` method. + TestWeatherService() : this.as(new$().object$); +} + +extension TestWeatherService$Methods on TestWeatherService { + /// init + TestWeatherService init() { + objc.checkOsVersionInternal( + 'TestWeatherService.init', + iOS: (false, (2, 0, 0)), + macOS: (false, (10, 0, 0)), + ); + final $ret = _objc_msgSend_151sglz( + object$.ref.retainAndReturnPointer(), + _sel_init, + ); + return TestWeatherService.fromPointer($ret, retain: false, release: true); + } +} + +/// TestWeatherServiceDelegate +extension type TestWeatherServiceDelegate._(objc.ObjCProtocol object$) + implements objc.ObjCProtocol { + /// Constructs a [TestWeatherServiceDelegate] that points to the same underlying object as [other]. + TestWeatherServiceDelegate.as(objc.ObjCObject other) : object$ = other; + + /// Constructs a [TestWeatherServiceDelegate] that wraps the given raw object pointer. + TestWeatherServiceDelegate.fromPointer( + ffi.Pointer other, { + bool retain = false, + bool release = false, + }) : object$ = objc.ObjCProtocol(other, retain: retain, release: release); + + /// Returns whether [obj] is an instance of [TestWeatherServiceDelegate]. + static bool conformsTo(objc.ObjCObject obj) { + return _objc_msgSend_e3qsqz( + obj.ref.pointer, + _sel_conformsToProtocol_, + _protocol_TestWeatherServiceDelegate, + ); + } +} + +extension TestWeatherServiceDelegate$Methods on TestWeatherServiceDelegate { + /// didUpdateWeather: + void didUpdateWeather(objc.NSString weather) { + _objc_msgSend_xtuoz7( + object$.ref.pointer, + _sel_didUpdateWeather_, + weather.ref.pointer, + ); + } +} + +interface class TestWeatherServiceDelegate$Builder { + /// Returns the [objc.Protocol] object for this protocol. + static objc.Protocol get $protocol => + objc.Protocol.fromPointer(_protocol_TestWeatherServiceDelegate.cast()); + + /// Builds an object that implements the TestWeatherServiceDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static TestWeatherServiceDelegate implement({ + required void Function(objc.NSString) didUpdateWeather_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'TestWeatherServiceDelegate', + ); + TestWeatherServiceDelegate$Builder.didUpdateWeather_.implement( + builder, + didUpdateWeather_, + ); + builder.addProtocol($protocol); + return TestWeatherServiceDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); + } + + /// Adds the implementation of the TestWeatherServiceDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilder( + objc.ObjCProtocolBuilder builder, { + required void Function(objc.NSString) didUpdateWeather_, + bool $keepIsolateAlive = true, + }) { + TestWeatherServiceDelegate$Builder.didUpdateWeather_.implement( + builder, + didUpdateWeather_, + ); + builder.addProtocol($protocol); + } + + /// Builds an object that implements the TestWeatherServiceDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static TestWeatherServiceDelegate implementAsListener({ + required void Function(objc.NSString) didUpdateWeather_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'TestWeatherServiceDelegate', + ); + TestWeatherServiceDelegate$Builder.didUpdateWeather_.implementAsListener( + builder, + didUpdateWeather_, + ); + builder.addProtocol($protocol); + return TestWeatherServiceDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); + } + + /// Adds the implementation of the TestWeatherServiceDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as listeners will + /// be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsListener( + objc.ObjCProtocolBuilder builder, { + required void Function(objc.NSString) didUpdateWeather_, + bool $keepIsolateAlive = true, + }) { + TestWeatherServiceDelegate$Builder.didUpdateWeather_.implementAsListener( + builder, + didUpdateWeather_, + ); + builder.addProtocol($protocol); + } + + /// Builds an object that implements the TestWeatherServiceDelegate protocol. To implement + /// multiple protocols, use [addToBuilder] or [objc.ObjCProtocolBuilder] directly. All + /// methods that can be implemented as blocking listeners will be. + /// + /// If `$keepIsolateAlive` is true, this protocol will keep this isolate + /// alive until it is garbage collected by both Dart and ObjC. + static TestWeatherServiceDelegate implementAsBlocking({ + required void Function(objc.NSString) didUpdateWeather_, + bool $keepIsolateAlive = true, + }) { + final builder = objc.ObjCProtocolBuilder( + debugName: 'TestWeatherServiceDelegate', + ); + TestWeatherServiceDelegate$Builder.didUpdateWeather_.implementAsBlocking( + builder, + didUpdateWeather_, + ); + builder.addProtocol($protocol); + return TestWeatherServiceDelegate.as( + builder.build(keepIsolateAlive: $keepIsolateAlive), + ); + } + + /// Adds the implementation of the TestWeatherServiceDelegate protocol to an existing + /// [objc.ObjCProtocolBuilder]. All methods that can be implemented as blocking + /// listeners will be. + /// + /// Note: You cannot call this method after you have called `builder.build`. + static void addToBuilderAsBlocking( + objc.ObjCProtocolBuilder builder, { + required void Function(objc.NSString) didUpdateWeather_, + bool $keepIsolateAlive = true, + }) { + TestWeatherServiceDelegate$Builder.didUpdateWeather_.implementAsBlocking( + builder, + didUpdateWeather_, + ); + builder.addProtocol($protocol); + } + + /// didUpdateWeather: + static final didUpdateWeather_ = + objc.ObjCProtocolListenableMethod( + _protocol_TestWeatherServiceDelegate, + _sel_didUpdateWeather_, + ffi.Native.addressOf< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >(_1yx5rho_protocolTrampoline_18v1jvf) + .cast(), + objc.getProtocolMethodSignature( + _protocol_TestWeatherServiceDelegate, + _sel_didUpdateWeather_, + isRequired: true, + isInstanceMethod: true, + ), + (void Function(objc.NSString) func) => + ObjCBlock_ffiVoid_ffiVoid_NSString.fromFunction( + (ffi.Pointer _, objc.NSString arg1) => func(arg1), + ), + (void Function(objc.NSString) func) => + ObjCBlock_ffiVoid_ffiVoid_NSString.listener( + (ffi.Pointer _, objc.NSString arg1) => func(arg1), + ), + (void Function(objc.NSString) func) => + ObjCBlock_ffiVoid_ffiVoid_NSString.blocking( + (ffi.Pointer _, objc.NSString arg1) => func(arg1), + ), + ); +} + +late final _class_TestSwiftInvoker = objc.getClass( + "protocols.TestSwiftInvoker", +); +late final _class_TestWeatherService = objc.getClass( + "protocols.TestWeatherService", +); +final _objc_msgSend_151sglz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_18qun1e = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_19nvye5 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_1cwp428 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_e3qsqz = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + bool Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_o762yo = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +final _objc_msgSend_xtuoz7 = objc.msgSendPointer + .cast< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + > + >() + .asFunction< + void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ) + >(); +late final _protocol_TestAsyncProtocol = objc.getProtocol( + "protocols.TestAsyncProtocol", +); +late final _protocol_TestWeatherServiceDelegate = objc.getProtocol( + "protocols.TestWeatherServiceDelegate", +); +late final _sel_alloc = objc.registerName("alloc"); +late final _sel_allocWithZone_ = objc.registerName("allocWithZone:"); +late final _sel_conformsToProtocol_ = objc.registerName("conformsToProtocol:"); +late final _sel_didUpdateWeather_ = objc.registerName("didUpdateWeather:"); +late final _sel_fetchDataWithParam_completionHandler_ = objc.registerName( + "fetchDataWithParam:completionHandler:", +); +late final _sel_fetchWeatherWithDelegate_ = objc.registerName( + "fetchWeatherWithDelegate:", +); +late final _sel_init = objc.registerName("init"); +late final _sel_invokeAsyncMethodOnBackgroundThreadWithProtocolInstance_param_completionHandler_ = + objc.registerName( + "invokeAsyncMethodOnBackgroundThreadWithProtocolInstance:param:completionHandler:", + ); +late final _sel_invokeAsyncMethodWithProtocolInstance_param_completionHandler_ = + objc.registerName( + "invokeAsyncMethodWithProtocolInstance:param:completionHandler:", + ); +late final _sel_isKindOfClass_ = objc.registerName("isKindOfClass:"); +late final _sel_new = objc.registerName("new"); +typedef instancetype = ffi.Pointer; +typedef Dartinstancetype = objc.ObjCObject; diff --git a/pkgs/swiftgen/test/integration/protocols_test.dart b/pkgs/swiftgen/test/integration/protocols_test.dart new file mode 100644 index 0000000000..9548122980 --- /dev/null +++ b/pkgs/swiftgen/test/integration/protocols_test.dart @@ -0,0 +1,73 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +@Timeout(Duration(minutes: 2)) +library; + +import 'dart:async'; +import 'dart:ffi'; + +import 'package:objective_c/objective_c.dart'; +import 'package:test/test.dart'; + +import 'protocols_bindings.dart'; +import 'util.dart'; + +void main() { + group('Protocols', () { + setUpAll(() async { + final gen = TestGenerator('protocols'); + await gen.generateAndVerifyBindings(); + DynamicLibrary.open(gen.dylibFile); + }); + + test('protocol', () async { + final result = Completer(); + final delegate = TestWeatherServiceDelegate$Builder.implementAsListener( + didUpdateWeather_: (NSString msg) { + result.complete(msg.toDartString()); + }, + ); + TestWeatherService.fetchWeatherWithDelegate(delegate); + expect(await result.future, 'Sunny, 25°C'); + }); + + for (final (name, invoke) in [ + ('same thread', TestSwiftInvoker.invokeAsyncMethodWithProtocolInstance), + ( + 'different thread', + TestSwiftInvoker + .invokeAsyncMethodOnBackgroundThreadWithProtocolInstance, + ), + ]) { + test('async protocol method, $name', () async { + final protocolInstance = TestAsyncProtocol$Builder.implementAsBlocking( + fetchDataWithParam_completionHandler_: + ( + NSString param, + ObjCBlock completionHandler, + ) { + final result = '${param.toDartString()} processed'.toNSString(); + completionHandler(result); + }, + ); + + final resultCompleter = Completer(); + final completionHandler = ObjCBlock_ffiVoid_NSString.blocking(( + NSString result, + ) { + resultCompleter.complete(result.toDartString()); + }); + + invoke( + protocolInstance, + param: 'input'.toNSString(), + completionHandler: completionHandler, + ); + + expect(await resultCompleter.future, 'input processed'); + }); + } + }); +} diff --git a/pkgs/swiftgen/test/integration/util.dart b/pkgs/swiftgen/test/integration/util.dart index b54dc493cf..2f76de7dea 100644 --- a/pkgs/swiftgen/test/integration/util.dart +++ b/pkgs/swiftgen/test/integration/util.dart @@ -16,6 +16,14 @@ String pkgDir = findPackageRoot('swiftgen').toFilePath(); Future hostTarget = Target.host(); +// There are language features that aren't supported in Swift2ObjC yet, but that +// we want to test in SwiftGen. So for now we write @objc annotated bindings for +// these features. As each of these features is supported, migrate the test to +// stop using hand-written @objc annotations. +// TODO(https://github.com/dart-lang/native/issues/1669): callbacks +// TODO(https://github.com/dart-lang/native/issues/1828): protocols +const objCCompatibleTests = {'callbacks', 'protocols'}; + class TestGenerator { final String name; late final String testDir; @@ -29,8 +37,10 @@ class TestGenerator { late final String objObjCFile; late final String dylibFile; late final String actualOutputFile; + final bool isObjCCompatible; - TestGenerator(this.name) { + TestGenerator(this.name) + : isObjCCompatible = objCCompatibleTests.contains(name) { testDir = path.absolute(path.join(pkgDir, 'test/integration')); tempDir = path.join(testDir, 'temp'); inputFile = path.join(testDir, '$name.swift'); @@ -48,10 +58,14 @@ class TestGenerator { await SwiftGenerator( target: await hostTarget, inputs: [ - SwiftFileInput(files: [Uri.file(inputFile)]), + isObjCCompatible + ? ObjCCompatibleSwiftFileInput(files: [Uri.file(inputFile)]) + : SwiftFileInput(files: [Uri.file(inputFile)]), ], output: Output( - swiftWrapperFile: SwiftWrapperFile(path: Uri.file(wrapperFile)), + swiftWrapperFile: isObjCCompatible + ? null + : SwiftWrapperFile(path: Uri.file(wrapperFile)), module: name, dartFile: Uri.file(outputFile), objectiveCFile: Uri.file(outputObjCFile), @@ -68,6 +82,9 @@ class TestGenerator { interfaces: fg.Interfaces( include: (decl) => decl.originalName.startsWith('Test'), ), + protocols: fg.Protocols( + include: (decl) => decl.originalName.startsWith('Test'), + ), ), ), ).generate( @@ -81,7 +98,7 @@ class TestGenerator { await generateBindings(); expect(File(inputFile).existsSync(), isTrue); - expect(File(wrapperFile).existsSync(), isTrue); + expect(File(wrapperFile).existsSync(), !isObjCCompatible); expect(File(outputFile).existsSync(), isTrue); // The generation pipeline also an obj file as a byproduct. @@ -91,7 +108,7 @@ class TestGenerator { await run('swiftc', [ '-c', inputFile, - wrapperFile, + if (!isObjCCompatible) wrapperFile, '-module-name', name, '-target', @@ -122,7 +139,7 @@ class TestGenerator { '-framework', 'Foundation', objInputFile, - objWrapperFile, + if (!isObjCCompatible) objWrapperFile, if (hasOutputObjCFile) objObjCFile, '-o', dylibFile, diff --git a/pubspec.yaml b/pubspec.yaml index 694222b532..43daea5a2c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,9 +1,8 @@ name: dart_lang_native_workspace -# TODO(goderbauer): reevaluate after https://github.com/dart-lang/ecosystem/issues/377 is resolved. publish_to: none environment: - sdk: '>=3.9.0 <4.0.0' + sdk: '>=3.10.0 <4.0.0' workspace: - pkgs/code_assets @@ -13,7 +12,26 @@ workspace: - pkgs/code_assets/example/sqlite_prebuilt - pkgs/code_assets/example/stb_image - pkgs/data_assets + - pkgs/ffi + # - pkgs/ffigen # TODO + # - pkgs/ffigen/example/add # TODO + # - pkgs/ffigen/example/c_json # TODO + # - pkgs/ffigen/example/ffinative # TODO + # - pkgs/ffigen/example/libclang-example # TODO + # - pkgs/ffigen/example/objective_c # TODO + # - pkgs/ffigen/example/shared_bindings # TODO + # - pkgs/ffigen/example/simple # TODO + # - pkgs/ffigen/example/swift # TODO - pkgs/hooks + - pkgs/hooks/example/build/download_asset + - pkgs/hooks/example/build/local_asset + - pkgs/hooks/example/build/native_add_app + - pkgs/hooks/example/build/native_add_library + - pkgs/hooks/example/build/native_dynamic_linking + - pkgs/hooks/example/build/system_library + - pkgs/hooks/example/build/use_dart_api + - pkgs/hooks/example/link/app_with_asset_treeshaking + - pkgs/hooks/example/link/package_with_assets - pkgs/hooks_runner - pkgs/hooks_runner/test_data/add_asset_link - pkgs/hooks_runner/test_data/complex_link @@ -36,18 +54,24 @@ workspace: - pkgs/hooks_runner/test_data/flag_enthusiast_1 - pkgs/hooks_runner/test_data/flag_enthusiast_2 - pkgs/hooks_runner/test_data/fun_with_flags - - pkgs/hooks_runner/test_data/infra_failure/ + - pkgs/hooks_runner/test_data/infra_failure - pkgs/hooks_runner/test_data/link_inverse_app - pkgs/hooks_runner/test_data/link_inverse_package - pkgs/hooks_runner/test_data/native_add - pkgs/hooks_runner/test_data/native_add_add_source - pkgs/hooks_runner/test_data/native_add_duplicate + # - pkgs/hooks_runner/test_data/native_add_version_skew # Intentionally uses incompatible older versions. + # - pkgs/hooks_runner/test_data/native_add_version_skew_2 # Intentionally uses incompatible older versions. - pkgs/hooks_runner/test_data/native_dynamic_linking - pkgs/hooks_runner/test_data/native_subtract - pkgs/hooks_runner/test_data/no_asset_for_link + - pkgs/hooks_runner/test_data/no_build_output - pkgs/hooks_runner/test_data/no_hook - pkgs/hooks_runner/test_data/package_reading_metadata - pkgs/hooks_runner/test_data/package_with_metadata + - pkgs/hooks_runner/test_data/pirate_adventure + - pkgs/hooks_runner/test_data/pirate_speak + - pkgs/hooks_runner/test_data/pirate_technology - pkgs/hooks_runner/test_data/recursive_invocation - pkgs/hooks_runner/test_data/relative_path - pkgs/hooks_runner/test_data/reusable_dynamic_library @@ -65,23 +89,41 @@ workspace: - pkgs/hooks_runner/test_data/wrong_build_output_3 - pkgs/hooks_runner/test_data/wrong_linker - pkgs/hooks_runner/test_data/wrong_namespace_asset - - pkgs/hooks/example/build/download_asset - - pkgs/hooks/example/build/local_asset - - pkgs/hooks/example/build/native_add_app - - pkgs/hooks/example/build/native_add_library - - pkgs/hooks/example/build/native_dynamic_linking - - pkgs/hooks/example/build/system_library - - pkgs/hooks/example/build/use_dart_api - - pkgs/hooks/example/link/app_with_asset_treeshaking - - pkgs/hooks/example/link/package_with_assets + # - pkgs/jni # TODO + # - pkgs/jni/example # TODO + # - pkgs/jnigen # TODO + # - pkgs/jnigen/android_test_runner # TODO + # - pkgs/jnigen/example/in_app_java # TODO + # - pkgs/jnigen/example/kotlin_plugin # TODO + # - pkgs/jnigen/example/kotlin_plugin/example # TODO + # - pkgs/jnigen/example/notification_plugin # TODO + # - pkgs/jnigen/example/notification_plugin/example # TODO + # - pkgs/jnigen/example/pdfbox_plugin # TODO + # - pkgs/jnigen/example/pdfbox_plugin/dart_example # TODO + # - pkgs/jnigen/example/pdfbox_plugin/example # TODO - pkgs/json_syntax_generator + # - pkgs/native_doc_dartifier # Cannot update to latest dependencies due to https://github.com/dart-lang/native/issues/2839 - pkgs/native_test_helpers - pkgs/native_toolchain_c + # - pkgs/objective_c # TODO + # - pkgs/objective_c/example/command_line # TODO + # - pkgs/objective_c/example/flutter_app # Requires Flutter. - pkgs/pub_formats - pkgs/record_use - pkgs/record_use/test_data/drop_data_asset - pkgs/record_use/test_data/drop_dylib_recording - - pkgs/repo_lint_rules + - pkgs/record_use/test_data/library_uris + - pkgs/record_use/test_data/library_uris_helper + # - pkgs/swift2objc # TODO + # - pkgs/swiftgen # TODO + # - pkgs/swiftgen/example # TODO + +# Used in tool/ +dev_dependencies: + args: ^2.7.0 + dart_flutter_team_lints: ^3.5.2 + path: ^1.9.1 + yaml: ^3.1.3 # Hook user-defines are specified in the pub workspace. hooks: diff --git a/tool/check_licenses.dart b/tool/check_licenses.dart new file mode 100644 index 0000000000..3940f2793f --- /dev/null +++ b/tool/check_licenses.dart @@ -0,0 +1,119 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:args/args.dart'; + +const _licenseHeader = ''' +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +'''; + +const _licenseTestString = 'Copyright (c) '; + +void main(List arguments) async { + final parser = ArgParser() + ..addFlag( + 'set-exit-if-changed', + negatable: false, + help: 'Return a non-zero exit code if any files were changed.', + ) + ..addFlag( + 'help', + abbr: 'h', + negatable: false, + help: 'Prints this help message.', + ); + + final argResults = parser.parse(arguments); + + if (argResults['help'] as bool) { + print('Usage: dart tool/check_licenses.dart [directories]'); + print(parser.usage); + return; + } + + final directories = argResults.rest.isEmpty ? ['.'] : argResults.rest; + final setExitIfChanged = argResults['set-exit-if-changed'] as bool; + + var generatedCount = 0; + var changedCount = 0; + + final stopwatch = Stopwatch()..start(); + + for (final dirPath in directories) { + final directory = Directory(dirPath); + if (!directory.existsSync()) { + print('Directory not found: $dirPath'); + continue; + } + + await for (final file in directory.list(recursive: true)) { + if (file is! File || !file.path.endsWith('.dart')) { + continue; + } + + if (_isIgnored(file.path)) { + continue; + } + + generatedCount++; + + final contents = await file.readAsString(); + if (_fileIsGenerated(contents, file.path)) { + continue; + } + + if (!contents.contains(_licenseTestString)) { + print('Adding license header to ${file.path}'); + final newContents = '${_licenseHeader.trimLeft()}\n$contents'; + await file.writeAsString(newContents); + changedCount++; + } + } + } + + final seconds = stopwatch.elapsedMilliseconds / 1000.0; + print( + 'Checked $generatedCount files ($changedCount changed) in ' + '${seconds.toStringAsFixed(2)} seconds.', + ); + + if (setExitIfChanged && changedCount > 0) { + exit(1); + } +} + +bool _isIgnored(String filePath) { + final segments = filePath.split(RegExp(r'[/\\]')); + for (var i = 0; i < segments.length; i++) { + final segment = segments[i]; + if (segment == '.dart_tool' || segment == '.git' || segment == '.jj') { + return true; + } + if (segment == 'build') { + // Only ignore 'build' if it's a sibling of 'pubspec.yaml'. + final parentPath = segments.take(i).join(Platform.pathSeparator); + final pubspec = File( + parentPath.isEmpty + ? 'pubspec.yaml' + : '$parentPath${Platform.pathSeparator}pubspec.yaml', + ); + if (pubspec.existsSync()) { + return true; + } + } + } + return false; +} + +bool _fileIsGenerated(String fileContents, String filePath) => + filePath.endsWith('.g.dart') || + fileContents + .split('\n') + .map((line) => line.trim()) + .takeWhile((line) => line.startsWith('//') || line.isEmpty) + .any((line) => line.toLowerCase().contains('generate')); diff --git a/tool/ci.dart b/tool/ci.dart index 6e6335e9f8..e3ca4b0204 100644 --- a/tool/ci.dart +++ b/tool/ci.dart @@ -2,16 +2,17 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:io'; import 'dart:ffi'; +import 'dart:io'; import 'package:args/args.dart'; +import 'package:path/path.dart' as p; import 'package:yaml/yaml.dart'; void main(List arguments) async { final parser = makeArgParser(); - final ArgResults argResults = parser.parse(arguments); + final argResults = parser.parse(arguments); final packages = loadPackagesFromPubspec(); @@ -51,6 +52,18 @@ ArgParser makeArgParser() { 'all', negatable: false, help: 'Enable all tasks. Overridden by --no- flags.', + ) + ..addFlag( + 'fast', + negatable: false, + help: 'Skip slow integration tests and apitool.', + ) + ..addFlag( + 'fix', + negatable: false, + help: + 'Apply auto-fixes (e.g., dart fix, dart format) instead of just ' + 'checking.', ); for (final task in tasks) { parser.addFlag(task.name, help: task.helpMessage); @@ -64,9 +77,9 @@ ArgParser makeArgParser() { /// task's name, its default state, and the help message for its corresponding /// command-line flag. /// -/// The main execution loop iterates through a list of [Task] instances. For each -/// instance, it uses [shouldRun] to determine if the task should be executed -/// based on the command-line flags, and if so, calls the [run] method. +/// The main execution loop iterates through a list of [Task] instances. For +/// each instance, it uses [shouldRun] to determine if the task should be +/// executed based on the command-line flags, and if so, calls the [run] method. abstract class Task { /// The name of the task, used for the command-line flag. /// @@ -96,6 +109,144 @@ abstract class Task { }); } +/// Ensures all packages are included in the pub workspace or a reason is +/// provided why they cannot be part of the workspace. +class WorkspaceTask extends Task { + const WorkspaceTask() + : super( + name: 'workspace', + helpMessage: + 'Check that all packages are included in the pub workspace.', + ); + + @override + Future run({ + required List packages, + required ArgResults argResults, + }) async { + final packagesInRepository = _packagesInRepository(); + final packagesInWorkspacePubspec = _packagesInWorkspacePubspec(); + + final error = []; + + if (packagesInWorkspacePubspec.missingReason.isNotEmpty) { + error + ..add( + 'The following packages are commented out in the workspace ' + 'pubspec, but no reason is given why they cannot be part of the ' + 'workspace:', + ) + ..addAll( + packagesInWorkspacePubspec.missingReason.map( + (package) => ' - $package', + ), + ) + ..add( + 'Please add a trailing comment to their entry providing a reason ' + 'for their exclusion from the workspace.', + ) + ..add(''); + } + + final notInRepository = packagesInWorkspacePubspec.packages.difference( + packagesInRepository, + ); + if (notInRepository.isNotEmpty) { + error + ..add( + 'The following packages are listed in the workspace pubspec, but ' + 'do not exist in the repository:', + ) + ..addAll(notInRepository.map((package) => ' - $package')) + ..add('Please remove them from the workspace pubspec.') + ..add(''); + } + + final notInWorkspacePubspec = packagesInRepository.difference( + packagesInWorkspacePubspec.packages, + ); + if (notInWorkspacePubspec.isNotEmpty) { + error + ..add( + 'The following packages exist in the repository, but are not part ' + 'of the workspace:', + ) + ..addAll(notInWorkspacePubspec.map((package) => ' - $package')) + ..add( + 'Please add them to the workspace. If that is not possible, add a ' + 'commented out entry to the root pubspec and provide a reason why ' + 'they cannot be part of the workspace as a trailing comment.', + ) + ..add(''); + } + if (error.isNotEmpty) { + print(error.join('\n')); + exit(1); + } + } + + Set _packagesInRepository() { + final packages = {}; + final rootDir = Directory.fromUri(repositoryRoot.resolve('pkgs')); + for (final entity in rootDir.listSync(recursive: true)) { + if (entity is File && entity.path.endsWith('pubspec.yaml')) { + if (entity.path.split(Platform.pathSeparator).contains('.dart_tool')) { + continue; + } + packages.add( + Uri.file( + p.relative(entity.parent.path, from: repositoryRoot.toFilePath()), + ).toString(), + ); + } + } + return packages; + } + + ({Set packages, List missingReason}) + _packagesInWorkspacePubspec() { + final pubspecLines = File.fromUri( + repositoryRoot.resolve('pubspec.yaml'), + ).readAsStringSync().split('\n'); + final workspaceEntries = pubspecLines + .skipWhile((line) => !line.trim().startsWith('workspace:')) + .skip(1) + .takeWhile( + (line) => + line.trim().startsWith('- ') || line.trim().startsWith('# - '), + ); + + final packages = {}; + final packagesWithMissingReason = []; + + // Regex breakdown: + // ^\s* : Start of line and any leading whitespace + // (#\s*)? : Optional leading '#' followed by optional whitespace (Group 1) + // -\s+ : The YAML list dash '-' and at least one space + // ([^\s#]+) : The actual path - any characters that aren't space or '#' (Group 2) + // (\s*#.*)? : Optional trailing '#' and everything after it (Group 3) + final regex = RegExp(r'^\s*(#\s*)?-\s+([^\s#]+)(\s*#.*)?'); + + for (final entry in workspaceEntries) { + final match = regex.firstMatch(entry); + + if (match != null) { + final hasLeadingHash = match.group(1) != null; + final path = match.group(2); + final trailingComment = match.group(3); + + if (hasLeadingHash) { + if (trailingComment == null || trailingComment.trim().length < 6) { + packagesWithMissingReason.add(path!); + } + } + packages.add(path!); + } + } + return (packages: packages, missingReason: packagesWithMissingReason); + } +} + /// Fetches dependencies using `dart pub get`. /// /// This is a prerequisite for most other tasks. @@ -105,7 +256,7 @@ class PubTask extends Task { name: 'pub', helpMessage: 'Run `dart pub get` on the root and non-workspace packages.\n' - 'Run `dart pub global activate coverage`.', + 'Run `dart pub global activate coverage` and `dart_apitool`.', ); @override @@ -118,12 +269,21 @@ class PubTask extends Task { 'pkgs/hooks_runner/test_data/native_add_version_skew/', 'pkgs/hooks_runner/test_data/native_add_version_skew_2/', ]; - for (final path in paths) { - await _runProcess('dart', ['pub', 'get', '--directory', path]); - } + await _runMaybeParallel([ + for (final path in paths) + () => _runProcess('dart', ['pub', 'get', '--directory', path]), + ], argResults); } } +/// Packages that have slow tests. +/// +/// https://github.com/dart-lang/native/issues/90#issuecomment-3879193057 +const slowTestPackages = [ + 'pkgs/hooks_runner', + 'pkgs/native_toolchain_c', +]; + /// Runs `dart analyze` to find static analysis issues. class AnalyzeTask extends Task { const AnalyzeTask() @@ -137,7 +297,18 @@ class AnalyzeTask extends Task { required List packages, required ArgResults argResults, }) async { - await _runProcess('dart', ['analyze', '--fatal-infos', ...packages]); + final paths = [ + ...packages, + 'tool', + 'pubspec.yaml', + ]; + if (argResults['fix'] as bool) { + await _runMaybeParallel([ + for (final path in paths) + () => _runProcess('dart', ['fix', '--apply', path]), + ], argResults); + } + await _runProcess('dart', ['analyze', '--fatal-infos', ...paths]); } } @@ -151,11 +322,12 @@ class FormatTask extends Task { required List packages, required ArgResults argResults, }) async { + final fix = argResults['fix'] as bool; await _runProcess('dart', [ 'format', - '--output=none', - '--set-exit-if-changed', + if (!fix) ...['--output=none', '--set-exit-if-changed'], ...packages, + 'tool', ]); } } @@ -181,9 +353,14 @@ class GenerateTask extends Task { 'pkgs/pub_formats/tool/generate.dart', 'pkgs/record_use/tool/generate_syntax.dart', ]; - for (final generator in generators) { - await _runProcess('dart', [generator, '--set-exit-if-changed']); - } + final fix = argResults['fix'] as bool; + await _runMaybeParallel([ + for (final generator in generators) + () => _runProcess('dart', [ + generator, + if (!fix) '--set-exit-if-changed', + ]), + ], argResults); } } @@ -207,6 +384,11 @@ class TestTask extends Task { required List packages, required ArgResults argResults, }) async { + if (argResults['fast'] as bool) { + packages = packages + .where((p) => !slowTestPackages.any((slow) => p.contains(slow))) + .toList(); + } final testUris = getUriInPackage(packages, 'test'); await _runProcess('dart', [ 'test', @@ -244,13 +426,14 @@ class ExampleTask extends Task { 'pkgs/hooks/example/build/system_library/', 'pkgs/hooks/example/build/use_dart_api/', ]; - for (final exampleWithTest in examplesWithTest) { - await _runProcess( - workingDirectory: repositoryRoot.resolve(exampleWithTest), - 'dart', - ['test'], - ); - } + await _runMaybeParallel([ + for (final exampleWithTest in examplesWithTest) + () => _runProcess( + workingDirectory: repositoryRoot.resolve(exampleWithTest), + 'dart', + ['test'], + ), + ], argResults); await _runProcess( workingDirectory: repositoryRoot.resolve( @@ -316,23 +499,107 @@ class CoverageTask extends Task { } } +/// Checks for leaked symbols in the public API using `dart_apitool`. +class ApiToolTask extends Task { + const ApiToolTask() + : super( + name: 'apitool', + helpMessage: 'Run `dart_apitool` to check for leaked symbols.', + ); + + @override + bool shouldRun(ArgResults argResults) { + if (argResults['fast'] as bool && !argResults.wasParsed(name)) { + return false; + } + return super.shouldRun(argResults); + } + + @override + Future run({ + required List packages, + required ArgResults argResults, + }) async { + if (pubTask.shouldRun(argResults)) { + await _runProcess('dart', [ + 'pub', + 'global', + 'activate', + 'dart_apitool', + '^0.23.1', + ]); + } + await _runMaybeParallel([ + for (final package in packages) + () async { + final outputFileName = '${package.replaceAll('/', '_')}_api.json'; + await _runProcess('dart', [ + 'pub', + 'global', + 'run', + 'dart_apitool:main', + 'extract', + '--input', + package, + '--set-exit-on-missing-export', + '--output', + outputFileName, + ]); + // Clean up the temporary file. + final apiJson = File.fromUri(repositoryRoot.resolve(outputFileName)); + if (apiJson.existsSync()) { + apiJson.deleteSync(); + } + }, + ], argResults); + } +} + +/// Checks for missing license headers. +class LicenseTask extends Task { + const LicenseTask() + : super( + name: 'license', + helpMessage: 'Check for missing license headers.', + ); + + @override + Future run({ + required List packages, + required ArgResults argResults, + }) async { + final fix = argResults['fix'] as bool; + await _runProcess('dart', [ + 'tool/check_licenses.dart', + if (!fix) '--set-exit-if-changed', + ...packages, + ]); + } +} + const pubTask = PubTask(); +const licenseTask = LicenseTask(); const analyzeTask = AnalyzeTask(); const formatTask = FormatTask(); const generateTask = GenerateTask(); const testTask = TestTask(); const exampleTask = ExampleTask(); const coverageTask = CoverageTask(); +const apiToolTask = ApiToolTask(); +const workspaceTask = WorkspaceTask(); // The order of tasks is intentional. final tasks = [ pubTask, + generateTask, + licenseTask, analyzeTask, formatTask, - generateTask, testTask, exampleTask, coverageTask, + apiToolTask, + workspaceTask, ]; final Uri repositoryRoot = Platform.script.resolve('../'); @@ -342,7 +609,7 @@ List loadPackagesFromPubspec() { final pubspecYaml = loadYaml( File.fromUri(repositoryRoot.resolve('pubspec.yaml')).readAsStringSync(), ); - final workspace = (pubspecYaml['workspace'] as List).cast(); + final workspace = ((pubspecYaml as Map)['workspace'] as List).cast(); final packages = workspace .where( (package) => @@ -369,6 +636,19 @@ List getUriInPackage(List packages, String subdir) { return testUris; } +Future _runMaybeParallel( + List Function()> tasks, + ArgResults argResults, +) async { + if (argResults['fast'] as bool) { + await Future.wait(tasks.map((task) => task())); + } else { + for (final task in tasks) { + await task(); + } + } +} + Future _runProcess( String executable, List arguments, { @@ -391,7 +671,7 @@ Future _runProcess( final exitCode = await process.exitCode; if (exitCode != 0) { - print('+$commandString failed with exitCode ${exitCode}.'); + print('+$commandString failed with exitCode $exitCode.'); exit(exitCode); } } From c089af9587eba45b028d3af185d63f3befe8feca Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Sun, 15 Mar 2026 16:14:44 -0400 Subject: [PATCH 08/14] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 931267e521a620a32ed77ec2dbdd984226ccf1c0 Author: Sigurd Meldgaard Date: Fri Mar 13 12:26:14 2026 +0100 [infra] Replace pub run with dart run (#3000) Co-authored-by: Parker Lougheed commit ac1144e65a4621b9f94324f307bc3437b5b74f66 Author: Daco Harkes Date: Fri Mar 13 02:11:24 2026 -0700 [record_use] Large ints (#3227) Bug: * https://github.com/dart-lang/native/issues/3220 commit 5cc737d735a6976cdf6491cdaf84f446d828f3cc Author: Daco Harkes Date: Fri Mar 13 00:57:31 2026 -0700 [record_use] Double constants (#3226) commit d61b82ad2f561a2145661c5885fe9e99ec97b891 Author: Liam Appelbe Date: Thu Mar 12 12:59:43 2026 +1100 [jnigen] Class bindings implement all super interfaces (#3201) commit c478dfede2b37000ea52ac57da7a48ab9e99f5af Author: Daco Harkes Date: Wed Mar 11 01:06:15 2026 -0700 [record_use] Canonicalize and sort references (#3216) Deduplicates identical references from the same loading unit. Also sorts the references. Closes: * https://github.com/dart-lang/native/issues/3092 AI transparency: * Generated with Gemini CLI. Architecture mine. Implementation AI. Iterated on with follow up prompts. Code has been reviewed by me. commit ebcfec5f58532669e865ba4d3fc51b0caced68a6 Author: Daco Harkes Date: Wed Mar 11 00:51:37 2026 -0700 [record_use] Change references to have a single loading unit (#3215) commit 4fd6bc1fd3026ec79cdc5dabe449c4e83dd762c0 Author: James Williams <66931+jwill@users.noreply.github.com> Date: Sun Mar 8 16:17:30 2026 -0700 [jnigen] Fix manual download - Integrate source download into temporary gradle script (#3039) commit d3978d3e1bdf3f2cc45def8e03811175271b8c40 Author: Liam Appelbe Date: Mon Mar 9 08:51:21 2026 +1100 [swiftgen] Add integration test for async protocol methods (#3191) commit 824ab6261e57cd3c67882205d4334816b4e9e3c5 Author: Daco Harkes Date: Fri Mar 6 03:19:05 2026 -0800 [infra] Release record_use, hooks, hooks_runner, and native_toolchain_c (#3202) commit dc51a9d1560b0315535249c0bff1d5a4aaaea7d7 Author: Daco Harkes Date: Fri Mar 6 00:16:29 2026 -0800 [infra] Add `native_toolchain_ninja` to external packages (#3205) commit c503ded797929f8f408d9a7e48ef3e6e9f0b9540 Author: Daco Harkes Date: Fri Mar 6 00:16:16 2026 -0800 [record_use] Library documentation (#3204) commit 1c9445531f505aaa269e4a8326c25e71d32c63d7 Author: Daco Harkes Date: Fri Mar 6 00:14:03 2026 -0800 [infra] Only run formatting on dev (#3203) commit bc1b32fc3bc5b625ac5273380bafd31e21fff7bb Author: Gurleen Kaur <174241618+Gurleen-kansray@users.noreply.github.com> Date: Thu Mar 5 08:07:41 2026 +0530 [ffigen] Move tmpDir into Context and use spaces in temp directory names (#3029) commit f208cfcc13c55a27d69c7c0df326ba794d6d376f Author: Liam Appelbe Date: Thu Mar 5 13:31:29 2026 +1100 [jni] Support custom exceptions (#3190) commit f2faed248782f05c16be19f2f60b7c088cd14992 Author: Daco Harkes Date: Wed Mar 4 09:56:25 2026 -0800 [record_use] Document what is supported (#3197) Add some doc-comments about what language features are supported and what is recorded. This is not the final API yet, but this gives our doc comments a starting point. (Also, not all things have landed yet in the SDK, these docs are written as if they were.) commit 6b1d6517544c00e8a152e758589424e67a078a89 Author: Daco Harkes Date: Wed Mar 4 06:09:44 2026 -0800 [infra] Revert "Disable Coveralls" (#3195) This reverts commit 9c943145b591d4c86df72890fb3dc82f4945960f. They are back up: https://status.coveralls.io/ Closes: https://github.com/dart-lang/native/issues/3177 commit 31e70be4d94824b0e3cc61af1cf4fd49886be827 Author: Daco Harkes Date: Wed Mar 4 06:04:53 2026 -0800 [record_use] Remove record_use_internal.dart (#3194) commit ebb766b6530419a33bd05a60e9b5c63b9e2158df Author: Daco Harkes Date: Wed Mar 4 06:01:06 2026 -0800 [infra] Disable non-working copyright health check (#3196) Until https://github.com/dart-lang/native/issues/3148 is addressed by @mosuem, lets reduce the noise. commit fa77bf746b3ebd9e952f2e480f115d3147b65e65 Author: Liam Appelbe Date: Tue Mar 3 11:02:42 2026 +1100 [jnigen] Extension types (#3093) commit 269d65c65a9555d3dcd1134784aead785c79174d Author: Hassnaa Mohamed Date: Tue Mar 3 01:47:37 2026 +0200 [swift2objc] feat:support swift tuples(return types) (#3158) commit 4a40b827a26790da4fb742d694e358f928c13def Author: Daco Harkes Date: Mon Mar 2 04:27:10 2026 -0800 [native_toolchain_c] Run less tests (#3183) commit be75c54afe15c950e94f9c8c9e262d5e5c704f62 Author: Daco Harkes Date: Mon Mar 2 02:01:16 2026 -0800 [hooks_runner] Use dot shorthands (#3179) commit 9d488f6067ec99a6466930af2975028c157caa96 Author: Daco Harkes Date: Mon Mar 2 01:43:19 2026 -0800 [hooks] Use dot shorthands (#3176) commit 205afffc73d980d28168132a97a270a8b6f8bd4c Author: Liam Appelbe Date: Mon Mar 2 11:34:20 2026 +1100 [swift2objc] Fix nesting bugs (#3173) commit 77d80f4a817eab3654dd68327a38c9ab8a74d335 Author: Daco Harkes Date: Fri Feb 27 03:45:30 2026 -0800 [native_toolchain_c] Apply dot shorthands (#3165) commit b2ec0d5f842aa5ea3290f318fc964461313e75e6 Author: Daco Harkes Date: Fri Feb 27 03:44:33 2026 -0800 [infra] Agent skill: Apply dot shorthands (#3164) commit ae6ca2436b7f0c06c6f78a08ae96acbadc55ae7b Author: Daco Harkes Date: Fri Feb 27 03:44:06 2026 -0800 [record_use] Use dot shorthands (#3171) commit 9c943145b591d4c86df72890fb3dc82f4945960f Author: Daco Harkes Date: Fri Feb 27 02:27:03 2026 -0800 [infra] Disable Coveralls (#3178) commit 4e1412b21290b039a2dff18b944528caec99ee0a Author: Daco Harkes Date: Thu Feb 26 07:25:58 2026 -0800 [record_use] Constructor definitions (#3170) commit dd59094acc1097ccf4c68553f5a3cf131478e7ec Author: Daco Harkes Date: Thu Feb 26 07:24:49 2026 -0800 [hooks_runner] Automatically add recorded uses to hook dependencies (#3169) commit dbcba1d40efa6339b4eee078411c67487b009094 Author: Daco Harkes Date: Thu Feb 26 07:23:02 2026 -0800 [record_use] Filter out nested constants from other packages (#3167) commit 754c69d453ad801ae1a3bb8b75167a951b0c8444 Author: Daco Harkes Date: Thu Feb 26 03:50:30 2026 -0800 [infra] Bump Dart API tool (#3163) commit 4c3db5fdb65f1f41c2301510e23826b8cdba9f72 Author: Nourhan H. <109472010+TheNourhan@users.noreply.github.com> Date: Thu Feb 26 12:41:05 2026 +0300 [swift2objc] fix: support optional primitives by boxing as wrapper types (#3140) commit 6bf102a0cc4c9e73c339d0a8ff1d0b39aca82502 Author: Cairo09 <160388974+Cairo09@users.noreply.github.com> Date: Thu Feb 26 04:38:53 2026 +0530 [ffigen] Added allocate constructor for native C structs (#3097) commit 173690df5fb579e0745918f679480abf59156c8d Author: Liam Appelbe Date: Thu Feb 26 06:40:38 2026 +0800 [infra] Try AI suggested fix for flaky iOS install (#3153) commit 8c3f3ecd2e8f06b0922951e3d433f8754cb4dd4c Author: Daco Harkes Date: Wed Feb 25 05:04:29 2026 -0800 [record_use] Deterministic serialization order (#3156) commit 4224cf59e18121bd63266f8999f81d78cd3ae21a Author: Daco Harkes Date: Wed Feb 25 04:40:20 2026 -0800 [record_use] Canonicalize before serialization (#3155) commit 3af76881b691bf9229f2d3230c3c6fbce18240c5 Author: Daco Harkes Date: Wed Feb 25 03:35:30 2026 -0800 [record_use] `Constant`s `_depth` and `_size` (#3154) commit 512fefceade6e890c0380adb65080307f74d6744 Author: Daco Harkes Date: Wed Feb 25 03:23:15 2026 -0800 [record_use] Enum constant instances (#3151) commit 9eae830e7a0ab3d5c60fe72e5d3b5a1215548218 Author: Liam Appelbe Date: Wed Feb 25 17:33:25 2026 +0800 [ffigen] Update docs about ObjC runtime types (#3152) commit aebbcec05c46c21152547608a79adce41f08686c Author: Cairo09 <160388974+Cairo09@users.noreply.github.com> Date: Wed Feb 25 07:55:15 2026 +0530 [swift2objc] Inout params support (#3132) commit 592e429edb2a49b7c19d832c02f9d917e7174728 Author: Daco Harkes Date: Tue Feb 24 11:19:08 2026 -0800 [record_use] Cache hash codes in Expando instances (#3150) For https://github.com/dart-lang/native/issues/3115, we want to store the depth of constant objects in an `Expando`, to avoid exponential runtime in deep constants. We already use hashmaps/hashsets on constants, and computing the hashCode is currently already recursing. To make computing the hashcode of a large `Recordings` linear, cache the `hashCode`s in an `Expando`. See the recommendation of this pattern in: * https://github.com/dart-lang/language/issues/2225 commit 4cbd204a48c76cf4e2e041f85ac3b9fa422fde65 Author: Daco Harkes Date: Tue Feb 24 10:23:49 2026 -0800 [record_use] Public API deal with non-const (#3147) This is not the final API yet, but the current internal API addresses some issues with the public API. So lets remove the old public API. Closes: * https://github.com/dart-lang/native/issues/2718 * https://github.com/dart-lang/native/issues/2938 The main design approach of using the new API, deep destructuring in a switch, and giving an error that you cannot tree-shake on failing to destructure: ```dart switch (call) { case CallWithArguments( positionalArguments: [StringConstant(value: final english), ...], ): // Shrink a translations file based on all the different translation // keys. print('Translating to pirate: $english'); case _: throw UnsupportError('Cannot determine which translations are used.'); } ``` ```dart switch (ship) { case InstanceConstantReference( instanceConstant: InstanceConstant( fields: {'name': StringConstant(value: final name)}, ), ): // Include the 3d model for this ship in the application but not // bundle the other ships. print('Pirate ship found: $name'); case _: throw UnsupportedError('Cannot determine which ships are used.'); } ``` commit 258d382d0f0c4ec449cf74ae39563ff6571d6441 Author: Daco Harkes Date: Tue Feb 24 01:18:45 2026 -0800 [record_use] Simplify `Metadata` (#3145) commit 37f263c46fefc5b5785993116338f4c91c15c11b Author: Daco Harkes Date: Tue Feb 24 00:24:22 2026 -0800 [record_use] Add SymbolConstant support (#3139) commit d4c6bf79aa2ab5cbd518845a9c2ad63c64346502 Author: Cairo09 <160388974+Cairo09@users.noreply.github.com> Date: Tue Feb 24 08:41:06 2026 +0530 [jnigen] Throw actionable error for wrong Java version (#3130) commit 7d68fee0390f3b4d569cf9b0eec6583da04fab74 Author: Daco Harkes Date: Mon Feb 23 03:50:41 2026 -0800 [record_use] Enum value constants (#3138) commit 8b2540aad7aa38b3249d68ff75a9da28ce364037 Author: Daco Harkes Date: Mon Feb 23 02:38:54 2026 -0800 [record_use] Constant Record Values (#3137) The `package:record_use` side of: * https://github.com/dart-lang/native/issues/3054 commit 4f1aa00d35bdbcdcaaffb46b8d031ea67ceb40c9 Author: Ryota Kobayashi <45661924+naipaka@users.noreply.github.com> Date: Mon Feb 23 17:59:14 2026 +0900 [ffigen] Fix SDK path detection for non-standard Xcode paths (#3135) commit dba74ff9e4d2408b7854afc5ce3394ce6e505d11 Author: Daco Harkes Date: Fri Feb 20 02:40:26 2026 -0800 [record_use] Mark recorded classes as final (#3131) At this point we don't want to support recording subtypes, we might allow this in the future, but we'll lock it down in the compiler for now. commit f8550838fcde605087358e595346240b12c896f6 Author: Daco Harkes Date: Fri Feb 20 01:38:24 2026 -0800 [record_use] Static call receiver (#3127) A field for storing receiver (non) constant values for static calls. Extension methods and extension types have receivers for their instance calls - which are static calls. Issue: * https://github.com/dart-lang/native/issues/2948 commit 8a97f6b2a8f8e218dbbc8b08c9d3db99839ebb62 Author: Daco Harkes Date: Fri Feb 20 01:13:15 2026 -0800 [record_use] Serialize `NonConstant` in the constant pool (#3126) This simplifies code. (Especially for the follow up PR: https://github.com/dart-lang/native/pull/3127) commit 4ff7f4cc7cc82712604fcf441f294ca6ea1606af Author: Daco Harkes Date: Fri Feb 20 00:45:37 2026 -0800 [record_use] Separate instance and static call recordings (#3124) commit 4df61e834a6b32d20bae8aee557887db05abf397 Author: Daco Harkes Date: Fri Feb 20 00:41:03 2026 -0800 [infra] Analyze the pubspec (#3125) commit e10223f7669a6fbe9e4cf7bfee284cd41dd42087 Author: Daco Harkes Date: Thu Feb 19 09:41:34 2026 -0800 [record_use] Smaller ints for hashcodes (#3128) commit 1ebc21186c5fdfb3af7584ce482154cc167796ce Author: Daco Harkes Date: Thu Feb 19 05:36:05 2026 -0800 [record_use] `LoadingUnit` Dart API (#3123) Dart API for: * https://github.com/dart-lang/native/issues/2979 * https://github.com/dart-lang/native/issues/3022 In the future we might add the full graph of loading units if necessary. commit 3879dca05a1577ffe87fbc5423a04ea684b1ef09 Author: Daco Harkes Date: Thu Feb 19 05:19:25 2026 -0800 [record_use] Store multiple loading units (#3122) commit 1ef9fb1f4f5a621d6597242b8e8ef2302f789057 Author: Daco Harkes Date: Thu Feb 19 02:07:15 2026 -0800 [record_use] JSON objects for loading units (#3116) The storage part of: * https://github.com/dart-lang/native/issues/2979 commit 5dbae2be75529957312cf1f2bec68d87987a7154 Author: Daco Harkes Date: Wed Feb 18 12:16:06 2026 -0800 [record_use] Move json strings in Dart to json files (#3112) Lets have all test data in the same format. Simplifies things. commit 1ccc1b722d183ca9a138dcc457816fc4058a4371 Author: Daco Harkes Date: Wed Feb 18 11:48:11 2026 -0800 [record_use] Instance constant definitions (#3121) Reland of https://github.com/dart-lang/native/pull/3110 to the right branch. (GitHub sometimes rebases stacked PRs to main and sometimes doesn't...) commit b88982b6b0fa77b635a98bd3f6c497c21de20aa7 Author: Daco Harkes Date: Wed Feb 18 09:28:07 2026 -0800 [record_use] Normalize definitions in JSON (#3109) Move the definitions into their own toplevel index. Towards: * https://github.com/dart-lang/native/issues/2867 Implementation follows the design from: * https://github.com/dart-lang/native/issues/3106 commit f36ecbf2e9e02366e533fcfde3628c5fb97235e0 Author: Daco Harkes Date: Wed Feb 18 09:13:22 2026 -0800 [record_use] Refactor (de)serialization order (#3108) commit 71b7a6666dda803860ccbb9a7e8a99c100474d19 Author: Daco Harkes Date: Wed Feb 18 07:43:25 2026 -0800 [record_use] (De)serialization context (#3107) commit 1931ea53d638aecc0eb23bd7bf0c5683d979efbe Author: Daco Harkes Date: Wed Feb 18 04:04:40 2026 -0800 [infra] Skip generated packages from workspace check (#3120) commit 47fef8e26a4f554a0801e303603f1e582393046e Author: Daco Harkes Date: Wed Feb 18 02:23:05 2026 -0800 [infra] Add license checker to ci script (#3114) commit 8bf375e99b777b7afb6894394f0b4856a40522f7 Author: Michael Goderbauer Date: Wed Feb 18 10:04:11 2026 +0100 [infra] add check to ensure all packages are accounted for in workspace (#2969) commit 938b8615b0858078ca941417664f997ea6d55f77 Author: Daco Harkes Date: Tue Feb 17 08:26:48 2026 -0800 [record_use] Adopt `DefinitionKind` in test data (#3118) commit e2f959d9ab5fbfb2d128b6d76cdef1614d506ae8 Author: Daco Harkes Date: Tue Feb 17 00:37:20 2026 -0800 [hooks_runner] Add missing license header (#3113) commit 550426711ebc8010a20af9f552fe4adce42ba6c9 Author: Daco Harkes Date: Tue Feb 17 00:25:56 2026 -0800 [hooks_runner] Slow test (#3111) commit a916dd3396f71b9c5eaa86b2caedf223aafdef16 Author: Daco Harkes Date: Mon Feb 16 22:20:16 2026 -0800 [hooks_runner] Add `CCACHE_` env variables to allowlist (#3103) commit 9d22ed8d1df89f5c86f98b0c9bc53700e516b0a8 Author: Hassnaa Mohamed Date: Tue Feb 17 02:29:02 2026 +0200 [swift2objc] feat: Generate implicit constructors for Swift structs (#2940) commit afcf7c4ae6007bb51bd70837ebfab4d7535a9d41 Author: Cairo09 <160388974+Cairo09@users.noreply.github.com> Date: Tue Feb 17 05:52:41 2026 +0530 [ffigen] allow isA (null) to return false for ObjCobject (#3059) commit 2e84fb913b11be0dddbd014e46185d247bbccc3f Author: Daco Harkes Date: Mon Feb 16 04:32:38 2026 -0800 [infra] Bump SDK version to 3.10.0 (#3104) commit 14169ab6e648cc06c4086facbb8e23b46b9fb35e Author: Daco Harkes Date: Mon Feb 16 01:10:25 2026 -0800 [infra] Contribution and PR docs (#3099) commit f08a85b8cc480a11996871c71442cc9f7cacf4a4 Author: Daco Harkes Date: Mon Feb 16 01:06:49 2026 -0800 [record_use] `Definition` rework JSON encoding (#3091) commit a44ec6c1a92cf70d68bc047ad83301dd83a7bd86 Author: Daco Harkes Date: Mon Feb 16 00:59:26 2026 -0800 [hooks_runner] Fix flaky test (#3101) commit 7f2cfc43923ad4bd2e6c44c4ce56d386a8682228 Author: Daco Harkes Date: Thu Feb 12 05:42:25 2026 -0800 [infra] Add a `--fix` flag to the ci tool (#3090) The generate task needs to go before the others in case it generates bad code. commit ec7142f12666de052c3165700a9dd8fef75c2c90 Author: Daco Harkes Date: Thu Feb 12 04:14:42 2026 -0800 [infra] Add `dart_apitool` check to `ci.dart` (#3082) commit 6b1dfa7f1932aa6d3bbba6ef2bb26470b2b83580 Author: Daco Harkes Date: Thu Feb 12 04:14:05 2026 -0800 [infra] Toplevel analysis options (#3084) commit ed8075b0162940e00cccbb6b6da229db7d8cc5af Author: Daco Harkes Date: Thu Feb 12 04:08:31 2026 -0800 [infra] Format tools directory (#3089) commit 91d34c652d1f98d8d905169de930b422c82bd665 Author: Daco Harkes Date: Thu Feb 12 03:35:28 2026 -0800 [record_use] Use `update_snippets.dart` (#3087) Fix the doc comments in this package. * Fixes the docs to be up to date with current usage. * Adds a pirate themed API doc. * Ignores the use cases for now. * In the future we should make these full fledged examples in the examples/ dir. * Makes the snippets tool more powerful with anchors and nested snippets. commit 73ba13f9d9fde8dc9ad065381984dd55f94b3d40 Author: Daco Harkes Date: Thu Feb 12 02:26:25 2026 -0800 [record_use] Rework `Definition`s (#3075) This change addresses the ambiguity issues in how we identify Dart definitions. The new API ensures we can unambiguously capture and reference all kinds of statically resolved symbols across classes, extensions, and extension types. Related bugs: * https://github.com/dart-lang/native/issues/2888 * https://github.com/dart-lang/native/issues/3062 Each segment in the path is now a `Name` object containing: * `name`: The string identifier. * `kind`: A `DefinitionKind` (e.g., `classKind`, `methodKind`, `getterKind`, `setterKind`, `operatorKind`). * `disambiguators`: A `Set` used to distinguish between `static` and `instance` members, which is critical for extensions and extension types. The `kind` and `disambiguators` are null. Setting them non-null will be done in a follow up PR. Implemented a "smart" `toString()` that produces valid, URI-friendly strings for use in tooling and documentation. * **Format:** `library#kind:name@disambiguator::kind:name` * **Example:** `package:my_pkg/foo.dart#class:MyClass::method:myMethod@static` (Taken from discussions on https://github.com/dart-lang/language/issues/4616) commit 8fcc79be32581198df6a55c3f2319527416a0deb Author: Daco Harkes Date: Thu Feb 12 02:23:01 2026 -0800 [pub_formats] Add missing dependency (#3088) commit ddb91fecc47dcbbf520a43b789a0ab8247fc4678 Author: Daco Harkes Date: Thu Feb 12 02:11:35 2026 -0800 [pub_formats] Add analysis options (#3083) commit cc90d34518c8462c0867fc6d1177028e474157ef Author: Daco Harkes Date: Wed Feb 11 06:07:26 2026 -0800 [ffi] Export leaked types (#3081) This is causing flags on Dart API Tool runs. We should just export them. commit 1bd5bb8301b8bbb9c0e021e33ee752e4c4162dcb Author: Daco Harkes Date: Wed Feb 11 05:45:58 2026 -0800 [infra] Delete `repo_lint_rules` and remove `custom_lint` (#3080) commit cce2932034068c98a7255417b68172969483cccd Author: Daco Harkes Date: Wed Feb 11 05:07:47 2026 -0800 [record_use] Rename `Identifier` to `Definition` (#3076) commit c6aca4ef4b6f38772e6d9725d3aa148fe31a849a Author: Daco Harkes Date: Wed Feb 11 04:46:38 2026 -0800 [hooks_runner] Increase test timeout (#3079) commit f1b6ca6a91ee171f9720ce7fe2b495c9a30e9ce2 Author: Daco Harkes Date: Wed Feb 11 04:21:00 2026 -0800 [infra] Parallelize tool/ci.dart PubTask, GenerateTask, and ExampleTask (#3074) commit 19365f602717720122938bfbccd0327bee249a51 Author: Daco Harkes Date: Wed Feb 11 04:20:39 2026 -0800 [infra] Add `--fast` to `tool/ci.dart` (#3073) commit 0343aba249200ee9b502a614b7444502aa8c8ab7 Author: Daco Harkes Date: Wed Feb 11 04:17:24 2026 -0800 [record_use] Require `package:` URIs in schema (#3071) Add `package:` library check to the json schema and validator. Follow up of: * https://github.com/dart-lang/native/pull/3069 * https://github.com/dart-lang/native/issues/2891 commit 0838740fb4e422366294425528bfe0c8ebfc4334 Author: Daco Harkes Date: Wed Feb 11 04:02:09 2026 -0800 [record_use] Run validation in `Recordings.fromJson` (#3078) https://github.com/dart-lang/native/pull/3064 revealed we weren't ever running the validator. Refiling of: * https://github.com/dart-lang/native/pull/3070 commit 9084e1d4dc773540c0347e2e2c2e8d2ffcdacf42 Author: Daco Harkes Date: Wed Feb 11 03:41:45 2026 -0800 [record_use] Update test data to `package:` URIs and cleanup dart2js tests (#3077) commit 4689b4b8e8ccfbf1c9a00442814f90ffb3404972 Author: Daco Harkes Date: Wed Feb 11 00:45:40 2026 -0800 [infra] ignore nested .dart_tool and other generated files (#3066) commit 898141ec6eae227af112d5595768b39630a9e4eb Author: Hassnaa Mohamed Date: Tue Feb 10 02:52:09 2026 +0200 [swift2objc] feat: support operator overloading (#2972) commit 0e06fcfca46471506ffcb5d1f988221bfb9d2d7f Author: Daco Harkes Date: Mon Feb 9 09:32:06 2026 -0800 [record_use] Remove definition loading unit (#3061) In `dart2js`, definitions currently include a `loading_unit` property which typically represents the "dominating" loading unit (the shared ancestor of all loading units where that definition is used). When assets are associated with a definition, using this definition-level `loading_unit` can lead to assets being loaded too early. For example, if a definition is used in two different deferred loading units, its dominating unit might be the main bundle. Loading the asset in the main bundle defeats the purpose of deferring it. To fix this, we want to postpone asset loading until one of the actual loading units that uses the definition is loaded. Since every recorded `Call` and `Instance` already includes its own `loading_unit`, the property on the `Definition` itself is redundant and misleading for the web backend. Closes: https://github.com/dart-lang/native/issues/2986 Issues to be addressed in follow up PRs: * https://github.com/dart-lang/native/issues/3022 * https://github.com/dart-lang/native/issues/2888 - Removed `loading_unit` from the `Definition` object in `record_use.schema.json`. - Updated `Recording` to use `identifier` directly as its key property. - Removed the `Definition` class. `Recordings` now uses `Identifier` as the primary key for the `callsForDefinition` and `instancesForDefinition` maps. - Added a `TODO` to `Identifier` to rename it to `Definition` in a future refactor ([#2888](https://github.com/dart-lang/native/issues/2888)). commit 51d34eb76bb2b08347cb8406f9d022dfcf13afe4 Author: Daco Harkes Date: Fri Feb 6 09:30:37 2026 -0800 [record_use] Support unsupported constants (#3056) commit 0819678f481c1e69d9c62ecf8b0449978ae21c0a Author: Daco Harkes Date: Thu Feb 5 07:21:07 2026 -0800 [record_use] Add constructor invocations to recorded instances (#3047) Refactored `InstanceReference` into a sealed class hierarchy to support constructor invocations and tear-offs alongside constant instances. - **Hierarchy:** Introduced `InstanceConstantReference`, `InstanceCreationReference`, and `ConstructorTearoffReference`. - **Schema:** Updated `record_use.schema.json` with a `type` discriminator for instances and regenerated `syntax.g.dart`. - **API:** Updated `Recordings` and `RecordedUsages` to handle the polymorphic types and improved semantic equality comparison. - **Migration:** Updated all JSON test data to include the required `"type": "constant"` field and ensured trailing newlines. - **Testing:** Added `test/instance_references_test.dart` and updated schema validation tests. Relevant issues: * https://github.com/dart-lang/native/issues/2907 * https://github.com/dart-lang/native/issues/2911 commit 918a5a80fe02f3b25b7b95bdf3167accde68b436 Author: Daco Harkes Date: Thu Feb 5 06:55:55 2026 -0800 [native_toolchain_c] Increase test timeout (#3051) commit 8b9b5a6d256f940ed1e0d97c43cd4ac482c103a7 Author: Daco Harkes Date: Thu Feb 5 06:45:20 2026 -0800 [record_use] `Identifiers` must only have `package` uris (#3045) Bug: https://github.com/dart-lang/native/issues/2891 (Needs a PR in the Dart SDK as well to avoid recording things outside package uris.) commit e359106d8b22a4bc54c0e381243a337e6d263c20 Author: Daco Harkes Date: Thu Feb 5 06:05:31 2026 -0800 [record_use] Remove source locations (#3043) This PR completely removes source location tracking (URI, line, column) from the `record_use` package. This type of debug information should not be needed for errors from a link hook if the APIs annotated with `@RecordUse()` are already annotated with `@mustBeConst`. Closes: https://github.com/dart-lang/native/issues/3023 commit 4003fc327ccd029955f2a4efbb753ab6fcde96ad Author: Daco Harkes Date: Thu Feb 5 05:43:24 2026 -0800 [hooks_runner] Filter recorded uses on definition package name (#3041) Closes: https://github.com/dart-lang/native/issues/3003 This PR introduces filtering for `recorded_uses.json` passed to link hooks. Instead of providing all recorded usages from the entire application to every link hook, each hook now receives only the usages of definitions defined within its own package. - **`NativeAssetsBuildRunner.link`**: - Now parses the `resourceIdentifiers` (if provided). - Iterates through each package in the build plan. - Filters the `Recordings` to include only those where the definition belongs to the current package. - Writes the filtered recordings to a `recorded_uses.json` file in the package's build directory. - Passes this filtered file to the link hook input. - **`Recordings` class**: - Added a `filter({String? definitionPackageName})` method. - This method filters `callsForDefinition` and `instancesForDefinition` based on the `importUri` of the definition, checking if it starts with `package:/`. - Added `pkgs/hooks_runner/test/build_runner/resources_test.dart`: - **`simple_link linking`**: Verifies basic linking behavior. - **`record_use_filtering linking`**: A complex test case involving three packages (`pirate_adventure`, `pirate_speak`, `pirate_technology`). - `pirate_adventure` (the app) calls functions in the other two packages. - The test verifies that the link hook for `pirate_speak` only receives recordings for `pirateSpeak` and `pirate_technology` only receives recordings for `useCannon`. - Verifies that the output assets are correctly generated based on this filtered input (treeshaking simulation). - Added test data in `pkgs/hooks_runner/test_data/`: - `pirate_adventure`: The main application. - `pirate_speak`: A library with a link hook that processes recordings. - `pirate_technology`: Another library with a link hook. Previously, link hooks received the global set of recorded uses. This was inefficient and potentially leaked information between packages. By filtering the recordings, we ensure that: 1. Link hooks only process data relevant to them (treeshaking their own assets). 2. We avoid passing unnecessary data across package boundaries during the build process. commit 9ebc083c1ae14b572ae4c0c08ad567abb5c1a7a8 Author: Daco Harkes Date: Thu Feb 5 05:14:21 2026 -0800 [record_use] Update MapConstant to support non-string keys (#3037) Bug: https://github.com/dart-lang/native/issues/2715 Will require in implementation in the Dart SDK, and a manual roll due to breaking change in json format. commit 4c78a125651d3499b616b2b0624ea35f3315d20c Author: Daco Harkes Date: Wed Feb 4 10:13:08 2026 -0800 [record_use] Remove annotation recording examples (#3046) Bug: https://github.com/dart-lang/native/issues/2977 Required to make https://dart-review.googlesource.com/c/sdk/+/478440 green. commit 7324caf5f329e47a32d248bb85637109624178fa Author: Daco Harkes Date: Wed Feb 4 09:05:39 2026 -0800 [native_toolchain_c] Don't require lld on `PATH` for MacOS -> Linux (#3044) commit 7eab15e61a425d14ce3b514793cf8959a973d60c Author: Daco Harkes Date: Wed Feb 4 08:44:42 2026 -0800 [hooks_runner] Release 1.0.2 (#3042) commit 4581b840bbb8d12104d28a3085e9e3fa5b660b57 Author: Liam Appelbe Date: Wed Feb 4 14:08:54 2026 +1100 [ffigen] Fix new use_null_aware_elements lint (#3038) commit ee7153295f17e1e1a5ea92e227056fe9422dc41a Author: Gurleen Kaur <174241618+Gurleen-kansray@users.noreply.github.com> Date: Wed Feb 4 04:15:19 2026 +0530 [objective_c] Make autoReleasePool return callback value (#3033) commit 4c03068db818f7157c854c2215351e878b008fd7 Author: Daco Harkes Date: Tue Feb 3 08:47:36 2026 -0800 [hooks] Document hook env vars (#3034) commit 39e3e71cc0f00a575ca96db12bc0cf8201d516d3 Author: Liam Appelbe Date: Thu Jan 29 11:46:01 2026 +1100 [objective_c] Prepare to publish (#3024) commit f67abb73ee5867fa0808e5dc96f692647de25241 Author: Liam Appelbe Date: Thu Jan 29 10:05:22 2026 +1100 [ffigen] Fix transitive inclusion edge cases (#2998) commit 87f554bfec165595af12d881c8fabc10d4669c3b Author: Liam Appelbe Date: Thu Jan 29 09:25:29 2026 +1100 [infra] Add needs-triage label to all new bugs (#3015) commit 8fe4664b9c6e56489aee4583a0d4d5841549ffb2 Author: Hannes Winkler Date: Wed Jan 28 12:25:44 2026 +0100 [native_toolchain_c] fix unportable link arg (#3005) commit 8454e250764041ce8dbdcf29343de6265c2dfafd Author: Ponng <88756812+zhponng@users.noreply.github.com> Date: Wed Jan 28 11:36:44 2026 +0800 [objective_c] feat: Add minimum OS version flags to build script (#3016) commit 0a37fd38b93b980dc2061480d203350b103a1628 Author: Liam Appelbe Date: Wed Jan 28 09:05:38 2026 +1100 [ffigen] Always sort bindings (#3010) commit 4298a2eff4e00738cb4985cbb497e644237d2241 Author: Loïc Sharma <737941+loic-sharma@users.noreply.github.com> Date: Mon Jan 26 23:50:28 2026 -0800 [ffi] Fix utf8.dart typo (#3007) commit 7d07eb525b7490932b500e0cc088f0e74b153719 Author: Liam Appelbe Date: Fri Jan 23 10:43:39 2026 +1100 [objective_c] Prepare to publish 9.2.4 (#3002) commit f77246fb4bb0c4ee0c9543bf27672c3ab20db348 Author: Marinko Date: Fri Jan 23 00:30:51 2026 +0100 [objective_c] - fix private pub dev issue (#2996) commit d29657907e84943799544996f41175ceab215a62 Author: Liam Appelbe Date: Thu Jan 22 09:54:26 2026 +1100 [native_toolchain_c] Use `-encryptable` linker flag (#2982) commit bf77b81e80a33114bb03861893393156e8ff3fbc Author: Daco Harkes Date: Wed Jan 21 12:27:39 2026 +0100 [record_use] Integration test case for library-uris (#2987) commit 7f45c84e7fa1d61c49723b17a21f0a16e23346d3 Author: Liam Appelbe Date: Wed Jan 21 10:03:44 2026 +1100 [ffigen] Fix block helper naming bug (#2963) commit 9c9b31c0f6426bdeab46ea5869e8687be57c7560 Author: Liam Appelbe Date: Wed Jan 21 09:39:24 2026 +1100 [jnigen] Kotlin void suspend funcs now return Future in Dart (#2922) commit 67ea02e64b6afed19e31316335421b79f7384c99 Author: Liam Appelbe Date: Wed Jan 21 09:27:59 2026 +1100 [objective_c] Fix a code signing bug (#2975) commit 34a8b7c34e97a56405bd157149d5a5069add4694 Author: Liam Appelbe Date: Wed Jan 21 09:22:37 2026 +1100 [native_toolchain_c] Clarify compiler/linker in cbuilder docs (#2936) commit 6127a50b865d658606eb19189f72776be7f418fb Author: Daco Harkes Date: Tue Jan 20 14:52:40 2026 +0100 [hooks_runner] Remove unused dep from test data (#2971) commit 2f33e1af716668ab79346fdded6fa3f05ffd827b Author: Daco Harkes Date: Tue Jan 20 09:32:24 2026 +0100 [record_use] Remove internal `fromJson` and `toJson` (#2985) This PR only leaves the top level `Recordings` and `RecordedUsages` JSON APIs. All internal from and to json have been removed. The format uses normalization (with constant indices), which means the to and from JSON of parts of the format are not useful by themselves. Users should not try to use JSON serialization of parts of the format, only the full format. Closes: https://github.com/dart-lang/native/issues/2901 This will require a manual roll into the Dart SDK to migrate `Metadata.fromJson` constructor calls. commit d5ff8ed37db2fe502fdb0cd6b360afaaa4522319 Author: Daco Harkes Date: Tue Jan 20 09:26:37 2026 +0100 [record_use] Use `snake_case` in JSON (#2978) commit c26f7567339152a57195d8f7fd6c3e86a42d5497 Author: Daco Harkes Date: Mon Jan 19 14:12:23 2026 +0100 [record_use] Record use cases (#2976) Document all the `package:record_use` use cases and what features they would need from `package:record_use` and the compiler implementations populating the recorded use file. commit 4fe954c3dad86a0d8991681fc6d2ae0cdf873b12 Author: Michael Goderbauer Date: Fri Jan 16 15:28:17 2026 +0100 Remove outdated TODO from root pubspec.yaml (#2970) commit d1bbeea1fda85d9f54181907c52beb97180a71f8 Author: Michael Goderbauer Date: Fri Jan 16 14:36:15 2026 +0100 [infra] add `ffi` to workspace (#2966) commit 30ee3d743d9d9eba7b22555e9f7b6a972e5d267b Author: Michael Goderbauer Date: Fri Jan 16 10:57:55 2026 +0100 Simplify native.yaml (#2965) The "experiment" is no longer an experiment and now available on stable. commit ab60a1501c4736a19dbe629ab404987612ebfa3e Author: Michael Goderbauer Date: Fri Jan 16 09:11:05 2026 +0100 [swift2objc] Fix link to repository in pubspec (#2958) commit 0c4cad2f7ffd6c72ecdc7a330b4fa3b36b5bfeed Author: Michael Goderbauer Date: Fri Jan 16 09:10:46 2026 +0100 [infra] Bump ffigen,objective_c,swiftgen dependencies (#2957) commit b45b6aede5e8d0cb32a06fc62c49093dc3cf6232 Author: Liam Appelbe Date: Fri Jan 16 08:47:05 2026 +1100 [swift2objc] Enum support (#2955) commit 20d244be9d886ce55bb4c10bb5fd067487445d6f Author: Michael Goderbauer Date: Thu Jan 15 11:13:08 2026 +0100 [infra] Bump workspace dependencies (#2956) Partially supersedes https://github.com/dart-lang/native/pull/2833. commit 35d02e8d3dbd0d5e704c1364a9662494c12985ea Author: Liam Appelbe Date: Thu Jan 15 09:42:03 2026 +1100 [swiftgen] Integration tests for callbacks and protocols (#2949) commit c4f419cfc091aaa7bc7ce9e84ac49bc752e87b02 Author: Daco Harkes Date: Wed Jan 14 11:58:19 2026 +0100 [record_use] Fix positional argument semantic equality (#2950) --- pkgs/hooks_runner/lib/src/build_runner/build_planner.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart b/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart index f9ebbb505a..35afe8e42e 100644 --- a/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart +++ b/pkgs/hooks_runner/lib/src/build_runner/build_planner.dart @@ -332,7 +332,8 @@ class PackageGraph { /// compilation. This enum holds static information about these hooks. enum Hook { link('link'), - build('build'); + build('build') + ; final String _scriptName; From 72c450d39c6863811291c3501300d4beae19aa60 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Sun, 15 Mar 2026 16:22:59 -0400 Subject: [PATCH 09/14] Updated Github PATH for Swiftly in CI --- .github/workflows/native_toolchain_c.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/native_toolchain_c.yaml b/.github/workflows/native_toolchain_c.yaml index 6bf7e4af4f..ae9ecfb97f 100644 --- a/.github/workflows/native_toolchain_c.yaml +++ b/.github/workflows/native_toolchain_c.yaml @@ -38,12 +38,12 @@ jobs: with: sdk: ${{ matrix.sdk }} - - run: | - curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \ - tar zxf swiftly-$(uname -m).tar.gz && \ - ./swiftly init --quiet-shell-followup -y && \ - . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \ - hash -r + - name: Install swiftly + run: | + curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz + tar zxf swiftly-$(uname -m).tar.gz + ./swiftly init --quiet-shell-followup -y + echo "$SWIFTLY_BIN_DIR" >> $GITHUB_PATH - name: Install the latest Swift toolchain run: swiftly install latest From bafbfd96d2eecbb593ff4375e3a9f3b48141bc40 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Thu, 19 Mar 2026 09:57:07 -0400 Subject: [PATCH 10/14] updated swiftly job with deps --- .github/workflows/native_toolchain_c.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/native_toolchain_c.yaml b/.github/workflows/native_toolchain_c.yaml index ae9ecfb97f..6721ec1281 100644 --- a/.github/workflows/native_toolchain_c.yaml +++ b/.github/workflows/native_toolchain_c.yaml @@ -37,6 +37,9 @@ jobs: - uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c with: sdk: ${{ matrix.sdk }} + + - name: Install swiftly dependencies + run: sudo apt-get update && sudo apt-get -y install libcurl4-openssl-dev - name: Install swiftly run: | From f7d636a6bfb747860d4320e30bee91c0b5aaffd1 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Thu, 19 Mar 2026 10:17:44 -0400 Subject: [PATCH 11/14] Fixed apple `ld` test by testing against stderr rather than stdout --- .../lib/src/native_toolchain/apple_clang.dart | 6 ++++-- .../lib/src/native_toolchain/clang.dart | 3 ++- .../lib/src/native_toolchain/recognizer.dart | 2 +- .../native_toolchain_c/lib/src/tool/tool_resolver.dart | 10 +++++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 82005c06fa..60911dcbd3 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -15,7 +15,8 @@ final Tool appleClang = Tool( defaultResolver: CliVersionResolver( wrappedResolver: CliFilter( cliArguments: ['--version'], - keepIf: ({required String stdout}) => stdout.contains('Apple clang'), + keepIf: ({required String stdout, required String stderr}) => + stdout.contains('Apple clang'), wrappedResolver: PathToolResolver( toolName: 'Apple Clang', executableName: 'clang', @@ -55,7 +56,8 @@ final Tool appleLd = Tool( executableName: OS.current.executableFileName('ld'), ), cliArguments: ['-v'], - keepIf: ({required String stdout}) => stdout.contains('Apple TAPI'), + keepIf: ({required String stdout, required String stderr}) => + stdout.contains('Apple TAPI') || stderr.contains('Apple TAPI'), ), ]), ); diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart index 41c47f28f1..8556d4f8d5 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/clang.dart @@ -16,7 +16,8 @@ final Tool clang = Tool( defaultResolver: CliVersionResolver( wrappedResolver: CliFilter( cliArguments: ['--version'], - keepIf: ({required String stdout}) => !stdout.contains('Apple clang'), + keepIf: ({required String stdout, required String stderr}) => + !stdout.contains('Apple clang'), wrappedResolver: ToolResolvers([ PathToolResolver( toolName: 'Clang', diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/recognizer.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/recognizer.dart index 73a0fb689a..5b98942acc 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/recognizer.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/recognizer.dart @@ -27,7 +27,7 @@ class CompilerRecognizer implements ToolResolver { if (filePath.contains('-gcc')) { tool = gcc; } else if (filePath.endsWith(os.executableFileName('clang'))) { - final stdout = await CliFilter.executeCli( + final (:stdout, :stderr) = await CliFilter.executeCli( uri, arguments: ['--version'], logger: logger, diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 35ba6f6316..32a517e76d 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -377,7 +377,7 @@ class RelativeToolResolver implements ToolResolver { class CliFilter implements ToolResolver { final ToolResolver wrappedResolver; final List cliArguments; - final bool Function({required String stdout}) keepIf; + final bool Function({required String stdout, required String stderr}) keepIf; CliFilter({ required this.wrappedResolver, @@ -400,12 +400,12 @@ class CliFilter implements ToolResolver { }) async { if (toolInstance.version != null) return toolInstance; logger?.finer('Checking if $toolInstance satisfies CLI filter.'); - final stdout = await executeCli( + final (:stdout, :stderr) = await executeCli( toolInstance.uri, arguments: cliArguments, logger: logger, ); - final doKeep = keepIf(stdout: stdout); + final doKeep = keepIf(stdout: stdout, stderr: stderr); if (doKeep) { logger?.fine('$toolInstance satisfies CLI filter.'); return toolInstance; @@ -414,7 +414,7 @@ class CliFilter implements ToolResolver { return null; } - static Future executeCli( + static Future<({String stdout, String stderr})> executeCli( Uri executable, { required List arguments, int expectedExitCode = 0, @@ -427,6 +427,6 @@ class CliFilter implements ToolResolver { ); final exitCode = process.exitCode; assert(exitCode == expectedExitCode); - return process.stdout; + return (stdout: process.stdout, stderr: process.stderr); } } From 31a1b15fef602f4134911983879818d3617474ac Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Thu, 19 Mar 2026 10:33:35 -0400 Subject: [PATCH 12/14] Add priority for builtin `ar` for apple --- .../lib/src/native_toolchain/apple_clang.dart | 8 +++-- .../lib/src/tool/tool_resolver.dart | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 60911dcbd3..6b5afcb0d4 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -34,9 +34,13 @@ final Tool appleAr = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ar'), ), - PathToolResolver( + AbsoluteToolResolver( toolName: 'Apple archiver', - executableName: OS.current.executableFileName('ar'), + wrappedResolver: PathToolResolver( + toolName: 'Apple archiver', + executableName: OS.current.executableFileName('ar'), + ), + absolutePath: Uri.file('/usr/bin/ar'), ), ]), ); diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 32a517e76d..6ab0f72c0d 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -374,6 +374,42 @@ class RelativeToolResolver implements ToolResolver { } } +class AbsoluteToolResolver implements ToolResolver { + final String toolName; + final ToolResolver wrappedResolver; + final Uri absolutePath; + + AbsoluteToolResolver({ + required this.toolName, + required this.wrappedResolver, + required this.absolutePath, + }); + + @override + Future> resolve(ToolResolvingContext context) async { + final logger = context.logger; + final otherToolInstances = await wrappedResolver.resolve(context); + + logger?.finer( + 'Checking if one of $toolName resolved as $otherToolInstances is ' + 'at the path $absolutePath', + ); + + final result = otherToolInstances + .where((instance) => instance.uri == absolutePath) + .toList(); + + if (result.isNotEmpty) { + logger?.fine('Found $result.'); + } else { + logger?.finer( + 'Found no $toolName with the specified absolute path $otherToolInstances.', + ); + } + return result; + } +} + class CliFilter implements ToolResolver { final ToolResolver wrappedResolver; final List cliArguments; From fd67c32d62537a12784e34b8ac14406434d853d5 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Thu, 19 Mar 2026 10:34:16 -0400 Subject: [PATCH 13/14] analyzing issues fixed --- pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 6ab0f72c0d..5feda869d9 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -403,7 +403,8 @@ class AbsoluteToolResolver implements ToolResolver { logger?.fine('Found $result.'); } else { logger?.finer( - 'Found no $toolName with the specified absolute path $otherToolInstances.', + 'Found no $toolName with the specified absolute path ' + '$otherToolInstances.', ); } return result; From d60f5146667c6ffeceff7fd3f27e714f049b1c12 Mon Sep 17 00:00:00 2001 From: Nikechukwu Okoronkwo Date: Fri, 20 Mar 2026 16:49:15 -0400 Subject: [PATCH 14/14] Replaced AbsoluteToolResolver with PathFilter for absolute path --- .../lib/src/native_toolchain/apple_clang.dart | 4 ++-- .../lib/src/tool/tool_resolver.dart | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart index 6b5afcb0d4..fd59529f04 100644 --- a/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart +++ b/pkgs/native_toolchain_c/lib/src/native_toolchain/apple_clang.dart @@ -34,13 +34,13 @@ final Tool appleAr = Tool( wrappedResolver: appleClang.defaultResolver!, relativePath: Uri.file('ar'), ), - AbsoluteToolResolver( + PathFilter( toolName: 'Apple archiver', wrappedResolver: PathToolResolver( toolName: 'Apple archiver', executableName: OS.current.executableFileName('ar'), ), - absolutePath: Uri.file('/usr/bin/ar'), + keepIf: ({required uri}) => uri == Uri.file('/usr/bin/ar'), ), ]), ); diff --git a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart index 5feda869d9..55aad9078b 100644 --- a/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart +++ b/pkgs/native_toolchain_c/lib/src/tool/tool_resolver.dart @@ -374,15 +374,15 @@ class RelativeToolResolver implements ToolResolver { } } -class AbsoluteToolResolver implements ToolResolver { +class PathFilter implements ToolResolver { final String toolName; final ToolResolver wrappedResolver; - final Uri absolutePath; + final bool Function({required Uri uri}) keepIf; - AbsoluteToolResolver({ + PathFilter({ required this.toolName, required this.wrappedResolver, - required this.absolutePath, + required this.keepIf, }); @override @@ -392,11 +392,11 @@ class AbsoluteToolResolver implements ToolResolver { logger?.finer( 'Checking if one of $toolName resolved as $otherToolInstances is ' - 'at the path $absolutePath', + 'matches filter', ); final result = otherToolInstances - .where((instance) => instance.uri == absolutePath) + .where((instance) => keepIf(uri: instance.uri)) .toList(); if (result.isNotEmpty) {